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/libraries/AC_PrecLand/AC_PrecLand_SITL.cpp
Views: 1798
#include <AP_HAL/AP_HAL.h>1#include "AC_PrecLand_SITL.h"23#if AC_PRECLAND_SITL_ENABLED45#include "AP_AHRS/AP_AHRS.h"6// init - perform initialisation of this backend7void AC_PrecLand_SITL::init()8{9_sitl = AP::sitl();10}1112// update - give chance to driver to get updates from sensor13void AC_PrecLand_SITL::update()14{15_state.healthy = _sitl->precland_sim.healthy();1617if (_state.healthy && _sitl->precland_sim.last_update_ms() != _los_meas_time_ms) {18const Vector3d position = _sitl->precland_sim.get_target_position();19const Matrix3d body_to_ned = AP::ahrs().get_rotation_body_to_ned().todouble();20_los_meas_body = body_to_ned.mul_transpose(-position).tofloat();21_distance_to_target = _sitl->precland_sim.option_enabled(SITL::SIM_Precland::Option::ENABLE_TARGET_DISTANCE) ? _los_meas_body.length() : 0.0f;22_los_meas_body /= _los_meas_body.length();2324if (_frontend._orient != Rotation::ROTATION_PITCH_270) {25// rotate body frame vector based on orientation26// this is done to have homogeneity among backends27// frontend rotates it back to get correct body frame vector28_los_meas_body.rotate_inverse(_frontend._orient);29_los_meas_body.rotate_inverse(ROTATION_PITCH_90);30}3132_have_los_meas = true;33_los_meas_time_ms = _sitl->precland_sim.last_update_ms();34} else {35_have_los_meas = false;36}3738_have_los_meas = _have_los_meas && AP_HAL::millis() - _los_meas_time_ms <= 1000;39}4041#endif // AC_PRECLAND_SITL_ENABLED424344