mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-11 02:13:57 -04:00
AP_AHRS: call INS update in AP_AHRS::update w/o holding data sem
We shouldn't be holding the data semaphore while waiting for the samples - lots of things might be unnecessarily blocked DCM's update function doesn't need to take the semaphore as it is already taken by AP_AHRS
This commit is contained in:
parent
c20914c0c6
commit
9dbd9d1e06
@ -30,6 +30,7 @@
|
|||||||
#include <AP_Notify/AP_Notify.h>
|
#include <AP_Notify/AP_Notify.h>
|
||||||
#include <AP_Vehicle/AP_Vehicle_Type.h>
|
#include <AP_Vehicle/AP_Vehicle_Type.h>
|
||||||
#include <GCS_MAVLink/GCS.h>
|
#include <GCS_MAVLink/GCS.h>
|
||||||
|
#include <AP_InertialSensor/AP_InertialSensor.h>
|
||||||
|
|
||||||
#define ATTITUDE_CHECK_THRESH_ROLL_PITCH_RAD radians(10)
|
#define ATTITUDE_CHECK_THRESH_ROLL_PITCH_RAD radians(10)
|
||||||
#define ATTITUDE_CHECK_THRESH_YAW_RAD radians(20)
|
#define ATTITUDE_CHECK_THRESH_YAW_RAD radians(20)
|
||||||
@ -287,6 +288,11 @@ void AP_AHRS::reset_gyro_drift(void)
|
|||||||
|
|
||||||
void AP_AHRS::update(bool skip_ins_update)
|
void AP_AHRS::update(bool skip_ins_update)
|
||||||
{
|
{
|
||||||
|
if (!skip_ins_update) {
|
||||||
|
// tell the IMU to grab some data
|
||||||
|
AP::ins().update();
|
||||||
|
}
|
||||||
|
|
||||||
// support locked access functions to AHRS data
|
// support locked access functions to AHRS data
|
||||||
WITH_SEMAPHORE(_rsem);
|
WITH_SEMAPHORE(_rsem);
|
||||||
|
|
||||||
@ -303,7 +309,7 @@ void AP_AHRS::update(bool skip_ins_update)
|
|||||||
// update autopilot-body-to-vehicle-body from _trim parameters:
|
// update autopilot-body-to-vehicle-body from _trim parameters:
|
||||||
update_trim_rotation_matrices();
|
update_trim_rotation_matrices();
|
||||||
|
|
||||||
update_DCM(skip_ins_update);
|
update_DCM();
|
||||||
|
|
||||||
// update takeoff/touchdown flags
|
// update takeoff/touchdown flags
|
||||||
update_flags();
|
update_flags();
|
||||||
@ -348,7 +354,7 @@ void AP_AHRS::update(bool skip_ins_update)
|
|||||||
|
|
||||||
if (_view != nullptr) {
|
if (_view != nullptr) {
|
||||||
// update optional alternative attitude view
|
// update optional alternative attitude view
|
||||||
_view->update(skip_ins_update);
|
_view->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
// update AOA and SSA
|
// update AOA and SSA
|
||||||
@ -394,7 +400,7 @@ void AP_AHRS::update(bool skip_ins_update)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AP_AHRS::update_DCM(bool skip_ins_update)
|
void AP_AHRS::update_DCM()
|
||||||
{
|
{
|
||||||
// we need to restore the old DCM attitude values as these are
|
// we need to restore the old DCM attitude values as these are
|
||||||
// used internally in DCM to calculate error values for gyro drift
|
// used internally in DCM to calculate error values for gyro drift
|
||||||
@ -404,7 +410,7 @@ void AP_AHRS::update_DCM(bool skip_ins_update)
|
|||||||
yaw = _dcm_attitude.z;
|
yaw = _dcm_attitude.z;
|
||||||
update_cd_values();
|
update_cd_values();
|
||||||
|
|
||||||
AP_AHRS_DCM::update(skip_ins_update);
|
AP_AHRS_DCM::update();
|
||||||
|
|
||||||
// keep DCM attitude available for get_secondary_attitude()
|
// keep DCM attitude available for get_secondary_attitude()
|
||||||
_dcm_attitude = {roll, pitch, yaw};
|
_dcm_attitude = {roll, pitch, yaw};
|
||||||
|
@ -90,7 +90,7 @@ public:
|
|||||||
// should be called if gyro offsets are recalculated
|
// should be called if gyro offsets are recalculated
|
||||||
void reset_gyro_drift() override;
|
void reset_gyro_drift() override;
|
||||||
|
|
||||||
void update(bool skip_ins_update=false) override;
|
void update(bool skip_ins_update=false);
|
||||||
void reset(bool recover_eulers = false) override;
|
void reset(bool recover_eulers = false) override;
|
||||||
|
|
||||||
// dead-reckoning support
|
// dead-reckoning support
|
||||||
@ -532,7 +532,7 @@ private:
|
|||||||
uint8_t _ekf_flags; // bitmask from Flags enumeration
|
uint8_t _ekf_flags; // bitmask from Flags enumeration
|
||||||
|
|
||||||
EKFType ekf_type(void) const;
|
EKFType ekf_type(void) const;
|
||||||
void update_DCM(bool skip_ins_update);
|
void update_DCM();
|
||||||
|
|
||||||
// get the index of the current primary IMU
|
// get the index of the current primary IMU
|
||||||
uint8_t get_primary_IMU_index(void) const;
|
uint8_t get_primary_IMU_index(void) const;
|
||||||
|
@ -78,7 +78,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
virtual void update(bool skip_ins_update=false) = 0;
|
virtual void update() = 0;
|
||||||
|
|
||||||
// returns false if we fail arming checks, in which case the buffer will be populated with a failure message
|
// returns false if we fail arming checks, in which case the buffer will be populated with a failure message
|
||||||
// requires_position should be true if horizontal position configuration should be checked
|
// requires_position should be true if horizontal position configuration should be checked
|
||||||
|
@ -65,18 +65,10 @@ void AP_AHRS::load_watchdog_home()
|
|||||||
|
|
||||||
// run a full DCM update round
|
// run a full DCM update round
|
||||||
void
|
void
|
||||||
AP_AHRS_DCM::update(bool skip_ins_update)
|
AP_AHRS_DCM::update()
|
||||||
{
|
{
|
||||||
// support locked access functions to AHRS data
|
|
||||||
WITH_SEMAPHORE(_rsem);
|
|
||||||
|
|
||||||
AP_InertialSensor &_ins = AP::ins();
|
AP_InertialSensor &_ins = AP::ins();
|
||||||
|
|
||||||
if (!skip_ins_update) {
|
|
||||||
// tell the IMU to grab some data
|
|
||||||
_ins.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ask the IMU how much time this sensor reading represents
|
// ask the IMU how much time this sensor reading represents
|
||||||
const float delta_t = _ins.get_delta_time();
|
const float delta_t = _ins.get_delta_time();
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public:
|
|||||||
void reset_gyro_drift() override;
|
void reset_gyro_drift() override;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void update(bool skip_ins_update=false) override;
|
void update() override;
|
||||||
void reset(bool recover_eulers = false) override;
|
void reset(bool recover_eulers = false) override;
|
||||||
|
|
||||||
// return true if yaw has been initialised
|
// return true if yaw has been initialised
|
||||||
|
@ -58,7 +58,7 @@ void AP_AHRS_View::set_pitch_trim(float trim_deg) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// update state
|
// update state
|
||||||
void AP_AHRS_View::update(bool skip_ins_update)
|
void AP_AHRS_View::update()
|
||||||
{
|
{
|
||||||
rot_body_to_ned = ahrs.get_rotation_body_to_ned();
|
rot_body_to_ned = ahrs.get_rotation_body_to_ned();
|
||||||
gyro = ahrs.get_gyro();
|
gyro = ahrs.get_gyro();
|
||||||
|
@ -34,7 +34,7 @@ public:
|
|||||||
AP_AHRS_View(AP_AHRS &ahrs, enum Rotation rotation, float pitch_trim_deg=0);
|
AP_AHRS_View(AP_AHRS &ahrs, enum Rotation rotation, float pitch_trim_deg=0);
|
||||||
|
|
||||||
// update state
|
// update state
|
||||||
void update(bool skip_ins_update=false);
|
void update();
|
||||||
|
|
||||||
// empty virtual destructor
|
// empty virtual destructor
|
||||||
virtual ~AP_AHRS_View() {}
|
virtual ~AP_AHRS_View() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user