sensors/vehicle_optical_flow: only get gyro if optical flow delta angle not available (#20416)

This commit is contained in:
Alex Klimaj
2022-10-17 10:23:36 -04:00
committed by GitHub
parent 116bb6049f
commit 8545164869
3 changed files with 12 additions and 4 deletions
@@ -102,7 +102,10 @@ void VehicleOpticalFlow::Run()
ParametersUpdate();
UpdateDistanceSensor();
UpdateSensorGyro();
if (!_delta_angle_available) {
UpdateSensorGyro();
}
sensor_optical_flow_s sensor_optical_flow;
@@ -129,8 +132,11 @@ void VehicleOpticalFlow::Run()
) {
// passthrough integrated gyro if available
_delta_angle += _flow_rotation * Vector3f{sensor_optical_flow.delta_angle};
_delta_angle_available = true;
} else {
_delta_angle_available = false;
// integrate synchronized gyro
gyroSample gyro_sample;
@@ -122,6 +122,8 @@ private:
int _distance_sensor_selected{-1}; // because we can have several distance sensor instances with different orientations
hrt_abstime _last_range_sensor_update{0};
bool _delta_angle_available{false};
struct gyroSample {
uint64_t time_us{}; ///< timestamp of the measurement (uSec)
matrix::Vector3f data{};