-
Notifications
You must be signed in to change notification settings - Fork 13.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
move IMU integration to sensors/vehicle_imu to fix potential accel/gyro sync issues #14906
Conversation
73b7e64
to
85e151c
Compare
@@ -267,18 +267,12 @@ rtps: | |||
id: 117 | |||
- msg: sensor_accel_fifo | |||
id: 118 | |||
- msg: sensor_accel_status | |||
id: 119 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dagar can you rearrange the ID's so we don't have unused numbers? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shift the entire set after 118 down? What's the expectation/requirement for these id numbers (persistence, etc)?
@dagar I tested that on a BMI088 and the sensor combined data is now free of duplicates! |
85e151c
to
b5067f4
Compare
- sensors: voted_sensos_update consume vehicle_imu - delete sensor_accel_integrated, sensor_gyro_integrated - merge sensor_accel_status/sensor_gyro_status into vehicle_imu_status
b5067f4
to
2906f40
Compare
f46ecfd
to
9ba72f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pushing this, looks good.
I went through this, not quite line-by-line, but close.
Can you ensure the vehicle_imu publication ordering? I.e. advertisement on object creation and creation ordering.
report.device_id = _device_id; | ||
report.temperature = _temperature; | ||
report.error_count = _error_count; | ||
report.x = val_calibrated(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now uses the trapezoidal integral whereas before it was the average. Almost the same, and possibly not noticeable, but IMO worth pointing out.
* | ||
* @param reset_samples New reset time interval for the integrator. | ||
*/ | ||
void set_reset_samples(uint8_t reset_samples) { _reset_samples_min = reset_samples; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why configure both the number of samples + integral time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VehicleIMU initially uses the configured integration rate (IMU_INTEG_RATE), but then switches over to samples once it has a good measure for the actual accel/gyro publication rate.
I kept a relaxed min interval in place as a crude protection after seeing quite a bit of variability in the mixed cases (fxas21002c + fxos8701cq, lsm303d + l3gd20, etc) that I haven't really explored in detail yet.
_accel_integrator.set_reset_interval(0); | ||
|
||
// run when there are enough new gyro samples, unregister accel | ||
_sensor_accel_sub.unregisterCallback(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming gyro is publishing at a faster or equal rate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should still be fine given the queue depth. We'll have to give this more thought over time depending on the range of situations we want to support/tolerate. After #14776 there's also the possibility of using the FIFO data at this level and integrating subsets to synchronize as closely as possible.
_accel_integrator.set_reset_interval(relaxed_reset_interval_min); | ||
|
||
} else { | ||
// otherwise let the gyro set the configuration and scheduling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not always do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This started life implemented for the known good/simple cases (already synchronized invensense accel + gyro) and then evolved to accommodate the others. I think always following the gyro makes sense and keeps the scheduling regular relative to the inner loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lockstep and SITL (non-root) was being a little weird with the possibility of gyro then accel publishing, but VehicleIMU running in between. I'll see if it can be simplified (sensor_gyro only scheduling).
If the flow of data seems a bit weird with |
This saves ~2.3 kB of flash on fmu-v2 and ~3.4 kB on fmu-v5. |
Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is your testing and confidence level?
I still see a possibility for vehicle_imu reordering: intantiation is based on accel.device_id > 0 && gyro.device_id > 0
, so it could be that a later IMU already has its ID published.
Reasonably confident for something that's never flown. I'm going to manually verify a few things like the propagation of clip counters. I'd also like to review bench log data from the non-synchronized cases we care about (bmi088, bmi055, nxp, original pixhawk, etc) and check for any surprises in the delta_angle_dt/delta_velocity_dt and ekf2 timeslip. Reviewing an actual flight test with a bmi088 as primary would be great.
In the current PR sensors indexes VehicleIMUs as _vehicle_imu_list[X] = sensor_accelX + sensor_gyroX. One simple idea could be to only build up that list sequentially. The sensors module is rescanning the available accels & gyros up until arming. Originally I was planning to pursue this post #14776 where the ordering will no longer matter. At that point I'd also like to do a pass to have |
69dab21
to
c4b6c72
Compare
I gave up on the minimum interval time requirement/protection in addition to the number of samples and I believe things are now reasonably under control on the BMI088. The accel & gyro publication rate of the BMI088 isn't nearly as regular as the other new drivers using FIFOs and interrupts. For example the BMI088 vs ICM20602 publication intervals on the Modalai board. BMI088vehicle_imu: publish interval: 41990 events, 5014.34us avg, min 4036us max 7055us 136.370us rms
vehicle_imu: accel update interval: 169309 events, 1243.74us avg, min 367us max 2551us 87.115us rms
vehicle_imu: gyro update interval: 209988 events, 1002.87us avg, min 224us max 3043us 164.365us rms ICM20602vehicle_imu: publish interval: 42162 events, 4990.85us avg, min 4649us max 5352us 37.751us rms
vehicle_imu: accel update interval: 168664 events, 1247.73us avg, min 1222us max 1273us 2.603us rms
vehicle_imu: gyro update interval: 168676 events, 1247.73us avg, min 1222us max 1273us 2.603us rms Note this also includes bootup and the initial period before the actual publication rate is computed and integration is configured to an appropriate number of samples. http://ci.px4.io:8080/blue/organizations/jenkins/PX4_misc%2FFirmware-hardware/detail/pr-sensors_vehicle_imu_integrate/54/pipeline/399#step-790-log-64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks as expected now.
Co-authored-by: Beat Küng <beat-kueng@gmx.net>
…ss we've fallen behind by more than 1 sample
3dc6e5a
to
3f21722
Compare
3f21722
to
470f418
Compare
260478b
to
9c0f8c5
Compare
40c1080
to
859b02e
Compare
859b02e
to
043f83a
Compare
TODO: