mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-05 09:10:36 +08:00
Separate RC and manual control terms
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
committed by
Matthias Grob
parent
e15752099f
commit
16f97635ce
@@ -37,7 +37,6 @@ using namespace time_literals;
|
||||
|
||||
void RcAndDataLinkChecks::checkAndReport(const Context &context, Report &reporter)
|
||||
{
|
||||
// RC
|
||||
manual_control_setpoint_s manual_control_setpoint;
|
||||
|
||||
if (!_manual_control_setpoint_sub.copy(&manual_control_setpoint)) {
|
||||
@@ -45,7 +44,7 @@ void RcAndDataLinkChecks::checkAndReport(const Context &context, Report &reporte
|
||||
reporter.failsafeFlags().manual_control_signal_lost = true;
|
||||
}
|
||||
|
||||
// Check if RC is valid
|
||||
// Check if manual control is valid
|
||||
if (!manual_control_setpoint.valid
|
||||
|| hrt_elapsed_time(&manual_control_setpoint.timestamp) > _param_com_rc_loss_t.get() * 1_s) {
|
||||
|
||||
@@ -77,14 +76,14 @@ void RcAndDataLinkChecks::checkAndReport(const Context &context, Report &reporte
|
||||
|
||||
if (reporter.failsafeFlags().gcs_connection_lost) {
|
||||
|
||||
// Prevent arming if we neither have RC nor a GCS connection. TODO: disabled for now due to MAVROS tests
|
||||
// Prevent arming if we neither have manual control nor a GCS connection. TODO: disabled for now due to MAVROS tests
|
||||
bool gcs_connection_required = _param_nav_dll_act.get() > 0
|
||||
/*|| (rc_is_optional && reporter.failsafeFlags().manual_control_signal_lost) */;
|
||||
NavModes affected_modes = gcs_connection_required ? NavModes::All : NavModes::None;
|
||||
events::LogLevel log_level = gcs_connection_required ? events::Log::Error : events::Log::Info;
|
||||
/* EVENT
|
||||
* @description
|
||||
* To arm, at least a data link or manual control (RC) must be present.
|
||||
* To arm, at least a data link or RC must be present.
|
||||
*
|
||||
* <profile name="dev">
|
||||
* This check can be configured via <param>NAV_DLL_ACT</param> parameter.
|
||||
|
||||
@@ -190,7 +190,7 @@ PARAM_DEFINE_INT32(COM_HOME_IN_AIR, 0);
|
||||
PARAM_DEFINE_INT32(COM_RC_IN_MODE, 3);
|
||||
|
||||
/**
|
||||
* RC input arm/disarm command duration
|
||||
* Manual control input arm/disarm command duration
|
||||
*
|
||||
* The default value of 1000 requires the stick to be held in the arm or disarm position for 1 second.
|
||||
*
|
||||
@@ -421,9 +421,9 @@ PARAM_DEFINE_INT32(COM_ARM_MAG_ANG, 60);
|
||||
PARAM_DEFINE_INT32(COM_ARM_MAG_STR, 2);
|
||||
|
||||
/**
|
||||
* Enable RC stick override of auto and/or offboard modes
|
||||
* Enable manual control stick override
|
||||
*
|
||||
* When RC stick override is enabled, moving the RC sticks more than COM_RC_STICK_OV
|
||||
* When enabled, moving the sticks more than COM_RC_STICK_OV
|
||||
* immediately gives control back to the pilot by switching to Position mode and
|
||||
* if position is unavailable Altitude mode.
|
||||
* Note: Only has an effect on multicopters, and VTOLs in multicopter mode.
|
||||
@@ -437,7 +437,7 @@ PARAM_DEFINE_INT32(COM_ARM_MAG_STR, 2);
|
||||
PARAM_DEFINE_INT32(COM_RC_OVERRIDE, 1);
|
||||
|
||||
/**
|
||||
* RC stick override threshold
|
||||
* Stick override threshold
|
||||
*
|
||||
* If COM_RC_OVERRIDE is enabled and the joystick input is moved more than this threshold
|
||||
* the autopilot the pilot takes over control.
|
||||
@@ -601,11 +601,10 @@ PARAM_DEFINE_INT32(COM_TAKEOFF_ACT, 0);
|
||||
PARAM_DEFINE_INT32(NAV_DLL_ACT, 0);
|
||||
|
||||
/**
|
||||
* Set RC loss failsafe mode
|
||||
* Set manual control loss failsafe mode
|
||||
*
|
||||
* The RC loss failsafe will only be entered after a timeout,
|
||||
* set by COM_RC_LOSS_T in seconds. If RC input checks have been disabled
|
||||
* by setting the COM_RC_IN_MODE param it will not be triggered.
|
||||
* The manual control loss failsafe will only be entered after a timeout,
|
||||
* set by COM_RC_LOSS_T in seconds.
|
||||
*
|
||||
* @value 1 Hold mode
|
||||
* @value 2 Return mode
|
||||
@@ -620,7 +619,7 @@ PARAM_DEFINE_INT32(NAV_DLL_ACT, 0);
|
||||
PARAM_DEFINE_INT32(NAV_RCL_ACT, 2);
|
||||
|
||||
/**
|
||||
* RC loss exceptions
|
||||
* Manual control loss exceptions
|
||||
*
|
||||
* Specify modes where manual control loss is ignored and no failsafe is triggered.
|
||||
* External modes requiring stick input will still failsafe.
|
||||
|
||||
@@ -456,7 +456,7 @@ void Failsafe::checkStateAndMode(const hrt_abstime &time_us, const State &state,
|
||||
vehicle_status_s::NAVIGATION_STATE_AUTO_VTOL_TAKEOFF
|
||||
&& in_forward_flight && !state.mission_finished;
|
||||
|
||||
// Manual control (RC) loss
|
||||
// Manual control (RC or joystick) loss
|
||||
if (!status_flags.manual_control_signal_lost) {
|
||||
// If manual control was lost and arming was allowed, consider it optional until we regain manual control
|
||||
_manual_control_lost_at_arming = false;
|
||||
|
||||
@@ -109,7 +109,7 @@ TEST_F(FailsafeTest, general)
|
||||
ASSERT_EQ(updated_user_intented_mode, state.user_intended_mode);
|
||||
ASSERT_EQ(failsafe.selectedAction(), FailsafeBase::Action::None);
|
||||
|
||||
// RC lost -> Hold, then RTL
|
||||
// manual control lost -> Hold, then RTL
|
||||
time += 10_ms;
|
||||
failsafe_flags.manual_control_signal_lost = true;
|
||||
updated_user_intented_mode = failsafe.update(time, state, false, stick_override_request, failsafe_flags);
|
||||
@@ -127,14 +127,14 @@ TEST_F(FailsafeTest, general)
|
||||
ASSERT_EQ(updated_user_intented_mode, state.user_intended_mode);
|
||||
ASSERT_EQ(failsafe.selectedAction(), FailsafeBase::Action::Descend);
|
||||
|
||||
// DL link regained -> RTL (RC still lost)
|
||||
// DL link regained -> RTL (manual control still lost)
|
||||
time += 10_ms;
|
||||
failsafe_flags.gcs_connection_lost = false;
|
||||
updated_user_intented_mode = failsafe.update(time, state, false, stick_override_request, failsafe_flags);
|
||||
ASSERT_EQ(updated_user_intented_mode, state.user_intended_mode);
|
||||
ASSERT_EQ(failsafe.selectedAction(), FailsafeBase::Action::RTL);
|
||||
|
||||
// RC lost cleared -> keep RTL
|
||||
// Manual control lost cleared -> keep RTL
|
||||
time += 10_ms;
|
||||
failsafe_flags.manual_control_signal_lost = false;
|
||||
updated_user_intented_mode = failsafe.update(time, state, false, stick_override_request, failsafe_flags);
|
||||
@@ -425,7 +425,7 @@ TEST_F(FailsafeTest, skip_failsafe)
|
||||
ASSERT_EQ(updated_user_intented_mode, state.user_intended_mode);
|
||||
ASSERT_EQ(failsafe.selectedAction(), FailsafeBase::Action::None);
|
||||
|
||||
// RC lost while in RTL -> stay in RTL and only warn
|
||||
// Manual control lost while in RTL -> stay in RTL and only warn
|
||||
failsafe_flags.manual_control_signal_lost = true;
|
||||
|
||||
updated_user_intented_mode = failsafe.update(time, state, false, false, failsafe_flags);
|
||||
|
||||
Reference in New Issue
Block a user