| 620 | } |
| 621 | |
| 622 | inline void checkManualControl() |
| 623 | { |
| 624 | if (!manual_control_timeout.isZero() && TIMEOUT(manual_control, manual_control_timeout)) { |
| 625 | throw std::runtime_error("Manual control timeout, RC is switched off?"); |
| 626 | } |
| 627 | |
| 628 | if (check_kill_switch) { |
| 629 | // switch values: https://github.com/PX4/PX4-Autopilot/blob/c302514a0809b1765fafd13c014d705446ae1113/msg/manual_control_setpoint.msg#L3 |
| 630 | const uint8_t SWITCH_POS_NONE = 0; // switch is not mapped |
| 631 | const uint8_t SWITCH_POS_ON = 1; // switch activated |
| 632 | const uint8_t SWITCH_POS_MIDDLE = 2; // middle position |
| 633 | const uint8_t SWITCH_POS_OFF = 3; // switch not activated |
| 634 | |
| 635 | const int KILL_SWITCH_BIT = 12; // https://github.com/PX4/Firmware/blob/c302514a0809b1765fafd13c014d705446ae1113/src/modules/mavlink/mavlink_messages.cpp#L3975 |
| 636 | uint8_t kill_switch = (manual_control.buttons & (0b11 << KILL_SWITCH_BIT)) >> KILL_SWITCH_BIT; |
| 637 | |
| 638 | if (kill_switch == SWITCH_POS_ON) |
| 639 | throw std::runtime_error("Kill switch is on"); |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | inline void checkState() |
| 644 | { |