Skip to content

Commit

Permalink
AP_Landing: move wind helper functions to AP_AHRS
Browse files Browse the repository at this point in the history
  • Loading branch information
magicrub committed Dec 20, 2023
1 parent cd72dcb commit b6b3b9d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 30 deletions.
27 changes: 0 additions & 27 deletions libraries/AP_Landing/AP_Landing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,33 +548,6 @@ bool AP_Landing::get_target_altitude_location(Location &location)
}
}

/*
* Determine how aligned heading_deg is with the wind. Return result
* is 1.0 when perfectly aligned heading into wind, -1 when perfectly
* aligned with-wind, and zero when perfect cross-wind. There is no
* distinction between a left or right cross-wind. Wind speed is ignored
*/
float AP_Landing::wind_alignment(const float heading_deg)
{
const Vector3f wind = ahrs.wind_estimate();
const float wind_heading_rad = atan2f(-wind.y, -wind.x);
return cosf(wind_heading_rad - radians(heading_deg));
}

/*
* returns head-wind in m/s, 0 for tail-wind.
*/
float AP_Landing::head_wind(void)
{
const float alignment = wind_alignment(ahrs.yaw_sensor*0.01f);

if (alignment <= 0) {
return 0;
}

return alignment * ahrs.wind_estimate().length();
}

/*
* returns target airspeed in cm/s depending on flight stage
*/
Expand Down
2 changes: 0 additions & 2 deletions libraries/AP_Landing/AP_Landing.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ class AP_Landing {

// helper functions
bool restart_landing_sequence(void);
float wind_alignment(const float heading_deg);
float head_wind(void);
int32_t get_target_airspeed_cm(void);

// accessor functions for the params and states
Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_Landing/AP_Landing_Slope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ int32_t AP_Landing::type_slope_get_target_airspeed_cm(void)

// when landing, add half of head-wind.
const float head_wind_comp = constrain_float(wind_comp, 0.0f, 100.0f)*0.01;
const int32_t head_wind_compensation_cm = head_wind() * head_wind_comp * 100;
const int32_t head_wind_compensation_cm = ahrs.head_wind() * head_wind_comp * 100;

const uint32_t max_airspeed_cm = AP_Landing::allow_max_airspeed_on_land() ? aparm.airspeed_max*100 : aparm.airspeed_cruise_cm;

Expand Down

0 comments on commit b6b3b9d

Please sign in to comment.