-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate ROS environment and setup demo MAVROS node (#39)
- Loading branch information
1 parent
3565ea3
commit 06155af
Showing
11 changed files
with
185 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ mav.* | |
terrain | ||
eeprom.bin | ||
logs | ||
build | ||
install | ||
log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
uint64 timestamp # time since system start (microseconds) | ||
|
||
float64 lat # Latitude, (degrees) | ||
float64 lon # Longitude, (degrees) | ||
float32 alt # Altitude AMSL, (meters) | ||
float32 alt_ellipsoid # Altitude above ellipsoid, (meters) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import std_msgs.msg | ||
import mavros_msgs.msg | ||
import mavros_msgs.srv | ||
import rclpy | ||
import rclpy.node | ||
from rclpy.qos import QoSProfile, ReliabilityPolicy, DurabilityPolicy, HistoryPolicy | ||
import sensor_msgs.msg | ||
from threading import Thread | ||
from uavf_2024.msg import GpsAltitudePosition | ||
import sys | ||
|
||
class CommanderNode(rclpy.node.Node): | ||
def __init__(self): | ||
super().__init__('uavf_commander_node') | ||
|
||
qos_profile = QoSProfile( | ||
reliability=ReliabilityPolicy.BEST_EFFORT, | ||
durability=DurabilityPolicy.VOLATILE, | ||
depth = 1 | ||
) | ||
|
||
# set up some clients - not all of these are used right now. | ||
|
||
self.global_pos_sub = self.create_subscription( | ||
sensor_msgs.msg.NavSatFix, | ||
'ap/geopose/filtered', | ||
self.global_pos_cb, | ||
qos_profile) | ||
self.got_pos = False | ||
|
||
self.arm_client = self.create_client(mavros_msgs.srv.CommandBool, 'mavros/cmd/arming') | ||
|
||
self.mode_client = self.create_client(mavros_msgs.srv.SetMode, 'mavros/set_mode') | ||
|
||
self.takeoff_client = self.create_client(mavros_msgs.srv.CommandTOL, 'mavros/cmd/takeoff') | ||
|
||
self.waypoints_client = self.create_client(mavros_msgs.srv.WaypointPush, 'mavros/mission/push') | ||
|
||
def global_pos_cb(self, global_pos): | ||
self.got_pos = True | ||
self.last_pos = global_pos | ||
|
||
if __name__ == '__main__': | ||
rclpy.init() | ||
node = CommanderNode() | ||
|
||
spinner = Thread(target = rclpy.spin, args = (node,)) | ||
|
||
|
||
with open(sys.argv[1]) as f: | ||
waypoints = [tuple(map(float, line.split(','))) for line in f] | ||
|
||
|
||
spinner.start() | ||
|
||
|
||
print('Pushing waypoints') | ||
|
||
node.waypoints_client.call(mavros_msgs.srv.WaypointPush.Request(start_index = 0, | ||
waypoints = | ||
[ | ||
mavros_msgs.msg.Waypoint( | ||
frame = mavros_msgs.msg.Waypoint.FRAME_GLOBAL_REL_ALT, | ||
command = mavros_msgs.msg.CommandCode.NAV_WAYPOINT, | ||
is_current = True, | ||
autocontinue = True, | ||
|
||
param1 = 0.0, | ||
param2 = 5.0, | ||
param3 = 0.0, | ||
param4 = float('NaN'), | ||
|
||
x_lat = wp[0], | ||
y_long = wp[1], | ||
z_alt = 20.0 | ||
) | ||
|
||
for wp in waypoints | ||
] | ||
)) | ||
|
||
print("Sent waypoints, setting node") | ||
|
||
|
||
node.mode_client.call(mavros_msgs.srv.SetMode.Request( \ | ||
base_mode = 0, | ||
custom_mode = 'AUTO' | ||
)) | ||
|
||
print('Set mode.') | ||
|
||
|
||
node.destroy_node() | ||
rclpy.shutdown() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
38.31729702009844, -76.55617670782419 | ||
38.31594832826572, -76.55657341657302 | ||
38.31546739500083, -76.55376201277696 | ||
38.31470980862425, -76.54936361414539 | ||
38.31424154692598, -76.54662761646904 | ||
38.31369801280048, -76.54342380058223 | ||
38.31331079191371, -76.54109648475954 | ||
38.31529941346197, -76.54052104837133 | ||
38.31587643291039, -76.54361305817427 | ||
38.31861642463319, -76.54538594175376 | ||
38.31862683616554, -76.55206138505936 | ||
38.31703471119464, -76.55244787859773 | ||
38.31674255749409, -76.55294546866578 | ||
38.31729702009844, -76.55617670782419 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
38.31619507, -76.55484077 | ||
38.31559883, -76.55582833 | ||
38.31591432, -76.55919177 | ||
38.31684638, -76.55708783 |