Skip to main content
Version: 2023

Gazebo

Gazebo is a set of open source tools for simulating robots in an environment. It is commonly used in robotics research and education.

We will be using Gazebo to simulate the robot (BlueROV2) in a virtual (pool) environment.

note

We will be using Gazebo Garden, the latest version of Gazebo.

Installation

The documentation for installing Gazebo can be found here. See "Binary Installation" for instructions on installing Gazebo on your operating system. Below is a summary of the steps.

note

Only Ubuntu is fully supported by Gazebo. macOS is partially supported. In Windows, the simulation will run, but the GUI will not work.

First we need to install ruby from Homebrew:

brew install ruby

Then we have to add the Homebrew Ruby to our path:

echo 'export PATH="$(brew --prefix)/opt/ruby/bin:$PATH"' >> ~/.zshrc

Now, we add the osrf/simulation tap:

brew tap osrf/simulation
Apple Silicon-based Macs

For Apple Silicon-based Macs, we need to modify the Formulae before installing Gazebo.

cd /opt/homebrew/Library/Taps/osrf/homebrew-simulation/Formula
sed -i '' 's|cmake_args << "-DCMAKE_INSTALL_RPATH=#{rpath}"|cmake_args << "-DCMAKE_INSTALL_RPATH=#{rpath};/opt/homebrew/lib"|' *.rb

Next we install Gazebo:

brew install gz-garden

Test the installation

To test your installation, run the following command:

In one terminal, run:

gz sim -v4 -s shapes.sdf

In another terminal, run:

gz sim -v4 -g

You should see a window pop up with some 3D objects in it.

Our custom simulation

We built a custom simulation for the BlueROV2. It lives in this repository: gazebo_bluerov2.

Clone the repository into your workspace:

git clone https://github.com/blksail-edu/gazebo_bluerov2

Build the simulation:

cd gazebo_bluerov2
./build.sh

Start the example simulation:

./launch.sh
warning

Sometimes, the simulation will not quit properly. If this happens, you will need to kill the process manually.

pkill -9 gz

Gazebo BlueROV2

Controlling the robot

Try controlling the depth of robot now with depth_control.py you previously wrote.

First, in the backseat, start the SITL:

cd PATH_TO_ARDUSUB
Tools/autotest/sim_vehicle.py -L RATBeach -v ArduSub -f vectored --model=JSON --out=udp:SIMULATION_COMPUTER_IP:14550 --console

Run your depth_control.py script in another terminal:

python3 depth_control.py

You should see the robot dive to the desired depth.