mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-25 16:51:16 +08:00
perf(ekf2): reconstruct the output position once per update (#29261)
* perf(ekf2): reconstruct the output position once per update After each filter update, the local position, odometry and global position publishers each rebuilt the output position in double precision: getLatLonAlt() three times, with trigonometry in the local-to-global step, and the projection back to local NED twice. Nothing changes the output predictor between them, so compute the global position and its local projection once and pass them to the publishers. The published values are bit-identical. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org> * refactor(ekf2): name the global-to-local conversion globalToLocalPosition getPosition(lla) projects any global position into the EKF's local frame rather than returning the estimator's position, so name it as the inverse of Ekf::localToGlobalPosition(). Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com> --------- Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org> Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com> Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
This commit is contained in:
1 parent
b8b35ed014
commit
93579610c6
9 files changed
+32
-30
No files matched your search
@@ -53,7 +53,7 @@
|
||||
*(.text.param_get)
|
||||
*(.text._ZN7sensors22VehicleAngularVelocity21SensorSelectionUpdateERKyb)
|
||||
*(.text._ZN3px49WorkQueue3AddEPNS_8WorkItemE)
|
||||
*(.text._ZN4EKF220PublishLocalPositionERKy)
|
||||
*(.text._ZN4EKF220PublishLocalPositionERKyRKN6matrix7Vector3IfEE)
|
||||
*(.text._mav_finalize_message_chan_send)
|
||||
*(.text._ZN7sensors22VehicleAngularVelocity16ParametersUpdateEb)
|
||||
*(.text._ZN6events12SendProtocol6updateERKy)
|
||||
@@ -176,7 +176,7 @@
|
||||
*(.text._ZN3Ekf24controlOpticalFlowFusionERKN9estimator9imuSampleE)
|
||||
*(.text._ZN19MavlinkStreamRawRpm4sendEv)
|
||||
*(.text._ZN13MavlinkStream10const_rateEv)
|
||||
*(.text._ZN4EKF215PublishOdometryERKyRKN9estimator9imuSampleE)
|
||||
*(.text._ZN4EKF215PublishOdometryERKyRKN9estimator9imuSampleERKN6matrix7Vector3IfEE)
|
||||
*(.text._ZN15FailureDetector20updateAttitudeStatusERK16vehicle_status_s)
|
||||
*(.text._ZN7Mavlink19configure_sik_radioEv)
|
||||
*(.text._ZN13BatteryStatus8adc_pollEv)
|
||||
@@ -582,7 +582,7 @@
|
||||
*(.text._ZN4uORB10DeviceNode15poll_notify_oneEP6pollfdm)
|
||||
*(.text._ZN3GPS21handleInjectDataTopicEv.part.0)
|
||||
*(.text._ZN9Commander17systemPowerUpdateEv)
|
||||
*(.text._ZN4EKF221PublishGlobalPositionERKy)
|
||||
*(.text._ZN4EKF221PublishGlobalPositionERKyRK9LatLonAlt)
|
||||
*(.text._ZNK12FailsafeBase17getSelectedActionERKNS_5StateERK16failsafe_flags_sbbRNS_19SelectedActionStateE)
|
||||
*(.text.imxrt_padctl_address)
|
||||
*(.text._ZNK6matrix6VectorIfLj2EE4unitEv)
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
*(.text.param_get)
|
||||
*(.text._ZN7sensors22VehicleAngularVelocity21SensorSelectionUpdateERKyb)
|
||||
*(.text._ZN3px49WorkQueue3AddEPNS_8WorkItemE)
|
||||
*(.text._ZN4EKF220PublishLocalPositionERKy)
|
||||
*(.text._ZN4EKF220PublishLocalPositionERKyRKN6matrix7Vector3IfEE)
|
||||
*(.text._mav_finalize_message_chan_send)
|
||||
*(.text._ZN7sensors22VehicleAngularVelocity16ParametersUpdateEb)
|
||||
*(.text._ZN6events12SendProtocol6updateERKy)
|
||||
@@ -171,7 +171,7 @@
|
||||
*(.text._ZN3Ekf24controlOpticalFlowFusionERKN9estimator9imuSampleE)
|
||||
*(.text._ZN19MavlinkStreamRawRpm4sendEv)
|
||||
*(.text._ZN13MavlinkStream10const_rateEv)
|
||||
*(.text._ZN4EKF215PublishOdometryERKyRKN9estimator9imuSampleE)
|
||||
*(.text._ZN4EKF215PublishOdometryERKyRKN9estimator9imuSampleERKN6matrix7Vector3IfEE)
|
||||
*(.text._ZN15FailureDetector20updateAttitudeStatusERK16vehicle_status_s)
|
||||
*(.text._ZN7Mavlink19configure_sik_radioEv)
|
||||
*(.text.getpid)
|
||||
@@ -568,7 +568,7 @@
|
||||
*(.text._ZN4uORB10DeviceNode15poll_notify_oneEP6pollfdm)
|
||||
*(.text._ZN3GPS21handleInjectDataTopicEv.part.0)
|
||||
*(.text._ZN9Commander17systemPowerUpdateEv)
|
||||
*(.text._ZN4EKF221PublishGlobalPositionERKy)
|
||||
*(.text._ZN4EKF221PublishGlobalPositionERKyRK9LatLonAlt)
|
||||
*(.text._ZNK12FailsafeBase17getSelectedActionERKNS_5StateERK16failsafe_flags_sbbRNS_19SelectedActionStateE)
|
||||
*(.text.imxrt_padctl_address)
|
||||
*(.text._ZNK6matrix6VectorIfLj2EE4unitEv)
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
*(.text.param_get)
|
||||
*(.text._ZN7sensors22VehicleAngularVelocity21SensorSelectionUpdateERKyb)
|
||||
*(.text._ZN3px49WorkQueue3AddEPNS_8WorkItemE)
|
||||
*(.text._ZN4EKF220PublishLocalPositionERKy)
|
||||
*(.text._ZN4EKF220PublishLocalPositionERKyRKN6matrix7Vector3IfEE)
|
||||
*(.text._mav_finalize_message_chan_send)
|
||||
*(.text._ZN7sensors22VehicleAngularVelocity16ParametersUpdateEb)
|
||||
*(.text._ZN6events12SendProtocol6updateERKy)
|
||||
@@ -174,7 +174,7 @@
|
||||
*(.text._ZN3Ekf24controlOpticalFlowFusionERKN9estimator9imuSampleE)
|
||||
*(.text._ZN19MavlinkStreamRawRpm4sendEv)
|
||||
*(.text._ZN13MavlinkStream10const_rateEv)
|
||||
*(.text._ZN4EKF215PublishOdometryERKyRKN9estimator9imuSampleE)
|
||||
*(.text._ZN4EKF215PublishOdometryERKyRKN9estimator9imuSampleERKN6matrix7Vector3IfEE)
|
||||
*(.text._ZN15FailureDetector20updateAttitudeStatusERK16vehicle_status_s)
|
||||
*(.text._ZN7Mavlink19configure_sik_radioEv)
|
||||
*(.text._ZN13BatteryStatus8adc_pollEv)
|
||||
@@ -570,7 +570,7 @@
|
||||
*(.text._ZN4uORB10DeviceNode15poll_notify_oneEP6pollfdm)
|
||||
*(.text._ZN3GPS21handleInjectDataTopicEv.part.0)
|
||||
*(.text._ZN9Commander17systemPowerUpdateEv)
|
||||
*(.text._ZN4EKF221PublishGlobalPositionERKy)
|
||||
*(.text._ZN4EKF221PublishGlobalPositionERKyRK9LatLonAlt)
|
||||
*(.text._ZNK12FailsafeBase17getSelectedActionERKNS_5StateERK16failsafe_flags_sbbRNS_19SelectedActionStateE)
|
||||
*(.text.imxrt_padctl_address)
|
||||
*(.text._ZNK6matrix6VectorIfLj2EE4unitEv)
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
*(.text.param_get)
|
||||
*(.text._ZN7sensors22VehicleAngularVelocity21SensorSelectionUpdateERKyb)
|
||||
*(.text._ZN3px49WorkQueue3AddEPNS_8WorkItemE)
|
||||
*(.text._ZN4EKF220PublishLocalPositionERKy)
|
||||
*(.text._ZN4EKF220PublishLocalPositionERKyRKN6matrix7Vector3IfEE)
|
||||
*(.text._mav_finalize_message_chan_send)
|
||||
*(.text._ZN7sensors22VehicleAngularVelocity16ParametersUpdateEb)
|
||||
*(.text._ZN6events12SendProtocol6updateERKy)
|
||||
@@ -174,7 +174,7 @@
|
||||
*(.text._ZN3Ekf24controlOpticalFlowFusionERKN9estimator9imuSampleE)
|
||||
*(.text._ZN19MavlinkStreamRawRpm4sendEv)
|
||||
*(.text._ZN13MavlinkStream10const_rateEv)
|
||||
*(.text._ZN4EKF215PublishOdometryERKyRKN9estimator9imuSampleE)
|
||||
*(.text._ZN4EKF215PublishOdometryERKyRKN9estimator9imuSampleERKN6matrix7Vector3IfEE)
|
||||
*(.text._ZN15FailureDetector20updateAttitudeStatusERK16vehicle_status_s)
|
||||
*(.text._ZN7Mavlink19configure_sik_radioEv)
|
||||
*(.text._ZN13BatteryStatus8adc_pollEv)
|
||||
@@ -569,7 +569,7 @@
|
||||
*(.text._ZN4uORB10DeviceNode15poll_notify_oneEP6pollfdm)
|
||||
*(.text._ZN3GPS21handleInjectDataTopicEv.part.0)
|
||||
*(.text._ZN9Commander17systemPowerUpdateEv)
|
||||
*(.text._ZN4EKF221PublishGlobalPositionERKy)
|
||||
*(.text._ZN4EKF221PublishGlobalPositionERKyRK9LatLonAlt)
|
||||
*(.text._ZNK12FailsafeBase17getSelectedActionERKNS_5StateERK16failsafe_flags_sbbRNS_19SelectedActionStateE)
|
||||
*(.text.imxrt_padctl_address)
|
||||
*(.text._ZNK6matrix6VectorIfLj2EE4unitEv)
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
*(.text.param_get)
|
||||
*(.text._ZN7sensors22VehicleAngularVelocity21SensorSelectionUpdateERKyb)
|
||||
*(.text._ZN3px49WorkQueue3AddEPNS_8WorkItemE)
|
||||
*(.text._ZN4EKF220PublishLocalPositionERKy)
|
||||
*(.text._ZN4EKF220PublishLocalPositionERKyRKN6matrix7Vector3IfEE)
|
||||
*(.text._mav_finalize_message_chan_send)
|
||||
*(.text._ZN7sensors22VehicleAngularVelocity16ParametersUpdateEb)
|
||||
*(.text._ZN6events12SendProtocol6updateERKy)
|
||||
@@ -176,7 +176,7 @@
|
||||
*(.text._ZN3Ekf24controlOpticalFlowFusionERKN9estimator9imuSampleE)
|
||||
*(.text._ZN19MavlinkStreamRawRpm4sendEv)
|
||||
*(.text._ZN13MavlinkStream10const_rateEv)
|
||||
*(.text._ZN4EKF215PublishOdometryERKyRKN9estimator9imuSampleE)
|
||||
*(.text._ZN4EKF215PublishOdometryERKyRKN9estimator9imuSampleERKN6matrix7Vector3IfEE)
|
||||
*(.text._ZN15FailureDetector20updateAttitudeStatusERK16vehicle_status_s)
|
||||
*(.text._ZN7Mavlink19configure_sik_radioEv)
|
||||
*(.text._ZN13BatteryStatus8adc_pollEv)
|
||||
@@ -582,7 +582,7 @@
|
||||
*(.text._ZN4uORB10DeviceNode15poll_notify_oneEP6pollfdm)
|
||||
*(.text._ZN3GPS21handleInjectDataTopicEv.part.0)
|
||||
*(.text._ZN9Commander17systemPowerUpdateEv)
|
||||
*(.text._ZN4EKF221PublishGlobalPositionERKy)
|
||||
*(.text._ZN4EKF221PublishGlobalPositionERKyRK9LatLonAlt)
|
||||
*(.text._ZNK12FailsafeBase17getSelectedActionERKNS_5StateERK16failsafe_flags_sbbRNS_19SelectedActionStateE)
|
||||
*(.text.imxrt_padctl_address)
|
||||
*(.text._ZNK6matrix6VectorIfLj2EE4unitEv)
|
||||
|
||||
@@ -641,9 +641,8 @@ bool EstimatorInterface::initialise_interface(uint64_t timestamp)
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector3f EstimatorInterface::getPosition() const
|
||||
Vector3f EstimatorInterface::globalToLocalPosition(const LatLonAlt &lla) const
|
||||
{
|
||||
LatLonAlt lla = _output_predictor.getLatLonAlt();
|
||||
float x;
|
||||
float y;
|
||||
|
||||
|
||||
@@ -261,7 +261,8 @@ public:
|
||||
Vector3f getVelocityDerivative() const { return _output_predictor.getVelocityDerivative(); }
|
||||
void resetVelocityDerivativeAccumulation() { return _output_predictor.resetVelocityDerivativeAccumulation(); }
|
||||
float getVerticalPositionDerivative() const { return _output_predictor.getVerticalPositionDerivative(); }
|
||||
Vector3f getPosition() const;
|
||||
Vector3f getPosition() const { return globalToLocalPosition(getLatLonAlt()); }
|
||||
Vector3f globalToLocalPosition(const LatLonAlt &lla) const;
|
||||
LatLonAlt getLatLonAlt() const { return _output_predictor.getLatLonAlt(); }
|
||||
const Vector3f &getOutputTrackingError() const { return _output_predictor.getOutputTrackingError(); }
|
||||
|
||||
|
||||
@@ -857,9 +857,13 @@ void EKF2::Run()
|
||||
if (_ekf.update()) {
|
||||
perf_set_elapsed(_ekf_update_perf, hrt_elapsed_time(&ekf_update_start));
|
||||
|
||||
PublishLocalPosition(now);
|
||||
PublishOdometry(now, imu_sample_new);
|
||||
PublishGlobalPosition(now);
|
||||
// the output position, reconstructed once for all position publications
|
||||
const LatLonAlt lla = _ekf.getLatLonAlt();
|
||||
const Vector3f position = _ekf.globalToLocalPosition(lla);
|
||||
|
||||
PublishLocalPosition(now, position);
|
||||
PublishOdometry(now, imu_sample_new, position);
|
||||
PublishGlobalPosition(now, lla);
|
||||
PublishSensorBias(now);
|
||||
|
||||
#if defined(CONFIG_EKF2_WIND)
|
||||
@@ -1364,7 +1368,7 @@ void EKF2::PublishEventFlags(const hrt_abstime ×tamp)
|
||||
}
|
||||
}
|
||||
|
||||
void EKF2::PublishGlobalPosition(const hrt_abstime ×tamp)
|
||||
void EKF2::PublishGlobalPosition(const hrt_abstime ×tamp, const LatLonAlt &lla)
|
||||
{
|
||||
if (_ekf.global_origin_valid() && _ekf.control_status().flags.yaw_align) {
|
||||
// generate and publish global position data
|
||||
@@ -1372,7 +1376,6 @@ void EKF2::PublishGlobalPosition(const hrt_abstime ×tamp)
|
||||
global_pos.timestamp_sample = timestamp;
|
||||
|
||||
// Position GPS / WGS84 frame
|
||||
const LatLonAlt lla = _ekf.getLatLonAlt();
|
||||
global_pos.lat = lla.latitude_deg();
|
||||
global_pos.lon = lla.longitude_deg();
|
||||
global_pos.lat_lon_valid = _ekf.isGlobalHorizontalPositionValid();
|
||||
@@ -1696,14 +1699,13 @@ void EKF2::PublishInnovationVariances(const hrt_abstime ×tamp)
|
||||
_estimator_innovation_variances_pub.publish(variances);
|
||||
}
|
||||
|
||||
void EKF2::PublishLocalPosition(const hrt_abstime ×tamp)
|
||||
void EKF2::PublishLocalPosition(const hrt_abstime ×tamp, const Vector3f &position)
|
||||
{
|
||||
vehicle_local_position_s lpos{};
|
||||
// generate vehicle local position data
|
||||
lpos.timestamp_sample = timestamp;
|
||||
|
||||
// Position of body origin in local NED frame
|
||||
const Vector3f position{_ekf.getPosition()};
|
||||
lpos.x = position(0);
|
||||
lpos.y = position(1);
|
||||
lpos.z = position(2);
|
||||
@@ -1819,7 +1821,7 @@ void EKF2::PublishLocalPosition(const hrt_abstime ×tamp)
|
||||
_local_position_pub.publish(lpos);
|
||||
}
|
||||
|
||||
void EKF2::PublishOdometry(const hrt_abstime ×tamp, const imuSample &imu_sample)
|
||||
void EKF2::PublishOdometry(const hrt_abstime ×tamp, const imuSample &imu_sample, const Vector3f &position)
|
||||
{
|
||||
// generate vehicle odometry data
|
||||
vehicle_odometry_s odom;
|
||||
@@ -1827,7 +1829,7 @@ void EKF2::PublishOdometry(const hrt_abstime ×tamp, const imuSample &imu_sa
|
||||
|
||||
// position
|
||||
odom.pose_frame = vehicle_odometry_s::POSE_FRAME_NED;
|
||||
_ekf.getPosition().copyTo(odom.position);
|
||||
position.copyTo(odom.position);
|
||||
|
||||
// orientation quaternion
|
||||
_ekf.getQuaternion().copyTo(odom.q);
|
||||
|
||||
@@ -192,12 +192,12 @@ private:
|
||||
estimator_bias_s fillEstimatorBiasMsg(const BiasEstimator::status &status, uint64_t timestamp_sample_us,
|
||||
uint64_t timestamp, uint32_t device_id = 0);
|
||||
void PublishEventFlags(const hrt_abstime ×tamp);
|
||||
void PublishGlobalPosition(const hrt_abstime ×tamp);
|
||||
void PublishGlobalPosition(const hrt_abstime ×tamp, const LatLonAlt &lla);
|
||||
void PublishInnovations(const hrt_abstime ×tamp);
|
||||
void PublishInnovationTestRatios(const hrt_abstime ×tamp);
|
||||
void PublishInnovationVariances(const hrt_abstime ×tamp);
|
||||
void PublishLocalPosition(const hrt_abstime ×tamp);
|
||||
void PublishOdometry(const hrt_abstime ×tamp, const imuSample &imu_sample);
|
||||
void PublishLocalPosition(const hrt_abstime ×tamp, const Vector3f &position);
|
||||
void PublishOdometry(const hrt_abstime ×tamp, const imuSample &imu_sample, const Vector3f &position);
|
||||
void PublishSensorBias(const hrt_abstime ×tamp);
|
||||
void PublishStates(const hrt_abstime ×tamp);
|
||||
void PublishStatus(const hrt_abstime ×tamp);
|
||||
|
||||
Reference in new issue
Block a user