Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

909 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ROS2Learn with Docker

This repository contains ROS 2 enabled Artificial Intelligence (AI) and Reinforcement Learning (RL) algorithms that run in selected environments. The repo was forked from the AcutronicRoboitcs/ros2learn and I highly encourage everyone to checkout the parent repo to learn more, especially if you want to learn how to use the repo without docker containers.

The repository contains the following:

  • algorithms: techniques used for training and teaching robots.
  • environments: pre-built environments of interest to train selected robots.
  • experiments: experiments and examples of the different utilities that this repository provides.

Pull container from docker hub

Pull the docker container containing the repo from the docker hub.

docker pull vanshrai/ros2learn

Build the container

Alternatively, instead of pulling the docker image from docker hub, you can build it locally. Please note that the building can take up to 30 minutes.

cd ~ && git clone -b staging https://github.com/vanshraisaini/ros2learn.git
cd ~/ros2learn/docker
docker build -t vanshrai/ros2learn .

Setup

Create a folder where the simulation and training data will be stored.

cd ~/. && mkdir ros2_learn

Start a new container

Before starting the container, move to the directory where all the data should be stored.

cd ~/ros2_learn/

Run a new r2l container

docker rm r2l || true && docker run -it --name=r2l -h ros2learn -v `pwd`:/tmp/ros2learn vanshrai/ros2learn

After starting the container, run the following command inside the container to load the visual models which will be used by gzclient later.

cp -r /root/ros2_mara_ws /tmp/ros2learn

Development/Research mode

You can install new software such as file editors (e.g. apt install nano), which would be useful if you are trying to find the optimal parameters for a network for instance.

# Inside Docker
apt update
apt install nano

Make sure you save the state of your docker container before exiting it by opening a new terminal and executing:

# Get the CONTAINER ID from the IMAGE called r2l.
docker ps
# Commit changes to the r2l container.
docker commit XXXXXXX r2l

Example:

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
b0d8de35f133        r2l                 "bash"              2 minutes ago       Up 2 minutes        11597/tcp           wizardly_lamarr

$ docker commit b0d8de35f133 r2l

Next time you want to run the container you will need to launch the existing one:

docker run -it r2l

Run a training script

# inside the docker container
cd ~/ros2learn/experiments/examples/MARA
python3 train_ppo2_mlp.py

Launch gzclient (GUI)

Make sure you have gazebo already installed in your main Ubuntu system and you are in the same path from which you executed the docker run command, that is, ~/ros2_learn folder. 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
# Please note that it may take some time for gzclient to set the world during the first launch.
cd ~/ros2_learn && git clone -b staging https://github.com/vanshraisaini/ros2learn.git
cp ~/ros2_learn/ros2learn/docker/gzclient.sh ./gzclient.sh
sh gzclient.sh

Visualize tensorboard

From your main OS, launch tensorboard pointing it to the files shared from the docker container. You can use the absolute path to any specific file or folder available in that directory.

cd ~/ros2_learn/ros2learn/docker
sudo tensorboard --logdir=`pwd`

About

ROS 2 enabled Reinforcement Learning algorithms

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages