Custom Simulator in SITL

Hi,

I am writing my custom simulator where I am updating the HIL_SENSOR, HIL_GPS and HIL_QUATERNION messages. However, I find that the performance is not good. By that I mean when flying a mission in QGC I see that the copter follows the waypoints but there are vibrations in the compass in pitching direction. Currently, I am sending all the above-mentioned messages at 10000us interval. I found that it is good to do that at 4000us interval. But my query is how does it matter since both plant and px4 timestamp is set to the HIL_SENSOR message timestamp and after all it is simulation. Also, I see that if I increase the timestamp interval from 10000us to say 15000us the mavlink message update rate as seen in QGC MAVLink inspector also increases and vice versa.

Can anyone please help me understand if I am missing something?

Thanks,

Sayan

Additionally, does the host computer performance matter in case of SITL?

The update rate matters a lot. PX4’s EKF expects IMU data around 200–250 Hz. If you send HIL_SENSOR too slow (like 100 Hz or less), you’ll see vibrations and noisy attitude. That’s why ~4000 µs works better — it matches the real IMU rate.

Thanks I will check.

Hi Sayan. I am also working Simulink based simulator and px4 hitl. But ekf2 doesnot startin even though i send all three messages you mentioned. Have you ever experienced this ekf module locked issue?

Thanks