mavlink / mavros

MAVLink to ROS gateway with proxy for Ground Control Station
Other
899 stars 994 forks source link

Modify Geofence via Mavros Interface? #1473

Open moooeeeep opened 4 years ago

moooeeeep commented 4 years ago

Issue details

I would like to specify a geofence for my drone from its onboard companion computer. There I have a ROS node, that takes care of the mission control and interfaces to the FCU via mavros. I would like to specify a geofence from within that node during flight, based on sensor data that is processed on the companion.

In the docs I didn't find a plugin for this, mavros_msgs doesn't seem to contain the relevant messages and services, so I assume that this functionality does not yet exist.

I only found this related feature request: https://github.com/mavlink/mavros/issues/1157

Has anyone dealt with this before (and can share any workarounds)? Did anyone make progress implementing this?

MAVROS version and platform

Mavros: 1.3.0 ROS: Melodic Ubuntu: 18.04

ZacharyLowell commented 3 years ago

Any progress made on this?

Jaeyoung-Lim commented 3 years ago

@moooeeeep @Dan-Moss @zlowell2 Since the command plugin provides an interface to send MAV_CMD messages, you can set the geofence using this interface

ZacharyLowell commented 3 years ago

@Jaeyoung-Lim which .msg file would be used to convey this interface though. The CommandCode.msg file contains the command type so we can reference/define the command in this message as something like:

command = NAV_FENCE_POLYGON_VERTEX_INCLUSION = 5001

but where do we define the longitude, latitude, alt, etc. associated with the geofence and which .msg file would this be contained in, before we send the message to the command node?

Sorry if this doesn't make any sense btw - let me know if need more clarification.

JqkerN commented 3 years ago

Would also know how to do that, did you figure out a way of sending geofence polygons through mavros?

moooeeeep commented 3 years ago

@Jaeyoung-Lim I feel this is more complicated than that. Geofences are not specified in a command message. You have to transmit them one by one via the mission protocol. The mavros mission (waypoint) plugin, which would seem relevant here, doesn't support changing the mission type to MAV_MISSION_TYPE_FENCE (also have a look at the feature request I've linked above). Probably one could copy and paste most of the code and create a specific fence plugin though. But I felt this would go beyond the effort I was able to put in at that point.

Eventually, I ended up specifying the geofence via an additional pymavlink interface that I connected locally via the gcs_url that I configured mavros to open up for this. I consider this a hacky workaround and I'm not exactly proud of getting it work this way, but at the end of the day it enabled me to transmit a single fence to the FCU. Which was enough to cover my use case. I didn't manage to transmit multiple fences though, as the next one would always overwrite the previously transmitted fence. Not sure if the bottleneck was my lack of knowledge of this whole stack or again an obscure limitation of the interface I ended up using.