gym_gazebo2 Installation

docker rm gg2 || true && docker run -it --name=gg2 -h gym-gazebo2 -v `pwd`:/tmp acutronicrobotics/gym-gazebo2
cp -r /root/ros2_mara_ws /tmp #Inside the docker container, used to load visual models

cd gym-gazebo2/docker
docker rm gg2 || true && docker run -it --name=gg2 -h gym-gazebo2 -v `pwd`:/tmp gg2
cp -r /root/ros2_mara_ws /tmp #Inside the docker container, used to load visual models
cd examples/MARA && python3 gg_random.py #Run the example

cd examples/MARA
python3 gg_random.py

Make sure you have gazebo already installed in your main Ubuntu system. If you are already running the simulation in the default port, you can access the visual interface the following way opening a new terminal:

# Do not use -g --gzclient flag
cd ~/gym-gazebo2/docker
sh gzclient.sh

For the complete MARA experiments installation, please refer first to the ROS2learn installation instructions: ros2learn/tutorials.

  • Gazebo 9.6. Install Gazebo 9.6 following the official one-liner installation instructions. Instructions.
  • ROS 2 Crystal.
    • Ubuntu 18: Install ROS 2 following the official instructions, binaries recommended. Instructions.

sudo apt update && sudo apt install -y \
  build-essential \
  cmake \
  git \
  python3-colcon-common-extensions \
  python3-pip \
  python-rosdep \
  python3-vcstool \
  python3-sip-dev \
  python3-numpy \
  wget

pip3 install tensorflow==1.12
pip3 install transforms3d billiard

# Fast-RTPS dependencies
sudo apt install --no-install-recommends -y \
  libasio-dev \
  libtinyxml2-dev

Following folder naming is recommended!

Create the workspace and download source files:

mkdir -p ~/ros2_mara_ws/src
cd ~/ros2_mara_ws
wget https://raw.githubusercontent.com/AcutronicRobotics/MARA/master/mara-ros2.repos
vcs import src < mara-ros2.repos
wget https://raw.githubusercontent.com/AcutronicRobotics/gym-gazebo2/master/provision/additional-repos.repos
vcs import src < additional-repos.repos
# Avoid compiling erroneus package
touch ~/ros2_mara_ws/src/orocos_kinematics_dynamics/orocos_kinematics_dynamics/COLCON_IGNORE

Generate HRIM dependencies:

cd ~/ros2_mara_ws/src/HRIM
pip3 install -e installator
hrim generate models/actuator/servo/servo.xml
hrim generate models/actuator/gripper/gripper.xml

Please make sure you are not sourcing ROS1 workspaces via bashrc or any other way.

Build the workspace using the --merge-install flag. Make sure you have enough Swap space.

source /opt/ros/crystal/setup.bash
cd ~/ros2_mara_ws
colcon build --merge-install
# Remove warnings
touch ~/ros2_mara_ws/install/share/orocos_kdl/local_setup.sh ~/ros2_mara_ws/install/share/orocos_kdl/local_setup.bash

A few packages are expected to throw warning messages. The expected output is the following:

35 packages finished [12min 26s]
4 packages had stderr output: cv_bridge orocos_kdl python_orocos_kdl robotiq_gripper_gazebo_plugins

Standalone URDF parser for Python3.

cd ~
git clone https://github.com/ros/urdf_parser_py.git -b melodic-devel
cd urdf_parser_py
pip3 install -e .

It is recommended to install Gym's latest version, which means using the source code. If you already installed Gym via pip3, you can uninstall it via pip3 uninstall gym to avoid overlapping:

cd ~
git clone https://github.com/openai/gym
cd gym
pip3 install -e .

Install the gym-gazebo2 reinforcement learning toolkit.

If you are using ros2learn:

cd ~/ros2learn/environments/gym-gazebo2
pip3 install -e .

If not:

cd ~ && git clone https://github.com/acutronicRobotics/gym-gazebo2
cd gym-gazebo2
pip3 install -e .

First we need setup ROS 2, MARA ROS 2 workspace and Gazebo. It is convenient that the required environment variables are automatically added to your bash session every time a new shell is launched:

#Navigate to module's root directory
cd gym-gazebo2
echo "source `pwd`/provision/mara_setup.sh" >> ~/.bashrc
source ~/.bashrc

Note: This setup file contains paths to ROS and Gazebo used by default by this toolkit. If you installed ROS from sources, you must modify the first line of the provisioning script:

-  source /opt/ros/crystal/setup.bash
+  source ~/ros2_ws/install/setup.bash
   source ~/ros2_mara_ws/install/setup.bash
   source /usr/share/gazebo-9/setup.sh
   export PYTHONPATH=$PYTHONPATH:~/ros2_mara_ws/install/lib/python3/dist-packages
   export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:~/ros2_mara_ws/src/MARA
   export GAZEBO_PLUGIN_PATH=$GAZEBO_PLUGIN_PATH:~/ros2_mara_ws/src/MARA/mara_gazebo_plugins/build/