2015-02-16 00:39:18 -04:00
|
|
|
//
|
|
|
|
// functions to support precision landing
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "Copter.h"
|
|
|
|
|
|
|
|
#if PRECISION_LANDING == ENABLED
|
|
|
|
|
|
|
|
void Copter::init_precland()
|
|
|
|
{
|
2018-09-21 04:02:20 -03:00
|
|
|
copter.precland.init(400);
|
2015-02-16 00:39:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Copter::update_precland()
|
|
|
|
{
|
2016-07-07 14:56:24 -03:00
|
|
|
int32_t height_above_ground_cm = current_loc.alt;
|
2015-09-11 06:15:02 -03:00
|
|
|
|
2016-07-07 14:56:24 -03:00
|
|
|
// use range finder altitude if it is valid, else try to get terrain alt
|
2016-04-27 09:18:35 -03:00
|
|
|
if (rangefinder_alt_ok()) {
|
2016-07-07 14:56:24 -03:00
|
|
|
height_above_ground_cm = rangefinder_state.alt_cm;
|
|
|
|
} else if (terrain_use()) {
|
2016-08-08 00:20:06 -03:00
|
|
|
if (!current_loc.get_alt_cm(Location_Class::ALT_FRAME_ABOVE_TERRAIN, height_above_ground_cm)) {
|
|
|
|
height_above_ground_cm = current_loc.alt;
|
|
|
|
}
|
2015-09-11 06:15:02 -03:00
|
|
|
}
|
|
|
|
|
2018-09-18 23:16:24 -03:00
|
|
|
precland.update(height_above_ground_cm, rangefinder_alt_ok());
|
2015-02-16 00:39:18 -04:00
|
|
|
}
|
|
|
|
#endif
|