mirror of https://github.com/ArduPilot/ardupilot
AP_AHRS: move to airspeed_estimate with pointer
This commit is contained in:
parent
a2e72de5ae
commit
f6897632f8
|
@ -180,19 +180,19 @@ Vector3f AP_AHRS::get_gyro_latest(void) const
|
|||
}
|
||||
|
||||
// return airspeed estimate if available
|
||||
bool AP_AHRS::airspeed_estimate(float *airspeed_ret) const
|
||||
bool AP_AHRS::airspeed_estimate(float &airspeed_ret) const
|
||||
{
|
||||
if (airspeed_sensor_enabled()) {
|
||||
*airspeed_ret = _airspeed->get_airspeed();
|
||||
airspeed_ret = _airspeed->get_airspeed();
|
||||
if (_wind_max > 0 && AP::gps().status() >= AP_GPS::GPS_OK_FIX_2D) {
|
||||
// constrain the airspeed by the ground speed
|
||||
// and AHRS_WIND_MAX
|
||||
const float gnd_speed = AP::gps().ground_speed();
|
||||
float true_airspeed = *airspeed_ret * get_EAS2TAS();
|
||||
float true_airspeed = airspeed_ret * get_EAS2TAS();
|
||||
true_airspeed = constrain_float(true_airspeed,
|
||||
gnd_speed - _wind_max,
|
||||
gnd_speed + _wind_max);
|
||||
*airspeed_ret = true_airspeed / get_EAS2TAS();
|
||||
airspeed_ret = true_airspeed / get_EAS2TAS();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ Vector2f AP_AHRS::groundspeed_vector(void)
|
|||
Vector2f gndVelADS;
|
||||
Vector2f gndVelGPS;
|
||||
float airspeed = 0;
|
||||
const bool gotAirspeed = airspeed_estimate_true(&airspeed);
|
||||
const bool gotAirspeed = airspeed_estimate_true(airspeed);
|
||||
const bool gotGPS = (AP::gps().status() >= AP_GPS::GPS_OK_FIX_2D);
|
||||
if (gotAirspeed) {
|
||||
const Vector3f wind = wind_estimate();
|
||||
|
|
|
@ -251,15 +251,15 @@ public:
|
|||
|
||||
// return an airspeed estimate if available. return true
|
||||
// if we have an estimate
|
||||
virtual bool airspeed_estimate(float *airspeed_ret) const WARN_IF_UNUSED;
|
||||
virtual bool airspeed_estimate(float &airspeed_ret) const WARN_IF_UNUSED;
|
||||
|
||||
// return a true airspeed estimate (navigation airspeed) if
|
||||
// available. return true if we have an estimate
|
||||
bool airspeed_estimate_true(float *airspeed_ret) const WARN_IF_UNUSED {
|
||||
bool airspeed_estimate_true(float &airspeed_ret) const WARN_IF_UNUSED {
|
||||
if (!airspeed_estimate(airspeed_ret)) {
|
||||
return false;
|
||||
}
|
||||
*airspeed_ret *= get_EAS2TAS();
|
||||
airspeed_ret *= get_EAS2TAS();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1039,11 +1039,11 @@ bool AP_AHRS_DCM::get_position(struct Location &loc) const
|
|||
}
|
||||
|
||||
// return an airspeed estimate if available
|
||||
bool AP_AHRS_DCM::airspeed_estimate(float *airspeed_ret) const
|
||||
bool AP_AHRS_DCM::airspeed_estimate(float &airspeed_ret) const
|
||||
{
|
||||
bool ret = false;
|
||||
if (airspeed_sensor_enabled()) {
|
||||
*airspeed_ret = _airspeed->get_airspeed();
|
||||
airspeed_ret = _airspeed->get_airspeed();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1053,7 +1053,7 @@ bool AP_AHRS_DCM::airspeed_estimate(float *airspeed_ret) const
|
|||
|
||||
// estimate it via GPS speed and wind
|
||||
if (have_gps()) {
|
||||
*airspeed_ret = _last_airspeed;
|
||||
airspeed_ret = _last_airspeed;
|
||||
ret = true;
|
||||
}
|
||||
|
||||
|
@ -1061,16 +1061,16 @@ bool AP_AHRS_DCM::airspeed_estimate(float *airspeed_ret) const
|
|||
// constrain the airspeed by the ground speed
|
||||
// and AHRS_WIND_MAX
|
||||
const float gnd_speed = AP::gps().ground_speed();
|
||||
float true_airspeed = *airspeed_ret * get_EAS2TAS();
|
||||
float true_airspeed = airspeed_ret * get_EAS2TAS();
|
||||
true_airspeed = constrain_float(true_airspeed,
|
||||
gnd_speed - _wind_max,
|
||||
gnd_speed + _wind_max);
|
||||
*airspeed_ret = true_airspeed / get_EAS2TAS();
|
||||
airspeed_ret = true_airspeed / get_EAS2TAS();
|
||||
}
|
||||
if (!ret) {
|
||||
// give the last estimate, but return false. This is used by
|
||||
// dead-reckoning code
|
||||
*airspeed_ret = _last_airspeed;
|
||||
airspeed_ret = _last_airspeed;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ public:
|
|||
|
||||
// return an airspeed estimate if available. return true
|
||||
// if we have an estimate
|
||||
bool airspeed_estimate(float *airspeed_ret) const override;
|
||||
bool airspeed_estimate(float &airspeed_ret) const override;
|
||||
|
||||
bool use_compass() override;
|
||||
|
||||
|
|
|
@ -489,7 +489,7 @@ Vector3f AP_AHRS_NavEKF::wind_estimate(void) const
|
|||
|
||||
// return an airspeed estimate if available. return true
|
||||
// if we have an estimate
|
||||
bool AP_AHRS_NavEKF::airspeed_estimate(float *airspeed_ret) const
|
||||
bool AP_AHRS_NavEKF::airspeed_estimate(float &airspeed_ret) const
|
||||
{
|
||||
return AP_AHRS_DCM::airspeed_estimate(airspeed_ret);
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
|
||||
// return an airspeed estimate if available. return true
|
||||
// if we have an estimate
|
||||
bool airspeed_estimate(float *airspeed_ret) const override;
|
||||
bool airspeed_estimate(float &airspeed_ret) const override;
|
||||
|
||||
// true if compass is being used
|
||||
bool use_compass() override;
|
||||
|
|
|
@ -88,11 +88,11 @@ public:
|
|||
return ahrs.wind_estimate();
|
||||
}
|
||||
|
||||
bool airspeed_estimate(float *airspeed_ret) const WARN_IF_UNUSED {
|
||||
bool airspeed_estimate(float &airspeed_ret) const WARN_IF_UNUSED {
|
||||
return ahrs.airspeed_estimate(airspeed_ret);
|
||||
}
|
||||
|
||||
bool airspeed_estimate_true(float *airspeed_ret) const WARN_IF_UNUSED {
|
||||
bool airspeed_estimate_true(float &airspeed_ret) const WARN_IF_UNUSED {
|
||||
return ahrs.airspeed_estimate_true(airspeed_ret);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue