PX4 / PX4-Autopilot

PX4 Autopilot Software
https://px4.io
BSD 3-Clause "New" or "Revised" License
8.2k stars 13.38k forks source link

SITL frequency simulation #18512

Open Antefos opened 2 years ago

Antefos commented 2 years ago

Hi everyone, I've read on the online guide that the control loops are able to run at frequencies like 1Khz. Working in SITL i noticed that the default loop frequency for example for the Rate controller is set to 250Hz, this is determined by the sensor mavlink data that arrives only on that frequency.

I would like to raise the frequency at least to 500 Hz , i've seen that in gazebo i can raise the pyblication rate for measurements, changing some parameters in the world definition, then I've tried to raise the IMU_GYRO_RATE MAX and IMU_INTG_RATEMAX but the messages are read always at 250 Hz, i cannot understand in which point the simulator read the messages at this specific frequency in order to raise it.

Someone can help me? or at least tell me if is it possible to run the simulation at higher frequency or not

Jaeyoung-Lim commented 2 years ago

@Antefos If you are talking about gazebo simulations specifically, the world is running on a lockstep, which is run at 250Hz by default: https://github.com/PX4/PX4-SITL_gazebo/blob/a3eef9d3a17078896f40abb0deaabfb0faad8c65/worlds/empty.world#L31

Antefos commented 2 years ago

@Jaeyoung-Lim Yes exactly, that is the default rate, but even if i use an higher rate, if i look at the gazebo topics the frequency is higher according to the one set by me, but looking at the uorb messages exchanged in the firmware the frequency is stuck at 250Hz.

The main problem is that I'm trying to use an HOSM+Feedback/Feedforward linearization to control a quadrotor, but a frequency of 250Hz give no robustness at all for this nonlinear control technique.

Antefos commented 2 years ago

I have some updates about it, I'm able to run the simulation faster disabling the lockstep parameter, however in this way the simulation and the firmware do not run simultaneusly, so i would like to keep the lockstep increasing the frequency (if possible).