How to Install gazebo_ros_pkgs from Source

Create a directory for the gazebo_ros_pkgs workspace :

1
mkdir -p gazebo_ros_pkgs/src

Copy this file, that gets gazebo_ros_pkgs and additional packages needed:

1
2
cd gazebo_ros_pkgs
wget https://raw.githubusercontent.com/ros-simulation/gazebo_ros_pkgs/foxy/gazebo_ros_pkgs.repos

Modify the file gazebo_ros_pkgs.repos, replace all the version by foxy.

1
2
3
4
5
6
7
8
9
10
11
12
13
repositories:
gazebo_ros_pkgs:
type: git
url: https://github.com/ros-simulation/gazebo_ros_pkgs.git
version: foxy
image_common:
type: git
url: https://github.com/ros-perception/image_common.git
version: foxy
vision_opencv:
type: git
url: https://github.com/ros-perception/vision_opencv.git
version: foxy

Note: The version tag in the yaml file indicates the branch we are checking out for a particular repository e.g. version: ros2 checks out the ros2 branch.

Get the packages into the src directory.

1
vcs import src < gazebo_ros_pkgs.repos

Switch to the branch matching your ROS distro.

1
vcs custom --args checkout foxy

Install all dependencies.

1
rosdep install --from-paths src --ignore-src -r -y

Then build all the packages.

1
colcon build --symlink-install

Note: Before building this ensure that the ROS 2 environment is sourced correctly.

Source this workspace’s install setup.

1
source gazebo_ros_pkgs/install/setup.bash