2021-03-18 00:12:54 -03:00
|
|
|
#include "Blimp.h"
|
|
|
|
|
|
|
|
// read_inertia - read inertia in from accelerometers
|
|
|
|
void Blimp::read_inertia()
|
|
|
|
{
|
|
|
|
// inertial altitude estimates. Use barometer climb rate during high vibrations
|
|
|
|
inertial_nav.update(vibration_check.high_vibes);
|
|
|
|
|
|
|
|
// pull position from ahrs
|
|
|
|
Location loc;
|
|
|
|
ahrs.get_position(loc);
|
|
|
|
current_loc.lat = loc.lat;
|
|
|
|
current_loc.lng = loc.lng;
|
|
|
|
|
|
|
|
// exit immediately if we do not have an altitude estimate
|
|
|
|
if (!inertial_nav.get_filter_status().flags.vert_pos) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// current_loc.alt is alt-above-home, converted from inertial nav's alt-above-ekf-origin
|
2021-10-20 05:31:19 -03:00
|
|
|
const int32_t alt_above_origin_cm = inertial_nav.get_position_z_up_cm();
|
2021-03-18 00:12:54 -03:00
|
|
|
current_loc.set_alt_cm(alt_above_origin_cm, Location::AltFrame::ABOVE_ORIGIN);
|
|
|
|
if (!ahrs.home_is_set() || !current_loc.change_alt_frame(Location::AltFrame::ABOVE_HOME)) {
|
|
|
|
// if home has not been set yet we treat alt-above-origin as alt-above-home
|
|
|
|
current_loc.set_alt_cm(alt_above_origin_cm, Location::AltFrame::ABOVE_HOME);
|
|
|
|
}
|
|
|
|
}
|