2015-05-29 23:12:49 -03:00
|
|
|
#include "Copter.h"
|
|
|
|
|
2012-11-07 06:03:30 -04:00
|
|
|
// read_inertia - read inertia in from accelerometers
|
2015-05-29 23:12:49 -03:00
|
|
|
void Copter::read_inertia()
|
2012-06-26 02:17:04 -03:00
|
|
|
{
|
2012-11-07 06:03:30 -04:00
|
|
|
// inertial altitude estimates
|
|
|
|
inertial_nav.update(G_Dt);
|
2013-02-01 23:00:09 -04:00
|
|
|
|
2016-04-19 04:16:06 -03:00
|
|
|
// pull position from interial nav library
|
|
|
|
current_loc.lng = inertial_nav.get_longitude();
|
|
|
|
current_loc.lat = inertial_nav.get_latitude();
|
|
|
|
|
2015-05-13 03:24:52 -03:00
|
|
|
// exit immediately if we do not have an altitude estimate
|
|
|
|
if (!inertial_nav.get_filter_status().flags.vert_pos) {
|
2015-02-26 01:17:02 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-13 03:24:52 -03:00
|
|
|
// 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
|
2014-06-10 23:57:01 -03:00
|
|
|
current_loc.flags.relative_alt = true;
|
2013-02-01 23:00:09 -04:00
|
|
|
climb_rate = inertial_nav.get_velocity_z();
|
2013-04-23 10:03:34 -03:00
|
|
|
}
|