mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 10:23:35 +08:00
Multi-EKF support (ekf2)
- ekf2 can now run in multi-instance mode (currently up to 9 instances)
- in multi mode all estimates are published to alternate topics (eg estimator_attitude instead of vehicle_attitude)
- new ekf2 selector runs in multi-instance mode to monitor and compare all instances, selecting a primary (eg N x estimator_attitude => vehicle_attitude)
- sensors module accel & gyro inconsistency checks are now relative to the mean of all instances, rather than the current primary (when active ekf2 selector is responsible for choosing primary accel & gyro)
- existing consumers of estimator_status must check estimator_selector_status to select current primary instance status
- ekf2 single instance mode is still fully supported and the default
Co-authored-by: Paul Riseborough <gncsolns@gmail.com>
This commit is contained in:
co-authored by
Paul Riseborough
parent
d5245a22d3
commit
0f411d6820
@@ -143,6 +143,8 @@ private:
|
||||
delete _dist_pubs[i];
|
||||
}
|
||||
|
||||
px4_lockstep_unregister_component(_lockstep_component);
|
||||
|
||||
_instance = nullptr;
|
||||
}
|
||||
|
||||
@@ -288,6 +290,8 @@ private:
|
||||
px4::atomic<bool> _has_initialized {false};
|
||||
#endif
|
||||
|
||||
int _lockstep_component{-1};
|
||||
|
||||
DEFINE_PARAMETERS(
|
||||
(ParamInt<px4::params::MAV_TYPE>) _param_mav_type,
|
||||
(ParamInt<px4::params::MAV_SYS_ID>) _param_mav_sys_id,
|
||||
|
||||
@@ -368,6 +368,10 @@ void Simulator::handle_message_hil_gps(const mavlink_message_t *msg)
|
||||
|
||||
void Simulator::handle_message_hil_sensor(const mavlink_message_t *msg)
|
||||
{
|
||||
if (_lockstep_component == -1) {
|
||||
_lockstep_component = px4_lockstep_register_component();
|
||||
}
|
||||
|
||||
mavlink_hil_sensor_t imu;
|
||||
mavlink_msg_hil_sensor_decode(msg, &imu);
|
||||
|
||||
@@ -399,6 +403,8 @@ void Simulator::handle_message_hil_sensor(const mavlink_message_t *msg)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
px4_lockstep_progress(_lockstep_component);
|
||||
}
|
||||
|
||||
void Simulator::handle_message_hil_state_quaternion(const mavlink_message_t *msg)
|
||||
@@ -627,9 +633,11 @@ void Simulator::send()
|
||||
parameters_update(false);
|
||||
check_failure_injections();
|
||||
_vehicle_status_sub.update(&_vehicle_status);
|
||||
send_controls();
|
||||
|
||||
// Wait for other modules, such as logger or ekf2
|
||||
px4_lockstep_wait_for_components();
|
||||
|
||||
send_controls();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user