Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/AntennaTracker/sensors.cpp
Views: 1798
#include "Tracker.h"12/*3update INS and attitude4*/5void Tracker::update_ahrs()6{7ahrs.update();8}910/*11read and update compass12*/13void Tracker::update_compass(void)14{15compass.read();16}1718// Save compass offsets19void Tracker::compass_save() {20if (AP::compass().available() &&21compass.get_learn_type() >= Compass::LEARN_INTERNAL &&22!hal.util->get_soft_armed()) {23compass.save_offsets();24}25}2627/*28read the GPS29*/30void Tracker::update_GPS(void)31{32gps.update();3334static uint32_t last_gps_msg_ms;35static uint8_t ground_start_count = 5;36if (gps.last_message_time_ms() != last_gps_msg_ms &&37gps.status() >= AP_GPS::GPS_OK_FIX_3D) {38last_gps_msg_ms = gps.last_message_time_ms();3940if (ground_start_count > 1) {41ground_start_count--;42} else if (ground_start_count == 1) {43// We countdown N number of good GPS fixes44// so that the altitude is more accurate45// -------------------------------------46if (current_loc.lat == 0 && current_loc.lng == 0) {47ground_start_count = 5;4849} else {50// Now have an initial GPS position51// use it as the HOME position in future startups52current_loc = gps.location();53IGNORE_RETURN(set_home(current_loc, false));54ground_start_count = 0;55}56}57}58}5960void Tracker::handle_battery_failsafe(const char* type_str, const int8_t action)61{62// NOP63// useful failsafes in the future would include actually recalling the vehicle64// that is tracked before the tracker loses power to continue tracking it65}666768