Browse Source

rtl: keep rtl altitude below max altitude

land_detector: delete unused class enum
sbg
Dennis Mannhart 8 years ago committed by Lorenz Meier
parent
commit
1774e01c00
  1. 8
      src/modules/land_detector/LandDetector.h
  2. 11
      src/modules/navigator/rtl.cpp
  3. 6
      src/modules/navigator/rtl.h

8
src/modules/land_detector/LandDetector.h

@ -61,10 +61,6 @@ public: @@ -61,10 +61,6 @@ public:
GROUND_CONTACT = 3
};
enum class BatteryLevel {
};
LandDetector();
virtual ~LandDetector();
@ -128,7 +124,7 @@ protected: @@ -128,7 +124,7 @@ protected:
virtual bool _get_freefall_state() = 0;
/**
* @return
* @return maximum altitude that can be reached
*/
virtual float _get_max_altitude() = 0;
@ -164,8 +160,6 @@ protected: @@ -164,8 +160,6 @@ protected:
float _altitude_max;
private:
static void _cycle_trampoline(void *arg);

11
src/modules/navigator/rtl.cpp

@ -84,6 +84,13 @@ RTL::on_inactive() @@ -84,6 +84,13 @@ RTL::on_inactive()
_rtl_state = RTL_STATE_NONE;
}
float
RTL::get_rtl_altitude()
{
return (_param_return_alt.get() < _navigator->get_land_detected()->alt_max) ? _param_return_alt.get() :
_navigator->get_land_detected()->alt_max;
}
void
RTL::on_activation()
{
@ -101,7 +108,7 @@ RTL::on_activation() @@ -101,7 +108,7 @@ RTL::on_activation()
/* if lower than return altitude, climb up first */
} else if (_navigator->get_global_position()->alt < (_navigator->get_home_position()->alt
+ _param_return_alt.get())) {
+ get_rtl_altitude())) {
_rtl_state = RTL_STATE_CLIMB;
/* otherwise go straight to return */
@ -145,7 +152,7 @@ RTL::set_rtl_item() @@ -145,7 +152,7 @@ RTL::set_rtl_item()
_navigator->get_global_position()->lat, _navigator->get_global_position()->lon);
// if we are close to home we do not climb as high, otherwise we climb to return alt
float climb_alt = _navigator->get_home_position()->alt + _param_return_alt.get();
float climb_alt = _navigator->get_home_position()->alt + get_rtl_altitude();
// we are close to home, limit climb to min
if (home_dist < _param_rtl_min_dist.get()) {

6
src/modules/navigator/rtl.h

@ -77,6 +77,12 @@ private: @@ -77,6 +77,12 @@ private:
*/
void advance_rtl();
/**
* Get rtl altitude
*/
float get_rtl_altitude();
enum RTLState {
RTL_STATE_NONE = 0,
RTL_STATE_CLIMB,

Loading…
Cancel
Save