mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 08:38:53 +08:00
ManualControl: fix payload power switch state when mapped with RC (RC_MAP_PAY_SW) (#26357)
* ManualControl: Payload Power Switch: default PAYLOAD_POWER_EN false if RC_MAP_PAY_SW is configured. Apply initial switch state for Payload Power * make format * ManualControl: init power_en in init() * ManualControl: Apply payload power state on first switch receipt if not armed * simplfy * fix idefs * simplify
This commit is contained in:
@@ -52,6 +52,15 @@ ManualControl::~ManualControl()
|
||||
|
||||
bool ManualControl::init()
|
||||
{
|
||||
#if defined(PAYLOAD_POWER_EN)
|
||||
|
||||
// If the payload power switch is mapped, default to power off until the RC switch explicitly commands it on.
|
||||
if (_param_rc_map_pay_sw.get()) {
|
||||
PAYLOAD_POWER_EN(false);
|
||||
}
|
||||
|
||||
#endif // PAYLOAD_POWER_EN
|
||||
|
||||
ScheduleNow();
|
||||
return true;
|
||||
}
|
||||
@@ -293,6 +302,18 @@ void ManualControl::processSwitches(hrt_abstime &now)
|
||||
} else if (!_armed) {
|
||||
// Directly initialize mode using RC switch but only before arming
|
||||
evaluateModeSlot(switches.mode_slot);
|
||||
#if defined(PAYLOAD_POWER_EN)
|
||||
|
||||
// Apply payload power state on first switch receipt if not armed
|
||||
if (switches.payload_power_switch == manual_control_switches_s::SWITCH_POS_ON) {
|
||||
PAYLOAD_POWER_EN(true);
|
||||
|
||||
} else if (switches.payload_power_switch == manual_control_switches_s::SWITCH_POS_OFF
|
||||
|| switches.payload_power_switch == manual_control_switches_s::SWITCH_POS_MIDDLE) {
|
||||
PAYLOAD_POWER_EN(false);
|
||||
}
|
||||
|
||||
#endif // PAYLOAD_POWER_EN
|
||||
}
|
||||
|
||||
_previous_switches = switches;
|
||||
|
||||
@@ -149,6 +149,7 @@ private:
|
||||
(ParamBool<px4::params::MAN_ARM_GESTURE>) _param_man_arm_gesture,
|
||||
(ParamFloat<px4::params::MAN_KILL_GEST_T>) _param_man_kill_gest_t,
|
||||
(ParamBool<px4::params::COM_ARM_SWISBTN>) _param_com_arm_swisbtn,
|
||||
(ParamInt<px4::params::RC_MAP_PAY_SW>) _param_rc_map_pay_sw,
|
||||
(ParamInt<px4::params::COM_FLTMODE1>) _param_fltmode_1,
|
||||
(ParamInt<px4::params::COM_FLTMODE2>) _param_fltmode_2,
|
||||
(ParamInt<px4::params::COM_FLTMODE3>) _param_fltmode_3,
|
||||
|
||||
Reference in New Issue
Block a user