terrain.cpp 821 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "Sub.h"
  2. // update terrain data
  3. void Sub::terrain_update()
  4. {
  5. #if AP_TERRAIN_AVAILABLE && AC_TERRAIN
  6. terrain.update();
  7. // tell the rangefinder our height, so it can go into power saving
  8. // mode if available
  9. #if RANGEFINDER_ENABLED == ENABLED
  10. float height;
  11. if (terrain.height_above_terrain(height, true)) {
  12. rangefinder.set_estimated_terrain_height(height);
  13. }
  14. #endif
  15. #endif
  16. }
  17. // log terrain data - should be called at 1hz
  18. void Sub::terrain_logging()
  19. {
  20. #if AP_TERRAIN_AVAILABLE && AC_TERRAIN
  21. if (should_log(MASK_LOG_GPS)) {
  22. terrain.log_terrain_data();
  23. }
  24. #endif
  25. }
  26. // should we use terrain data for things including the home altitude
  27. bool Sub::terrain_use()
  28. {
  29. #if AP_TERRAIN_AVAILABLE && AC_TERRAIN
  30. return (g.terrain_follow > 0);
  31. #else
  32. return false;
  33. #endif
  34. }