Skip to content

Commit

Permalink
Plane: add flag to disable wp speed scaling on heading and groundtrack
Browse files Browse the repository at this point in the history
  • Loading branch information
magate committed Aug 29, 2024
1 parent 0a3bdbf commit cec3820
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ArduPlane/quadplane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,13 @@ const AP_Param::GroupInfo QuadPlane::var_info2[] = {
// @User: Standard
AP_GROUPINFO("BCK_PIT_LIM", 38, QuadPlane, q_bck_pitch_lim, 10.0f),

// @Param: WP_SPD_SCALE
// @DisplayName: Do waypoint speed scaling based on heading and groundtrack
// @Description: This flag can be used to disable the waypoint speed scaling based on heading and ground track difference. When landing on a moving platform it is possible to have a prevailing headwind that is not in the direction of the groundspeed vector.
// @Values: 0 1
// @User: Advanced
AP_GROUPINFO("WP_SPD_SCALE", 39, QuadPlane, q_do_wp_speed_scaling, 1),

AP_GROUPEND
};

Expand Down Expand Up @@ -3009,7 +3016,7 @@ float QuadPlane::get_scaled_wp_speed(float target_bearing_deg) const
{
const float yaw_difference = fabsf(wrap_180(degrees(plane.ahrs.get_yaw()) - target_bearing_deg));
const float wp_speed = wp_nav->get_default_speed_xy() * 0.01;
if (yaw_difference > 20) {
if (q_do_wp_speed_scaling == 1 && yaw_difference > 20) {
// this gives a factor of 2x reduction in max speed when
// off by 90 degrees, and 3x when off by 180 degrees
const float speed_reduction = linear_interpolate(1, 3,
Expand Down
3 changes: 3 additions & 0 deletions ArduPlane/quadplane.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,9 @@ class QuadPlane
float q_bck_pitch_lim_cd; // backward pitch limit applied when using Q_BCK_PIT_LIM
uint32_t q_pitch_limit_update_ms; // last time the backward pitch limit was updated

// flag to disable the use of wp speed scaling on heading and groundtrack difference
uint32_t q_do_wp_speed_scaling;

// when did we last run the attitude controller?
uint32_t last_att_control_ms;

Expand Down

0 comments on commit cec3820

Please sign in to comment.