#pragma once12/*3This program is free software: you can redistribute it and/or modify4it under the terms of the GNU General Public License as published by5the Free Software Foundation, either version 3 of the License, or6(at your option) any later version.78This program is distributed in the hope that it will be useful,9but WITHOUT ANY WARRANTY; without even the implied warranty of10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11GNU General Public License for more details.1213You should have received a copy of the GNU General Public License14along with this program. If not, see <http://www.gnu.org/licenses/>.15*/1617/*18* SITL-based AHRS (Attitude Heading Reference System) interface for19* ArduPilot20*21*/2223#include "AP_AHRS_config.h"2425#if AP_AHRS_SIM_ENABLED2627#include "AP_AHRS_Backend.h"2829#include <GCS_MAVLink/GCS.h>30#include <SITL/SITL.h>3132#if HAL_NAVEKF3_AVAILABLE33#include <AP_NavEKF3/AP_NavEKF3.h>34#endif3536class AP_AHRS_SIM : public AP_AHRS_Backend {37public:3839#if HAL_NAVEKF3_AVAILABLE40AP_AHRS_SIM(NavEKF3 &_EKF3) :41AP_AHRS_Backend(),42EKF3(_EKF3)43{ }44~AP_AHRS_SIM() {}45#else46// a version of the constructor which doesn't take a non-existant47// NavEKF3 class instance as a parameter.48AP_AHRS_SIM() : AP_AHRS_Backend() { }49#endif5051CLASS_NO_COPY(AP_AHRS_SIM);5253// reset the current gyro drift estimate54// should be called if gyro offsets are recalculated55void reset_gyro_drift() override {};5657// Methods58void update() override { }59void get_results(Estimates &results) override;60void reset() override { return; }6162// get latest altitude estimate above ground level in meters and validity flag63bool get_hagl(float &hagl) const override WARN_IF_UNUSED;6465// return a wind estimation vector, in m/s66bool wind_estimate(Vector3f &wind) const override;6768// return an airspeed estimate if available. return true69// if we have an estimate70bool airspeed_EAS(float &airspeed_ret) const override;7172// return an airspeed estimate if available. return true73// if we have an estimate from a specific sensor index74bool airspeed_EAS(uint8_t airspeed_index, float &airspeed_ret) const override;7576// return a ground vector estimate in meters/second, in North/East order77Vector2f groundspeed_vector() override;7879bool use_compass() override { return true; }8081// is the AHRS subsystem healthy?82bool healthy() const override { return true; }8384// returns false if we fail arming checks, in which case the buffer will be populated with a failure message85// requires_position should be true if horizontal position configuration should be checked (not used)86bool pre_arm_check(bool requires_position, char *failure_msg, uint8_t failure_msg_len) const override { return true; }8788// get_filter_status - returns filter status as a series of flags89bool get_filter_status(nav_filter_status &status) const override;9091// relative-origin functions for fallback in AP_InertialNav92bool get_origin(Location &ret) const override;93bool get_relative_position_NED_origin(Vector3p &vec) const override;94bool get_relative_position_NE_origin(Vector2p &posNE) const override;95bool get_relative_position_D_origin(postype_t &posD) const override;9697void send_ekf_status_report(class GCS_MAVLINK &link) const override;9899void get_control_limits(float &ekfGndSpdLimit, float &controlScaleXY) const override;100bool get_innovations(Vector3f &velInnov, Vector3f &posInnov, Vector3f &magInnov, float &tasInnov, float &yawInnov) const override;101bool get_variances(float &velVar, float &posVar, float &hgtVar, Vector3f &magVar, float &tasVar) const override;102103private:104105// dead-reckoning support106bool get_location(Location &loc) const;107108#if HAL_NAVEKF3_AVAILABLE109// a reference to the EKF3 backend that we can use to send in110// body-frame-odometry data into the EKF. Rightfully there should111// be something over in the SITL directory doing this.112NavEKF3 &EKF3;113#endif114115class SITL::SIM *_sitl;116uint32_t _last_body_odm_update_ms;117};118119#endif // AP_AHRS_SIM_ENABLED120121122