mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 17:33:34 +08:00
actuator: add support for MAV_CMD_DO_SET_ACTUATOR
Adds support for using the MAVLink command MAV_CMD_DO_SET_ACTUATOR to
update the actuator values on control group 3 aux{1, 2, 3}. A simple
deconfliction with rc_update is implemented: when a MAVLink command is
sent, RC is disabled for that channel until a major stick movement is
detected.
This commit is contained in:
committed by
Lorenz Meier
parent
ada05165f1
commit
b257f9d1fd
@@ -501,8 +501,39 @@ void MavlinkReceiver::handle_message_command_both(mavlink_message_t *msg, const
|
||||
send_ack = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
} else if (cmd_mavlink.command == MAV_CMD_DO_SET_ACTUATOR) {
|
||||
// since we're only paying attention to 3 AUX outputs, the
|
||||
// index should be 0, otherwise ignore the message
|
||||
if (((int) vehicle_command.param7) == 0) {
|
||||
actuator_controls_s actuator_controls{};
|
||||
actuator_controls.timestamp = hrt_absolute_time();
|
||||
|
||||
// update with existing values to avoid changing unspecified controls
|
||||
_actuator_controls_3_sub.update(&actuator_controls);
|
||||
|
||||
bool updated = false;
|
||||
|
||||
if (PX4_ISFINITE(vehicle_command.param1)) {
|
||||
actuator_controls.control[5] = vehicle_command.param1;
|
||||
updated = true;
|
||||
}
|
||||
|
||||
if (PX4_ISFINITE(vehicle_command.param2)) {
|
||||
actuator_controls.control[6] = vehicle_command.param2;
|
||||
updated = true;
|
||||
}
|
||||
|
||||
if (PX4_ISFINITE(vehicle_command.param3)) {
|
||||
actuator_controls.control[7] = vehicle_command.param3;
|
||||
updated = true;
|
||||
}
|
||||
|
||||
if (updated) {
|
||||
_actuator_controls_pubs[3].publish(actuator_controls);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
send_ack = false;
|
||||
|
||||
if (msg->sysid == mavlink_system.sysid && msg->compid == mavlink_system.compid) {
|
||||
|
||||
@@ -411,6 +411,7 @@ private:
|
||||
uORB::Subscription _vehicle_attitude_sub{ORB_ID(vehicle_attitude)};
|
||||
uORB::Subscription _vehicle_local_position_sub{ORB_ID(vehicle_local_position)};
|
||||
uORB::Subscription _vehicle_status_sub{ORB_ID(vehicle_status)};
|
||||
uORB::Subscription _actuator_controls_3_sub{ORB_ID(actuator_controls_3)};
|
||||
|
||||
uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user