Implementing MAV_CMD_DO_ORBIT

Hi everyone,

I’m working on a companion computer application (Raspberry Pi + pymavlink) that controls an ArduCopter drone via MAVLink. One feature we need is orbiting around a defined GPS coordinate – not around the drone’s current position as CIRCLE mode currently does.

I left a comment on GitHub issue #15098 which has been open since 2020: Missing ArduPilot mavlink support to light up QGC features · Issue #15098 · ArduPilot/ardupilot · GitHub

Before diving into the implementation, I’ve already done some source code analysis and wanted to share what I found and ask for guidance.

What I found in the source:

  • AC_Circle already has an init() that accepts an explicit center vector as parameter – the infrastructure for a defined center point already exists
  • ModeAuto already has circle_movetoedge_start() which takes an explicit Location parameter – this is already used for mission waypoints
  • The missing piece seems to be purely on the MAVLink command handler side in GCS_Mavlink.cpp

So my assumption is that MAV_CMD_DO_ORBIT could be implemented without major changes to the CIRCLE mode itself – mainly wiring up the MAVLink command to the existing circle_movetoedge_start() infrastructure, plus periodically sending ORBIT_EXECUTION_STATUS back to the GCS.

My questions:

  1. Is this analysis correct, or is there a reason the existing circle_movetoedge_start() path can’t be reused for MAV_CMD_DO_ORBIT?
  2. Is anyone already working on this?
  3. Would a PR be welcome? We’re willing to implement this properly with SITL tests and documentation.

Thanks in advance for any guidance!


Setup: ArduCopter 4.x, Pixhawk, Raspberry Pi companion computer, SITL on Ubuntu 22.04

3 Likes

Hi @Researcher86,

Thanks very much for looking into this. Your analysis looks correct to me. We’ve already got all the required code in place for use when the LOITER_TURNS waypoint command is executed from within an Auto mode mission so what’s required is just adding support for it as an “immediate” command (a command executed while the vehicle is in Guided mode). As you say this should mostly be about adding code to GCS_MAVlink.cpp. It’s also possible that some code from ModeAuto might need to be moved somewhere (AC_Circle?) to allow it to be reused from within ModeGuide and ModeAuto without duplication.

A PR would be very welcome!

Could this be accomplished using DO_SET_ROI and DO_SET_ROI_LOCATION?

Hi @davidbitton,

No, I think they’re different. DO_SET_ROI points the camera gimbal and/or vehicle’s nose at a Location while DO_ORBIT (or LOITER_TURNS) makes the vehicle fly a circle around a location

Hi all,

PR is submitted: ArduCopter: add MAV_CMD_DO_ORBIT support in Guided mode by researcher3 · Pull Request #32434 · ArduPilot/ardupilot · GitHub

Implemented MAV_CMD_DO_ORBIT as an immediate command in Guided mode.
SITL tested with autotest included as well as a plot and bin.log file.

I indeed made use of DO_SET_ROI. If you don‘t use it, it will just circle around the coordinate like an airplane (not facing the center).

Still some limitations to overcome (param2, speed).

ORBIT_EXECUTION_STATUS still needs to be implemented.

2 Likes