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/Blimp/commands.cpp
Views: 1798
#include "Blimp.h"12// checks if we should update ahrs/RTL home position from the EKF3void Blimp::update_home_from_EKF()4{5// exit immediately if home already set6if (ahrs.home_is_set()) {7return;8}910// special logic if home is set in-flight11if (motors->armed()) {12set_home_to_current_location_inflight();13} else {14// move home to current ekf location (this will set home_state to HOME_SET)15if (!set_home_to_current_location(false)) {16// ignore failure17}18}19}2021// set_home_to_current_location_inflight - set home to current GPS location (horizontally) and EKF origin vertically22void Blimp::set_home_to_current_location_inflight()23{24// get current location from EKF25Location temp_loc;26Location ekf_origin;27if (ahrs.get_location(temp_loc) && ahrs.get_origin(ekf_origin)) {28temp_loc.alt = ekf_origin.alt;29if (!set_home(temp_loc, false)) {30return;31}32}33}3435// set_home_to_current_location - set home to current GPS location36bool Blimp::set_home_to_current_location(bool lock)37{38// get current location from EKF39Location temp_loc;40if (ahrs.get_location(temp_loc)) {41if (!set_home(temp_loc, lock)) {42return false;43}44return true;45}46return false;47}4849// set_home - sets ahrs home (used for RTL) to specified location50// initialises inertial nav and compass on first call51// returns true if home location set successfully52bool Blimp::set_home(const Location& loc, bool lock)53{54// check EKF origin has been set55Location ekf_origin;56if (!ahrs.get_origin(ekf_origin)) {57return false;58}5960// set ahrs home (used for RTL)61if (!ahrs.set_home(loc)) {62return false;63}6465// lock home position66if (lock) {67ahrs.lock_home();68}6970// return success71return true;72}737475