ekf2: check if vision_position pos/vel are valid before using them

This commit is contained in:
ChristophTobler 2018-01-09 18:46:07 +01:00 committed by Lorenz Meier
parent 6609e4843b
commit 66c67f89e6
1 changed files with 5 additions and 2 deletions

View File

@ -867,8 +867,11 @@ void Ekf2::run()
ev_data.posErr = fmaxf(_ev_pos_noise.get(), fmaxf(ev_pos.eph, ev_pos.epv));
ev_data.angErr = _ev_ang_noise.get();
// use timestamp from external computer, clocks are synchronized when using MAVROS
_ekf.setExtVisionData(vision_position_updated ? ev_pos.timestamp : ev_att.timestamp, &ev_data);
// only set data if all positions and velocities are valid
if (ev_pos.xy_valid && ev_pos.z_valid && ev_pos.v_xy_valid && ev_pos.v_z_valid) {
// use timestamp from external computer, clocks are synchronized when using MAVROS
_ekf.setExtVisionData(vision_position_updated ? ev_pos.timestamp : ev_att.timestamp, &ev_data);
}
}
orb_check(vehicle_land_detected_sub, &vehicle_land_detected_updated);