Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_AHRS/AP_AHRS_SIM.h
9693 views
1
#pragma once
2
3
/*
4
This program is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
/*
19
* SITL-based AHRS (Attitude Heading Reference System) interface for
20
* ArduPilot
21
*
22
*/
23
24
#include "AP_AHRS_config.h"
25
26
#if AP_AHRS_SIM_ENABLED
27
28
#include "AP_AHRS_Backend.h"
29
30
#include <GCS_MAVLink/GCS.h>
31
#include <SITL/SITL.h>
32
33
#if HAL_NAVEKF3_AVAILABLE
34
#include <AP_NavEKF3/AP_NavEKF3.h>
35
#endif
36
37
class AP_AHRS_SIM : public AP_AHRS_Backend {
38
public:
39
40
#if HAL_NAVEKF3_AVAILABLE
41
AP_AHRS_SIM(NavEKF3 &_EKF3) :
42
AP_AHRS_Backend(),
43
EKF3(_EKF3)
44
{ }
45
~AP_AHRS_SIM() {}
46
#else
47
// a version of the constructor which doesn't take a non-existant
48
// NavEKF3 class instance as a parameter.
49
AP_AHRS_SIM() : AP_AHRS_Backend() { }
50
#endif
51
52
CLASS_NO_COPY(AP_AHRS_SIM);
53
54
// reset the current gyro drift estimate
55
// should be called if gyro offsets are recalculated
56
void reset_gyro_drift() override {};
57
58
// Methods
59
void update() override { }
60
void get_results(Estimates &results) override;
61
void reset() override { return; }
62
63
// get latest altitude estimate above ground level in meters and validity flag
64
bool get_hagl(float &hagl) const override WARN_IF_UNUSED;
65
66
// return a wind estimation vector, in m/s
67
bool wind_estimate(Vector3f &wind) const override;
68
69
// return an airspeed estimate if available. return true
70
// if we have an estimate
71
bool airspeed_EAS(float &airspeed_ret) const override;
72
73
// return an airspeed estimate if available. return true
74
// if we have an estimate from a specific sensor index
75
bool airspeed_EAS(uint8_t airspeed_index, float &airspeed_ret) const override;
76
77
// return a ground vector estimate in meters/second, in North/East order
78
Vector2f groundspeed_vector() override;
79
80
bool use_compass() override { return true; }
81
82
// is the AHRS subsystem healthy?
83
bool healthy() const override { return true; }
84
85
// returns false if we fail arming checks, in which case the buffer will be populated with a failure message
86
// requires_position should be true if horizontal position configuration should be checked (not used)
87
bool pre_arm_check(bool requires_position, char *failure_msg, uint8_t failure_msg_len) const override { return true; }
88
89
// get_filter_status - returns filter status as a series of flags
90
bool get_filter_status(nav_filter_status &status) const override;
91
92
// relative-origin functions for fallback in AP_InertialNav
93
bool get_origin(Location &ret) const override;
94
bool get_relative_position_NED_origin(Vector3p &vec) const override;
95
bool get_relative_position_NE_origin(Vector2p &posNE) const override;
96
bool get_relative_position_D_origin(postype_t &posD) const override;
97
98
void send_ekf_status_report(class GCS_MAVLINK &link) const override;
99
100
void get_control_limits(float &ekfGndSpdLimit, float &controlScaleXY) const override;
101
bool get_innovations(Vector3f &velInnov, Vector3f &posInnov, Vector3f &magInnov, float &tasInnov, float &yawInnov) const override;
102
bool get_variances(float &velVar, float &posVar, float &hgtVar, Vector3f &magVar, float &tasVar) const override;
103
104
private:
105
106
// dead-reckoning support
107
bool get_location(Location &loc) const;
108
109
#if HAL_NAVEKF3_AVAILABLE
110
// a reference to the EKF3 backend that we can use to send in
111
// body-frame-odometry data into the EKF. Rightfully there should
112
// be something over in the SITL directory doing this.
113
NavEKF3 &EKF3;
114
#endif
115
116
class SITL::SIM *_sitl;
117
uint32_t _last_body_odm_update_ms;
118
};
119
120
#endif // AP_AHRS_SIM_ENABLED
121
122