2016-01-14 15:30:56 -04:00
|
|
|
#include "Sub.h"
|
2015-12-30 18:57:56 -04:00
|
|
|
|
|
|
|
// read_inertia - read inertia in from accelerometers
|
2016-01-14 15:30:56 -04:00
|
|
|
void Sub::read_inertia()
|
2015-12-30 18:57:56 -04:00
|
|
|
{
|
|
|
|
// inertial altitude estimates
|
2019-06-28 10:55:49 -03:00
|
|
|
inertial_nav.update();
|
2015-12-30 18:57:56 -04:00
|
|
|
|
2019-06-28 10:55:49 -03:00
|
|
|
// pull position from ahrs
|
|
|
|
Location loc;
|
2022-01-20 19:42:41 -04:00
|
|
|
ahrs.get_location(loc);
|
2019-06-28 10:55:49 -03:00
|
|
|
current_loc.lat = loc.lat;
|
|
|
|
current_loc.lng = loc.lng;
|
2016-05-03 01:45:37 -03:00
|
|
|
|
2015-12-30 18:57:56 -04:00
|
|
|
// exit immediately if we do not have an altitude estimate
|
|
|
|
if (!inertial_nav.get_filter_status().flags.vert_pos) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-10-20 05:30:56 -03:00
|
|
|
current_loc.alt = inertial_nav.get_position_z_up_cm();
|
2015-12-30 18:57:56 -04:00
|
|
|
|
2016-10-11 00:27:51 -03:00
|
|
|
// get velocity, altitude is always absolute frame, referenced from
|
|
|
|
// water's surface
|
2021-10-20 05:30:56 -03:00
|
|
|
climb_rate = inertial_nav.get_velocity_z_up_cms();
|
2015-12-30 18:57:56 -04:00
|
|
|
}
|