Skip to content

User_Inst_Gazebo

Mehmet Emre Çakal edited this page Oct 10, 2024 · 9 revisions

1.3.2 Gazebo Setup for VM

Note: This tutorial assumes that you have completed tutorials:

This tutorial shows how to install and setup Gazebo, which is used for robot simulation in ROS. Gazebo is an independent software, like many other programs that are bundled with ROS, it might require additional installation depending on your ROS installation configuration.

ROS2 Humble
* __Important:__ Due to known rendering issues with Gazebo Fortress, if you are using WSL or Docker, hardware rendering might not work, depending on your platform (especially with Intel GPUs, integrated or not). *In that case*, we have two recommendations to solve the issue. 1. __Forcing Discrete GPU__ - Ubuntu on WSL, will automatically select the first numbered GPU to render any OpenGL software, that is, your Intel/AMD integrated GPU. If you get rendering issues with your integrated GPU, and you have an additional discrete GPU, you can force mesa adapters to use with OpenGL. ```bash # First, install mesa utils if you don't have: sudo apt-get install mesa-utils ``` - Then, check your default renderer: ``` bash glxinfo | grep OpenGL
  # Output:
  # OpenGL vendor string: Microsoft Corporation
  # OpenGL renderer string: D3D12 (NVIDIA Quadro RTX 3000)
  # OpenGL core profile version string: 4.2 (Core Profile) Mesa 23.2.1-1ubuntu3.1~22.04.2
  # OpenGL core profile shading language version string: 4.20
  # OpenGL core profile context flags: (none)
  # OpenGL core profile profile mask: core profile
  # OpenGL core profile extensions:
  # OpenGL version string: 4.2 (Compatibility Profile) Mesa 23.2.1-1ubuntu3.1~22.04.2
  # OpenGL shading language version string: 4.20
  # OpenGL context flags: (none)
  # OpenGL profile mask: compatibility profile
  # OpenGL extensions:
  # OpenGL ES profile version string: OpenGL ES 3.1 Mesa 23.2.1-1ubuntu3.1~22.04.2
  # OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
  # OpenGL ES profile extensions:
  ```
  - If you don't see your discrete GPU, you can force it:
  
  ```bash
  export MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA # or AMD
  ```

  - Please notice that this is a Linux environment variable and unless it's on bash, you need to run that in each new terminal. If this is solved your rendering problem, you can add it to bash to make it permanent:
  ```bash
  echo 'export MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA' >> ~/.bashrc
  ```
  
  > If this did not solve rendering issues and you insist using your discrete GPU, please ensure that you have your GPU drivers installed in Ubuntu.

2. __Forcing Software Render__ 
  - This method will completely disable any GPU you have while using Gazebo (or any other OpenGL program that you are planning to use on your WSL). Similarly, you can define an environment variable to force software rendering:
  ```bash
  export LIBGL_ALWAYS_SOFTWARE=1

  # And again, unless you add this to the .bash(rc), you need to run this code every time you open a new terminal, before launching Gazebo. If you want to add:
  echo 'export LIBGL_ALWAYS_SOFTWARE=1' >> ~/.bashrc
  ```
ROS1 Noetic
  • Using the following commands, setup your Ubuntu VM to accept software from packages.osrfoundation.org and install the Gazebo7 packages.
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get install gazebo7
  • Install the required packages
sudo apt-get install libgazebo7-*
  • Make sure that you now have the prefered Gazebo version. (Note: If you are using Oracle VM VirtualBox, there may occur a rendering issue with Gazebo. In order to avoid this, we use Gazebo version 7.x.x.)
gazebo --version

Note: Visit the gazebosim webpage and its tutorial page for more details.


Next tutorial: TurtleBot Setup (Optional for ROS2 users)


© Siemens AG, 2017-2024

Clone this wiki locally