|
|
|
@ -1708,18 +1708,15 @@ void EKF2::UpdateMagSample(ekf2_timestamps_s &ekf2_timestamps)
@@ -1708,18 +1708,15 @@ void EKF2::UpdateMagSample(ekf2_timestamps_s &ekf2_timestamps)
|
|
|
|
|
void EKF2::UpdateRangeSample(ekf2_timestamps_s &ekf2_timestamps) |
|
|
|
|
{ |
|
|
|
|
if (!_distance_sensor_selected) { |
|
|
|
|
// get subscription index of first downward-facing range sensor
|
|
|
|
|
uORB::SubscriptionMultiArray<distance_sensor_s> distance_sensor_subs{ORB_ID::distance_sensor}; |
|
|
|
|
|
|
|
|
|
if (distance_sensor_subs.advertised()) { |
|
|
|
|
for (unsigned i = 0; i < distance_sensor_subs.size(); i++) { |
|
|
|
|
if (_distance_sensor_subs.advertised()) { |
|
|
|
|
for (unsigned i = 0; i < _distance_sensor_subs.size(); i++) { |
|
|
|
|
distance_sensor_s distance_sensor; |
|
|
|
|
|
|
|
|
|
if (distance_sensor_subs[i].copy(&distance_sensor)) { |
|
|
|
|
if (_distance_sensor_subs[i].update(&distance_sensor)) { |
|
|
|
|
// only use the first instace which has the correct orientation
|
|
|
|
|
if ((hrt_elapsed_time(&distance_sensor.timestamp) < 100_ms) |
|
|
|
|
&& (distance_sensor.orientation == distance_sensor_s::ROTATION_DOWNWARD_FACING)) { |
|
|
|
|
|
|
|
|
|
if (_distance_sensor_sub.ChangeInstance(i)) { |
|
|
|
|
int ndist = orb_group_count(ORB_ID(distance_sensor)); |
|
|
|
|
|
|
|
|
|