Skip to content
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

IMU: parameterize IMU integration time (IMU_INTEG_RATE) #14759

Merged
merged 16 commits into from
May 6, 2020

Conversation

dagar
Copy link
Member

@dagar dagar commented Apr 25, 2020

This effectively controls the vehicle_attitude publication rate and subsequently how fast the attitude controllers run. It's not something I expect regular users to to change, but this is better than having a magic hard coded number.

We might want to consider lowering this by default for FW.

@dagar
Copy link
Member Author

dagar commented Apr 25, 2020

Historically the IMU integration time was 4000 us (250 Hz) and only very recently changed to 2500 us (400 Hz). We could also consider if 5000 us (200 Hz) is a better default.

By default on most systems the rate controller (inner loop) is running at 800 Hz (synchronized with primary gyro).

@dagar
Copy link
Member Author

dagar commented Apr 25, 2020

Changing the integration from 2500 us -> 5000 us saves about 7% cpu on F4 boards. This is spread out over running the attitude controller, the ekf2 frontend (heavier than expected), and a bit of logging/mavlink (HIGHRES_IMU).

@dagar dagar force-pushed the pr-sensors_imu_integration branch 2 times, most recently from 912f92b to f4f154d Compare April 25, 2020 14:55
@dagar dagar force-pushed the pr-sensors_imu_integration branch from f4f154d to 7732f2d Compare April 25, 2020 14:57
@dagar
Copy link
Member Author

dagar commented Apr 25, 2020

Yet another factor to consider for the default is the impact on default logging rate and ekf2 replay.

On a typical simple multicopter configuration the nominal logging rate changes from ~ 47 KiB/s (IMU integration 2500 us) down to ~32 KiB/s (IMU integration 5000 us).

That being said, our top priority should be optimizing control and we'll work back from there.

mhkabir
mhkabir previously approved these changes Apr 26, 2020
MaEtUgR
MaEtUgR previously approved these changes Apr 27, 2020
Copy link
Member

@MaEtUgR MaEtUgR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making 200Hz the default attitude update rate also for multicopters makes sense to me.


if (imu_integration_time_us != _param_imu_integ_time.get()) {
_param_imu_integ_time.set(imu_integration_time_us);
_param_imu_integ_time.commit_no_notification();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it a problem that all Gyroscope and Accelerometer drivers would try to correct the out of range parameter more or less at the same time?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would at least define the [1000, 20000] interval shared to make sure it's always in sync.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I didn't like that part either. Very soon (early in the v1.12 release cycle) the plan is to gut all of this code from PX4Accelerometer/PX4Gyroscope and move it "downstream" to sensors/vehicle_imu where we can effectively synchronize accel + gyro.

@MaEtUgR
Copy link
Member

MaEtUgR commented Apr 27, 2020

One more question I forgot to ask in the review: Is there a specific reason why the new parameter is an interval while all others I know of are rates in Hz? Just thinking about the user perspective.

@dagar
Copy link
Member Author

dagar commented Apr 27, 2020

One more question I forgot to ask in the review: Is there a specific reason why the new parameter is an interval while all others I know of are rates in Hz? Just thinking about the user perspective.

Not really, I was thinking about it from the perspective of what was already hard coded and aligning with the current ecl/EKF filter update expressed as an interval (10 ms). We reset the integrator and publish the integrated value every ____ microseconds.

@dagar dagar dismissed stale reviews from MaEtUgR and mhkabir via 7733a55 April 27, 2020 15:57
@dagar dagar marked this pull request as ready for review April 27, 2020 15:57
@dagar
Copy link
Member Author

dagar commented Apr 27, 2020

Default changed to 5000 us.

@dagar
Copy link
Member Author

dagar commented Apr 27, 2020

SITL appears to be broken with 5000 us IMU integration.

@julianoes
Copy link
Contributor

julianoes commented Apr 28, 2020

dagar added a commit to PX4/jMAVSim that referenced this pull request Apr 28, 2020
 - this goes along with the change PX4 side PX4/PX4-Autopilot#14759
@dagar
Copy link
Member Author

dagar commented Apr 28, 2020

This was tested by @mhkabir in #14735.

Screenshot from 2020-04-28 12-22-06

It also fixes ekf2 replay logging with no logger changes (#14734).

$ ulog_info 6a006545-b3bf-446f-9baf-f89c5fcfb542.ulg 
Logging start time: 0:00:01, duration: 0:06:00
No Dropouts

RomanBapst
RomanBapst previously approved these changes Apr 28, 2020
dagar added a commit to PX4/PX4-SITL_gazebo-classic that referenced this pull request May 1, 2020
 - this goes along with the change PX4 side PX4/PX4-Autopilot#14759
dagar added a commit to PX4/jMAVSim that referenced this pull request May 1, 2020
 - this goes along with the change PX4 side PX4/PX4-Autopilot#14759
@dagar
Copy link
Member Author

dagar commented May 1, 2020

CI SITL MC_avoidance and MC_safe_landing still failing due to the sitl_gazebo version.

dagar added a commit to PX4/PX4-SITL_gazebo-classic that referenced this pull request May 1, 2020
 - this goes along with the change PX4 side PX4/PX4-Autopilot#14759
@dagar
Copy link
Member Author

dagar commented May 5, 2020

I've made 2 changes to the PR.

  1. renamed IMU_INTEG_TIME -> IMU_INTEG_RATE (I think most users find rate slightly more intuitive)
  2. Dropped the sitl_gazebo and jmavsim rate changes for now until we can resolve the performance problems change default update rate to 200 Hz PX4-SITL_gazebo-classic#474.

@dagar dagar force-pushed the pr-sensors_imu_integration branch from 3ed7a8a to 570ee7a Compare May 5, 2020 21:12
@dagar dagar changed the title IMU: parameterize IMU integration time (IMU_INTEG_TIME) IMU: parameterize IMU integration time (IMU_INTEG_RATE) May 5, 2020
@dagar dagar force-pushed the pr-sensors_imu_integration branch from a9ebe46 to 4fddd84 Compare May 5, 2020 23:36
@dagar dagar merged commit ca998c1 into master May 6, 2020
@dagar dagar deleted the pr-sensors_imu_integration branch May 6, 2020 00:34
@dagar dagar added this to the Release v1.11.0 milestone May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants