Skip to content

Add support for MAV_CMD_DO_SET_ACTUATOR#32033

Open
Williangalvani wants to merge 3 commits into
ArduPilot:masterfrom
Williangalvani:mav_cmd_do_set_actuator
Open

Add support for MAV_CMD_DO_SET_ACTUATOR#32033
Williangalvani wants to merge 3 commits into
ArduPilot:masterfrom
Williangalvani:mav_cmd_do_set_actuator

Conversation

@Williangalvani

@Williangalvani Williangalvani commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

@peterbarker peterbarker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In its current form this is really just a normalised replacement for MAV_CMD_DO_SET_SERVO, I guess?

At the moment I think all boards are going to pay a penalty for having this feature, but only Sub firmwares will get any benefit. We should probably move the instantiation of the thing up to AP_Vehicle and have the feature off by default. Probably only need to do the latter on this PR. Also needs adding to build_options.py

Comment thread Tools/autotest/ardusub.py
Comment thread libraries/AP_Actuators/actuators.cpp Outdated
Comment thread libraries/AP_Actuators/AP_Actuators.cpp
Comment thread libraries/AP_Actuators/AP_Actuators.h Outdated
Comment thread libraries/AP_Actuators/actuators.h Outdated
Comment thread libraries/GCS_MAVLink/GCS_Common.cpp Outdated
Comment thread libraries/GCS_MAVLink/GCS_Common.cpp
Comment thread libraries/GCS_MAVLink/GCS_Common.cpp Outdated
Comment thread libraries/GCS_MAVLink/GCS_Common.cpp Outdated
Comment thread libraries/GCS_MAVLink/GCS_Common.cpp Outdated
@Williangalvani Williangalvani force-pushed the mav_cmd_do_set_actuator branch 5 times, most recently from fc85180 to d40b42d Compare February 26, 2026 15:43
@Williangalvani Williangalvani mentioned this pull request Mar 2, 2026
10 tasks
@Williangalvani

Copy link
Copy Markdown
Contributor Author

In its current form this is really just a normalised replacement for MAV_CMD_DO_SET_SERVO, I guess?

The goal here is to allow controlling "A thing" instead of "Output pin number X"
This makes it easier to move things around, and makes (IMO) the output mapping more consistent.

We can easily switch functions around in BlueOS and don't need to think "Right, output X needs to be disabled because I have a custom device using DO_SET_SERVO on it"
Screenshot 2026-03-06 at 13 56 17

@ES-Alexander

Copy link
Copy Markdown
Contributor

We can easily switch functions around in BlueOS and don't need to think "Right, output X needs to be disabled because I have a custom device using DO_SET_SERVO on it"

There are several benefits to this:

  1. A common point of confusion in the past having been "why do I need to disable this to be able to use it?"
  2. Having dedicated output types allows users to control those outputs, without needing the mental overhead of which spot it happens to be plugged in.
  3. That better enables manufacturers+integrators to set up and configure a vehicle in advance, and users can focus on how they want to control it.
  4. If control software only needs to know what is connected, not where, then it's more straightforward to transfer control profiles between software and devices, for different vehicles
    • This is part of why we're trying to move away from MANUAL_CONTROL button functions - if you need the autopilot to know how the inputs are configured then it's harder to have transferrable control profiles that you can "take with you", so to speak.

@Williangalvani Williangalvani force-pushed the mav_cmd_do_set_actuator branch from d40b42d to 7b014d1 Compare March 6, 2026 18:12
@Williangalvani Williangalvani force-pushed the mav_cmd_do_set_actuator branch from 7b014d1 to 0360326 Compare March 24, 2026 14:50
@Williangalvani Williangalvani force-pushed the mav_cmd_do_set_actuator branch from 0360326 to d1cc22c Compare May 8, 2026 17:40
@github-actions github-actions Bot added the Python label May 8, 2026
@Williangalvani Williangalvani force-pushed the mav_cmd_do_set_actuator branch 2 times, most recently from 0ee4c0a to 481e1b3 Compare May 12, 2026 15:46
@Williangalvani Williangalvani force-pushed the mav_cmd_do_set_actuator branch 2 times, most recently from 63e797c to a3127bb Compare May 21, 2026 15:07
@Williangalvani Williangalvani force-pushed the mav_cmd_do_set_actuator branch from a3127bb to bddd1cb Compare May 27, 2026 19:15

@ES-Alexander ES-Alexander left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looking good (to me) - nice! :D

A few comments around cleanliness :-)

Comment thread libraries/AP_Actuators/AP_Actuators.cpp Outdated
Comment thread libraries/GCS_MAVLink/GCS_Common.cpp Outdated
Comment thread Tools/autotest/ardusub.py
Comment thread Tools/autotest/ardusub.py Outdated
Williangalvani and others added 3 commits June 4, 2026 12:27
Move the existing ArduSub Actuators class out of ArduSub/ and into libraries/AP_Actuators/
Renamed Actuators -> AP_Actuators and make it a singleton.
ArduSub continues to own the AP_Actuators instance via
ParametersG2 and behaviour is unchanged.
Wire MAV_CMD_DO_SET_ACTUATOR into handle_command_int_packet() and
forward to AP_Actuators::set_actuator() via the new
handle_command_do_set_actuator() helper.

 * command_long_requires_scaling() lets a command declare that its
   param5/param6 should be scaled by 1e7 (rather than truncated)
   when packed into COMMAND_INT.x/y;
 * convert_COMMAND_LONG_scaled_param() implements the encode side,
   using INT32_MAX as the encoded NaN;
 * convert_COMMAND_LONG_to_COMMAND_INT() picks between the existing
   loc_param path and the new scaled path based on the command;
 * handle_command_do_set_actuator() decodes x/y back to floats,
   restoring NaN from INT32_MAX, and feeds all six slots through
   the existing isnan-skip + set_actuator() loop.

Non-zero indexes are rejected as we currently only support 6
actuators
Map each supported actuator (1..6) onto its own SERVO output with a
distinct PWM range and exercise -1, -0.5, 0, +0.5, +1 against every
slot, asserting that the resulting PWM matches
servo_min + (servo_max - servo_min) * (value + 1) / 2 on the right
servo channel.

Also assert:

 * a single COMMAND_LONG carrying values for all six supported
   actuators applies them in one shot and preserves the
   param->actuator mapping (which exercises the param5/param6
   scaling path through convert_COMMAND_LONG_to_COMMAND_INT);
 * a follow-up command that only moves one actuator leaves the
   other actuators' PWMs untouched (NaN-as-ignore semantics for
   both the float p1..p4 path and the scaled-int p5/p6 path);
 * sending the command as COMMAND_INT with a non-zero actuator-set
   index in z returns MAV_RESULT_DENIED, since only the first set
   (actuators 1..6) is supported.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Williangalvani Williangalvani force-pushed the mav_cmd_do_set_actuator branch from bddd1cb to 4457b6d Compare June 4, 2026 15:29
@Williangalvani Williangalvani marked this pull request as ready for review June 4, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants