Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yeshasvitirupachuri/5f7cf2cac48fbe70dac399f68791e6fa to your computer and use it in GitHub Desktop.
Save yeshasvitirupachuri/5f7cf2cac48fbe70dac399f68791e6fa to your computer and use it in GitHub Desktop.
ROS2 and Gazebo ROS Plugins Installation for Developers participating in GSoC2019 with the project Migrating Gazebo plugins to ROS2

ROS2 and Gazebo ROS Plugins Installation for Developers

NOTE This setup is with ROS2 Dashing Diademata

ROS2 can be installed with the binaries or from the sources. It is ideal to have the source installation so that as a developer one can have more access and control over the workflow. The master branch of ros2 repositories are the currently the stable for development.

  • Create a workspace that holds ros2 source code
mkdir -p ~/ros2_master_ws/src
cd ~/ros2_master_ws
  • Get the code base repositories and import them to src directory
wget https://raw.githubusercontent.com/ros2/ros2/master/ros2.repos
vcs import src < ros2.repos
  • Install the dependencies using rosdep
sudo rosdep init
rosdep update
# [Ubuntu 18.04]
rosdep install --from-paths src --ignore-src --rosdistro crystal -y --skip-keys "console_bridge fastcdr fastrtps libopensplice67 libopensplice69 rti-connext-dds-5.3.1 urdfdom_headers"
  • Build the code in the workspace
cd ~/ros2_master_ws
colcon build --symlink-install

Colcon build system will create build, install and log directories in ros2_master_ws workspace directory.

  • Source the ros2 environment to load the build libraries and executables
source ~/ros2_master_ws/install/local_setup.bash
  • Testing ros2 installation

Once the local_setup.bash script is sourced correctly you can verify ros2 installation by running the following talker and listener programs on seperate terminals

ros2 run demo_nodes_cpp talker
ros2 run demo_nodes_py listener

If you see the data from the talker terminal displayed on the listener terminal, everything is fine.

Gazebo should be installed either through the binaries or from source. Currently, gazebo9 is the minimum supported version for ros2 gazebo_ros_pkgs. The installation notes related to gazebo_ros_pkgs are present here. As pointed in the overview of the ROS2 integration documentation, the stable git branch for development is ros2.

  • Create a workspace and get gazebo_ros_pkgs
mkdir -p ~/gazebo_ros_pks_ws/src
cd ~/gazebo_ros_pkgs
  • Create a file named ros2.yaml and copy the contents of this file that gets gazebo_ros_pkgs and additional packages needed.

Old Link https://bitbucket.org/snippets/chapulina/geRKyA/ros2repos-supplement-gazebo_ros_pkgs

  • Get the packages to the src directory
vcs import src < ros2.yaml
  • Build the gazebo_ros_pkgs packages
colcon build --symlink-install

NOTE: Before building this ensure that ros2 environment is sourced correctly

source ~/ros2_master_ws/install/local_setup.bash
  • Source the ros2 environment to load the build libraries
source ~/gazebo_ros_pkgs_ws/install/local_setup.bash

Testing gazebo_ros_pkgs

  • Run gazebo with a demo world
    gazebo --verbose ~/gazebo_ros_pkgs_ws/src/ros-simulation/gazebo_ros_pkgs/gazebo_plugins/worlds/gazebo_ros_diff_drive_demo.world

If all the environments are loaded correctly, you will see a small mobile robot spawned in gazebo.

  • Send control commands to the mobile robot
ros2 topic pub /demo/cmd_demo geometry_msgs/Twist '{linear: {x: 1.0}}' -1

The mobile robot moves forward in gazebo. This test concludes that the gazebo_ros_pkgs are correctly installed.

@yeshasvitirupachuri
Copy link
Author

yeshasvitirupachuri commented Nov 9, 2020

Is there an updated ros2.yaml file? That link is dead

@guru-florida I updated the link, please try the new link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment