mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-18 01:10:35 +08:00
mavlink: handle failure injection commands
This adds handling of MAVLink failure injection commands. An additional parameter is added as a guard to prevent triggering any failures by accident.
This commit is contained in:
@@ -504,6 +504,8 @@ public:
|
||||
bool forward_heartbeats_enabled() const { return _param_mav_hb_forw_en.get(); }
|
||||
bool odometry_loopback_enabled() const { return _param_mav_odom_lp.get(); }
|
||||
|
||||
bool failure_injection_enabled() const { return _param_sys_failure_injection_enabled.get(); }
|
||||
|
||||
struct ping_statistics_s {
|
||||
uint64_t last_ping_time;
|
||||
uint32_t last_ping_seq;
|
||||
@@ -667,7 +669,8 @@ private:
|
||||
(ParamBool<px4::params::MAV_HB_FORW_EN>) _param_mav_hb_forw_en,
|
||||
(ParamBool<px4::params::MAV_ODOM_LP>) _param_mav_odom_lp,
|
||||
(ParamInt<px4::params::MAV_RADIO_TOUT>) _param_mav_radio_timeout,
|
||||
(ParamInt<px4::params::SYS_HITL>) _param_sys_hitl
|
||||
(ParamInt<px4::params::SYS_HITL>) _param_sys_hitl,
|
||||
(ParamInt<px4::params::SYS_FAILURE_EN>) _param_sys_failure_injection_enabled
|
||||
)
|
||||
|
||||
perf_counter_t _loop_perf{perf_alloc(PC_ELAPSED, MODULE_NAME": tx run elapsed")}; /**< loop performance counter */
|
||||
|
||||
@@ -472,6 +472,16 @@ void MavlinkReceiver::handle_message_command_both(mavlink_message_t *msg, const
|
||||
|
||||
_actuator_controls_pubs[actuator_controls_s::GROUP_INDEX_GIMBAL].publish(actuator_controls);
|
||||
|
||||
} else if (cmd_mavlink.command == MAV_CMD_INJECT_FAILURE) {
|
||||
if (_mavlink->failure_injection_enabled()) {
|
||||
_cmd_pub.publish(vehicle_command);
|
||||
send_ack = false;
|
||||
|
||||
} else {
|
||||
result = vehicle_command_ack_s::VEHICLE_RESULT_DENIED;
|
||||
send_ack = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
send_ack = false;
|
||||
|
||||
Reference in New Issue
Block a user