PX4 Firmware
PX4 Autopilot Software http://px4.io
Landingslope.hpp
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2012-2017 PX4 Development Team. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * 3. Neither the name PX4 nor the names of its contributors may be
16  * used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  ****************************************************************************/
33 
34 /*
35  * @file landingslope.h
36  *
37  * @author Thomas Gubler <thomasgubler@gmail.com>
38  */
39 
40 #ifndef LANDINGSLOPE_H_
41 #define LANDINGSLOPE_H_
42 
43 #include <math.h>
44 
46 {
47 private:
48  /* see Documentation/fw_landing.png for a plot of the landing slope */
49  float _landing_slope_angle_rad{0.0f}; /**< phi in the plot */
50  float _flare_relative_alt{0.0f}; /**< h_flare,rel in the plot */
52  float _H1_virt{0.0f}; /**< H1 in the plot */
53  float _H0{0.0f}; /**< h_flare,rel + H1 in the plot */
54  float _d1{0.0f}; /**< d1 in the plot */
55  float _flare_constant{0.0f};
56  float _flare_length{0.0f}; /**< d1 + delta d in the plot */
57  float _horizontal_slope_displacement{0.0f}; /**< delta d in the plot */
58 
59  void calculateSlopeValues();
60 
61 public:
62  Landingslope() = default;
63  ~Landingslope() = default;
64 
65  /**
66  *
67  * @return relative altitude of point on landing slope at distance to landing waypoint=wp_landing_distance
68  */
69  float getLandingSlopeRelativeAltitude(float wp_landing_distance);
70 
71  /**
72  *
73  * @return relative altitude of point on landing slope at distance to landing waypoint=wp_landing_distance
74  * Performs check if aircraft is in front of waypoint to avoid climbout
75  */
76  float getLandingSlopeRelativeAltitudeSave(float wp_landing_distance, float bearing_lastwp_currwp,
77  float bearing_airplane_currwp);
78 
79  /**
80  *
81  * @return Relative altitude of point on landing slope at distance to landing waypoint=wp_landing_distance
82  */
83  static float getLandingSlopeRelativeAltitude(float wp_landing_distance, float horizontal_slope_displacement,
85 
86  /**
87  *
88  * @return Absolute altitude of point on landing slope at distance to landing waypoint=wp_landing_distance
89  */
90  static float getLandingSlopeAbsoluteAltitude(float wp_landing_distance, float wp_landing_altitude,
91  float horizontal_slope_displacement, float landing_slope_angle_rad);
92 
93  /**
94  *
95  * @return distance to landing waypoint of point on landing slope at altitude=slope_altitude
96  */
97  static float getLandingSlopeWPDistance(float slope_altitude, float wp_landing_altitude,
98  float horizontal_slope_displacement, float landing_slope_angle_rad);
99 
100  float getFlareCurveRelativeAltitudeSave(float wp_landing_distance, float bearing_lastwp_currwp,
101  float bearing_airplane_currwp);
102 
103  void update(float landing_slope_angle_rad_new,
104  float flare_relative_alt_new,
105  float motor_lim_relative_alt_new,
106  float H1_virt_new);
107 
108 
112  float flare_length() { return _flare_length; }
114 
115 };
116 
117 
118 #endif /* LANDINGSLOPE_H_ */
void update(float landing_slope_angle_rad_new, float flare_relative_alt_new, float motor_lim_relative_alt_new, float H1_virt_new)
static float getLandingSlopeAbsoluteAltitude(float wp_landing_distance, float wp_landing_altitude, float horizontal_slope_displacement, float landing_slope_angle_rad)
float _flare_relative_alt
h_flare,rel in the plot
float _flare_constant
Landingslope()=default
float getLandingSlopeRelativeAltitudeSave(float wp_landing_distance, float bearing_lastwp_currwp, float bearing_airplane_currwp)
float _H1_virt
H1 in the plot.
~Landingslope()=default
float getLandingSlopeRelativeAltitude(float wp_landing_distance)
float _flare_length
d1 + delta d in the plot
float _horizontal_slope_displacement
delta d in the plot
float landing_slope_angle_rad()
void calculateSlopeValues()
float _H0
h_flare,rel + H1 in the plot
float motor_lim_relative_alt()
static float getLandingSlopeWPDistance(float slope_altitude, float wp_landing_altitude, float horizontal_slope_displacement, float landing_slope_angle_rad)
float getFlareCurveRelativeAltitudeSave(float wp_landing_distance, float bearing_lastwp_currwp, float bearing_airplane_currwp)
float _motor_lim_relative_alt
float flare_length()
float _d1
d1 in the plot
float horizontal_slope_displacement()
float _landing_slope_angle_rad
phi in the plot
float flare_relative_alt()