mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-06 13:21:36 +08:00
ekf2: move ekf_gps_drift publication to method
This commit is contained in:
+21
-15
@@ -923,21 +923,6 @@ void EKF2::Run()
|
|||||||
_estimator_sensor_bias_pub.publish(bias);
|
_estimator_sensor_bias_pub.publish(bias);
|
||||||
}
|
}
|
||||||
|
|
||||||
// publish GPS drift data only when updated to minimise overhead
|
|
||||||
float gps_drift[3];
|
|
||||||
bool blocked;
|
|
||||||
|
|
||||||
if (_ekf.get_gps_drift_metrics(gps_drift, &blocked)) {
|
|
||||||
ekf_gps_drift_s drift_data;
|
|
||||||
drift_data.hpos_drift_rate = gps_drift[0];
|
|
||||||
drift_data.vpos_drift_rate = gps_drift[1];
|
|
||||||
drift_data.hspd = gps_drift[2];
|
|
||||||
drift_data.blocked = blocked;
|
|
||||||
drift_data.timestamp = _replay_mode ? now : hrt_absolute_time();
|
|
||||||
|
|
||||||
_ekf_gps_drift_pub.publish(drift_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
/* Check and save learned magnetometer bias estimates */
|
/* Check and save learned magnetometer bias estimates */
|
||||||
|
|
||||||
@@ -1010,6 +995,9 @@ void EKF2::Run()
|
|||||||
PublishWindEstimate(now);
|
PublishWindEstimate(now);
|
||||||
PublishYawEstimatorStatus(now);
|
PublishYawEstimatorStatus(now);
|
||||||
|
|
||||||
|
// publish status/logging messages
|
||||||
|
PublishEkfDriftMetrics(now);
|
||||||
|
|
||||||
if (!_mag_decl_saved && _standby) {
|
if (!_mag_decl_saved && _standby) {
|
||||||
_mag_decl_saved = update_mag_decl(_param_ekf2_mag_decl);
|
_mag_decl_saved = update_mag_decl(_param_ekf2_mag_decl);
|
||||||
}
|
}
|
||||||
@@ -1239,6 +1227,24 @@ void EKF2::PublishAttitude(const hrt_abstime ×tamp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EKF2::PublishEkfDriftMetrics(const hrt_abstime ×tamp)
|
||||||
|
{
|
||||||
|
// publish GPS drift data only when updated to minimise overhead
|
||||||
|
float gps_drift[3];
|
||||||
|
bool blocked;
|
||||||
|
|
||||||
|
if (_ekf.get_gps_drift_metrics(gps_drift, &blocked)) {
|
||||||
|
ekf_gps_drift_s drift_data;
|
||||||
|
drift_data.hpos_drift_rate = gps_drift[0];
|
||||||
|
drift_data.vpos_drift_rate = gps_drift[1];
|
||||||
|
drift_data.hspd = gps_drift[2];
|
||||||
|
drift_data.blocked = blocked;
|
||||||
|
drift_data.timestamp = _replay_mode ? timestamp : hrt_absolute_time();
|
||||||
|
|
||||||
|
_ekf_gps_drift_pub.publish(drift_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EKF2::PublishOdometry(const hrt_abstime ×tamp, const imuSample &imu)
|
void EKF2::PublishOdometry(const hrt_abstime ×tamp, const imuSample &imu)
|
||||||
{
|
{
|
||||||
// generate vehicle odometry data
|
// generate vehicle odometry data
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ private:
|
|||||||
bool update_mag_decl(Param &mag_decl_param);
|
bool update_mag_decl(Param &mag_decl_param);
|
||||||
|
|
||||||
void PublishAttitude(const hrt_abstime ×tamp);
|
void PublishAttitude(const hrt_abstime ×tamp);
|
||||||
|
void PublishEkfDriftMetrics(const hrt_abstime ×tamp);
|
||||||
void PublishOpticalFlowVel(const hrt_abstime ×tamp, const optical_flow_s &optical_flow);
|
void PublishOpticalFlowVel(const hrt_abstime ×tamp, const optical_flow_s &optical_flow);
|
||||||
void PublishOdometry(const hrt_abstime ×tamp, const imuSample &imu);
|
void PublishOdometry(const hrt_abstime ×tamp, const imuSample &imu);
|
||||||
void PublishWindEstimate(const hrt_abstime ×tamp);
|
void PublishWindEstimate(const hrt_abstime ×tamp);
|
||||||
|
|||||||
Reference in New Issue
Block a user