Skip to content

Commit dd89665

Browse files
Thomas StastnyJaeyoung-Lim
authored andcommitted
multiply track error boundary by scale factor in calculation of waypoint switch distance
1 parent 0b40586 commit dd89665

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

src/lib/npfg/npfg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ void NPFG::navigateLevelFlight(const float heading)
605605

606606
float NPFG::switchDistance(float wp_radius) const
607607
{
608-
return math::min(wp_radius, track_error_bound_);
608+
return math::min(wp_radius, track_error_bound_ * switch_distance_multiplier_);
609609
} // switchDistance
610610

611611
Vector2f NPFG::getLocalPlanarVector(const Vector2d &origin, const Vector2d &target) const

src/lib/npfg/npfg.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ class NPFG
135135
*/
136136
void setAirspeedBuffer(float buf) { airspeed_buffer_ = math::max(buf, 0.1f); }
137137

138+
/*
139+
* Set the switch distance multiplier.
140+
*/
141+
void setSwitchDistanceMultiplier(float mult) { switch_distance_multiplier_ = math::max(mult, 0.1f); }
142+
138143
/*
139144
* @return Controller proportional gain [rad/s]
140145
*/
@@ -369,6 +374,8 @@ class NPFG
369374
float min_gsp_track_keeping_max_{5.0f}; // maximum, minimum forward ground speed demand from track keeping logic [m/s]
370375

371376
// guidance parameters
377+
float switch_distance_multiplier_{0.318f}; // a value multiplied by the track error boundary resulting in a lower switch distance
378+
// ^as the bearing angle changes quadratically (instead of linearly as in L1), the time constant (automatically calculated for on track stability) proportional track error boundary typically over estimates the required switching distance
372379
float airspeed_buffer_{1.5f}; // size of the region above the feasibility boundary (into feasible space) where a continuous transition from feasible to infeasible is imposed [m/s]
373380
float inv_nte_fraction_{0.5f}; // inverse normalized track error fraction ...
374381
// ^determines at what fraction of the normalized track error the maximum track keeping forward ground speed demand is reached

src/modules/fw_pos_control_l1/FixedwingPositionControl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ FixedwingPositionControl::parameters_update()
119119
_npfg.setNormalizedTrackErrorFraction(_param_npfg_nte_fraction.get());
120120
_npfg.setRollTimeConst(_param_npfg_roll_time_const.get());
121121
_npfg.setAirspeedBuffer(_param_npfg_airspeed_buffer.get());
122+
_npfg.setSwitchDistanceMultiplier(_param_npfg_switch_distance_multiplier.get());
122123
_npfg.setRollLimit(radians(_param_fw_r_lim.get()));
123124
_npfg.setRollSlewRate(radians(_param_fw_l1_r_slew_max.get()));
124125

src/modules/fw_pos_control_l1/FixedwingPositionControl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ class FixedwingPositionControl final : public ModuleBase<FixedwingPositionContro
388388
(ParamFloat<px4::params::NPFG_NTE_FRAC>) _param_npfg_nte_fraction,
389389
(ParamFloat<px4::params::NPFG_ROLL_TC>) _param_npfg_roll_time_const,
390390
(ParamFloat<px4::params::NPFG_ASPD_BUF>) _param_npfg_airspeed_buffer,
391+
(ParamFloat<px4::params::NPFG_SW_DST_MLT>) _param_npfg_switch_distance_multiplier,
391392

392393
(ParamFloat<px4::params::FW_LND_AIRSPD_SC>) _param_fw_lnd_airspd_sc,
393394
(ParamFloat<px4::params::FW_LND_ANG>) _param_fw_lnd_ang,

src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,21 @@ PARAM_DEFINE_FLOAT(NPFG_ROLL_TC, 0.5f);
237237
*/
238238
PARAM_DEFINE_FLOAT(NPFG_ASPD_BUF, 1.5f);
239239

240+
/**
241+
* NPFG switch distance multiplier
242+
*
243+
* Multiplied by the track error boundary to determine when the aircraft switches
244+
* to the next waypoint and/or path segment. Should be less than 1. 1/pi (0.32)
245+
* sets the switch distance equivalent to that of the L1 controller.
246+
*
247+
* @min 0.1
248+
* @max 1.0
249+
* @decimal 2
250+
* @increment 0.01
251+
* @group FW NPFG Control
252+
*/
253+
PARAM_DEFINE_FLOAT(NPFG_SW_DST_MLT, 0.32f);
254+
240255
/**
241256
* Cruise throttle
242257
*

0 commit comments

Comments
 (0)