mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-23 14:07:34 +08:00
manual_control: move override detection
This also removes the option to ignore throttle for the override detection as it's not really required anymore.
This commit is contained in:
committed by
Matthias Grob
parent
1c15cc11d8
commit
cda6524421
@@ -36,10 +36,9 @@
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
enum OverrideBits {
|
||||
enum class OverrideBits : int32_t {
|
||||
OVERRIDE_AUTO_MODE_BIT = (1 << 0),
|
||||
OVERRIDE_OFFBOARD_MODE_BIT = (1 << 1),
|
||||
OVERRIDE_IGNORE_THROTTLE_BIT = (1 << 2)
|
||||
};
|
||||
|
||||
bool ManualControl::update()
|
||||
@@ -63,10 +62,10 @@ bool ManualControl::update()
|
||||
bool ManualControl::wantsOverride(const vehicle_control_mode_s &vehicle_control_mode,
|
||||
const vehicle_status_s &vehicle_status)
|
||||
{
|
||||
const bool override_auto_mode = (_param_rc_override.get() & OverrideBits::OVERRIDE_AUTO_MODE_BIT)
|
||||
const bool override_auto_mode = (_param_rc_override.get() & static_cast<int32_t>(OverrideBits::OVERRIDE_AUTO_MODE_BIT))
|
||||
&& vehicle_control_mode.flag_control_auto_enabled;
|
||||
|
||||
const bool override_offboard_mode = (_param_rc_override.get() & OverrideBits::OVERRIDE_OFFBOARD_MODE_BIT)
|
||||
const bool override_offboard_mode = (_param_rc_override.get() & static_cast<int32_t>(OverrideBits::OVERRIDE_OFFBOARD_MODE_BIT))
|
||||
&& vehicle_control_mode.flag_control_offboard_enabled;
|
||||
|
||||
// in Descend manual override is enbaled independently of COM_RC_OVERRIDE
|
||||
@@ -74,19 +73,8 @@ bool ManualControl::wantsOverride(const vehicle_control_mode_s &vehicle_control_
|
||||
|
||||
|
||||
if (_rc_available && (override_auto_mode || override_offboard_mode || override_landing)) {
|
||||
const float minimum_stick_change = .01f * _param_com_rc_stick_ov.get();
|
||||
|
||||
const bool rpy_moved = (fabsf(_manual_control_setpoint.x - _last_manual_control_setpoint.x) > minimum_stick_change)
|
||||
|| (fabsf(_manual_control_setpoint.y - _last_manual_control_setpoint.y) > minimum_stick_change)
|
||||
|| (fabsf(_manual_control_setpoint.r - _last_manual_control_setpoint.r) > minimum_stick_change);
|
||||
// Throttle change value doubled to achieve the same scaling even though the range is [0,1] instead of [-1,1]
|
||||
const bool throttle_moved =
|
||||
(fabsf(_manual_control_setpoint.z - _last_manual_control_setpoint.z) * 2.f > minimum_stick_change);
|
||||
const bool use_throttle = !(_param_rc_override.get() & OverrideBits::OVERRIDE_IGNORE_THROTTLE_BIT);
|
||||
|
||||
if (rpy_moved || (use_throttle && throttle_moved)) {
|
||||
return true;
|
||||
}
|
||||
return _manual_control_setpoint.user_override;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -669,10 +669,9 @@ PARAM_DEFINE_INT32(COM_REARM_GRACE, 1);
|
||||
* override is always enabled.
|
||||
*
|
||||
* @min 0
|
||||
* @max 7
|
||||
* @max 3
|
||||
* @bit 0 Enable override during auto modes (except for in critical battery reaction)
|
||||
* @bit 1 Enable override during offboard mode
|
||||
* @bit 2 Ignore throttle stick
|
||||
* @group Commander
|
||||
*/
|
||||
PARAM_DEFINE_INT32(COM_RC_OVERRIDE, 1);
|
||||
|
||||
Reference in New Issue
Block a user