前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >基于ROS和gazebo对gym中robotics扩展

基于ROS和gazebo对gym中robotics扩展

作者头像
CreateAMind
发布2018-07-24 15:18:32
9910
发布2018-07-24 15:18:32
举报
文章被收录于专栏:CreateAMind

#gym-gazebo

This work presents an extension of the initial OpenAI gym for robotics using ROS and Gazebo. A whitepaper about this work is available at https://arxiv.org/abs/1608.05742(论文地址). Please use the following BibTex entry to cite our work:

代码语言:javascript
复制
@misc{1608.05742,
	Author = {Iker Zamora and Nestor Gonzalez Lopez and Victor Mayoral Vilches and Alejandro Hernandez Cordero},
	Title = {Extending the OpenAI Gym for robotics: a toolkit for reinforcement learning using ROS and Gazebo},
	Year = {2016},
	Eprint = {arXiv:1608.05742},
}

Visit erlerobotics/gym (主页)for more information and videos.

The following are some of the available gazebo environments for the [Turtlebot]([Soccer environment]), one of the currently supported robots:

GazeboCircuit2TurtlebotLidar-v0

A simple circuit with straight tracks and 90 degree turns. Highly discretized LIDAR readings are used to train the Turtlebot. Scripts implementing Q-learning and Sarsa can be found in the examples folder.

GazeboCircuit2TurtlebotLidarNn-v0

A simple circuit with straight tracks and 90 degree turns. A LIDAR is used to train the Turtlebot. Scripts implementing DQN can be found in the examples folder.

GazeboCircuit2cTurtlebotCameraNnEnv-v0

A simple circuit with straight tracks and 90 degree turns with high contrast colors between the floor and the walls. A camera is used to train the Turtlebot. Scripts implementing DQN using CNN can be found in the examples folder.

Installation

Table of Contents

  • Docker
  • Ubuntu
    • Automatic installation
    • Step-by-step installation
    • Keras and Theano installation
    • Enablig GPU for Theano
    • Requirements
    • ROS Indigo
    • Gazebo
    • Gym Gazebo Pip
    • Dependencies
    • Usage

Docker

Build/fetch the container:

代码语言:javascript
复制
docker pull erlerobotics/gym-gazebo:latest # to fetch the container# docker build -t gym-gazebo .

Enter the container

代码语言:javascript
复制
docker run -it erlerobotics/gym-gazebo

If you wish to run examples that require plugins like cameras, create a fake screen with:

代码语言:javascript
复制
xvfb-run -s "-screen 0 1400x900x24" bash

If you have an equivalent release of Gazebo installed locally, you can connect to the gzserver inside the container using gzclient GUI by setting the address of the master URI to the containers public address.

代码语言:javascript
复制
export GAZEBO_MASTER_IP=$(sudo docker inspect --format '{{ .NetworkSettings.IPAddress }}' "id of running container")
export GAZEBO_MASTER_URI=$GAZEBO_MASTER_IP:11345
gzclient

Ubuntu

Requirements

  • Ubuntu 14.04
  • 2GB free space

ROS Indigo

Install the Robot Operating System via:

ros-indigo-desktop-full is the only recommended installation.

  • Ubuntu: http://wiki.ros.org/indigo/Installation/Ubuntu
  • Others: http://wiki.ros.org/indigo/Installation

Gazebo

  • Setup your computer to accept software from packages.osrfoundation.org:
代码语言:javascript
复制
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
  • Setup keys:
代码语言:javascript
复制
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
  • Install Gazebo:
代码语言:javascript
复制
sudo apt-get update
sudo apt-get remove .*gazebo.* && sudo apt-get update && sudo apt-get install gazebo7 libgazebo7-dev

Gym Gazebo Pip

代码语言:javascript
复制
git clone https://github.com/erlerobot/gym-gazebocd gym-gazebo
sudo pip install -e .

Dependencies

There are two options to install dependencies: automatic installation or step-by-step installation

Automatic installation

Install dependencies running setup.bash. If you are going to use DQN with Keras, also install Keras and Theano.

代码语言:javascript
复制
cd gym_gazebo/envs/installation
bash setup.bash

Before running a environment, load the corresponding setup script. For example, to load the Turtlebot execute:

  • Turtlebot
代码语言:javascript
复制
cd gym_gazebo/envs/installation
bash turtlebot_setup.bash

Step-by-step installation

Needs to be updated, use automatic installation.

Keras and Theano installation

This part of the installation is required only for the environments using DQN.

代码语言:javascript
复制
# install dependenciessudo pip install h5py
sudo apt-get install gfortran# install sript specific dependencies (temporal)sudo apt-get install python-skimage# install Theanogit clone git://github.com/Theano/Theano.gitcd Theano/
sudo python setup.py develop#isntall Kerassudo pip install keras

dot_parser error fix:

代码语言:javascript
复制
sudo pip install --upgrade pydot
sudo pip install --upgrade pyparsing
Enablig GPU for Theano

Follow the instructions here and change $PATH instead of $CUDA_ROOT.

Working on a clean installation of Ubuntu 14.04 using CUDA 7.5.

The following flags are needed in order to execute in GPU mode, using an alias is recommended.

代码语言:javascript
复制
THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32

Usage

Build and install gym-gazebo

In the root directory of the repository:

代码语言:javascript
复制
sudo pip install -e .

Running an environment

  • Load the environment variables corresponding to the robot you want to launch. E.g. to load the Turtlebot:
代码语言:javascript
复制
cd gym_gazebo/envs/installation
bash turtlebot_setup.bash

Note: all the setup scripts are available in gym_gazebo/envs/installation

  • Run any of the examples available in examples/. E.g.:
代码语言:javascript
复制
cd examples/scripts_turtlebot
python circuit2_turtlebot_lidar_qlearn.py

Display the simulation

To see what's going on in Gazebo during a simulation, simply run gazebo client:

代码语言:javascript
复制
gzclient

Display reward plot

Display a graph showing the current reward history by running the following script:

代码语言:javascript
复制
cd examples/utilities
python display_plot.py

HINT: use --help flag for more options.

Killing background processes

Sometimes, after ending or killing the simulation gzserver and rosmaster stay on the background, make sure you end them before starting new tests.

We recommend creating an alias to kill those processes.

代码语言:javascript
复制
echo "alias k='killall -9 gzserver gzclient roslaunch rosmaster'" >> ~/.bashrc
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2017-08-23,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 CreateAMind 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • GazeboCircuit2TurtlebotLidar-v0
  • GazeboCircuit2TurtlebotLidarNn-v0
  • GazeboCircuit2cTurtlebotCameraNnEnv-v0
  • Installation
    • Table of Contents
      • Docker
        • Ubuntu
          • Requirements
            • ROS Indigo
              • Gazebo
                • Gym Gazebo Pip
                  • Dependencies
                    • Automatic installation
                    • Step-by-step installation
                    • Keras and Theano installation
                  • Usage
                    • Build and install gym-gazebo
                    • Running an environment
                    • Display the simulation
                    • Display reward plot
                    • Killing background processes
                相关产品与服务
                容器服务
                腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
                领券
                问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档