123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- #pragma once
- class AP_AHRS_DCM : public AP_AHRS {
- public:
- AP_AHRS_DCM()
- : AP_AHRS()
- , _error_rp(1.0f)
- , _error_yaw(1.0f)
- , _mag_earth(1, 0)
- , _imu1_weight(0.5f)
- {
- _dcm_matrix.identity();
-
-
- _ki = 0.0087f;
- _ki_yaw = 0.01f;
- }
-
- AP_AHRS_DCM(const AP_AHRS_DCM &other) = delete;
- AP_AHRS_DCM &operator=(const AP_AHRS_DCM&) = delete;
-
- const Vector3f &get_gyro() const override {
- return _omega;
- }
-
- const Matrix3f &get_rotation_body_to_ned() const override {
- return _body_dcm_matrix;
- }
-
- const Matrix3f &get_DCM_rotation_body_to_ned(void) const override { return _body_dcm_matrix; }
-
- const Vector3f &get_gyro_drift() const override {
- return _omega_I;
- }
-
-
- void reset_gyro_drift() override;
-
- void update(bool skip_ins_update=false) override;
- void reset(bool recover_eulers = false) override;
-
- void reset_attitude(const float &roll, const float &pitch, const float &yaw) override;
-
- virtual bool get_position(struct Location &loc) const override;
-
- float get_error_rp() const override {
- return _error_rp;
- }
- float get_error_yaw() const override {
- return _error_yaw;
- }
-
- Vector3f wind_estimate() const override {
- return _wind;
- }
- void get_relative_position_D_home(float &posD) const override;
-
-
- bool airspeed_estimate(float *airspeed_ret) const override;
- bool use_compass() override;
- bool set_home(const Location &loc) override WARN_IF_UNUSED;
- void estimate_wind(void);
-
- bool healthy() const override;
- bool get_velocity_NED(Vector3f &vec) const override;
- private:
- float _ki;
- float _ki_yaw;
-
- void matrix_update(float _G_Dt);
- void normalize(void);
- void check_matrix(void);
- bool renorm(Vector3f const &a, Vector3f &result);
- void drift_correction(float deltat);
- void drift_correction_yaw(void);
- float yaw_error_compass();
- void euler_angles(void);
- bool have_gps(void) const;
- bool use_fast_gains(void) const;
- void load_watchdog_home();
- void backup_attitude(void);
-
- Matrix3f _dcm_matrix;
-
- Matrix3f _body_dcm_matrix;
- Vector3f _omega_P;
- Vector3f _omega_yaw_P;
- Vector3f _omega_I;
- Vector3f _omega_I_sum;
- float _omega_I_sum_time;
- Vector3f _omega;
-
- Vector3f ra_delayed(uint8_t instance, const Vector3f &ra);
- Vector3f _ra_delay_buffer[INS_MAX_INSTANCES];
-
- float _P_gain(float spin_rate);
-
- float _yaw_gain(void) const;
-
- float _renorm_val_sum;
- uint16_t _renorm_val_count;
- float _error_rp;
- float _error_yaw;
-
- uint32_t _gps_last_update;
-
- Vector3f _ra_sum[INS_MAX_INSTANCES];
- Vector3f _last_velocity;
- float _ra_deltat;
- uint32_t _ra_sum_start;
-
- float _last_declination;
- Vector2f _mag_earth;
-
- bool _have_gps_lock;
-
- int32_t _last_lat;
- int32_t _last_lng;
-
- float _position_offset_north;
- float _position_offset_east;
-
- bool _have_position;
-
- Vector3f _last_fuse;
- Vector3f _last_vel;
- uint32_t _last_wind_time;
- float _last_airspeed;
- uint32_t _last_consistent_heading;
-
- Vector3f _wind;
- float _imu1_weight;
-
- uint32_t _last_failure_ms;
-
- uint32_t _last_startup_ms;
- };
|