Skip to content
This repository has been archived by the owner on Sep 8, 2021. It is now read-only.

sloretz/drake_ros2_demos

Repository files navigation

Examples with Drake and ROS 2

This repo shows examples of using Drake and ROS 2 together. It uses the pydrake API and is of prototype quality. For a similar effort in ROS 1, see EricCousineau-TRI/repro drake_ros1_hacks.

Most of this is being merged into https://github.com/RobotLocomotion/drake-ros so see that repo for futher development and examples

Prerequisites

Install ROS 2 Rolling using the Linux binary instructions and enable the ROS 2 testing apt repo. Install the apt packages ros-rolling-desktop and ros-rolling-sdformat-urdf. Extract the Drake binary installation, install it's prerequisites, and use this Python virutalenv trick.

Setup

Once the prerequisites are met, install drake_ros into the Drake virtualenv.

. path/to/drake/bin/activate
cd path/to/this/repo
cd drake_ros/
python setup.py develop

ROS 2 tf and Robot Model Demo

This demo shows RViz visualizing a single UR10 robot being simulated by Drake. Set up two terminals: one for launching RViz, and another for launching the Drake simulation.

. /opt/ros/rolling/setup.bash
cd path/to/this/repo
AMENT_PREFIX_PATH="$AMENT_PREFIX_PATH:$(pwd)" rviz2 -d view.rviz
. /opt/ros/rolling/setup.bash
. path/to/drake/bin/activate
cd path/to/this/repo
AMENT_PREFIX_PATH="$AMENT_PREFIX_PATH:$(pwd)" ./ros2_demo.py

ur10_rviz_drake

Interactive Markers Demo

This demonstrates using interactive markers to control an iiwa14 being simulated by Drake. Set up two terminals: one for launching RViz, and another for launching the Drake simulation.

. /opt/ros/rolling/setup.bash
cd path/to/this/repo
AMENT_PREFIX_PATH="$AMENT_PREFIX_PATH:$(pwd)" rviz2 -d interactive_demo.rviz
. /opt/ros/rolling/setup.bash
. path/to/drake/bin/activate
cd path/to/this/repo
AMENT_PREFIX_PATH="$AMENT_PREFIX_PATH:$(pwd)" ./interactive_demo.py

iiwa14_interactive_drake

Using a Container

There is a definition file for a Singularity container.

First build and install Singularity. Afterwards, build a Singularity sandbox from the definition file.

singularity build --fakeroot --sandbox ~/drake-ros2-demos.sandbox demos.singularity.def

Create a shell with access to an NVidia graphics card and run one of the RViz configs for your chosen demo.

$ singularity shell --nv --writable-tmpfs ~/drake-ros2-demos.sandbox
Singularity> rviz2 -d view.rviz

Create a shell into the sandbox and run one of the demos.

$ singularity shell --writable ~/drake-ros2-demos.sandbox
Singularity> ./ros2_demo.py