Motion Planner Augmented Reinforcement Learning for Robot Manipulation in Obstructed Environments (CoRL 2020)

Overview

Motion Planner Augmented Reinforcement Learning for Robot Manipulation in Obstructed Environments

[Project website] [Paper]

This project is a PyTorch implementation of Motion Planner Augmented Reinforcement Learning for Robot Manipulation in Obstructed Environments, published in CoRL 2020.

Deep reinforcement learning (RL) agents are able to learn contact-rich manipulation tasks by maximizing a reward signal, but require large amounts of experience, especially in environments with many obstacles that complicate exploration. In contrast, motion planners use explicit models of the agent and environment to plan collision-free paths to faraway goals, but suffer from inaccurate models in tasks that require contacts with the environment. To combine the benefits of both approaches, we propose motion planner augmented RL (MoPA-RL) which augments the action space of an RL agent with the long-horizon planning capabilities of motion planners.

Prerequisites

Installation

  1. Install Mujoco 2.0 and add the following environment variables into ~/.bashrc or ~/.zshrc.
# Download mujoco 2.0
$ wget https://www.roboti.us/download/mujoco200_linux.zip -O mujoco.zip
$ unzip mujoco.zip -d ~/.mujoco
$ mv ~/.mujoco/mujoco200_linux ~/.mujoco/mujoco200

# Copy mujoco license key `mjkey.txt` to `~/.mujoco`

# Add mujoco to LD_LIBRARY_PATH
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/.mujoco/mujoco200/bin

# For GPU rendering (replace 418 with your nvidia driver version)
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/nvidia-418

# Only for a headless server
$ export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so:/usr/lib/nvidia-418/libGL.so
  1. Download this repository and install python dependencies
# Install system packages
sudo apt-get install libgl1-mesa-dev libgl1-mesa-glx libosmesa6-dev patchelf libopenmpi-dev libglew-dev python3-pip python3-numpy python3-scipy

# Download this repository
git clone https://github.com/clvrai/mopa-rl.git

# Install required python packages in your new env
cd mopa-rl
pip install -r requirements.txt
  1. Install ompl
# Linux
sudo apt install libyaml-cpp-dev
sh ./scripts/misc/installEigen.sh #from the home directory # install Eigen

# Mac OS
brew install libyaml yaml-cpp
brew install eigen

# Build ompl
git clone [email protected]:ompl/ompl.git ../ompl
cd ../ompl
cmake .
sudo make install

# if ompl-x.x (x.x is the version) is installed in /usr/local/include, you need to rename it to ompl
mv /usr/local/include/ompl-x.x /usr/local/include/ompl
  1. Build motion planner python wrapper
cd ./mopa-rl/motion_planner
python setup.py build_ext --inplace

Available environments

PusherObstacle-v0 SawyerPushObstacle-v0 SawyerLiftObstacle-v0 SawyerAssemblyObstacle-v0
2D Push Sawyer Push Sawyer Lift Sawyer Assembly

How to run experiments

  1. Launch a virtual display (only for a headless server)
sudo /usr/bin/X :1 &
  1. Train policies
  • 2-D Push
sh ./scripts/2d/baseline.sh  # baseline
sh ./scripts/2d/mopa.sh  # MoPA-SAC
sh ./scripts/2d/mopa_ik.sh  # MoPA-SAC IK
  • Sawyer Push
sh ./scripts/3d/push/baseline.sh  # baseline
sh ./scripts/3d/push/mopa.sh  # MoPA-SAC
sh ./scripts/3d/push/mopa_ik.sh  # MoPA-SAC IK
  • Sawyer Lift
sh ./scripts/3d/lift/baseline.sh  # baseline
sh ./scripts/3d/lift/mopa.sh  # MoPA-SAC
sh ./scripts/3d/lift/mopa_ik.sh  # MoPA-SAC IK
  • Sawyer Assembly
sh ./scripts/3d/assembly/baseline.sh  # baseline
sh ./scripts/3d/assembly/mopa.sh  # MoPA-SAC
sh ./scripts/3d/assembly/mopa_ik.sh  # MoPA-SAC IK

Directories

The structure of the repository:

  • rl: Reinforcement learning code
  • env: Environment code for simulated experiments (2D Push and all Sawyer tasks)
  • config: Configuration files
  • util: Utility code
  • motion_planners: Motion planner code
  • scripts: Scripts for all experiments

Log directories:

  • logs/rl.ENV.DATE.PREFIX.SEED:
    • cmd.sh: A command used for running a job
    • git.txt: Log gitdiff
    • prarms.json: Summary of parameters
    • video: Generated evaulation videos (every evalute_interval)
    • wandb: Training summary of W&B, like tensorboard summary
    • ckpt_*.pt: Stored checkpoints (every ckpt_interval)
    • replay_*.pt: Stored replay buffers (every ckpt_interval)

Trouble shooting

Mujoco GPU rendering

To use GPU rendering for mujoco, you need to add /usr/lib/nvidia-000 (000 should be replaced with your NVIDIA driver version) to LD_LIBRARY_PATH before installing mujoco-py. Then, during mujoco-py compilation, it will show you linuxgpuextension instead of linuxcpuextension. In Ubuntu 18.04, you may encounter an GL-related error while building mujoco-py, open venv/lib/python3.7/site-packages/mujoco_py/gl/eglshim.c and comment line 5 #include <GL/gl.h> and line 7 #include <GL/glext.h>.

Virtual display on headless machines

On servers, you don’t have a monitor. Use this to get a virtual monitor for rendering and put DISPLAY=:1 in front of a command.

# Run the next line for Ubuntu
$ sudo apt-get install xserver-xorg libglu1-mesa-dev freeglut3-dev mesa-common-dev libxmu-dev libxi-dev

# Configure nvidia-x
$ sudo nvidia-xconfig -a --use-display-device=None --virtual=1280x1024

# Launch a virtual display
$ sudo /usr/bin/X :1 &

# Run a command with DISPLAY=:1
DISPLAY=:1 <command>

pybind11-dev not found

wget http://archive.ubuntu.com/ubuntu/pool/universe/p/pybind11/pybind11-dev_2.2.4-2_all.deb
sudo apt install ./pybind11-dev_2.2.4-2_all.deb

References

Citation

If you find this useful, please cite

@inproceedings{yamada2020mopa,
  title={Motion Planner Augmented Reinforcement Learning for Robot Manipulation in Obstructed Environments},
  author={Jun Yamada and Youngwoon Lee and Gautam Salhotra and Karl Pertsch and Max Pflueger and Gaurav S. Sukhatme and Joseph J. Lim and Peter Englert},
  booktitle={Conference on Robot Learning},
  year={2020}
}

Authors

Jun Yamada*, Youngwoon Lee*, Gautam Salhotra, Karl Pertsch, Max Pflueger, Gaurav S. Sukhatme, Joseph J. Lim, and Peter Englert at USC CLVR and USC RESL (*Equal contribution)

Comments
  • ompl no state space issue

    ompl no state space issue

    Hi! I'm trying to set up the motion planner wrapper. I've cloned ompl (from the official source) into the mopa-rl directory, and run the setup commands. I then cd'ed into motion-planners and tried running the command, but ended up with this issue: cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ ./src/mujoco_ompl_interface.cpp:2:10: fatal error: ompl/base/StateSpace.h: No such file or directory 2 | #include <ompl/base/StateSpace.h> | ^~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. error: command '/usr/bin/gcc' failed with exit code 1 I'm not entirely sure where this is coming from, so if anyone had any insight, that would be greatly appreciated. Thanks!

    opened by tarunc20 2
  • Issue with running mopa-sac on SAC push

    Issue with running mopa-sac on SAC push

    Hi,

    I'm trying to run the script scripts/2d/mopa.sh and I get the following segmentation fault, and I'm not really sure where to start with addressing this. If anyone has any suggestions, that would be greatly appreciated.

    Thanks! [a53:232685] *** Process received signal *** [a53:232685] Signal: Segmentation fault (11) [a53:232685] Signal code: Address not mapped (1) [a53:232685] Failing at address: (nil) [a53:232685] [ 0] /lib/x86_64-linux-gnu/libpthread.so.0(+0x14420)[0x7fc8b0d30420] [a53:232685] [ 1] /home/tarunc/mopa-rl/motion_planners/planner.cpython-37m-x86_64-linux-gnu.so(_ZN6MjOmpl26MujocoStateValidityChecker21addGlueTransformationERKSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS7_EE+0x59)[0x7fc8300bf2a9] [a53:232685] [ 2] /home/tarunc/mopa-rl/motion_planners/planner.cpython-37m-x86_64-linux-gnu.so(_ZN13MotionPlanner16KinematicPlanner12isValidStateESt6vectorIdSaIdEE+0x1e9)[0x7fc8300bd3a9] [a53:232685] [ 3] /home/tarunc/mopa-rl/motion_planners/planner.cpython-37m-x86_64-linux-gnu.so(+0x41937)[0x7fc8300d3937] [a53:232685] [ 4] /home/tarunc/mopa-rl/motion_planners/planner.cpython-37m-x86_64-linux-gnu.so(+0x41e32)[0x7fc8300d3e32] [a53:232685] [ 5] python(_PyMethodDescr_FastCallKeywords+0xdb)[0x5643905dfd4b] [a53:232685] [ 6] python(+0x17faae)[0x5643905e0aae] [a53:232685] [ 7] python(_PyEval_EvalFrameDefault+0x661)[0x564390624601] [a53:232685] [ 8] python(_PyFunction_FastCallKeywords+0x187)[0x5643905998d7] [a53:232685] [ 9] python(+0x17f9c5)[0x5643905e09c5] [a53:232685] [10] python(_PyEval_EvalFrameDefault+0x661)[0x564390624601] [a53:232685] [11] python(_PyFunction_FastCallKeywords+0x187)[0x5643905998d7] [a53:232685] [12] python(+0x17f9c5)[0x5643905e09c5] [a53:232685] [13] python(_PyEval_EvalFrameDefault+0x661)[0x564390624601] [a53:232685] [14] python(_PyFunction_FastCallKeywords+0x187)[0x5643905998d7] [a53:232685] [15] python(+0x17f9c5)[0x5643905e09c5] [a53:232685] [16] python(_PyEval_EvalFrameDefault+0x661)[0x564390624601] [a53:232685] [17] python(+0x1901a5)[0x5643905f11a5] [a53:232685] [18] python(_PyMethodDef_RawFastCallKeywords+0xe9)[0x5643905aa639] [a53:232685] [19] python(_PyEval_EvalFrameDefault+0x4428)[0x5643906283c8] [a53:232685] [20] python(_PyFunction_FastCallKeywords+0x187)[0x5643905998d7] [a53:232685] [21] python(+0x17f9c5)[0x5643905e09c5] [a53:232685] [22] python(_PyEval_EvalFrameDefault+0x661)[0x564390624601] [a53:232685] [23] python(_PyFunction_FastCallKeywords+0x187)[0x5643905998d7] [a53:232685] [24] python(_PyEval_EvalFrameDefault+0x3f5)[0x564390624395] [a53:232685] [25] python(_PyEval_EvalCodeWithName+0x255)[0x564390579e85] [a53:232685] [26] python(+0x1d7d8e)[0x564390638d8e] [a53:232685] [27] python(_PyMethodDef_RawFastCallKeywords+0xe9)[0x5643905aa639] [a53:232685] [28] python(_PyEval_EvalFrameDefault+0x4428)[0x5643906283c8] [a53:232685] [29] python(_PyEval_EvalCodeWithName+0x255)[0x564390579e85] [a53:232685] *** End of error message *** Segmentation fault (core dumped)

    opened by tarunc20 1
  • MoPA-RL: error: argument --gpu expected one argument

    MoPA-RL: error: argument --gpu expected one argument

    Hi, thank you for your generous sharing. I have installed all the libraries and when I execute code sh ./scripts/2d/baseline.sh, I encounter the following problem MoPA-RL: error: argument --gpu expected one argument. Do u know how to fix it? Looking forward to your reply, thanks!

    opened by QUIlToT 0
  • Related GL issues

    Related GL issues

    Hi! It seems that there is no #include <GL/gl.h> and #include <GL/glext.h> in the env/lib/python3.7/site-packages/mujoco_py/gl/eglshim.c.

    My mujoco_py version is 2.0.2.5 and the first 9 lines in eglshim.c are:

    #define EGL_EGLEXT_PROTOTYPES
    #include "egl.h"
    #include "eglext.h"
    #include <GL/glew.h>
    
    #include "mujoco.h"
    #include "mjrender.h"
    
    #include "glshim.h"
    

    Looking forward to your reply! Thx!

    opened by QUIlToT 2
  • Some questions about the settings in the XML files

    Some questions about the settings in the XML files

    Hi! Thanks for your generous sharing!

    When I read the XML files, I noticed there are a lot of duplications of the body, such as the indicator link, dummy link or joint, goal link or joint.

    What are the differences between the above settings and the real link or joint? In other words, what's the role of the above settings in the RL simulation?

    Looking forward to your reply!

    opened by QUIlToT 2
  • Can't create a PyKinematicPlanner

    Can't create a PyKinematicPlanner

    when try to run sh ./scripts/2d/mopa.sh, there will be sh: 2: Syntax error: "(" unexpected, ERROR: Invalid activation key. After checking, I think there is something wrong with PyKinematicPlanner. Could anyone can fix it?

    opened by yuyang16101066 4
Owner
Cognitive Learning for Vision and Robotics (CLVR) lab @ USC
Learning and Reasoning for Artificial Intelligence, especially focused on perception and action. Led by Professor Joseph J. Lim @ USC
Cognitive Learning for Vision and Robotics (CLVR) lab @ USC
Official implementation of "Accelerating Reinforcement Learning with Learned Skill Priors", Pertsch et al., CoRL 2020

Accelerating Reinforcement Learning with Learned Skill Priors [Project Website] [Paper] Karl Pertsch1, Youngwoon Lee1, Joseph Lim1 1CLVR Lab, Universi

Cognitive Learning for Vision and Robotics (CLVR) lab @ USC 134 Dec 6, 2022
[ICML 2020] Prediction-Guided Multi-Objective Reinforcement Learning for Continuous Robot Control

PG-MORL This repository contains the implementation for the paper Prediction-Guided Multi-Objective Reinforcement Learning for Continuous Robot Contro

MIT Graphics Group 65 Jan 7, 2023
ManiSkill-Learn is a framework for training agents on SAPIEN Open-Source Manipulation Skill Challenge (ManiSkill Challenge), a large-scale learning-from-demonstrations benchmark for object manipulation.

ManiSkill-Learn ManiSkill-Learn is a framework for training agents on SAPIEN Open-Source Manipulation Skill Challenge, a large-scale learning-from-dem

Hao Su's Lab, UCSD 48 Dec 30, 2022
Guiding evolutionary strategies by (inaccurate) differentiable robot simulators @ NeurIPS, 4th Robot Learning Workshop

Guiding Evolutionary Strategies by Differentiable Robot Simulators In recent years, Evolutionary Strategies were actively explored in robotic tasks fo

Vladislav Kurenkov 4 Dec 14, 2021
DrQ-v2: Improved Data-Augmented Reinforcement Learning

DrQ-v2: Improved Data-Augmented RL Agent Method DrQ-v2 is a model-free off-policy algorithm for image-based continuous control. DrQ-v2 builds on DrQ,

Facebook Research 234 Jan 1, 2023
Manipulation OpenAI Gym environments to simulate robots at the STARS lab

Manipulator Learning This repository contains a set of manipulation environments that are compatible with OpenAI Gym and simulated in pybullet. In par

STARS Laboratory 5 Dec 8, 2022
Public implementation of "Learning from Suboptimal Demonstration via Self-Supervised Reward Regression" from CoRL'21

Self-Supervised Reward Regression (SSRR) Codebase for CoRL 2021 paper "Learning from Suboptimal Demonstration via Self-Supervised Reward Regression "

null 19 Dec 12, 2022
O2O-Afford: Annotation-Free Large-Scale Object-Object Affordance Learning (CoRL 2021)

O2O-Afford: Annotation-Free Large-Scale Object-Object Affordance Learning Object-object Interaction Affordance Learning. For a given object-object int

Kaichun Mo 26 Nov 4, 2022
PyBullet CartPole and Quadrotor environments—with CasADi symbolic a priori dynamics—for learning-based control and reinforcement learning

safe-control-gym Physics-based CartPole and Quadrotor Gym environments (using PyBullet) with symbolic a priori dynamics (using CasADi) for learning-ba

Dynamic Systems Lab 300 Dec 28, 2022
Attention-driven Robot Manipulation (ARM) which includes Q-attention

Attention-driven Robotic Manipulation (ARM) This codebase is home to: Q-attention: Enabling Efficient Learning for Vision-based Robotic Manipulation I

Stephen James 84 Dec 29, 2022
MohammadReza Sharifi 27 Dec 13, 2022
Space robot - (Course Project) Using the space robot to capture the target satellite that is disabled and spinning, then stabilize and fix it up

Space robot - (Course Project) Using the space robot to capture the target satellite that is disabled and spinning, then stabilize and fix it up

Mingrui Yu 3 Jan 7, 2022
PyTorch implementation of "Conformer: Convolution-augmented Transformer for Speech Recognition" (INTERSPEECH 2020)

PyTorch implementation of Conformer: Convolution-augmented Transformer for Speech Recognition. Transformer models are good at capturing content-based

Soohwan Kim 565 Jan 4, 2023
PyTorch implementation of CVPR 2020 paper (Reference-Based Sketch Image Colorization using Augmented-Self Reference and Dense Semantic Correspondence) and pre-trained model on ImageNet dataset

Reference-Based-Sketch-Image-Colorization-ImageNet This is a PyTorch implementation of CVPR 2020 paper (Reference-Based Sketch Image Colorization usin

Yuzhi ZHAO 11 Jul 28, 2022
[IROS'21] SurRoL: An Open-source Reinforcement Learning Centered and dVRK Compatible Platform for Surgical Robot Learning

SurRoL IROS 2021 SurRoL: An Open-source Reinforcement Learning Centered and dVRK Compatible Platform for Surgical Robot Learning Features dVRK compati

Med-AIR@CUHK 55 Jan 3, 2023
Learning to Simulate Dynamic Environments with GameGAN (CVPR 2020)

Learning to Simulate Dynamic Environments with GameGAN PyTorch code for GameGAN Learning to Simulate Dynamic Environments with GameGAN Seung Wook Kim,

null 199 Dec 26, 2022
gym-anm is a framework for designing reinforcement learning (RL) environments that model Active Network Management (ANM) tasks in electricity distribution networks.

gym-anm is a framework for designing reinforcement learning (RL) environments that model Active Network Management (ANM) tasks in electricity distribution networks. It is built on top of the OpenAI Gym toolkit.

Robin Henry 99 Dec 12, 2022
PyTorch implementations of deep reinforcement learning algorithms and environments

Deep Reinforcement Learning Algorithms with PyTorch This repository contains PyTorch implementations of deep reinforcement learning algorithms and env

Petros Christodoulou 4.7k Jan 4, 2023
CompilerGym is a library of easy to use and performant reinforcement learning environments for compiler tasks

CompilerGym is a library of easy to use and performant reinforcement learning environments for compiler tasks

Facebook Research 721 Jan 3, 2023