Skip to content

Commit

Permalink
landing_slope: added wrap_pi to getLandingSlope and getFlareCurve
Browse files Browse the repository at this point in the history
 - fixes #16132
  • Loading branch information
AlexanderAurora authored and dagar committed Nov 12, 2020
1 parent 68e60ba commit bf5e7cb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/landing_slope/Landingslope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "Landingslope.hpp"

#include <mathlib/mathlib.h>
#include <matrix/math.hpp>

void
Landingslope::update(float landing_slope_angle_rad_new,
Expand Down Expand Up @@ -77,7 +78,7 @@ Landingslope::getLandingSlopeRelativeAltitudeSave(float wp_landing_distance, flo
float bearing_airplane_currwp)
{
/* If airplane is in front of waypoint return slope altitude, else return waypoint altitude */
if (fabsf(bearing_airplane_currwp - bearing_lastwp_currwp) < math::radians(90.0f)) {
if (fabsf(matrix::wrap_pi(bearing_airplane_currwp - bearing_lastwp_currwp)) < math::radians(90.0f)) {
return getLandingSlopeRelativeAltitude(wp_landing_distance);

}
Expand All @@ -90,7 +91,7 @@ Landingslope::getFlareCurveRelativeAltitudeSave(float wp_landing_distance, float
float bearing_airplane_currwp)
{
/* If airplane is in front of waypoint return flare curve altitude, else return waypoint altitude */
if (fabsf(bearing_airplane_currwp - bearing_lastwp_currwp) < math::radians(90.0f)) {
if (fabsf(matrix::wrap_pi(bearing_airplane_currwp - bearing_lastwp_currwp)) < math::radians(90.0f)) {
return _H0 * expf(-math::max(0.0f, _flare_length - wp_landing_distance) / _flare_constant) - _H1_virt;

}
Expand Down

0 comments on commit bf5e7cb

Please sign in to comment.