mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 04:03:34 +08:00
Handle rc toggle mode buttons to initialize flight modes
Signed-off-by: Claudio Micheli <claudio@auterion.com>
This commit is contained in:
committed by
Matthias Grob
parent
c50daae4a3
commit
05d40f40d4
@@ -2428,7 +2428,7 @@ Commander::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_armed.armed && _manual_control.isMavlink() && (_internal_state.main_state_changes == 0)) {
|
if (!_armed.armed && _manual_control.isModeInitializationRequired() && (_internal_state.main_state_changes == 0)) {
|
||||||
// if there's never been a mode change force position control as initial state
|
// if there's never been a mode change force position control as initial state
|
||||||
_internal_state.main_state = commander_state_s::MAIN_STATE_POSCTL;
|
_internal_state.main_state = commander_state_s::MAIN_STATE_POSCTL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,6 +177,14 @@ bool ManualControl::wantsArm(const vehicle_control_mode_s &vehicle_control_mode,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ManualControl::isModeInitializationRequired()
|
||||||
|
{
|
||||||
|
const bool isMavlink = _manual_control_setpoint.data_source > manual_control_setpoint_s::SOURCE_RC;
|
||||||
|
const bool rc_uses_toggle_buttons = !isMavlink && _param_rc_map_flightmode_buttons.get() > 0;
|
||||||
|
|
||||||
|
return (isMavlink || rc_uses_toggle_buttons);
|
||||||
|
}
|
||||||
|
|
||||||
void ManualControl::updateParams()
|
void ManualControl::updateParams()
|
||||||
{
|
{
|
||||||
ModuleParams::updateParams();
|
ModuleParams::updateParams();
|
||||||
|
|||||||
@@ -64,12 +64,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool update();
|
bool update();
|
||||||
bool isRCAvailable() const { return _rc_available; }
|
bool isRCAvailable() const { return _rc_available; }
|
||||||
bool isMavlink() const { return _manual_control_setpoint.data_source > manual_control_setpoint_s::SOURCE_RC; }
|
|
||||||
bool wantsOverride(const vehicle_control_mode_s &vehicle_control_mode, const vehicle_status_s &vehicle_status);
|
bool wantsOverride(const vehicle_control_mode_s &vehicle_control_mode, const vehicle_status_s &vehicle_status);
|
||||||
bool wantsDisarm(const vehicle_control_mode_s &vehicle_control_mode, const vehicle_status_s &vehicle_status,
|
bool wantsDisarm(const vehicle_control_mode_s &vehicle_control_mode, const vehicle_status_s &vehicle_status,
|
||||||
manual_control_switches_s &manual_control_switches, const bool landed);
|
manual_control_switches_s &manual_control_switches, const bool landed);
|
||||||
bool wantsArm(const vehicle_control_mode_s &vehicle_control_mode, const vehicle_status_s &vehicle_status,
|
bool wantsArm(const vehicle_control_mode_s &vehicle_control_mode, const vehicle_status_s &vehicle_status,
|
||||||
const manual_control_switches_s &manual_control_switches, const bool landed);
|
const manual_control_switches_s &manual_control_switches, const bool landed);
|
||||||
|
bool isModeInitializationRequired();
|
||||||
bool isThrottleLow() const { return _last_manual_control_setpoint.z < 0.1f; }
|
bool isThrottleLow() const { return _last_manual_control_setpoint.z < 0.1f; }
|
||||||
bool isThrottleAboveCenter() const { return _last_manual_control_setpoint.z > 0.6f; }
|
bool isThrottleAboveCenter() const { return _last_manual_control_setpoint.z > 0.6f; }
|
||||||
hrt_abstime getLastRcTimestamp() const { return _last_manual_control_setpoint.timestamp; }
|
hrt_abstime getLastRcTimestamp() const { return _last_manual_control_setpoint.timestamp; }
|
||||||
@@ -96,6 +96,7 @@ private:
|
|||||||
(ParamBool<px4::params::COM_ARM_SWISBTN>) _param_com_arm_swisbtn,
|
(ParamBool<px4::params::COM_ARM_SWISBTN>) _param_com_arm_swisbtn,
|
||||||
(ParamBool<px4::params::COM_REARM_GRACE>) _param_com_rearm_grace,
|
(ParamBool<px4::params::COM_REARM_GRACE>) _param_com_rearm_grace,
|
||||||
(ParamInt<px4::params::COM_RC_OVERRIDE>) _param_rc_override,
|
(ParamInt<px4::params::COM_RC_OVERRIDE>) _param_rc_override,
|
||||||
(ParamFloat<px4::params::COM_RC_STICK_OV>) _param_com_rc_stick_ov
|
(ParamFloat<px4::params::COM_RC_STICK_OV>) _param_com_rc_stick_ov,
|
||||||
|
(ParamInt<px4::params::RC_MAP_FLTM_BTN>) _param_rc_map_flightmode_buttons
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user