mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-25 00:30:50 +08:00
feat(failure_detector)!: rename the tilt parameters to FD_TILT_ERROR
The tilt check limits the error from the attitude setpoint, which the FD_FAIL_R name no longer describes. FD_FAIL_R becomes FD_TILT_ERROR, now a float, and FD_FAIL_R_TTRI becomes FD_TILT_ERROR_T. The old roll and pitch limits and trigger times meant something else, so they start at the new defaults instead of being taken over. Only a check disabled for both roll and pitch stays disabled, as -1.
This commit is contained in:
1 parent
8225bb350f
commit
fa877566a4
20 files changed
+56
-40
No files matched your search
@@ -50,7 +50,7 @@ void FailureDetectorChecks::checkAndReport(const Context &context, Report &repor
|
||||
* The vehicle tilt deviated from the attitude setpoint, by more than the configured angle.
|
||||
*
|
||||
* <profile name="dev">
|
||||
* This check can be configured via <param>FD_FAIL_R</param> parameter.
|
||||
* This check can be configured via <param>FD_TILT_ERROR</param> parameter.
|
||||
* </profile>
|
||||
*/
|
||||
reporter.armingCheckFailure(NavModes::All, health_component_t::system, events::ID("check_failure_detector_tilt"),
|
||||
|
||||
@@ -123,14 +123,11 @@ void FailureDetector::updateAttitudeStatus(const vehicle_status_s &vehicle_statu
|
||||
z_setpoint = matrix::Quatf(attitude_setpoint.q_d).dcm_z();
|
||||
}
|
||||
|
||||
// angle between body z-axis and setpoint z-axis
|
||||
const float max_tilt_error_deg = _param_fd_tilt_error.get();
|
||||
const float tilt_error = acosf(math::constrain(q.dcm_z().dot(z_setpoint), -1.f, 1.f));
|
||||
// -1 disables, 0 as well for backwards compatibility
|
||||
const int max_tilt_error_deg = _param_fd_fail_r.get();
|
||||
const bool tilt_status = (max_tilt_error_deg > 0)
|
||||
&& (tilt_error > math::radians(static_cast<float>(max_tilt_error_deg)));
|
||||
const bool tilt_status = (max_tilt_error_deg > 0.f) && (tilt_error > math::radians(max_tilt_error_deg));
|
||||
|
||||
_tilt_failure_hysteresis.set_hysteresis_time_from(false, (hrt_abstime)(1_s * _param_fd_fail_r_ttri.get()));
|
||||
_tilt_failure_hysteresis.set_hysteresis_time_from(false, (hrt_abstime)(1_s * _param_fd_tilt_error_t.get()));
|
||||
_tilt_failure_hysteresis.set_state_and_update(tilt_status, attitude.timestamp);
|
||||
_failure_detector_status.flags.tilt = _tilt_failure_hysteresis.get_state();
|
||||
}
|
||||
|
||||
@@ -130,8 +130,8 @@ private:
|
||||
failure_injection::MotorFailureMasks _injected_motor_masks{};
|
||||
|
||||
DEFINE_PARAMETERS(
|
||||
(ParamInt<px4::params::FD_FAIL_R>) _param_fd_fail_r,
|
||||
(ParamFloat<px4::params::FD_FAIL_R_TTRI>) _param_fd_fail_r_ttri,
|
||||
(ParamFloat<px4::params::FD_TILT_ERROR>) _param_fd_tilt_error,
|
||||
(ParamFloat<px4::params::FD_TILT_ERROR_T>) _param_fd_tilt_error_t,
|
||||
(ParamBool<px4::params::FD_EXT_ATS_EN>) _param_fd_ext_ats_en,
|
||||
(ParamInt<px4::params::FD_EXT_ATS_TRIG>) _param_fd_ext_ats_trig,
|
||||
(ParamInt<px4::params::FD_IMB_PROP_THR>) _param_fd_imb_prop_thr,
|
||||
|
||||
@@ -48,7 +48,7 @@ using matrix::Eulerf;
|
||||
using matrix::Quatf;
|
||||
using matrix::Vector3f;
|
||||
|
||||
static constexpr int kMaxTiltErrorDeg = 60;
|
||||
static constexpr float kMaxTiltErrorDeg = 60.f;
|
||||
|
||||
// Tilt by angle around a horizontal axis, direction 0° tilts around the x-axis (roll), 90° around the y-axis (pitch)
|
||||
static Quatf tilt(float angle_deg, float direction_deg = 0.f)
|
||||
@@ -76,10 +76,10 @@ public:
|
||||
_status.vehicle_type = vehicle_status_s::VEHICLE_TYPE_ROTARY_WING;
|
||||
}
|
||||
|
||||
void setParams(int32_t max_tilt_error_deg, float trigger_time_s)
|
||||
void setParams(float max_tilt_error_deg, float trigger_time_s)
|
||||
{
|
||||
param_set(param_handle(px4::params::FD_FAIL_R), &max_tilt_error_deg);
|
||||
param_set(param_handle(px4::params::FD_FAIL_R_TTRI), &trigger_time_s);
|
||||
param_set(param_handle(px4::params::FD_TILT_ERROR), &max_tilt_error_deg);
|
||||
param_set(param_handle(px4::params::FD_TILT_ERROR_T), &trigger_time_s);
|
||||
updateParams();
|
||||
}
|
||||
|
||||
@@ -195,11 +195,11 @@ TEST_F(FailureDetectorTiltTest, StaleSetpointFallsBackToLevel)
|
||||
|
||||
TEST_F(FailureDetectorTiltTest, NoTriggerWhenDisabled)
|
||||
{
|
||||
setParams(-1, 0.1f);
|
||||
setParams(-1.f, 0.1f);
|
||||
EXPECT_FALSE(updateAfterTriggerTime(tilt(180.f)));
|
||||
|
||||
// 0 also disables for backwards compatibility
|
||||
setParams(0, 0.1f);
|
||||
setParams(0.f, 0.1f);
|
||||
EXPECT_FALSE(updateAfterTriggerTime(tilt(180.f)));
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ module_name: failure_detector
|
||||
parameters:
|
||||
- group: Failure Detector
|
||||
definitions:
|
||||
FD_FAIL_R:
|
||||
FD_TILT_ERROR:
|
||||
description:
|
||||
short: FailureDetector Max Tilt Error
|
||||
long: |-
|
||||
@@ -14,15 +14,16 @@ parameters:
|
||||
which disarms motors but does not set outputs to failsafe values.
|
||||
|
||||
Set to -1 to disable.
|
||||
type: int32
|
||||
type: float
|
||||
default: 60
|
||||
min: -1
|
||||
max: 180
|
||||
unit: deg
|
||||
FD_FAIL_R_TTRI:
|
||||
decimal: 0
|
||||
FD_TILT_ERROR_T:
|
||||
description:
|
||||
short: Tilt failure trigger time
|
||||
long: Seconds (decimal) that the tilt error has to exceed FD_FAIL_R before being considered as a failure.
|
||||
long: Seconds (decimal) that the tilt error has to exceed FD_TILT_ERROR before being considered as a failure.
|
||||
type: float
|
||||
default: 1.0
|
||||
unit: s
|
||||
|
||||
Reference in new issue
Block a user