Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build_wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
matrix:
os:
- ubuntu-latest
- macos-14
- macos-15
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
run: xvfb-run make pytest

pythonpackage-macos:
runs-on: macos-14
runs-on: macos-15
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
Expand Down
11 changes: 1 addition & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,6 @@ FetchContent_Declare(Eigen3
URL https://gitlab.com/libeigen/eigen/-/archive/3.4.1/eigen-3.4.1.tar.gz
EXCLUDE_FROM_ALL
)
FetchContent_Declare(
egl_headers
GIT_REPOSITORY https://github.com/KhronosGroup/EGL-Registry.git
GIT_TAG main
GIT_SHALLOW TRUE
)

FetchContent_MakeAvailable(pybind11 Eigen3 egl_headers)
# egl headers
include_directories(${egl_headers_SOURCE_DIR}/api)
FetchContent_MakeAvailable(pybind11 Eigen3)

add_subdirectory(src)
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ RUN chmod +x /usr/local/bin/link-editable-source \
pybind11 \
cmake \
ninja \
"mujoco==3.2.6" \
"mujoco==4.0.1" \
"pin==3.7.0" \
&& uv pip install /opt/rcs-src \
&& uv pip install --no-build-isolation /opt/rcs-src/extensions/rcs_fr3 \
Expand Down
1 change: 0 additions & 1 deletion docs/getting_started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ Here is a simple example of direct robot control using the low-level API:
```python
import rcs
from rcs import sim
from rcs._core.sim import CameraType
from rcs.camera.sim import SimCameraConfig, SimCameraSet
from time import sleep
import numpy as np
Expand Down
58 changes: 55 additions & 3 deletions docs/user_guide/scene_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ This is the main top-level config for the scene API.
| `task_cfg` | Optional task-specific config | Add pick/place or other task logic |
| `scene` | Base scene XML path or scene key | Usually from `SCENE_PATHS[...]` |
| `gripper_cfgs` | Optional gripper config per robot | Add one gripper per robot |
| `camera_cfgs` | Optional camera config dictionary | Define resolution, type, and frame rate for named cameras |
| `camera_cfgs` | Optional camera config dictionary | Define the model camera, resolution and frame rate for named cameras |
| `max_relative_movement` | Relative action limit | Limit per-step Cartesian delta |
| `relative_to` | Relative action reference | Usually `RelativeTo.LAST_STEP` or `RelativeTo.NONE` |
| `robot_to_shared_base_frame` | Per-robot offset relative to the shared base frame | Multi-robot layouts |
Expand Down Expand Up @@ -149,8 +149,8 @@ Each gripper entry usually defines:

Each camera entry usually defines:

- camera identifier
- camera type
- camera identifier, the name of the camera in the MuJoCo model. Cameras attached to a body or with a
tracking `mode` in MJCF move with the simulation, e.g. for videos.
- resolution
- frame rate

Expand Down Expand Up @@ -299,6 +299,58 @@ Example:

- `depth[y, x] == 1500` means the point is about **1.5 m** away from the camera

## Camera timing

Simulation cameras render in Python (`rcs.camera.sim.SimCameraSet`) and show one of two simulation states:

- `render_on_demand=True` (default): the state at the moment the frames are requested, e.g. after the
last env step.
- `render_on_demand=False`: the state at the last *exposure* of each camera, like a real camera that
records at its `frame_rate`. While the simulation steps, it captures its state at each camera frame
rate (the state only, no rendering, about a microsecond per capture); frames are rendered from the
latest captured state when they are requested. With a 30 Hz camera and a 10 Hz env, an observation
therefore shows the scene up to 33 ms before the end of the env step, as a real camera would.

```python
camera_set = SimCameraSet(simulation, camera_cfgs, physical_units=True, render_on_demand=False)
```

Captures follow a fixed schedule of simulation time (`k / frame_rate`, no drift) and happen at the
physics step closest to each capture time. Frame time stamps are the simulation time of the rendered
state, and `get_timestamp_frames(ts)` renders the latest exposure at or before `ts` (the last
`max_buffer_frames` captured states are kept). Cameras with different frame rates are captured
independently.

## Rendering backend (Filament)

By default, simulation cameras and the GUI use MuJoCo's classic OpenGL renderer. MuJoCo >= 4.0 also
ships the physically based [Filament](https://github.com/google/filament) renderer and the new
MuJoCo Studio viewer. Switch to them with the `renderer` flag of `SimConfig`:

```python
from rcs.sim import RendererBackend, SimConfig

sim_cfg = SimConfig(async_control=False, realtime=False, renderer=RendererBackend.FILAMENT)
```

With this flag

- `SimCameraSet(...)` returns a `FilamentSimCameraSet`: color and depth images are rendered with Filament
instead of the classic renderer (both timing modes below are supported). Depth images always use the
metric units described above. The depth pass is a second Filament render per camera, so
it is skipped when `CameraSetWrapper(include_depth=False)` (or `FilamentSimCameraSet(render_depth=False)`)
is used.
- `open_gui()` launches MuJoCo Studio instead of the passive `mujoco.viewer`. Studio runs in the GUI
subprocess under a regular `python` interpreter (not `mjpython`, also on macOS).

Environment variables for fine tuning:

- `RCS_FILAMENT_GRAPHICS_API=opengl|vulkan` graphics API of the camera renderer (default `opengl`, or `vulkan`
on Linux without an X display, where Filament's OpenGL backend does not work)
- `RCS_FILAMENT_SOFTWARE_RENDERING=1` force software rendering for the cameras
- `RCS_FILAMENT_GFX=opengl|vulkan|web|...` Studio graphics mode; `web` serves the viewer over http instead
of opening a window

### Camera placement

#### Fixed scene camera
Expand Down
12 changes: 2 additions & 10 deletions examples/fr3/fr3_direct_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np
from rcs._core.common import RobotPlatform
from rcs._core.sim import CameraType, SimConfig
from rcs._core.sim import SimConfig
from rcs.camera.sim import SimCameraConfig, SimCameraSet
from rcs.envs.configs import EmptyWorldFR3
from rcs_fr3._core import hw
Expand Down Expand Up @@ -86,18 +86,10 @@ def main():
gripper_cfg = cfg.gripper_cfgs[fr3] # type: ignore
gripper = sim.SimGripper(simulation, gripper_cfg)

# add camera to have a rendering gui
# render the wrist camera of the model
cameras = {
"default_free": sim.SimCameraConfig(
identifier="",
type=CameraType.default_free,
resolution_width=1280,
resolution_height=720,
frame_rate=20,
),
"wrist": SimCameraConfig(
identifier="wrist_0",
type=CameraType.fixed,
resolution_width=640,
resolution_height=480,
frame_rate=30,
Expand Down
3 changes: 2 additions & 1 deletion examples/fr3/fr3_env_cartesian_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import gymnasium as gym
from rcs._core.common import RobotPlatform
from rcs._core.sim import SimConfig
from rcs._core.sim import RendererBackend, SimConfig
from rcs.camera.sim import SimCameraSet
from rcs.envs.base import (
CameraSetWrapper,
Expand Down Expand Up @@ -50,6 +50,7 @@ def main():
sim_cfg = SimConfig(
realtime=False,
async_control=False,
renderer=RendererBackend.FILAMENT,
)

mjmodel = scene.create_model(cfg)
Expand Down
4 changes: 0 additions & 4 deletions include/rcs/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ Eigen::Matrix<double, N, M, Eigen::ColMajor> array2eigen(
Eigen::Matrix<double, N, M, Eigen::ColMajor> matrix(array.data());
return matrix;
}
void bootstrap_egl_context(std::uintptr_t fn_addr, std::uintptr_t display,
std::uintptr_t context);
void bootstrap_gl_context();
void ensure_current();

/***
* @brief thread safe holder for a single value, e.g. to hand data from a
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ requires = [
"pybind11",
"cmake",
"ninja",
"mujoco==3.10.0",
"mujoco==4.0.1",
"pin==3.7.0",
]
build-backend = "scikit_build_core.build"
Expand Down Expand Up @@ -36,7 +36,7 @@ dependencies = [
"rpyc~=6.0.2",
"pyarrow",
"simplejpeg",
"mujoco==3.10.0",
"mujoco==4.0.1",
"pin==3.7.0",
# pin 3.7.0 currently resolves against older urdfdom/tinyxml SONAMEs at runtime
"cmeel-urdfdom<5",
Expand Down Expand Up @@ -76,7 +76,7 @@ dev = [
"twine~=6.0",
]
build_deps = [
"mujoco==3.10.0",
"mujoco==4.0.1",
"pin==3.7.0",
"cmeel-urdfdom<5",
"cmeel-tinyxml2<11",
Expand All @@ -93,7 +93,7 @@ environment = { SKBUILD_BUILD_DIR = "/tmp/rcs-build/{wheel_tag}" }
archs = ["x86_64"]
manylinux-x86_64-image = "manylinux_2_28"
before-all = "yum install -y epel-release && yum install -y libXi-devel libXcursor-devel libXinerama-devel libXrandr-devel glfw-devel"
repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel} --exclude libmujoco.so.3.10.0 --exclude libpinocchio_default.so.3.7.0 --exclude libpinocchio_parsers.so.3.7.0"
repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel} --exclude libmujoco.so.4.0.1 --exclude libpinocchio_default.so.3.7.0 --exclude libpinocchio_parsers.so.3.7.0"

[tool.cibuildwheel.macos]
archs = ["arm64"]
Expand Down
2 changes: 0 additions & 2 deletions python/rcs/_core/common.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,6 @@ def FrankaHandTCPOffset() -> numpy.ndarray[tuple[typing.Literal[4], typing.Liter
def IdentityRotMatrix() -> numpy.ndarray[tuple[typing.Literal[3], typing.Literal[3]], numpy.dtype[numpy.float64]]: ...
def IdentityRotQuatVec() -> numpy.ndarray[tuple[typing.Literal[4]], numpy.dtype[numpy.float64]]: ...
def IdentityTranslation() -> numpy.ndarray[tuple[typing.Literal[3]], numpy.dtype[numpy.float64]]: ...
def _bootstrap_egl_context(fn_addr: int, display: int, context: int) -> None: ...
def _bootstrap_gl_context() -> None: ...

HARDWARE: RobotPlatform # value = <RobotPlatform.HARDWARE: 1>
LATERAL_GRASP: GraspType # value = <GraspType.LATERAL_GRASP: 2>
Expand Down
Loading
Loading