Stretch Simulation in ROS2
Use this package to use ROS2 with Stretch in Mujoco.
System Requirements
Stretch Simulation supports the following environments:
Native Ubuntu 24.04 workstation with an Nvidia GPU
Docker environment with GPU support
Minimum: 16GB RAM. Recommended: 32GB RAM.
Note: This package is not supported on Metal (MacOS) at this time due to the lack of GPU acceleration and OpenGL 1.5+ support in Docker, and slow performance in UTM with a virtual machine.
Launching
The main launch file is stretch_mujoco_driver.launch.py which you can invoke by running:
ros2 launch stretch_simulation stretch_mujoco_driver.launch.pyThis launch file has many arguments that you can pass via the command-line.
Driver Options
mode(default=position, options:position,navigation,trajectory,gamepad) - command mode for the robotuse_cameras(default=false) - Enabling the cameras uses a bit of CPU
Scene Options
By default, the Stretch spawns into a simple three-walled scene with objects on a table.
By setting
use_robocasato True, you can spawn into a number of different RoboCasa environments.You can also use your own custom scene by providing the absolute path to its XML to the
scene_xmlpath. The Stretch 4 robot will be included at the origin if you have<include file="stretch_4/stretch_4.xml"/>in the scene xml.
Visualization Options
use_mujoco_viewer(default=true)use_rviz(default=true)
Note: If using zenoh middleware, you should run
ros2 run rmw_zenoh_cpp rmw_zenohdin its own terminal.
Nav2
First go through the Getting Started guide to set up your environment.
Mapping
This section is similar to https://docs.hello-robot.com/0.3/ros2/navigation_stack/#mapping, but uses the Stretch simulation environment.
To map the simulated environment, run the following:
To save your map, run:
Navigation
To run navigation on a previously generated map, run:
You may want to dynamically reduce the cost_map inflation radius for most Robocasa environments:
Pre-mapped scene
There are maps included in this package that you can use with navigation out of the box.
Launch the pre-mapped environment using the following commands:
Web Teleop
You can use Stretch Web Teleop with the Stretch Simulation environment!
Before you start, install the dependencies for Stretch Web Teleop by following these instructions.
Use the following commands to start Stretch Mujoco with Web Teleop:
Cameras and PointClouds
Please use the use_cameras:=true argument to enable cameras and pointclouds. e.g. ros2 launch stretch_simulation stretch_mujoco_driver.launch.py use_mujoco_viewer:=true mode:=navigation use_cameras:=true
There are five camera topics being published:
RGB and Depth for the D405 camera in the gripper.
RGB and Depth or the D435i camera in the head.
RGB for the wide-lens camera in the head.
The RGB and Depth frames are used to create two PointCloud2 topics as well.

Stretch Drivers
Simulation Drivers interface with the simulator to read and write data.
Simulation Drivers mimic the StretchDriver in stretch_core, which talks to the real robot.
You could display all the launch options available to the Stretch Mujoco Driver using: ros2 launch stretch_simulation stretch_mujoco_driver.launch.py --show-args:
You can also set the node's argument arguments=["--ros-args", "--log-level", "debug"] in the launch file to display Sim-to-Real time and other useful debug information.
Getting Started
You should go through all the sections in Getting Started to run this package correctly.
Note: If you are running on a Stretch robot, you may not need to run Stretch Simulation, unless you are trying to test out the simulation environment.
Estimated install time: ~1-2hrs.
Docker Install (Recommended)
If you are on Linux or Windows, you can use the Docker setup to get started using Docker with hardware acceleration. This is not supported on MacOS due to the lack of OpenGL 1.5+ support in Docker.
Native Install
If you would like to install Stretch Simulation directly on your host machine, please follow the README_SETUP instructions.
Last updated
Was this helpful?
