RCS is a unified and multilayered robot control interface over a MuJoCo simulation and real world robot currently implemented for the FR3.
We build and test RCS on the latest Debian and on the latest Ubuntu LTS.
- Install the system dependencies:
sudo apt install $(cat debian_deps.txt)- Create, activate and configure a Python virtual environment:
python3 -m venv .venv
source .venv/bin/activatealternatively, with Conda:
conda create -n rcs python=3.11 # Version ensures that python is installed to the environment
conda activate rcsThen, install the package:
pip install -r requirements_dev.txt
pip config --site set global.no-build-isolation false- Build and install RCS:
pip install -ve .Prereqs: Docker + docker-compose, X11 on host, NVIDIA driver + NVIDIA Container Toolkit (legacy runtime: nvidia).
Layout: docker/Dockerfile, overrides in docker/compose/ (base.yml, gui.yml, gpu.yml, hw.yml).
docker-compose -f docker/compose/base.yml build dev
export XAUTHORITY=${XAUTHORITY:-$HOME/.Xauthority}
xhost +local:docker
docker-compose -f docker/compose/base.yml -f docker/compose/gui.yml -f docker/compose/gpu.yml -f docker/compose/hw.yml run --rm run bash
(Use fewer -f files for lighter setups, e.g., GUI+GPU without HW.)
pip install -ve extensions/rcs_fr3
cd examples
python fr3_env_cartesian_control.py
nvidia-smimissing in container: ensure it exists on host at/usr/bin/nvidia-smi(GPU override bind-mounts it).- GUI can’t open: re-run the
xhostcommand and confirm$DISPLAYis set on the host.
The python package is called rcs.
Simple direct robot control:
import rcs
from rcs import sim
from rcs._core.sim import CameraType
from rcs.camera.sim import SimCameraConfig, SimCameraSet
from time import sleep
simulation = sim.Sim(rcs.scenes["fr3_empty_world"].mjb)
urdf_path = rcs.scenes["fr3_empty_world"].urdf
ik = rcs.common.RL(str(urdf_path))
cfg = sim.SimRobotConfig()
cfg.add_id("0")
cfg.tcp_offset = rcs.common.Pose(rcs.common.FrankaHandTCPOffset())
robot = rcs.sim.SimRobot(simulation, ik, cfg)
gripper_cfg_sim = sim.SimGripperConfig()
gripper_cfg_sim.add_id("0")
gripper = sim.SimGripper(simulation, gripper_cfg_sim)
camera_set = SimCameraSet(simulation, {})
simulation.open_gui()
# wait for gui
sleep(5)
# step the robot 10 cm in x direction
robot.set_cartesian_position(
robot.get_cartesian_position() * rcs.common.Pose(translation=np.array([0.1, 0, 0]))
)
# close gripper
gripper.grasp()
simulation.step_until_convergence()
input("press enter to close")from rcs.envs.creators import SimEnvCreator
from rcs.envs.utils import (
default_mujoco_cameraset_cfg,
default_sim_gripper_cfg,
default_sim_robot_cfg,
)
from rcs.envs.base import ControlMode, RelativeTo
env_rel = SimEnvCreator()(
control_mode=ControlMode.JOINTS,
collision_guard=False,
robot_cfg=default_sim_robot_cfg(),
gripper_cfg=default_sim_gripper_cfg(),
cameras=default_mujoco_cameraset_cfg(),
max_relative_movement=np.deg2rad(5),
relative_to=RelativeTo.LAST_STEP,
)
env_rel.get_wrapper_attr("sim").open_gui()
for _ in range(100):
obs, info = env_rel.reset()
for _ in range(10):
# sample random relative action and execute it
act = env_rel.action_space.sample()
print(act)
obs, reward, terminated, truncated, info = env_rel.step(act)
print(obs)
if truncated or terminated:
logger.info("Truncated or terminated!")
returnCheckout the python examples in the examples folder:
- fr3_direct_control.py shows direct robot control with RCS's python bindings
- fr3_env_joint_control.py and fr3_env_cartesian_control.py demonstrates RCS's high level gymnasium interface both for joint- and end effector space control All of these examples work both in the MuJoCo simulation as well as on your hardware FR3.
To enable hardware usage in RCS, install the needed hardware extensions via pip. RCS itself comes with a couple of supported extensions e.g. control of the FR3 via the rcs_fr3 extension. All native supported extension are located in extensions.
To install extensions:
pip install -ve extensions/rcs_fr3For more details real the readme file of the respective extension.
After the required hardware extensions are installed the examples also above work on real hardware: Switch to hardware by setting the following flag:
# ROBOT_INSTANCE = RobotPlatform.SIMULATION
ROBOT_INSTANCE = RobotPlatform.HARDWARESome modules include command line interfaces, e.g. rcs_fr3 defines useful commands to handle the FR3 robot without the need to use the Desk Website. You can see the available subcommands as follows:
python -m rcs_fr3 --help
python -m rcs_realsense --help# check for c++ formatting errors
make cppcheckformat
# fix them
make cppformat
# Linting with clang tidy
make cpplint
# check for python formatting errors
make pycheckformat
# fix them
make pyformat
# Linting with ruff and mypy
make pylint
# Testing
make pytestWe use autogenerated python stub files (.pyi) in the _core folder to show our linters the expected types of the C++ Python bindings.
If the python bindings in the C++ code have changed you might need to regenerate them by using:
make stubgenTODO