2016-03-19 03:25:13 -03:00
|
|
|
#include "Copter.h"
|
|
|
|
|
|
|
|
// update terrain data
|
|
|
|
void Copter::terrain_update()
|
|
|
|
{
|
|
|
|
#if AP_TERRAIN_AVAILABLE && AC_TERRAIN
|
|
|
|
terrain.update();
|
|
|
|
|
|
|
|
// tell the rangefinder our height, so it can go into power saving
|
|
|
|
// mode if available
|
2016-04-27 07:55:35 -03:00
|
|
|
#if RANGEFINDER_ENABLED == ENABLED
|
2016-03-19 03:25:13 -03:00
|
|
|
float height;
|
|
|
|
if (terrain.height_above_terrain(height, true)) {
|
2016-04-27 08:37:04 -03:00
|
|
|
rangefinder.set_estimated_terrain_height(height);
|
2016-03-19 03:25:13 -03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// log terrain data - should be called at 1hz
|
|
|
|
void Copter::terrain_logging()
|
|
|
|
{
|
|
|
|
#if AP_TERRAIN_AVAILABLE && AC_TERRAIN
|
|
|
|
if (should_log(MASK_LOG_GPS)) {
|
2019-01-17 19:17:23 -04:00
|
|
|
terrain.log_terrain_data();
|
2016-03-19 03:25:13 -03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// should we use terrain data for things including the home altitude
|
|
|
|
bool Copter::terrain_use()
|
|
|
|
{
|
|
|
|
#if AP_TERRAIN_AVAILABLE && AC_TERRAIN
|
2016-04-21 02:04:19 -03:00
|
|
|
return (g.terrain_follow > 0);
|
2016-03-19 03:25:13 -03:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|