Code Monkey home page Code Monkey logo

gym-sawyer's Introduction

gym-sawyer

Sawyer environments for reinforcement learning that use the OpenAI Gym interface, as well as Dockerfiles with ROS to communicate with the real robot or a simulated one with Gazebo.

This repository is under development, so all code is still experimental.

Docker containers

Sawyer Simulation

We use Gazebo to simulate Sawyer, so a dedicated GPU is required (see System Requirements). Currently only NVIDIA GPUs are supported.

NVIDIA GPU

This section contains instructions to build the docker image and run the docker container for the simulated Sawyer in the ROS environment using an NVIDIA GPU.

Prerequisites

Tested on Ubuntu 16.04

Instructions
  1. In the root folder of your cloned repository build the image by running:
$ make build-nvidia-sawyer-sim
  1. After the image is built, run the container:
$ make run-nvidia-sawyer-sim
  1. Gazebo and MoveIt! should open with Sawyer in them

  2. To exit the container, type sudo docker stop sawyer-sim in a new terminal.

Control Sim Sawyer
  1. Open a new terminal in the container by running:
$ docker exec -it sawyer-sim bash
  1. Once inside the terminal, run the following commands to execute a keyboard controller:
$ cd ~/ros_ws
$ ./intera.sh sim
$ rosrun intera_examples joint_position_keyboard.py
  1. The following message should appear:
Initializing node...
Getting robot state...
[INFO] [1544554222.728405, 33.526000]: Enabling robot...
[INFO] [1544554222.729527, 33.527000]: Robot Enabled
Controlling joints. Press ? for help, Esc to quit.
  1. Type ? to get the keys that control sawyer.
View the header camera in Sim Sawyer
  1. Perform the first step from the previous section
  2. Once in the container shell, run the following command:
rosrun image_view image_view image:=/io/internal_camera/head_camera/image_raw

Sawyer Robot

A dedicated GPU is recommended for rviz and other visualization tools. Currently only NVIDIA GPUs are supported.

NVIDIA GPU

This section contains instructions to build the docker image and run the docker container for the Sawyer robot in the ROS environment using an NVIDIA GPU.

Prerequisites
  • Same as sawyer simulation.
Instructions
  1. Export sawyer hostname, sawyer ip address, and workstation ip address.
$ export SAWYER_HOSTNAME=__sawyerhostname__  
$ export SAWYER_IP=__sawyerip__ 
$ export WORKSTATION_IP=__workip__ 
  1. In the root folder of your cloned repository build the image by running:
$ make build-nvidia-sawyer-robot 
  1. After the image is built, run the container:
$ make run-nvidia-sawyer-robot
  1. Rviz should open with Sawyer in it. Now you can plan and execute trajectories through rviz.

  2. To exit the container, type sudo docker stop sawyer-robot in a new terminal.

Garage-ROS-Intera

To run Reinforcement Learning algorithms along with the Sawyer robot, we use the garage docker images that include an extensive library of utilities and primitives for RL experiments.

On top of the garage images, we add the layers for ROS and Intera that work with Python3 (garage runs with Python3), so we're able to communicate with Sawyer through ROS communication using the convenient libraries for Python rospy, intera_interface, moveit_commander and moveit_msgs.

Under this schema, two docker containers are needed: one for the simulated or real sawyer, and another with garage-ros-intera. The former creates the ROS master while the latter subscribes to the ROS topics to control and visualize what Sawyer is doing through Reinforcement Learning algorithms.

Prerequisites

Tested on Ubuntu 16.04. It's recommended to use the versions indicated above for docker-ce and docker-compose.

Instructions

In the root of the gym-sawyer repository execute:

$ make run-nvidia-sawyer-<type>

Where type can be sim (run simulated Sawyer on Gazebo) or robot (you're connected to a real Sawyer).

Once the container is up and running (make sure Gazebo is fully initialized if running simulated Sawyer). Then run:

$ make run-garage-<type>-ros RUN_CMD="examples/hello_world_sawyer.py"

Where type can be:

  • headless: garage without environment visualization.
  • nvidia: garage with environment visualization using an NVIDIA graphics card. If your computer has an NVIDIA GPU, use this image to render the environments in garage, and the pre-requisites are the same as for the Sawyer Simulation image.

You should see Sawyer moving to neutral position and then waving its arm three times.

The command to execute in the image is specified in the variable RUN_CMD.

Run your local repository of garage with ros-intera

If you're working with garage in your local repository and would like to include your latests changes, follow these instructions.

  1. Make sure to run build your docker image for garage first. For further information, visit garage.
  2. Then rebuild and run the garage-ros image:
$ make run-garage-<type>-ros RUN_CMD="..."

gym-sawyer's People

Contributors

akumaraguru avatar gautams3 avatar ryanjulian avatar taohnouaccountb avatar utkarshjp7 avatar zhanpenghe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gym-sawyer's Issues

The key for ROS Kinetic was updated

RUN apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116

It seems ROS updated this key recently so it causes the following error:
W: GPG error: http://packages.ros.org/ros/ubuntu xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F42ED6FBAB17C654 E: The repository 'http://packages.ros.org/ros/ubuntu xenial InRelease' is not signed. ERROR: Service 'nvidia-ros-intera' failed to build: The command '/bin/sh -c apt -qy update && DEBIAN_FRONTEND=noninteractive apt -qy install git-core python-argparse python-rosdep python-rosinstall python-vcstools python-wstool ros-kinetic-actionlib ros-kinetic-actionlib-msgs ros-kinetic-control-msgs ros-kinetic-cv-bridge ros-kinetic-desktop-full ros-kinetic-dynamic-reconfigure ros-kinetic-joystick-drivers ros-kinetic-rospy-message-converter ros-kinetic-rviz ros-kinetic-tf2-ros ros-kinetic-trajectory-msgs ros-kinetic-xacro && apt-get clean && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100 Makefile:24: recipe for target 'build-nvidia-sawyer-sim' failed make: *** [build-nvidia-sawyer-sim] Error 1

Suggested way to solve it could be replacing it with the new one from the official installation guide:
apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

online training

Hi :) it would be nice to have an alternative that allows online training, especially because during the pandemic there are a lot of students trying to work from home.
So far, Mujoco is not compatible with it because of the machine-ID limitation.
Do you think this is a feasible step for the future?

Use docker compose for contrib.ros simulation

We can make the docker setup for contrib.ros simpler to understand and maintain by splitting the docker into (at least) 2 different containers

  1. garage.contrib.ros container containing only the ROS client libraries but no intera joint server, no ROS master, and no Gazebo env
  2. A container with the intera joint server and whatever is necessary for connecting to either a simulated or real robot
  3. (optional) A container with Gazebo, which simulates the robot (this would not be launched for a real robot experiment)

Migrated from rlworkgroup/garage#284

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.