2015-02-16 00:39:18 -04:00
|
|
|
//
|
|
|
|
// functions to support precision landing
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "Copter.h"
|
|
|
|
|
|
|
|
#if PRECISION_LANDING == ENABLED
|
|
|
|
|
|
|
|
void Copter::init_precland()
|
|
|
|
{
|
|
|
|
copter.precland.init();
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-07-15 14:21:10 -03:00
|
|
|
copter.precland.update(height_above_ground_cm, rangefinder_alt_ok());
|
2015-02-16 00:39:18 -04:00
|
|
|
}
|
|
|
|
#endif
|