mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 09:43:34 +08:00
feat(fw-launch-detection): use acceleration magnitude instead of body-forward (#26857)
* feat(fw-launch-detection): use acceleration magnitude for launch detection * docs: update takeoff docs --------- Co-authored-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
co-authored by
Silvan Fuhrer
parent
d617971b3e
commit
5d26d7126a
@@ -253,7 +253,7 @@ FixedWingModeManager::vehicle_attitude_poll()
|
||||
_pitch = euler_angles(1);
|
||||
|
||||
const Vector3f body_acceleration = R.transpose() * Vector3f{_local_pos.ax, _local_pos.ay, _local_pos.az};
|
||||
_body_acceleration_x = body_acceleration(0);
|
||||
_body_acceleration_norm = body_acceleration.norm();
|
||||
|
||||
const Vector3f body_velocity = R.transpose() * Vector3f{_local_pos.vx, _local_pos.vy, _local_pos.vz};
|
||||
_body_velocity_x = body_velocity(0);
|
||||
@@ -1196,8 +1196,8 @@ FixedWingModeManager::control_auto_takeoff(const hrt_abstime &now, const float c
|
||||
if (_control_mode.flag_armed) {
|
||||
/* Perform launch detection */
|
||||
|
||||
/* Detect launch using body X (forward) acceleration */
|
||||
_launchDetector.update(control_interval, _body_acceleration_x);
|
||||
/* Detect launch using body acceleration norm */
|
||||
_launchDetector.update(control_interval, _body_acceleration_norm);
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -1372,8 +1372,8 @@ FixedWingModeManager::control_auto_takeoff_no_nav(const hrt_abstime &now, const
|
||||
_launchDetector.getLaunchDetected() < launch_detection_status_s::STATE_FLYING) {
|
||||
|
||||
if (_control_mode.flag_armed) {
|
||||
/* Detect launch using body X (forward) acceleration */
|
||||
_launchDetector.update(control_interval, _body_acceleration_x);
|
||||
/* Detect launch using body acceleration norm */
|
||||
_launchDetector.update(control_interval, _body_acceleration_norm);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
@@ -258,7 +258,7 @@ private:
|
||||
float _pitch{0.0f}; // [rad] current pitch angle from attitude
|
||||
float _throttle{0.0f}; // [0-1] last set throttle
|
||||
|
||||
float _body_acceleration_x{0.f};
|
||||
float _body_acceleration_norm{0.f};
|
||||
float _body_velocity_x{0.f};
|
||||
|
||||
MapProjection _global_local_proj_ref{};
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
namespace launchdetection
|
||||
{
|
||||
|
||||
void LaunchDetector::update(const float dt, const float accel_x)
|
||||
void LaunchDetector::update(const float dt, const float accel_norm)
|
||||
{
|
||||
switch (state_) {
|
||||
case launch_detection_status_s::STATE_WAITING_FOR_LAUNCH:
|
||||
@@ -58,8 +58,8 @@ void LaunchDetector::update(const float dt, const float accel_x)
|
||||
info_delay_counter_s_ = 0.f; // reset counter
|
||||
}
|
||||
|
||||
/* Detect a acceleration that is longer and stronger as the minimum given by the params */
|
||||
if (accel_x > param_fw_laun_ac_thld_.get()) {
|
||||
/* Detect an acceleration that is longer and stronger than the minimum given by the params */
|
||||
if (accel_norm > param_fw_laun_ac_thld_.get()) {
|
||||
acceleration_detected_counter_ += dt;
|
||||
|
||||
if (acceleration_detected_counter_ > param_fw_laun_ac_t_.get()) {
|
||||
|
||||
@@ -67,10 +67,10 @@ public:
|
||||
/**
|
||||
* @brief Updates the state machine based on the current vehicle condition.
|
||||
*
|
||||
* @param dt Time step [us]
|
||||
* @param accel_x Measured acceleration in body x [m/s/s]
|
||||
* @param dt Time step [s]
|
||||
* @param accel_norm Norm of acceleration in the body frame [m/s^2]
|
||||
*/
|
||||
void update(const float dt, const float accel_x);
|
||||
void update(const float dt, const float accel_norm);
|
||||
|
||||
/**
|
||||
* @brief Get the Launch Detected state
|
||||
|
||||
@@ -5,8 +5,8 @@ parameters:
|
||||
FW_LAUN_AC_THLD:
|
||||
description:
|
||||
short: Trigger acceleration threshold
|
||||
long: Launch is detected when acceleration in body forward direction is above
|
||||
FW_LAUN_AC_THLD for FW_LAUN_AC_T seconds.
|
||||
long: Launch is detected when the norm of body acceleration
|
||||
is above FW_LAUN_AC_THLD for FW_LAUN_AC_T seconds.
|
||||
type: float
|
||||
default: 30.0
|
||||
unit: m/s^2
|
||||
@@ -16,8 +16,8 @@ parameters:
|
||||
FW_LAUN_AC_T:
|
||||
description:
|
||||
short: Trigger time
|
||||
long: Launch is detected when acceleration in body forward direction is above
|
||||
FW_LAUN_AC_THLD for FW_LAUN_AC_T seconds.
|
||||
long: Launch is detected when the norm of body acceleration
|
||||
is above FW_LAUN_AC_THLD for FW_LAUN_AC_T seconds.
|
||||
type: float
|
||||
default: 0.05
|
||||
unit: s
|
||||
|
||||
Reference in New Issue
Block a user