mirror of
https://github.com/CopterExpress/clover.git
synced 2026-05-26 11:43:25 +00:00
simple_offboard: fix checking kill switch state
This commit is contained in:
@@ -496,10 +496,16 @@ inline void checkManualControl()
|
||||
}
|
||||
|
||||
if (check_kill_switch) {
|
||||
const int KILL_SWITCH_BIT = 12; // https://github.com/PX4/Firmware/blob/c302514a0809b1765fafd13c014d705446ae1113/src/modules/mavlink/mavlink_messages.cpp#L3975
|
||||
bool kill_switch = manual_control.buttons & (1 << KILL_SWITCH_BIT);
|
||||
// switch values: https://github.com/PX4/PX4-Autopilot/blob/c302514a0809b1765fafd13c014d705446ae1113/msg/manual_control_setpoint.msg#L3
|
||||
const uint8_t SWITCH_POS_NONE = 0; // switch is not mapped
|
||||
const uint8_t SWITCH_POS_ON = 1; // switch activated
|
||||
const uint8_t SWITCH_POS_MIDDLE = 2; // middle position
|
||||
const uint8_t SWITCH_POS_OFF = 3; // switch not activated
|
||||
|
||||
if (kill_switch)
|
||||
const int KILL_SWITCH_BIT = 12; // https://github.com/PX4/Firmware/blob/c302514a0809b1765fafd13c014d705446ae1113/src/modules/mavlink/mavlink_messages.cpp#L3975
|
||||
uint8_t kill_switch = (manual_control.buttons & (0b11 << KILL_SWITCH_BIT)) >> KILL_SWITCH_BIT;
|
||||
|
||||
if (kill_switch == SWITCH_POS_ON)
|
||||
throw std::runtime_error("Kill switch is on");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user