mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-13 21:43:35 +08:00
terrain_estimator: initialize with valid delayed measurement
This commit is contained in:
committed by
Mathieu Bresciani
parent
0623b2b02d
commit
a998da1781
@@ -46,8 +46,6 @@
|
||||
bool Ekf::initHagl()
|
||||
{
|
||||
bool initialized = false;
|
||||
// get most recent range measurement from buffer
|
||||
const rangeSample &latest_measurement = _range_buffer.get_newest();
|
||||
|
||||
if (!_control_status.flags.in_air) {
|
||||
// if on ground, do not trust the range sensor, but assume a ground clearance
|
||||
@@ -57,11 +55,9 @@ bool Ekf::initHagl()
|
||||
initialized = true;
|
||||
|
||||
} else if ((_params.terrain_fusion_mode & TerrainFusionMask::TerrainFuseRangeFinder)
|
||||
&& _range_sensor.isHealthy()
|
||||
&& isRecent(latest_measurement.time_us, (uint64_t)2e5)) {
|
||||
&& _range_sensor.isDataHealthy()) {
|
||||
// if we have a fresh measurement, use it to initialise the terrain estimator
|
||||
// TODO: the latest measurment did not go through the checks and could be invalid!
|
||||
_terrain_vpos = _state.pos(2) + latest_measurement.rng * _range_sensor.getCosTilt();
|
||||
_terrain_vpos = _state.pos(2) + _range_sensor.getRange() * _range_sensor.getCosTilt();
|
||||
// initialise state variance to variance of measurement
|
||||
_terrain_var = sq(_params.range_noise);
|
||||
// success
|
||||
|
||||
Reference in New Issue
Block a user