Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/ArduSub/inertia.cpp
9451 views
1
#include "Sub.h"
2
3
// read_inertia - read inertia in from accelerometers
4
void Sub::read_inertia()
5
{
6
// inertial altitude estimates
7
inertial_nav.update();
8
sub.pos_control.update_estimates();
9
10
// pull position from ahrs
11
Location loc;
12
ahrs.get_location(loc);
13
current_loc.lat = loc.lat;
14
current_loc.lng = loc.lng;
15
16
// exit immediately if we do not have an altitude estimate
17
if (!AP::ahrs().has_status(AP_AHRS::Status::VERT_POS)) {
18
return;
19
}
20
21
current_loc.alt = inertial_nav.get_position_z_up_cm();
22
23
// get velocity, altitude is always absolute frame, referenced from
24
// water's surface
25
climb_rate = inertial_nav.get_velocity_z_up_cms();
26
}
27
28