Strange frequency jumps in SITL

Hello everyone, I continue to dive into Gazebo + SITL, I noticed a strange moment that while sitl is not running, the gazebo topic outputs the following imu frequency:

interval [0]: 0.00128104s
interval [1]: 0.00132531s
interval [2]: 0.00130436s
interval [3]: 0.00128077s
interval [4]: 0.0012758s
interval [5]: 0.00127371s
interval [6]: 0.0012682s
interval [7]: 0.00124611s
interval [8]: 0.00128635s
interval [9]: 0.00126324s
average rate: 780.951
min: 0.00124611s max: 0.00132531s std dev: 2.0767e-05s window: 10

When I run SITL, the frequency increases dramatically:
interval [0]: 0.00096508s
interval [1]: 0.00100307s
interval [2]: 0.000989035s
interval [3]: 0.00100942s
interval [4]: 0.000987515s
interval [5]: 0.0010056s
interval [6]: 0.00099632s
interval [7]: 0.0010031s
interval [8]: 0.000991505s
interval [9]: 0.00100838s
average rate: 1004.11
min: 0.00096508s max: 0.00100942s std dev: 1.27386e-05s window: 10

Parametrs in copter sdf:

<link name="imu_link">

      <inertial>

<pose>0 0 0.1 0 0 0</pose>

<mass>0.015</mass>

<inertia>

<ixx>0.00001</ixx>

<ixy>0</ixy>

<ixz>0</ixz>

<iyy>0.00002</iyy>

<iyz>0</iyz>

<izz>0.00002</izz>

</inertia>

</inertial>




<sensor name="imu_sensor" type="imu">

<pose degrees="true">0 0 0 180 0 0</pose>

<always_on>1</always_on>

<update_rate>1000.0</update_rate>

</sensor>

<sensor name="mag_sensor" type="magnetometer">

<pose>0 0 0 0 0 0</pose>

<always_on>1</always_on>

<update_rate>400.0</update_rate>

<topic>/sensors/compass</topic>

</sensor>

<sensor name="baro_sensor" type="air_pressure">

<pose>0 0 0 0 0 0</pose>

<always_on>1</always_on>

<update_rate>400.0</update_rate>

<topic>/sensor/baro</topic>

</sensor>

</link>

Parametrs in world sdf:

<physics name="1ms" type="ode">

      <max_step_size>0.001</max_step_size>

<real_time_factor>1.0</real_time_factor>

</physics>
  1. What is the reason for this? and how does it work?
  2. How can I get an imu frequency greater than 1000? Or is it impossible?

@rhys I think you know the answers to these questions. Thank you in advance.

If SITL is not running the ArdupilotPlugin blocks for a while trying to establish a connection. The default is to run lock-step, so this will slow the system update loop (where the IMU system is also updated).

It’s also visible in the RTF display in the GUI - it will be slower before the link to SITL is established.

What about the imu frequency? Is it possible to get more than 1000?

I’m not sure. Could be the sampling, If one message is delayed, and the other follows on time there will be a shorter time between them? It’s a small sample size and you’re looking at zeromq messages received stats. Most Gazebo publishers follow much the same pattern, so if the IMU update period is throttled to 1000Hz it will attempt to publish the message after the corresponding period measured in sim time has passed.

@rhys thank you for answer, but I have another one.

If I set the frequency above 1000, even 1001, the simulation dies after the first tick. I’m wondering if it’s possible to change the parameters to get messages published at a higher frequency? (I understand about the frequency jumps in the topic, thanks.) Is this even possible, considering that I can run the simulation itself at a frequency above 1000 (<max_step_size>0.0005</max_step_size>)?