Add support for MAV_CMD_DO_SET_ACTUATOR#32033
Conversation
peterbarker
left a comment
There was a problem hiding this comment.
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
fc85180 to
d40b42d
Compare
There are several benefits to this:
|
d40b42d to
7b014d1
Compare
7b014d1 to
0360326
Compare
0360326 to
d1cc22c
Compare
0ee4c0a to
481e1b3
Compare
63e797c to
a3127bb
Compare
a3127bb to
bddd1cb
Compare
ES-Alexander
left a comment
There was a problem hiding this comment.
Generally looking good (to me) - nice! :D
A few comments around cleanliness :-)
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>
bddd1cb to
4457b6d
Compare

depends on ArduPilot/mavlink#437