I’m experimenting with a pixhawk HKPilot32 autopilot and am trying to set up geofence using MAVLink through an Arduino.
As far as my research goes, it appears MAVLink supports enabling the geofence through command MAV_CMD_DO_FENCE_ENABLE. Also, MAV_MISSION_TYPE reveals if fenced mission is enabled. Although I can’t seem to find any command that sets the lat/lng of a polygon geofence, it seems nuttX controller module can handle this through navigator command.
I can confirm that QGC allows the (circle and polygon) geofence to be set (I haven’t actually tested it yet). However, I’m not sure if QGC is doing this through NuttX or uORB.
So, my questions are as follows:
- Is there any MAVLink command that allows circle and polygon geofence to be set?
- How is a MAV_CMD_* sent to pixhawk? Should mavlink_msg_mission_item_encode() be used along with COMMAND_LONG and pass MAV_CMD_DO_FENCE_ENABLE as command?
- Is there a direct way to inquire which commands an autopilot firmware supports?
- Is QGC communicating with pixhawk through uORB or NuttX to set the geofence coordinates and enable/disable them?
I’m very new to autopilots (DroneSDK, MAVLink, pixhawk) so any help is appreciated!
Thanks for your reply!
- I’m experimenting with the commands and the capabilities so I’ll test the radius geofence from the parameter list too.
Interestingly, I came to find out that the polygon geofence can be set through geofence.txt file on SD card - pending testing. I’m looking into how the Return Point/Rally Points and action-on-breach can be set through MAVLink and how to take back control after it has returned to the specified Return Point.
The resources I’ve been coming across are from ArduPilot and Pixhawk and some seem to be old. So, it makes me wonder, how similar are ArduPilot and Pixhawk systems when it comes to navigation? Are there few subtle differences between these two or are they different in many ways?
No, I’m afraid I’m not uploading anything as the goal is to set these configurations through MAVLink. Thanks for the link to your pull request. I’m looking further into this.
How do you go about executing grep?
So no uORB for comms - gotcha; NuttX is an RTOS - silly me How are the mission items sent over MAVLink?
So Pixhawk is the hardware and PX4 is the software, just to clarify. And in general the mission and geofence protocol is the same but there are some differences that I know of (e.g. ArduPilot missions are 1-based, PX4 missions are 0-based), and also not all command are interpreted the same or supported for both.
\2. How do you go about executing grep?
Oh, that’s just searching in code. Use your favorite editor or IDE, or GitHub.
Or look at the grep manual https://linux.die.net/man/1/grep
\3. Have a look at the docs here: https://mavlink.io/en/services/mission.html
Ah, then I can’t use the headers from ardupilotmega for pixhawk. Cool cool
Will look into the the rest and post updates as I progress. Thanks for the support, Julian!