Skip to content

[Bug] MAVLink IMU dropouts in SITL #26230

@mcberry23

Description

@mcberry23

Describe the bug

I am integrating PX4 with a custom built EKF via MAVSDK that depends on consistent IMU timing. In SITL testing, I am receiving a high rate of IMU message dropouts via the SCALED_IMU message when requesting via MAVSDK.

To Reproduce

If I add a print statement to SCALED_IMU.hpp to print the delta time of msg.time_boot_ms with the previous iteration, I would expect a consistent value of approximately 0.0040 s.

float delta_t_s = (float) (msg.time_boot_ms - previous_time_ms) / 1000.0f;
PX4_INFO("Scaled IMU dt: %.4f s",(double) delta_t_s);
previous_time_ms = msg.time_boot_ms;

In reality, I also observe a significant number of 0.0080 s and 0.0000 s which is an indication that there are dropped and duplicate samples.

INFO  [mavlink] Scaled IMU dt: 0.0040 s
INFO  [mavlink] Scaled IMU dt: 0.0040 s
INFO  [mavlink] Scaled IMU dt: 0.0040 s
INFO  [mavlink] Scaled IMU dt: 0.0040 s
INFO  [mavlink] Scaled IMU dt: 0.0080 s
INFO  [mavlink] Scaled IMU dt: 0.0040 s
INFO  [mavlink] Scaled IMU dt: 0.0040 s
INFO  [mavlink] Scaled IMU dt: 0.0080 s
INFO  [mavlink] Scaled IMU dt: 0.0040 s
INFO  [mavlink] Scaled IMU dt: 0.0000 s
INFO  [mavlink] Scaled IMU dt: 0.0040 s
INFO  [mavlink] Scaled IMU dt: 0.0080 s
INFO  [mavlink] Scaled IMU dt: 0.0000 s
INFO  [mavlink] Scaled IMU dt: 0.0080 s
INFO  [mavlink] Scaled IMU dt: 0.0040 s
INFO  [mavlink] Scaled IMU dt: 0.0080 s

Expected behavior

If I add a print statement to VehicleIMU.cpp to print the delta time of imu.timestamp, I get a consistent rate:

INFO  [vehicle_imu] vehicle_imu dt: 0.0040 s
INFO  [vehicle_imu] vehicle_imu dt: 0.0040 s
INFO  [vehicle_imu] vehicle_imu dt: 0.0040 s
INFO  [vehicle_imu] vehicle_imu dt: 0.0040 s
INFO  [vehicle_imu] vehicle_imu dt: 0.0040 s
INFO  [vehicle_imu] vehicle_imu dt: 0.0040 s
INFO  [vehicle_imu] vehicle_imu dt: 0.0040 s
INFO  [vehicle_imu] vehicle_imu dt: 0.0040 s
INFO  [vehicle_imu] vehicle_imu dt: 0.0040 s
INFO  [vehicle_imu] vehicle_imu dt: 0.0040 s
INFO  [vehicle_imu] vehicle_imu dt: 0.0040 s
INFO  [vehicle_imu] vehicle_imu dt: 0.0040 s
INFO  [vehicle_imu] vehicle_imu dt: 0.0040 s
INFO  [vehicle_imu] vehicle_imu dt: 0.0040 s

This implies the simulator is producing consistent IMU messages, but that the timing is corrupted when pulling the data from the uorb stream.

Screenshot / Media

No response

Flight Log

No response

Software Version

I have validated this behavior occurs with PX4 v1.14.4 and v1.16.0. It is simulator agnostic as both Gazebo Classic and the new Gazebo. I am running on a Ubuntu 22.04 virtual machine.

Flight controller

PX4 SITL

Vehicle type

Multicopter

How are the different components wired up (including port information)

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions