PX4 SITL - Gazebo/Ogre problem

Hi. I’ve just installed Ubuntu 22.04 and the simulation environment as described here https://docs.px4.io/main/en/dev_setup/dev_env_linux_ubuntu.html#simulation-and-nuttx-pixhawk-target. The installation is performed with two shell commands:

  1. Download PX4 Source Code: git clone https://github.com/PX4/PX4-Autopilot.git --recursive
  2. Run ubuntu.sh: bash ./PX4-Autopilot/Tools/setup/ubuntu.sh

No errors occurred during the installation. However, when I run the simulation (make px4_sitl gz_x500), an exception of Ogre occurs and Gazebo is terminated. Below is the log returned.

[0/1] cd /home/pedro/DroneSimulators/PX4-Autopilot/build/px4_sitl_default/src/modu...L=gz_x500 /home/pedro/DroneSimulators/PX4-Autopilot/build/px4_sitl_default/bin/px4

______  __   __    ___ 
| ___ \ \ \ / /   /   |
| |_/ /  \ V /   / /| |
|  __/   /   \  / /_| |
| |     / /^\ \ \___  |
\_|     \/   \/     |_/

px4 starting.

INFO  [px4] startup script: /bin/sh etc/init.d-posix/rcS 0
INFO  [init] found model autostart file as SYS_AUTOSTART=4001
INFO  [param] selected parameter default file parameters.bson
INFO  [param] importing from 'parameters.bson'
INFO  [parameters] BSON document size 274 bytes, decoded 274 bytes (INT32:11, FLOAT:3)
INFO  [param] selected parameter backup file parameters_backup.bson
INFO  [dataman] data manager file './dataman' size is 7866640 bytes
INFO  [init] starting gazebo with world: /home/pedro/DroneSimulators/PX4-Autopilot/Tools/simulation/gz/worlds/default.sdf
WARN  [init] PX4_GZ_MODEL_NAME or PX4_GZ_MODEL not set using PX4_SIM_MODEL.
INFO  [gz_bridge] world: default, model name: x500_0, simulation model: x500
INFO  [lockstep_scheduler] setting initial absolute time to 8000 us
INFO  [commander] LED: open /dev/led0 failed (22)
INFO  [tone_alarm] home set
INFO  [mavlink] mode: Normal, data rate: 4000000 B/s on udp port 18570 remote port 14550
INFO  [mavlink] mode: Onboard, data rate: 4000000 B/s on udp port 14580 remote port 14540
INFO  [mavlink] mode: Onboard, data rate: 4000 B/s on udp port 14280 remote port 14030
INFO  [tone_alarm] notify negative
INFO  [mavlink] mode: Gimbal, data rate: 400000 B/s on udp port 13030 remote port 13280
INFO  [logger] logger started (mode=all)
INFO  [logger] Start file log (type: full)
INFO  [logger] [logger] ./log/2023-07-05/16_40_36.ulg
INFO  [logger] Opened full log file: ./log/2023-07-05/16_40_36.ulg
INFO  [mavlink] MAVLink only on localhost (set param MAV_{i}_BROADCAST = 1 to enable network)
INFO  [mavlink] MAVLink only on localhost (set param MAV_{i}_BROADCAST = 1 to enable network)
INFO  [px4] Startup script returned successfully
pxh> terminate called after throwing an instance of 'Ogre::RenderingAPIException'
  what():  OGRE EXCEPTION(3:RenderingAPIException): Vertex Program 100000000VertexShader_vs failed to compile. See compile log above for details. in GLSLShader::compile at ./RenderSystems/GL3Plus/src/GLSL/OgreGLSLShader.cpp (line 361)
Stack trace (most recent call last) in thread 4479:
#10   Object "[0xffffffffffffffff]", at 0xffffffffffffffff, in 
#9    Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f18700469ff, in 
#8    Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f186ffb4b42, in 
#7    Object "/lib/x86_64-linux-gnu/libQt5Core.so.5", at 0x7f186a3bc99d, in 
#6    Object "/lib/x86_64-linux-gnu/libQt5Core.so.5", at 0x7f186a3baf90, in qTerminate()
#5    Object "/lib/x86_64-linux-gnu/libstdc++.so.6", at 0x7f186c0472b6, in std::terminate()
#4    Object "/lib/x86_64-linux-gnu/libstdc++.so.6", at 0x7f186c04724b, in 
#3    Object "/lib/x86_64-linux-gnu/libstdc++.so.6", at 0x7f186c03bbbd, in 
#2    Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f186ff487f2, in abort
#1    Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f186ff62475, in raise
#0    Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f186ffb6a7c, in pthread_kill
Aborted (Signal sent by tkill() 3851 1000)
INFO  [commander] Ready for takeoff!

It seems that the simulation is running, but the Gazebo is terminated.

Any ideas of how the gazebo simulation can be fixed?

Thanks in advance.

is this native Ubuntu 20.04?

If it is WSL2 Ubuntu installation then you may want to check these issues. Close to being resolved, but still exist. One workaround is to use OGRE1 instead of 2, however I haven’t found a way how to run px4 with it just yet.
OGRE2: Gazebo (Fortress) rendering with OGRE2 crashes in a WSL2 environment with a dedicated GPU present, aka WSLg · Issue #662 · gazebosim/gz-rendering (github.com)
No camera/render on ubuntu (WSLg + vGPU) · Issue #920 · gazebosim/gz-sim (github.com)

I found out that one can add --render-engine ogre argument to px4 script that runs Ignition Gazebo simulation in file https://github.com/PX4/PX4-Autopilot/blob/61aee73b91ff76c6555173bc0c7846d7c7dab7e2/ROMFS/px4fmu_common/init.d-posix/px4-rc.simulator#L86

So instead of

${gz_command} ${gz_sub_command} -g &

it should be like

${gz_command} ${gz_sub_command} -g --render-engine ogre &
1 Like

Thank you for posting this!