mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 05:43:34 +08:00
Check if offboard mode was activated before publishing controls
This commit is contained in:
committed by
Thomas Gubler
parent
220fb19eb7
commit
0f51907dd6
@@ -684,19 +684,29 @@ MavlinkReceiver::handle_message_set_actuator_control_target(mavlink_message_t *m
|
|||||||
orb_publish(ORB_ID(offboard_control_mode), _offboard_control_mode_pub, &offboard_control_mode);
|
orb_publish(ORB_ID(offboard_control_mode), _offboard_control_mode_pub, &offboard_control_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
actuator_controls.timestamp = hrt_absolute_time();
|
|
||||||
|
|
||||||
/* Set duty cycles for the servos in actuator_controls_0 */
|
/* If we are in offboard control mode, publish the actuator controls */
|
||||||
for(size_t i = 0; i < 8; i++) {
|
bool updated;
|
||||||
actuator_controls.control[i] = set_actuator_control_target.controls[i];
|
orb_check(_control_mode_sub, &updated);
|
||||||
|
if (updated) {
|
||||||
|
orb_copy(ORB_ID(vehicle_control_mode), _control_mode_sub, &_control_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_actuator_controls_pub < 0) {
|
if (_control_mode.flag_control_offboard_enabled) {
|
||||||
_actuator_controls_pub = orb_advertise(ORB_ID(actuator_controls_0), &actuator_controls);
|
|
||||||
} else {
|
actuator_controls.timestamp = hrt_absolute_time();
|
||||||
orb_publish(ORB_ID(actuator_controls_0), _actuator_controls_pub, &actuator_controls);
|
|
||||||
|
/* Set duty cycles for the servos in actuator_controls_0 */
|
||||||
|
for(size_t i = 0; i < 8; i++) {
|
||||||
|
actuator_controls.control[i] = set_actuator_control_target.controls[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_actuator_controls_pub < 0) {
|
||||||
|
_actuator_controls_pub = orb_advertise(ORB_ID(actuator_controls_0), &actuator_controls);
|
||||||
|
} else {
|
||||||
|
orb_publish(ORB_ID(actuator_controls_0), _actuator_controls_pub, &actuator_controls);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user