mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 08:38:53 +08:00
Update COM_RC_IN_MODE enum naming
This commit is contained in:
committed by
Tobias Büchli
parent
acf5766f9c
commit
f1f3c81566
@@ -75,7 +75,7 @@ void RcCalibrationChecks::checkAndReport(const Context &context, Report &reporte
|
||||
return;
|
||||
}
|
||||
|
||||
// return early when joystick only or stick input disabled
|
||||
// return early when stick input from RC is disabled (MAVLink only or manual control disabled)
|
||||
if (_param_com_rc_in_mode.get() == 1 || _param_com_rc_in_mode.get() == 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -490,7 +490,7 @@ void Failsafe::checkStateAndMode(const hrt_abstime &time_us, const State &state,
|
||||
rc_loss_ignored_takeoff || rc_loss_ignored_external_mode || ignore_any_link_loss_vtol_takeoff_fixedwing
|
||||
|| _manual_control_lost_at_arming || rc_loss_ignored_altitude_cruise;
|
||||
|
||||
if (_param_com_rc_in_mode.get() != int32_t(RcInMode::StickInputDisabled) && !rc_loss_ignored) {
|
||||
if (_param_com_rc_in_mode.get() != int32_t(RcInMode::DisableManualControl) && !rc_loss_ignored) {
|
||||
CHECK_FAILSAFE(status_flags, manual_control_signal_lost,
|
||||
fromNavDllOrRclActParam(_param_nav_rcl_act.get()).causedBy(Cause::ManualControlLoss));
|
||||
}
|
||||
@@ -531,7 +531,7 @@ void Failsafe::checkStateAndMode(const hrt_abstime &time_us, const State &state,
|
||||
|
||||
// If manual control loss and GCS connection loss are disabled and we lose both command links and the mission finished,
|
||||
// trigger RTL to avoid losing the vehicle
|
||||
if ((_param_com_rc_in_mode.get() == int32_t(RcInMode::StickInputDisabled) || rc_loss_ignored_mission)
|
||||
if ((_param_com_rc_in_mode.get() == int32_t(RcInMode::DisableManualControl) || rc_loss_ignored_mission)
|
||||
&& _param_nav_dll_act.get() == int32_t(gcs_connection_loss_failsafe_mode::Disabled)
|
||||
&& state.mission_finished) {
|
||||
_last_state_mission_control_lost = checkFailsafe(_caller_id_mission_control_lost, _last_state_mission_control_lost,
|
||||
|
||||
@@ -128,15 +128,15 @@ private:
|
||||
|
||||
// COM_RC_IN_MODE parameter values
|
||||
enum class RcInMode : int32_t {
|
||||
RcTransmitterOnly = 0, // RC Transmitter only
|
||||
JoystickOnly = 1, // Joystick only
|
||||
RcAndJoystickWithFallback = 2, // RC And Joystick with fallback
|
||||
RcOrJoystickKeepFirst = 3, // RC or Joystick keep first
|
||||
StickInputDisabled = 4, // input disabled
|
||||
RcThenJoystickAscendingPriority = 5, // RC, then Joystick ascending prio
|
||||
JoystickAscendingThenRcPriority = 6, // Joystick ascending prio, then RC
|
||||
RcThenJoystickDescendingPriority = 7, // RC, then Joystick descending prio
|
||||
JoystickDescendingThenRcPriority = 8 // Joystick descending prio, then RC
|
||||
RcOnly = 0,
|
||||
MavLinkOnly = 1,
|
||||
RcOrMavlinkWithFallback = 2,
|
||||
RcOrMavlinkKeepFirst = 3,
|
||||
DisableManualControl = 4,
|
||||
PriorityRcThenMavlinkAscending = 5,
|
||||
PriorityMavlinkAscendingThenRc = 6,
|
||||
PriorityRcThenMavlinkDescending = 7,
|
||||
PriorityMavlinkDescendingThenRc = 8
|
||||
};
|
||||
|
||||
enum class command_after_high_wind_failsafe : int32_t {
|
||||
|
||||
@@ -48,10 +48,10 @@ void ManualControlSelector::updateWithNewInputSample(uint64_t now, const manual_
|
||||
|
||||
const bool update_existing_input = _setpoint.valid && (input.data_source == _setpoint.data_source);
|
||||
const bool start_using_new_input = !_setpoint.valid;
|
||||
const bool is_priority_mode = (_rc_in_mode == RcInMode::RcThenJoystickAscendingPriority
|
||||
|| _rc_in_mode == RcInMode::JoystickAscendingThenRcPriority
|
||||
|| _rc_in_mode == RcInMode::RcThenJoystickDescendingPriority
|
||||
|| _rc_in_mode == RcInMode::JoystickDescendingThenRcPriority);
|
||||
const bool is_priority_mode = (_rc_in_mode == RcInMode::PriorityRcThenMavlinkAscending
|
||||
|| _rc_in_mode == RcInMode::PriorityMavlinkAscendingThenRc
|
||||
|| _rc_in_mode == RcInMode::PriorityRcThenMavlinkDescending
|
||||
|| _rc_in_mode == RcInMode::PriorityMavlinkDescendingThenRc);
|
||||
|
||||
// Switch to new input if it's valid and we don't already have a valid one
|
||||
if (isInputValid(input, now) && (update_existing_input || start_using_new_input || is_priority_mode)) {
|
||||
@@ -76,24 +76,24 @@ bool ManualControlSelector::isInputValid(const manual_control_setpoint_s &input,
|
||||
bool match = false;
|
||||
|
||||
switch (_rc_in_mode) { // COM_RC_IN_MODE
|
||||
case RcInMode::RcTransmitterOnly:
|
||||
case RcInMode::RcOnly:
|
||||
match = isRc(input.data_source);
|
||||
break;
|
||||
|
||||
case RcInMode::JoystickOnly:
|
||||
case RcInMode::MavLinkOnly:
|
||||
match = isMavlink(input.data_source);
|
||||
break;
|
||||
|
||||
case RcInMode::RcAndJoystickWithFallback:
|
||||
case RcInMode::RcOrMavlinkWithFallback:
|
||||
match = true;
|
||||
break;
|
||||
|
||||
case RcInMode::RcOrJoystickKeepFirst:
|
||||
case RcInMode::RcOrMavlinkKeepFirst:
|
||||
match = (input.data_source == _first_valid_source)
|
||||
|| (_first_valid_source == manual_control_setpoint_s::SOURCE_UNKNOWN);
|
||||
break;
|
||||
|
||||
case RcInMode::RcThenJoystickAscendingPriority:
|
||||
case RcInMode::PriorityRcThenMavlinkAscending:
|
||||
if (isRc(input.data_source)) {
|
||||
match = true;
|
||||
|
||||
@@ -108,7 +108,7 @@ bool ManualControlSelector::isInputValid(const manual_control_setpoint_s &input,
|
||||
|
||||
break;
|
||||
|
||||
case RcInMode::JoystickAscendingThenRcPriority:
|
||||
case RcInMode::PriorityMavlinkAscendingThenRc:
|
||||
if (isMavlink(input.data_source)) {
|
||||
if (!_setpoint.valid || isRc(_setpoint.data_source)) {
|
||||
match = true;
|
||||
@@ -125,7 +125,7 @@ bool ManualControlSelector::isInputValid(const manual_control_setpoint_s &input,
|
||||
|
||||
break;
|
||||
|
||||
case RcInMode::RcThenJoystickDescendingPriority:
|
||||
case RcInMode::PriorityRcThenMavlinkDescending:
|
||||
if (isRc(input.data_source)) {
|
||||
match = true;
|
||||
|
||||
@@ -140,7 +140,7 @@ bool ManualControlSelector::isInputValid(const manual_control_setpoint_s &input,
|
||||
|
||||
break;
|
||||
|
||||
case RcInMode::JoystickDescendingThenRcPriority:
|
||||
case RcInMode::PriorityMavlinkDescendingThenRc:
|
||||
if (isMavlink(input.data_source)) {
|
||||
if (!_setpoint.valid || isRc(_setpoint.data_source)) {
|
||||
match = true;
|
||||
@@ -157,7 +157,7 @@ bool ManualControlSelector::isInputValid(const manual_control_setpoint_s &input,
|
||||
|
||||
break;
|
||||
|
||||
case RcInMode::StickInputDisabled:
|
||||
case RcInMode::DisableManualControl:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -53,20 +53,20 @@ private:
|
||||
|
||||
// COM_RC_IN_MODE parameter values
|
||||
enum class RcInMode : int32_t {
|
||||
RcTransmitterOnly = 0, // RC Transmitter only
|
||||
JoystickOnly = 1, // Joystick only
|
||||
RcAndJoystickWithFallback = 2, // RC And Joystick with fallback
|
||||
RcOrJoystickKeepFirst = 3, // RC or Joystick keep first
|
||||
StickInputDisabled = 4, // input disabled
|
||||
RcThenJoystickAscendingPriority = 5, // RC, then Joystick ascending prio
|
||||
JoystickAscendingThenRcPriority = 6, // Joystick ascending prio, then RC
|
||||
RcThenJoystickDescendingPriority = 7, // RC, then Joystick descending prio
|
||||
JoystickDescendingThenRcPriority = 8 // Joystick descending prio, then RC
|
||||
RcOnly = 0,
|
||||
MavLinkOnly = 1,
|
||||
RcOrMavlinkWithFallback = 2,
|
||||
RcOrMavlinkKeepFirst = 3,
|
||||
DisableManualControl = 4,
|
||||
PriorityRcThenMavlinkAscending = 5,
|
||||
PriorityMavlinkAscendingThenRc = 6,
|
||||
PriorityRcThenMavlinkDescending = 7,
|
||||
PriorityMavlinkDescendingThenRc = 8
|
||||
};
|
||||
|
||||
manual_control_setpoint_s _setpoint{};
|
||||
uint64_t _timeout{0};
|
||||
RcInMode _rc_in_mode{RcInMode::RcTransmitterOnly};
|
||||
RcInMode _rc_in_mode{RcInMode::RcOnly};
|
||||
int _instance{-1};
|
||||
uint8_t _first_valid_source{manual_control_setpoint_s::SOURCE_UNKNOWN};
|
||||
};
|
||||
|
||||
@@ -352,7 +352,7 @@ TEST(ManualControlSelector, RcOutdated)
|
||||
EXPECT_EQ(selector.instance(), -1);
|
||||
}
|
||||
|
||||
TEST(ManualControlSelector, RcThenJoystickAscendingPriority)
|
||||
TEST(ManualControlSelector, PriorityRcThenMavlinkAscending)
|
||||
{
|
||||
ManualControlSelector selector;
|
||||
selector.setRcInMode(5); // Configure RC, then Joystick ascending
|
||||
@@ -456,7 +456,7 @@ TEST(ManualControlSelector, RcThenJoystickAscendingPriority)
|
||||
EXPECT_EQ(selector.instance(), 2);
|
||||
}
|
||||
|
||||
TEST(ManualControlSelector, JoystickAscendingThenRcPriority)
|
||||
TEST(ManualControlSelector, PriorityMavlinkAscendingThenRc)
|
||||
{
|
||||
ManualControlSelector selector;
|
||||
selector.setRcInMode(6); // Configure Joystick ascending, then RC
|
||||
@@ -560,7 +560,7 @@ TEST(ManualControlSelector, JoystickAscendingThenRcPriority)
|
||||
EXPECT_EQ(selector.instance(), 0);
|
||||
}
|
||||
|
||||
TEST(ManualControlSelector, RcThenJoystickDescendingPriority)
|
||||
TEST(ManualControlSelector, PriorityRcThenMavlinkDescending)
|
||||
{
|
||||
ManualControlSelector selector;
|
||||
selector.setRcInMode(7); // Configure RC, then Joystick descending
|
||||
@@ -664,7 +664,7 @@ TEST(ManualControlSelector, RcThenJoystickDescendingPriority)
|
||||
EXPECT_EQ(selector.instance(), 1);
|
||||
}
|
||||
|
||||
TEST(ManualControlSelector, JoystickDescendingThenRcPriority)
|
||||
TEST(ManualControlSelector, PriorityMavlinkDescendingThenRc)
|
||||
{
|
||||
ManualControlSelector selector;
|
||||
selector.setRcInMode(8); // Configure Joystick descending, then RC
|
||||
|
||||
Reference in New Issue
Block a user