2015-12-30 18:57:56 -04:00
|
|
|
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
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
|
|
|
|
inertial_nav.update(G_Dt);
|
|
|
|
}
|
|
|
|
|
|
|
|
// read_inertial_altitude - pull altitude and climb rate from inertial nav library
|
2016-01-14 15:30:56 -04:00
|
|
|
void Sub::read_inertial_altitude()
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// without home return alt above the EKF origin
|
|
|
|
if (ap.home_state == HOME_UNSET) {
|
|
|
|
// with inertial nav we can update the altitude and climb rate at 50hz
|
|
|
|
current_loc.alt = inertial_nav.get_altitude();
|
|
|
|
} else {
|
|
|
|
// with inertial nav we can update the altitude and climb rate at 50hz
|
|
|
|
current_loc.alt = pv_alt_above_home(inertial_nav.get_altitude());
|
|
|
|
}
|
|
|
|
|
|
|
|
// set flags and get velocity
|
|
|
|
current_loc.flags.relative_alt = true;
|
|
|
|
climb_rate = inertial_nav.get_velocity_z();
|
|
|
|
}
|