PX4 SITL magnetometer and accelerometer 'jumps'

Hello everyone,

I am working on a custom build simulator of a VTOL octocopter using PX4. The drone has been tuned, lifts off, is able to fly and it can rotate when it is hovering. However, when flying in any direction with reasonable speed (>5 m/s) I see the drone ‘jumping’ on the map (QGC), often around 10 meters in what seems to be random direction. This goes together with the drone instantly going to a different heading, often more than 90 degrees within a timestep. At the same time, error messages such as ‘Preflight Fail: High Accelerometer Bias’ and ‘Compass needs calibration - land now!’ pop up.

I have been working on this problem for a couple of weeks now, but unfortunately I have yet to find an answer. For information, I am giving PX4 magnetometer data from an IGRF python library, which PX4 then converts to an attitude. The IMU data comes from the simulator state variables. Even when disabling the noise on these simulated sensors, I still have both errors.

I have included a log file at the bottom of this post. The big ‘jumps’ are not visible in the trajectory plot, however. But you can see big spikes in the yaw angle of the drone. Please let me know if you require additional information from my side, or if you know how to fix these errors.

Thanks!

VTOL accelerometer and magnetometer jumps

1 Like

I have the same issue, actually. Anyone got info on this? I have never gotten the autotune to work on the yaw-axis. I think it has to do with the magnetometer settings in PX4.

1 Like

Hey, is this still active? I’ve faced the same issue, however, the issue was the values for the accelerometer. Check your acceleration computation via finite differences of the inertial velocity and rotate them into bodyframe (don’t forget to subtract the gravitational acceleration beforehand) and compare it to the bodyframe accelerations (don’t forget to subtract the rotated gravitational acceleration) and compare each. If there is a mismatch, this might be due to your update scheme.
The estimator calculates directly the attitude with rates and accelerations. however if you some kind mix up the attitude from your simulation model during the update process, it will compute different accelerations which lead to oscillating behavior and those jumps.

Hope this will help if still needed.