inertia.cpp 645 B

12345678910111213141516171819202122232425
  1. #include "Sub.h"
  2. // read_inertia - read inertia in from accelerometers
  3. void Sub::read_inertia()
  4. {
  5. // inertial altitude estimates
  6. inertial_nav.update();
  7. // pull position from ahrs
  8. Location loc;
  9. ahrs.get_position(loc);
  10. current_loc.lat = loc.lat;
  11. current_loc.lng = loc.lng;
  12. // exit immediately if we do not have an altitude estimate
  13. if (!inertial_nav.get_filter_status().flags.vert_pos) {
  14. return;
  15. }
  16. current_loc.alt = inertial_nav.get_altitude();
  17. // get velocity, altitude is always absolute frame, referenced from
  18. // water's surface
  19. climb_rate = inertial_nav.get_velocity_z();
  20. }