For anyone else facing this issue here is a solution worked out by a team member:
Edit this file, which is part of jMAVSim repository, Visualizer3D.java, and change setVisible(true) to setVisible(false).
Run the command ant in the terminal to recompile jMAVSim
Now jMAVSim will no longer have a GUI and hence the SITL experience will run much faster, albeit without the graphic visual. Qgroundcontrol can still be used to interact with plane.
The Gazebo simulation consists of a physics simulator gzserver and a GUI gzclient. You can run it headlessly, i.e. without the GUI by simply not starting gzclient.
PX4 supports this with by setting the HEADLESS variable:
I am seeing the same issues as you. Running SITL gazebo headless on my MBP 2015, the flight performance is visibly affected by high CPU load. Unfortunately it seems px4 is not running on simulation time, but rather on system time, albeit synchronizing the two clocks every now and again as evidenced by the many “simulator is slow” messages. This is a shortcoming of the SITL simulation and may be worth opening an issue on Github.
As for your setup, the only thing I can suggest is running QGC on your host OS, although I doubt that makes a significant difference.
Two ideas come to mind to reduce the SITL computational burden:
Reduce the system rates
Connect PX4 to simulation time
@Nicolas mentioned the second approach and how that would take changing where posix-px4 sources time. It seems the first approach may be easier. For example, halve the rates of all systems (e.g. sensors from 500 Hz to 250 Hz, estimators and controllers again run at halve the nominal rate, as should message RX/TX).
Does anyone have experience or thoughts on this with Gazebo? I found where to change the simulation rate from the world model. For the plane world model: plane.world can specify simulation rate and maximum step size. But without making changes elsewhere it the system will again be unstable. It seems this needs changes to:
@Lukas - Good question but I’m not up to date on the process anymore. Hopefully others can help.
Perhaps a new thread with the questions would be appropriate.