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/Rover/commands.cpp
Views: 1798
#include "Rover.h"12// set ahrs home to current location from inertial-nav location3bool Rover::set_home_to_current_location(bool lock)4{5Location temp_loc;6if (ahrs.have_inertial_nav() && ahrs.get_location(temp_loc)) {7if (!set_home(temp_loc, lock)) {8return false;9}10// we have successfully set AHRS home, set it for SmartRTL11g2.smart_rtl.set_home(true);12return true;13}14return false;15}1617// sets ahrs home to specified location18// returns true if home location set successfully19bool Rover::set_home(const Location& loc, bool lock)20{21// set ahrs home22if (!ahrs.set_home(loc)) {23return false;24}2526// lock home position27if (lock) {28ahrs.lock_home();29}3031// Save Home to EEPROM32mode_auto.mission.write_home_to_storage();3334// send text of home position to ground stations35gcs().send_text(MAV_SEVERITY_INFO, "Set HOME to %.6f %.6f at %.2fm",36static_cast<double>(loc.lat * 1.0e-7f),37static_cast<double>(loc.lng * 1.0e-7f),38static_cast<double>(loc.alt * 0.01f));3940// return success41return true;42}4344// called periodically while disarmed to update our home position to45// our current location46void Rover::update_home()47{48if (ahrs.home_is_locked()) {49// we've been explicitly told our home location50return;51}5253Location loc{};54if (!ahrs.get_location(loc)) {55return;56}5758barometer.update_calibration();5960if (ahrs.home_is_set() &&61loc.get_distance(ahrs.get_home()) < DISTANCE_HOME_MINCHANGE) {62// insufficiently moved from current home - don't change it63return;64}6566IGNORE_RETURN(ahrs.set_home(loc));67}686970