From 078fdc1b2c9f12202c81367b9a1f97ec231da5fc Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 18 Nov 2026 18:21:53 -0700 Subject: [PATCH 1/7] Add Mac (Apple Silicon) ros and robocasa containers and mac sim bringups Run either robot's RoboCasa sim and stack natively on arm64, without an NVIDIA GPU: the command path, the legs and walking on /cmd_vel. No lidar, navigation, model servers or Isaac on the Mac. - docker/mac/: arm64 Base, Ros and Robocasa Dockerfiles (Ubuntu 22.04, CPU torch, no GPU vision stack), arm64 locks derived from the amd64 ones (derive_arm64_locks.sh), and a build-time check that the Unitree SDK's DDS and a ROS node share a domain in one process (the SDK's libddsc copy is renamed: on arm64 the shared soname made the binding segfault). - docker-compose.mac.yml: arm64 images, no NVIDIA runtime, CPU rendering, no lidar, and a CycloneDDS URI without the 16 MB buffer minimum the VM refuses. configure_platform adds it on Darwin arm64 (GOLEM_PLATFORM); Isaac is refused there; docker_stack.sh starts the mac bringups. - golem_robocasa: opt-in GOLEM_RENDER=cpu (OSMesa, requires GOLEM_LIDAR=0) past the GPU check; the H1-2 honours GOLEM_LIDAR=0 as the G1 does. Defaults are unchanged. - golem_bringup: h12_sim gains use_nav and use_vision (default true); h12_mac_sim and g1_mac_sim include the sim bringups without nav, vision or skills. - docs/MAC.md: setup, running, and speeds measured on an M3. On Linux the wrappers make the same docker calls as before; the x86 Dockerfiles, compose file and amd64 locks are unchanged. Co-Authored-By: Claude Opus 5.5 --- .dockerignore | 4 + CLAUDE.md | 17 +- .../launch/g1/g1_mac_sim.launch.py | 36 +++ .../launch/h12/h12_mac_sim.launch.py | 44 +++ .../launch/h12/h12_sim.launch.py | 18 +- .../golem_bringup/test/test_launch_layout.py | 4 +- .../src/golem_bringup/test/test_sim_time.py | 37 +++ docker/docker-compose.mac.yml | 45 +++ docker/locks/SOURCES.md | 11 + docker/locks/base-arm64-01.txt | 6 + docker/locks/base-arm64-02.txt | 6 + docker/locks/base-arm64-03.txt | 6 + docker/locks/base-arm64.txt | 103 ++++++ docker/locks/robocasa-arm64-01.txt | 8 + docker/locks/robocasa-arm64-02.txt | 9 + docker/locks/robocasa-arm64-03.txt | 9 + docker/locks/robocasa-arm64-04.txt | 8 + docker/locks/robocasa-arm64-05.txt | 11 + docker/locks/robocasa-arm64.txt | 218 +++++++++++++ docker/locks/ros-arm64-01.txt | 7 + docker/locks/ros-arm64-02.txt | 7 + docker/locks/ros-arm64-03.txt | 7 + docker/locks/ros-arm64-04.txt | 7 + docker/locks/ros-arm64-05.txt | 8 + docker/locks/ros-arm64-06.txt | 11 + docker/locks/ros-arm64-07.txt | 10 + docker/locks/ros-arm64-08.txt | 7 + docker/locks/ros-arm64-09.txt | 9 + docker/locks/ros-arm64-10.txt | 8 + docker/locks/ros-arm64-11.txt | 6 + docker/locks/ros-arm64.txt | 304 ++++++++++++++++++ docker/mac/BaseDockerfile | 138 ++++++++ docker/mac/RobocasaDockerfile | 121 +++++++ docker/mac/RosDockerfile | 161 ++++++++++ docker/mac/check_unitree_dds.py | 45 +++ docker/mac/derive_arm64_locks.sh | 31 ++ docker/scripts/docker_build.sh | 19 +- docker/scripts/docker_common.sh | 34 +- docker/scripts/docker_run.sh | 2 + docker/scripts/docker_stack.sh | 16 +- docker/scripts/launch_robocasa.sh | 16 +- docs/MAC.md | 117 +++++++ docs/index.md | 3 +- golem_robocasa/g1/g1_mujoco.py | 5 +- golem_robocasa/h12_mujoco.py | 17 +- golem_robocasa/h12_sensors.py | 54 ++-- golem_robocasa/sim_common.py | 37 ++- mkdocs.yml | 1 + tests/docker/test_source_pins.py | 45 ++- tests/docker/test_workflows.py | 88 +++++ tests/robocasa/test_gpu_required.py | 59 +++- 51 files changed, 1941 insertions(+), 59 deletions(-) create mode 100644 core_ws/src/golem_bringup/launch/g1/g1_mac_sim.launch.py create mode 100644 core_ws/src/golem_bringup/launch/h12/h12_mac_sim.launch.py create mode 100644 docker/docker-compose.mac.yml create mode 100644 docker/locks/base-arm64-01.txt create mode 100644 docker/locks/base-arm64-02.txt create mode 100644 docker/locks/base-arm64-03.txt create mode 100644 docker/locks/base-arm64.txt create mode 100644 docker/locks/robocasa-arm64-01.txt create mode 100644 docker/locks/robocasa-arm64-02.txt create mode 100644 docker/locks/robocasa-arm64-03.txt create mode 100644 docker/locks/robocasa-arm64-04.txt create mode 100644 docker/locks/robocasa-arm64-05.txt create mode 100644 docker/locks/robocasa-arm64.txt create mode 100644 docker/locks/ros-arm64-01.txt create mode 100644 docker/locks/ros-arm64-02.txt create mode 100644 docker/locks/ros-arm64-03.txt create mode 100644 docker/locks/ros-arm64-04.txt create mode 100644 docker/locks/ros-arm64-05.txt create mode 100644 docker/locks/ros-arm64-06.txt create mode 100644 docker/locks/ros-arm64-07.txt create mode 100644 docker/locks/ros-arm64-08.txt create mode 100644 docker/locks/ros-arm64-09.txt create mode 100644 docker/locks/ros-arm64-10.txt create mode 100644 docker/locks/ros-arm64-11.txt create mode 100644 docker/locks/ros-arm64.txt create mode 100644 docker/mac/BaseDockerfile create mode 100644 docker/mac/RobocasaDockerfile create mode 100644 docker/mac/RosDockerfile create mode 100644 docker/mac/check_unitree_dds.py create mode 100755 docker/mac/derive_arm64_locks.sh create mode 100644 docs/MAC.md diff --git a/.dockerignore b/.dockerignore index 98f5b7ae..7d8f7895 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,6 +7,7 @@ # docker/scripts/package_humble_runtime.py IsaacDockerfile # docker/locks/** every Dockerfile # docker/patches/** RobocasaDockerfile +# docker/mac/check_unitree_dds.py mac/BaseDockerfile # Their .git entries stay out. * !core_ws @@ -30,3 +31,6 @@ docker/scripts/* !docker/locks/** !docker/patches !docker/patches/** +!docker/mac +docker/mac/* +!docker/mac/check_unitree_dds.py diff --git a/CLAUDE.md b/CLAUDE.md index ef17f128..404a4324 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -33,7 +33,9 @@ configured per robot, and start from one bringup package, `golem_bringup`. Each against its sim and the real robot, so code moves between them unchanged. The G1 runs in Unitree's debug mode: Unitree's own controller is released, and the stack drives every motor on `rt/lowcmd`, as on the H1-2. The stack runs on one -platform, x86 Linux with an NVIDIA GPU. +platform, x86 Linux with an NVIDIA GPU. An Apple Silicon Mac runs a reduced +RoboCasa sim of either robot (no lidar, navigation, model servers or Isaac): +`docs/MAC.md`. The H1-2 is the default everywhere. `GOLEM_ROBOT=g1` or `--g1` on a simulator or stack wrapper selects the G1 where the attached robot matters: the sim and @@ -45,7 +47,7 @@ pages are in `docs/g1/` (start at `docs/g1/index.md`). | Path | What it is | |---|---| -| `docker/` | the images and containers (Dockerfiles, `docker-compose.yml`, the G1 overlay `docker-compose.g1.yml`, `scripts/`) | +| `docker/` | the images and containers (Dockerfiles, `docker-compose.yml`, the G1 overlay `docker-compose.g1.yml`, `scripts/`; the Mac's arm64 images in `docker/mac/` with the overlay `docker-compose.mac.yml`, `docs/MAC.md`) | | `core_ws/` | the ROS 2 workspace — where the bulk of development happens (see §4); the G1's own package is `core_ws/src/dex_3/`, the safety layer, arm controller, leg controller, SLAM/navigation and skills both robots run in `core_ws/src/golem_safety/`, `core_ws/src/golem_upper_ik/`, `core_ws/src/golem_lowerbody_rl/`, `core_ws/src/golem_slam/` and `core_ws/src/golem_skills/` | | `golem_robocasa/` | RoboCasa/MuJoCo simulator entry point for both robots (`h12_mujoco.py`; `--g1` hands over to the G1 sim package `golem_robocasa/g1/`) and the ROS/DDS bridges | | `CL_isaaclab_sim/` | Isaac Lab simulator, H1-2 only (`sim_main.py`, DDS bridges, tasks) | @@ -89,7 +91,11 @@ launch bringup**. ### Robot selection -`docker/scripts/docker_common.sh` owns this. On simulator and stack wrappers, +`docker/scripts/docker_common.sh` owns this, and the platform too: on Darwin +arm64 (or `GOLEM_PLATFORM=mac`) every wrapper adds `docker-compose.mac.yml` +(the arm64 images of `docker/mac/`, no NVIDIA runtime, `GOLEM_RENDER=cpu`, +`GOLEM_LIDAR=0`), refuses Isaac, and `docker_stack.sh` starts `h12_mac_sim` or +`g1_mac_sim`; on Linux nothing changes (`docs/MAC.md`). On simulator and stack wrappers, the robot is `--g1`/`--h12` on the wrapper, else `GOLEM_ROBOT` from the shell, else from `docker/.env`, else `h12`. The selection means "which robot is attached" and matters only where that is inherent: which robot the RoboCasa sim @@ -519,7 +525,10 @@ H1-2 imports and hands the G1 over to `golem_robocasa/g1/g1_mujoco.py`. Both sims render their cameras and the MID-360's rays through EGL on an NVIDIA GPU: without one (MuJoCo not on EGL, no EGL device, a software renderer) the sim stops at start, once its command line is parsed and before it builds a scene or -starts ROS or DDS, with one message (`sim_common.require_gpu`). The H1-2 +starts ROS or DDS, with one message (`sim_common.require_gpu`). The one way past +it is the Mac images' opt-in `GOLEM_RENDER=cpu` (OSMesa, and only with +`GOLEM_LIDAR=0`, which the H1-2 sim honours as the G1's does; +`sim_common.require_renderer`). The H1-2 stays the default, and nothing on the G1 path may change its behaviour. The robots share `sim_common.py`, `measurement_bridge.py`, the pacer in `sim_timing.py` (its `--timing` report is the H1-2's only) and the `mujoco_sensors` node in diff --git a/core_ws/src/golem_bringup/launch/g1/g1_mac_sim.launch.py b/core_ws/src/golem_bringup/launch/g1/g1_mac_sim.launch.py new file mode 100644 index 00000000..b1847334 --- /dev/null +++ b/core_ws/src/golem_bringup/launch/g1/g1_mac_sim.launch.py @@ -0,0 +1,36 @@ +""" +Start the G1 against the Mac's RoboCasa sim: g1_sim without navigation or skills. + + ros2 launch golem_bringup g1_mac_sim.launch.py [use_hands:=false] [use_rviz:=false] + +The Mac sim (docker/docker-compose.mac.yml, docs/MAC.md) renders on the CPU and has no +MID-360, so this includes g1_sim.launch.py with use_nav and use_skills false. Everything +else is g1_sim's: g1_core with sim:=true (golem_safety and the controller on sim_split, +the leg node running HOMIE, which releases the sim's elastic band once the policy runs), +the Dex3-1 hand driver (use_hands) and, with use_rviz, RViz. + +Start the simulator first; every node joins the launching shell's ROS_DOMAIN_ID, which +must be a sim domain (safety_node refuses sim:=true on domain 0). +""" + +from golem_bringup.include import include +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration + + +def generate_launch_description(): + """Declare the Mac bringup's arguments and include g1_sim without nav or skills.""" + return LaunchDescription([ + DeclareLaunchArgument('use_rviz', default_value='false', + description='true: start RViz (needs a display in golem_ros)'), + DeclareLaunchArgument('use_hands', default_value='true', + description='true: start dex3_hands, the Dex3-1 hand driver'), + # The whole G1 sim bringup, without the parts the Mac cannot run. + include('golem_bringup', 'g1/g1_sim.launch.py', { + 'use_rviz': LaunchConfiguration('use_rviz'), + 'use_hands': LaunchConfiguration('use_hands'), + 'use_nav': 'false', + 'use_skills': 'false', + }), + ]) diff --git a/core_ws/src/golem_bringup/launch/h12/h12_mac_sim.launch.py b/core_ws/src/golem_bringup/launch/h12/h12_mac_sim.launch.py new file mode 100644 index 00000000..2260f7c4 --- /dev/null +++ b/core_ws/src/golem_bringup/launch/h12/h12_mac_sim.launch.py @@ -0,0 +1,44 @@ +""" +Start the H1-2 against the Mac's RoboCasa sim: h12_sim without navigation or model servers. + + ros2 launch golem_bringup h12_mac_sim.launch.py [policy:=almi] [use_rviz:=false] + +The Mac sim (docker/docker-compose.mac.yml, docs/MAC.md) renders on the CPU and has no +MID-360, and the Mac's golem_ros image has no model-server stack, so this includes +h12_sim.launch.py with use_nav, use_vision and use_skills false. Everything else is +h12_sim's, in its order: the leg node's check first, then the state publishers, the +command path (estop_node on the sim's estop box, safety_node, frame_task_server), the +legs and, with use_rviz, RViz. + +SAFETY: the operator gates are h12_sim's: the sim's estop box (ENTER on the sim's +terminal; golem_safety then latches until restart), and the leg policy holds its +pre-pose until + ros2 service call /lowerbody/confirm_engage std_srvs/srv/Trigger + +Start the simulator first; every node joins the launching shell's ROS_DOMAIN_ID, which +must be a sim domain (safety_node refuses sim:=true on domain 0). +""" + +from golem_bringup.include import include +from launch import LaunchDescription +from launch.actions import DeclareLaunchArgument +from launch.substitutions import LaunchConfiguration + + +def generate_launch_description(): + """Declare the Mac bringup's arguments and include h12_sim without nav or vision.""" + return LaunchDescription([ + DeclareLaunchArgument('use_rviz', default_value='false', + description='true: start RViz (needs a display in golem_ros)'), + DeclareLaunchArgument('policy', default_value='almi', + description='The policy golem_lowerbody_rl runs on the legs: ' + 'almi, fame or walk; any other is refused'), + # The whole H1-2 sim bringup, without the parts the Mac cannot run. + include('golem_bringup', 'h12/h12_sim.launch.py', { + 'use_rviz': LaunchConfiguration('use_rviz'), + 'policy': LaunchConfiguration('policy'), + 'use_nav': 'false', + 'use_vision': 'false', + 'use_skills': 'false', + }), + ]) diff --git a/core_ws/src/golem_bringup/launch/h12/h12_sim.launch.py b/core_ws/src/golem_bringup/launch/h12/h12_sim.launch.py index 420d85d4..20bfd36b 100644 --- a/core_ws/src/golem_bringup/launch/h12/h12_sim.launch.py +++ b/core_ws/src/golem_bringup/launch/h12/h12_sim.launch.py @@ -9,8 +9,10 @@ (h12_control as on the real robot: the safety/controller pairing check before any node, then estop_node on the sim's estop box, safety_node and frame_task_server with the real robot's configs and delays), the leg controller (h12_lowerbody, with the start pose taken -as verified), the model servers and golem_skills (golem_vision_models), navigation, the -static camera_link -> camera_color_optical_frame TF and RViz (use_rviz). +as verified), the model servers and golem_skills (golem_vision_models; use_vision), +navigation (use_nav), the static camera_link -> camera_color_optical_frame TF and RViz +(use_rviz). use_vision and use_nav default to true; h12_mac_sim.launch.py turns both off +for the Mac sim, which has no lidar and no GPU for the model servers. SAFETY: the sim runs the real robot's operator gates: the estop box the sim serves (ENTER on the sim's terminal or viewer presses it; golem_safety then latches until restart), and @@ -75,6 +77,13 @@ def generate_launch_description(): 'start-up (clear_logs)'), DeclareLaunchArgument('rviz_config', default_value=default_rviz, description='RViz config file (path)'), + DeclareLaunchArgument('use_vision', default_value='true', + description='true: start the model servers (gemini, sam, and ' + 'with use_skills graspgen and golem_skills); ' + 'false: none of them, use_skills included'), + DeclareLaunchArgument('use_nav', default_value='true', + description="true: golem_slam's FAST-LIO, SLAM and Nav2 on the " + "sim's MID-360; false: no navigation"), # SAFETY: first, so a refused policy or run config starts no node: the leg # block, which checks them too, is included after the others. @@ -102,9 +111,10 @@ def generate_launch_description(): 'model_visualization': LaunchConfiguration('model_visualization'), 'model_clear_logs': LaunchConfiguration('model_clear_logs'), 'record_runs': LaunchConfiguration('record_runs'), - }), + }, condition=IfCondition(LaunchConfiguration('use_vision'))), # SLAM and Nav2, driving the legs on /cmd_vel. - include('golem_slam', 'navigation.launch.py', {**sim_time, 'robot': 'h12'}), + include('golem_slam', 'navigation.launch.py', {**sim_time, 'robot': 'h12'}, + condition=IfCondition(LaunchConfiguration('use_nav'))), # For Isaac: its head camera's images are stamped # camera_color_optical_frame (CL_isaaclab_sim's ros_sensor_bridge.py, diff --git a/core_ws/src/golem_bringup/test/test_launch_layout.py b/core_ws/src/golem_bringup/test/test_launch_layout.py index de101c83..a50bde8a 100644 --- a/core_ws/src/golem_bringup/test/test_launch_layout.py +++ b/core_ws/src/golem_bringup/test/test_launch_layout.py @@ -16,9 +16,9 @@ PACKAGE = Path(__file__).resolve().parents[1] TOP_LEVEL = { - 'h12': ('h12_sim', 'h12_real_robot', 'h12_real_desktop', + 'h12': ('h12_sim', 'h12_mac_sim', 'h12_real_robot', 'h12_real_desktop', 'h12_safety_grippers', 'lmg_sim', 'lmg_real'), - 'g1': ('g1_sim', 'g1_real_robot'), + 'g1': ('g1_sim', 'g1_mac_sim', 'g1_real_robot'), } INSTALLED = ('launch/**/*.launch.py', 'rviz/**/*.rviz') diff --git a/core_ws/src/golem_bringup/test/test_sim_time.py b/core_ws/src/golem_bringup/test/test_sim_time.py index ef351f6d..ada592b3 100644 --- a/core_ws/src/golem_bringup/test/test_sim_time.py +++ b/core_ws/src/golem_bringup/test/test_sim_time.py @@ -32,6 +32,8 @@ ('lmg_sim.launch.py', {'start_position_verified': 'true', 'use_slam': 'true', 'use_skills': 'true'}, True), ('g1_sim.launch.py', {'use_skills': 'true', 'use_nav': 'true', 'use_rviz': 'true'}, True), + ('h12_mac_sim.launch.py', {'use_rviz': 'true'}, True), + ('g1_mac_sim.launch.py', {'use_rviz': 'true'}, True), ('h12_real_robot.launch.py', {'start_position_verified': 'true'}, False), ('lmg_real.launch.py', {'start_position_verified': 'true'}, False), ('h12_real_desktop.launch.py', {'use_hand_cameras': 'true'}, False), @@ -132,3 +134,38 @@ def test_every_node_runs_on_its_bringups_clock(launch_file, args, sim_time, monk wrong = [(package, executable, name, value) for package, executable, name, value in nodes if value not in allowed] assert wrong == [], f'{launch_file}: nodes not on use_sim_time {sim_time}: {wrong}' + + +# Packages of the nodes the Mac sim bringups leave out: navigation (no lidar on the Mac +# sim) and the model servers and skills (no GPU stack in the Mac's golem_ros). +NAV_AND_VISION = ('fast_lio', 'golem_slam', 'slam_toolbox', 'octomap_server', + 'pointcloud_to_laserscan', 'model_server', 'golem_skills') + + +def _packages(launch_file, args): + """Return the packages of the nodes launch_file starts with args, on a sim domain.""" + return {package for package, _, _, _ in _nodes(launch_file, args)} + + +@pytest.mark.parametrize('mac_file, sim_file, sim_args, core', [ + ('h12_mac_sim.launch.py', 'h12_sim.launch.py', {'use_rviz': 'false'}, + {'golem_safety', 'golem_upper_ik', 'golem_lowerbody_rl', 'estop'}), + ('g1_mac_sim.launch.py', 'g1_sim.launch.py', {'use_rviz': 'false'}, + {'golem_safety', 'golem_upper_ik', 'golem_lowerbody_rl', 'dex_3'}), +]) +def test_mac_sim_is_the_sim_bringup_without_nav_or_vision(mac_file, sim_file, sim_args, core, + monkeypatch): + """A Mac sim bringup starts its sim bringup's command path and legs, no nav or vision node.""" + monkeypatch.setenv('ROS_DOMAIN_ID', SIM_DOMAIN) + mac = _packages(mac_file, {}) + assert core <= mac, mac + assert mac.isdisjoint(NAV_AND_VISION), mac & set(NAV_AND_VISION) + assert not [package for package in mac if package.startswith('nav2_')], mac + assert mac <= _packages(sim_file, sim_args), mac + + +def test_h12_sim_defaults_keep_nav_and_vision(monkeypatch): + """h12_sim.launch.py with its defaults still starts navigation and the model servers.""" + monkeypatch.setenv('ROS_DOMAIN_ID', SIM_DOMAIN) + packages = _packages('h12_sim.launch.py', {}) + assert {'fast_lio', 'model_server', 'golem_skills'} <= packages, packages diff --git a/docker/docker-compose.mac.yml b/docker/docker-compose.mac.yml new file mode 100644 index 00000000..ccbc6ff4 --- /dev/null +++ b/docker/docker-compose.mac.yml @@ -0,0 +1,45 @@ +# The Mac (Apple Silicon) overlay on docker-compose.yml. docker_common.sh's +# configure_platform adds it when the platform is mac (Darwin on arm64, or +# GOLEM_PLATFORM=mac), never on Linux, so the x86 / NVIDIA services are as the +# base file declares them. It swaps the images for the arm64 builds of +# docker/mac/, drops the NVIDIA runtime, and sets the sims' CPU rendering. +# Container names, mounts and the host network are the base file's: on +# OrbStack or Docker Desktop (host networking on) both containers share the +# Linux VM's network, so DDS between them works; the macOS host is not on it, +# so ros2 and RViz run inside golem_ros. docs/MAC.md has the flow and what the +# Mac sims leave out (lidar, navigation, the GPU vision models, Isaac). +services: + robocasa: + build: + dockerfile: docker/mac/RobocasaDockerfile + image: golem_sim_robocasa:arm64 + platform: linux/arm64 + # No NVIDIA GPU: the base file's runtime is removed (Compose >= 2.24). + runtime: !reset null + # 2 GB of /dev/shm: the base file's 16 GB exceeds a laptop VM's memory. + shm_size: 2g + environment: + # gpu (the sims' default, an NVIDIA GPU over EGL) or cpu (OSMesa, no + # MID-360): golem_robocasa/sim_common.py. The Mac has only cpu. + GOLEM_RENDER: cpu + # Both robots' MID-360: the Mac has no lidar caster, so 0 (1 stops the + # sim at start with GOLEM_RENDER=cpu). configure_platform exports the + # same default, so docker-compose.g1.yml's GOLEM_LIDAR agrees. + GOLEM_LIDAR: ${GOLEM_LIDAR:-0} + # Software-rendered cameras cost the most per step: off unless asked for. + GOLEM_CAMERAS: ${GOLEM_CAMERAS:-0} + ros: + build: + dockerfile: docker/mac/RosDockerfile + image: golem_ros:arm64 + platform: linux/arm64 + runtime: !reset null + shm_size: 2g + environment: + # core_ws/cyclonedds.xml, then an override of its 16 MB minimum UDP + # receive buffer: the minimum makes every ROS node fail to create its + # domain unless the kernel's net.core.rmem_max allows it, which the + # OrbStack / Docker Desktop VM does not by default (docs/DDS_TUNING.md + # raises it on Linux hosts). The Mac sims stream no lidar or cameras by + # default, the bursts the large buffer absorbs. + CYCLONEDDS_URI: "file:///home/code/cyclonedds.xml," diff --git a/docker/locks/SOURCES.md b/docker/locks/SOURCES.md index b0cc3e3d..dca9f3ff 100644 --- a/docker/locks/SOURCES.md +++ b/docker/locks/SOURCES.md @@ -107,3 +107,14 @@ under `/opt/robocasa/robocasa/models/assets` (123,434 files at capture). This catches changed contents, additions and removals without committing a large file manifest. Updating assets requires explicit review and regenerating the digest from the approved tree, not accepting a mismatch during a normal build. + +## The Mac's arm64 locks + +`*-arm64*.txt` are the Mac images' locks (`docker/mac/`, `docs/MAC.md`), derived +from their `*-amd64*.txt` twins by `docker/mac/derive_arm64_locks.sh`: the CUDA +wheels dropped, torch and torchvision on their `+cpu` builds, open3d 0.18.0 +(0.19.0 has no linux/aarch64 wheel). Rerun the script after any amd64 lock +change; `tests/docker/test_source_pins.py` checks they match. The Mac base image +is `ubuntu:jammy-20260901.2`, pinned by digest, and installs `ca-certificates` +from the image's live `ports.ubuntu.com` lists before switching to the snapshot, +the one package not resolved against it. diff --git a/docker/locks/base-arm64-01.txt b/docker/locks/base-arm64-01.txt new file mode 100644 index 00000000..93470ca1 --- /dev/null +++ b/docker/locks/base-arm64-01.txt @@ -0,0 +1,6 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# base-amd64-01.txt; edit the amd64 lock and rerun the script. +-c base-arm64.txt +mujoco==3.13.0 +numpy==2.2.6 +psutil==5.9.0 diff --git a/docker/locks/base-arm64-02.txt b/docker/locks/base-arm64-02.txt new file mode 100644 index 00000000..694d5ebc --- /dev/null +++ b/docker/locks/base-arm64-02.txt @@ -0,0 +1,6 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# base-amd64-02.txt; edit the amd64 lock and rerun the script. +-c base-arm64.txt +mujoco==3.13.0 +numpy==2.2.6 +psutil==5.9.0 diff --git a/docker/locks/base-arm64-03.txt b/docker/locks/base-arm64-03.txt new file mode 100644 index 00000000..5fd4146e --- /dev/null +++ b/docker/locks/base-arm64-03.txt @@ -0,0 +1,6 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# base-amd64-03.txt; edit the amd64 lock and rerun the script. +-c base-arm64.txt +mujoco==3.13.0 +numpy==2.2.6 +psutil==5.9.0 diff --git a/docker/locks/base-arm64.txt b/docker/locks/base-arm64.txt new file mode 100644 index 00000000..f23c3d19 --- /dev/null +++ b/docker/locks/base-arm64.txt @@ -0,0 +1,103 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# base-amd64.txt; edit the amd64 lock and rerun the script. +# Recorded from installed Linux images, 2026-09-17. +absl-py==2.5.0 +argcomplete==1.8.1 +attrs==21.2.0 +black==26.5.1 +blinker==1.4 +catkin-pkg-modules==1.1.1 +click==8.5.0 +cmeel==0.61.0 +cmeel-assimp==6.0.5 +cmeel-boost==1.90.0 +cmeel-console-bridge==1.0.2.3 +cmeel-octomap==1.10.0 +cmeel-qhull==8.0.2.1 +cmeel-tinyxml2==11.0.0 +cmeel-urdfdom==6.0.0 +cmeel-zlib==1.3.2 +coal==3.0.3 +cryptography==3.4.8 +cyclonedds==0.10.2 +daqp==0.9.1 +dbus-python==1.2.18 +delegator-py==0.1.1 +distro==1.7.0 +docutils==0.17.1 +eigenpy==3.13.0 +empy==3.3.4 +etils==1.13.0 +filelock==3.32.3 +flake8==4.0.1 +fsspec==2026.7.0 +glfw==2.10.2 +glob2==0.7 +httplib2==0.20.2 +importlib-metadata==4.6.4 +importlib-resources==7.1.0 +iniconfig==1.1.1 +isort==9.0.1 +jeepney==0.7.1 +jinja2==3.1.6 +keyring==23.5.0 +lark==1.1.1 +launchpadlib==1.10.16 +lazr-restfulclient==0.14.4 +lazr-uri==1.0.6 +libcoal==3.0.3 +libpinocchio==4.1.0 +lxml==4.8.0 +markdown-it-py==4.2.0 +markupsafe==3.0.3 +mccabe==0.6.1 +mdurl==0.1.2 +mink==1.3.0 +more-itertools==8.10.0 +mpmath==1.3.0 +mypy-extensions==1.1.0 +netifaces==0.11.0 +networkx==3.4.2 +oauthlib==3.2.0 +opencv-python==5.0.0.93 +packaging==26.3 +pathspec==1.1.1 +pexpect==4.9.0 +pillow==12.3.0 +pin==4.1.0 +pink==0.8.1 +platformdirs==4.11.9 +pluggy==0.13.0 +ptyprocess==0.7.0 +py==1.10.0 +pycodestyle==2.8.0 +pydocstyle==6.1.1 +pyflakes==2.4.0 +pygments==2.21.0 +pygobject==3.42.1 +pyjwt==2.3.0 +pyopengl==3.1.10 +pyparsing==2.4.7 +pytest==6.2.5 +python-apt==2.4.0+ubuntu4.1 +python-dateutil==2.8.1 +pytokens==0.4.1 +pyyaml==5.4.1 +qpsolvers==4.13.0 +rich==15.0.0 +rich-click==1.9.9 +roman==3.3 +rosdistro-modules==1.1.0 +rospkg-modules==1.6.3 +scipy==1.15.3 +secretstorage==3.3.1 +six==1.16.0 +snowballstemmer==2.2.0 +sympy==1.14.0 +toml==0.10.2 +tomli==2.4.1 +torch==2.14.0+cpu +torchvision==0.29.0+cpu +typing-extensions==4.16.0 +wadllib==1.3.6 +zipp==4.1.0 diff --git a/docker/locks/robocasa-arm64-01.txt b/docker/locks/robocasa-arm64-01.txt new file mode 100644 index 00000000..98c9acfb --- /dev/null +++ b/docker/locks/robocasa-arm64-01.txt @@ -0,0 +1,8 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# robocasa-amd64-01.txt; edit the amd64 lock and rerun the script. +# Constraints for RobocasaDockerfile: mujoco 3.3.1, numpy and Pillow. +-c robocasa-arm64.txt +huggingface-hub==1.31.0 +mujoco==3.3.1 +numpy==2.2.6 +psutil==7.2.2 diff --git a/docker/locks/robocasa-arm64-02.txt b/docker/locks/robocasa-arm64-02.txt new file mode 100644 index 00000000..d8003768 --- /dev/null +++ b/docker/locks/robocasa-arm64-02.txt @@ -0,0 +1,9 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# robocasa-amd64-02.txt; edit the amd64 lock and rerun the script. +# Constraints for RobocasaDockerfile: robosuite. numpy 2.2.5: robocasa's +# setup.py pins it. +-c robocasa-arm64.txt +huggingface-hub==1.31.0 +mujoco==3.3.1 +numpy==2.2.5 +psutil==7.2.2 diff --git a/docker/locks/robocasa-arm64-03.txt b/docker/locks/robocasa-arm64-03.txt new file mode 100644 index 00000000..648df137 --- /dev/null +++ b/docker/locks/robocasa-arm64-03.txt @@ -0,0 +1,9 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# robocasa-amd64-03.txt; edit the amd64 lock and rerun the script. +# Constraints for RobocasaDockerfile: robocasa (numpy 2.2.5 and mujoco +# 3.3.1 by its setup.py). +-c robocasa-arm64.txt +huggingface-hub==1.31.0 +mujoco==3.3.1 +numpy==2.2.5 +psutil==7.2.2 diff --git a/docker/locks/robocasa-arm64-04.txt b/docker/locks/robocasa-arm64-04.txt new file mode 100644 index 00000000..a4bac1c6 --- /dev/null +++ b/docker/locks/robocasa-arm64-04.txt @@ -0,0 +1,8 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# robocasa-amd64-04.txt; edit the amd64 lock and rerun the script. +# Constraints for RobocasaDockerfile: robosuite_models, mimicgen and mink. +-c robocasa-arm64.txt +huggingface-hub==1.31.0 +mujoco==3.3.1 +numpy==2.2.5 +psutil==7.2.2 diff --git a/docker/locks/robocasa-arm64-05.txt b/docker/locks/robocasa-arm64-05.txt new file mode 100644 index 00000000..6e4e82e7 --- /dev/null +++ b/docker/locks/robocasa-arm64-05.txt @@ -0,0 +1,11 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# robocasa-amd64-05.txt; edit the amd64 lock and rerun the script. +# Constraints for RobocasaDockerfile: mujoco 3.17.0 over RoboCasa's 3.3.1 +# (numpy stays robocasa's 2.2.5); websockets 16.1.1 is 3.17.0's one new +# dependency (its Studio web server, which the sims do not run). +-c robocasa-arm64.txt +huggingface-hub==1.31.0 +mujoco==3.17.0 +numpy==2.2.5 +psutil==7.2.2 +websockets==16.1.1 diff --git a/docker/locks/robocasa-arm64.txt b/docker/locks/robocasa-arm64.txt new file mode 100644 index 00000000..446abc2f --- /dev/null +++ b/docker/locks/robocasa-arm64.txt @@ -0,0 +1,218 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# robocasa-amd64.txt; edit the amd64 lock and rerun the script. +# Common constraint set for every uv step in docker/RobocasaDockerfile, at the +# versions of the validated image (provenance: SOURCES.md). Each numbered +# robocasa-amd64-NN.txt includes it with -c and pins the packages whose +# version changes between steps (huggingface-hub, mujoco, numpy, psutil), +# which this set leaves out. +absl-py==2.5.0 +aiohappyeyeballs==2.7.1 +aiohttp==3.14.3 +aiosignal==1.4.0 +annotated-types==0.8.0 +anyio==4.15.1 +argcomplete==1.8.1 +async-timeout==5.0.1 +attrs==26.1.0 +av==17.1.0 +beautifulsoup4==4.15.0 +black==26.5.1 +blinker==1.9.0 +catkin-pkg-modules==1.1.1 +certifi==2026.7.22 +chardet==7.6.0 +charset-normalizer==3.5.1 +click==8.5.0 +cloudpickle==3.1.2 +cmake==4.4.3 +cmeel==0.61.0 +cmeel-assimp==6.0.5 +cmeel-boost==1.90.0 +cmeel-console-bridge==1.0.2.3 +cmeel-octomap==1.10.0 +cmeel-qhull==8.0.2.1 +cmeel-tinyxml2==11.0.0 +cmeel-urdfdom==6.0.0 +cmeel-zlib==1.3.2 +coal==3.0.3 +colcon-argcomplete==0.3.3 +colcon-bash==0.5.0 +colcon-cd==0.2.1 +colcon-cmake==0.2.30 +colcon-common-extensions==0.3.0 +colcon-core==0.21.2 +colcon-defaults==0.2.9 +colcon-devtools==0.3.0 +colcon-library-path==0.2.1 +colcon-metadata==0.3.1 +colcon-notification==0.3.2 +colcon-output==0.2.14 +colcon-package-information==0.4.1 +colcon-package-selection==0.2.10 +colcon-parallel-executor==0.3.0 +colcon-pkg-config==0.1.0 +colcon-powershell==0.5.0 +colcon-python-setup-py==0.2.9 +colcon-recursive-crawl==0.2.3 +colcon-ros==0.5.0 +colcon-test-result==0.3.8 +colcon-zsh==0.5.0 +cryptography==3.4.8 +cyclonedds==0.10.2 +daqp==0.9.1 +datasets==3.6.0 +dbus-python==1.2.18 +deepdiff==8.6.2 +delegator-py==0.1.1 +diffusers==0.40.0 +dill==0.3.8 +distlib==0.3.4 +distro==1.7.0 +docutils==0.17.1 +draccus==0.10.0 +eigenpy==3.13.0 +einops==0.8.2 +empy==3.3.4 +etils==1.13.0 +evdev==1.9.3 +exceptiongroup==1.3.1 +farama-notifications==0.0.6 +filelock==3.32.3 +flake8==4.0.1 +flask==3.1.3 +frozenlist==1.8.0 +fsspec==2025.3.0 +gdown==6.3.0 +gitdb==4.0.12 +gitpython==3.1.62 +glfw==2.10.2 +glob2==0.7 +grpcio==1.84.0 +gym==0.26.2 +gym-notices==0.1.0 +gymnasium==0.29.1 +h11==0.16.0 +h5py==3.16.0 +hf-xet==1.6.0 +hidapi==0.15.0 +httpcore==1.0.9 +httplib2==0.20.2 +httpx==0.28.1 +idna==3.19 +imageio==2.37.4 +imageio-ffmpeg==0.6.0 +importlib-metadata==9.0.1 +importlib-resources==7.1.0 +iniconfig==2.3.0 +isort==9.0.1 +itsdangerous==2.2.0 +jeepney==0.7.1 +jinja2==3.1.6 +jsonlines==4.0.0 +keyring==23.5.0 +lark==1.1.1 +launchpadlib==1.10.16 +lazr-restfulclient==0.14.4 +lazr-uri==1.0.6 +lerobot==0.3.3 +libcoal==3.0.3 +libpinocchio==4.1.0 +llvmlite==0.44.0 +lxml==6.1.3 +markdown==3.10.3 +markdown-it-py==4.2.0 +markupsafe==3.0.3 +mccabe==0.6.1 +mdurl==0.1.2 +mergedeep==1.3.4 +mink==0.0.5 +more-itertools==8.10.0 +mpi4py==3.1.3 +mpmath==1.3.0 +multidict==6.8.0 +multiprocess==0.70.16 +mypy-extensions==1.1.0 +netifaces==0.11.0 +networkx==3.4.2 +notify2==0.3 +numba==0.61.2 +oauthlib==3.2.0 +opencv-python==5.0.0.93 +opencv-python-headless==5.0.0.93 +orderly-set==5.5.0 +packaging==26.3 +pandas==2.3.3 +pathspec==1.1.1 +pexpect==4.9.0 +pillow==12.3.0 +pin==4.1.0 +pink==0.8.1 +platformdirs==4.11.9 +pluggy==1.6.0 +propcache==0.5.4 +protobuf==3.19.6 +ptyprocess==0.7.0 +py==1.10.0 +pyarrow==25.0.1 +pycodestyle==2.8.0 +pydantic==2.13.5 +pydantic-core==2.46.5 +pydocstyle==6.1.1 +pyflakes==2.4.0 +pygame==2.6.1 +pygments==2.21.0 +pygobject==3.42.1 +pyjwt==2.3.0 +pynput==1.8.2 +pyopengl==3.1.10 +pyparsing==2.4.7 +pyserial==3.5 +pysocks==1.7.1 +pytest==9.1.1 +python-apt==2.4.0+ubuntu4.1 +python-dateutil==2.9.0.post0 +python-xlib==0.33 +pytokens==0.4.1 +pytz==2026.3.post1 +pyyaml==6.0.3 +pyyaml-include==1.4.1 +qpsolvers==4.13.0 +quadprog==0.1.13 +regex==2026.9.10 +requests==2.34.2 +rerun-sdk==0.22.1 +rich==15.0.0 +rich-click==1.9.9 +roman==3.3 +rosdistro-modules==1.1.0 +rospkg-modules==1.6.3 +safetensors==0.8.0 +scipy==1.15.3 +secretstorage==3.3.1 +sentry-sdk==2.69.2 +six==1.17.0 +smmap==5.0.3 +snowballstemmer==2.2.0 +soupsieve==2.9.2 +sympy==1.14.0 +tensorboard==2.20.0 +tensorboard-data-server==0.7.2 +termcolor==3.3.0 +tianshou==0.4.10 +toml==0.10.2 +tomli==2.4.1 +torch==2.7.1 +torchcodec==0.5 +torchvision==0.22.1 +tqdm==4.70.1 +typing-extensions==4.16.0 +typing-inspect==0.9.0 +typing-inspection==0.4.4 +tzdata==2026.4 +urllib3==2.8.0 +wadllib==1.3.6 +wandb==0.25.0 +werkzeug==3.1.8 +xxhash==4.0.1 +yarl==1.25.1 +zipp==4.1.0 diff --git a/docker/locks/ros-arm64-01.txt b/docker/locks/ros-arm64-01.txt new file mode 100644 index 00000000..b5959c13 --- /dev/null +++ b/docker/locks/ros-arm64-01.txt @@ -0,0 +1,7 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# ros-amd64-01.txt; edit the amd64 lock and rerun the script. +# Constraints for RosDockerfile: the controller / IK pip stack. +-c ros-arm64.txt +huggingface-hub==0.27.0 +numpy==1.26.4 +psutil==5.9.0 diff --git a/docker/locks/ros-arm64-02.txt b/docker/locks/ros-arm64-02.txt new file mode 100644 index 00000000..b35d2480 --- /dev/null +++ b/docker/locks/ros-arm64-02.txt @@ -0,0 +1,7 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# ros-amd64-02.txt; edit the amd64 lock and rerun the script. +# Constraints for RosDockerfile: the model_server ML stack. +-c ros-arm64.txt +huggingface-hub==0.27.0 +numpy==1.26.4 +psutil==5.9.0 diff --git a/docker/locks/ros-arm64-03.txt b/docker/locks/ros-arm64-03.txt new file mode 100644 index 00000000..8e21a9e8 --- /dev/null +++ b/docker/locks/ros-arm64-03.txt @@ -0,0 +1,7 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# ros-amd64-03.txt; edit the amd64 lock and rerun the script. +# Constraints for RosDockerfile: headless OpenCV and iopath. +-c ros-arm64.txt +huggingface-hub==0.27.0 +numpy==1.26.4 +psutil==5.9.0 diff --git a/docker/locks/ros-arm64-04.txt b/docker/locks/ros-arm64-04.txt new file mode 100644 index 00000000..829bc989 --- /dev/null +++ b/docker/locks/ros-arm64-04.txt @@ -0,0 +1,7 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# ros-amd64-04.txt; edit the amd64 lock and rerun the script. +# Constraints for RosDockerfile: CLIP from its pinned checkout. +-c ros-arm64.txt +huggingface-hub==0.27.0 +numpy==1.26.4 +psutil==5.9.0 diff --git a/docker/locks/ros-arm64-05.txt b/docker/locks/ros-arm64-05.txt new file mode 100644 index 00000000..d036e147 --- /dev/null +++ b/docker/locks/ros-arm64-05.txt @@ -0,0 +1,8 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# ros-amd64-05.txt; edit the amd64 lock and rerun the script. +# Constraints for RosDockerfile: hydra-core, which SAM3 resolves its model +# configs with. +-c ros-arm64.txt +huggingface-hub==0.27.0 +numpy==1.26.4 +psutil==5.9.0 diff --git a/docker/locks/ros-arm64-06.txt b/docker/locks/ros-arm64-06.txt new file mode 100644 index 00000000..bb4083c9 --- /dev/null +++ b/docker/locks/ros-arm64-06.txt @@ -0,0 +1,11 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# ros-amd64-06.txt; edit the amd64 lock and rerun the script. +# Constraints for RosDockerfile: the numpy / setuptools / wheel clamp after +# the ML stack (step 6), and the final clamp, the image's last step, which +# installs only those three names. +-c ros-arm64.txt +huggingface-hub==0.27.0 +numpy==1.26.4 +psutil==5.9.0 +setuptools==59.6.0 +wheel==0.43.0 diff --git a/docker/locks/ros-arm64-07.txt b/docker/locks/ros-arm64-07.txt new file mode 100644 index 00000000..db42b7f6 --- /dev/null +++ b/docker/locks/ros-arm64-07.txt @@ -0,0 +1,10 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# ros-amd64-07.txt; edit the amd64 lock and rerun the script. +# Constraints for RosDockerfile: the GraspGenX wheel build. setuptools 77 +# goes only into the staged build directory (/tmp/bsetup), never into the +# system site-packages. +-c ros-arm64.txt +huggingface-hub==0.27.0 +numpy==1.26.4 +psutil==5.9.0 +setuptools==77.0.3 diff --git a/docker/locks/ros-arm64-08.txt b/docker/locks/ros-arm64-08.txt new file mode 100644 index 00000000..280adef7 --- /dev/null +++ b/docker/locks/ros-arm64-08.txt @@ -0,0 +1,7 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# ros-amd64-08.txt; edit the amd64 lock and rerun the script. +# Constraints for RosDockerfile: GraspGenX's additive dependencies. +-c ros-arm64.txt +huggingface-hub==0.27.0 +numpy==1.26.4 +psutil==5.9.0 diff --git a/docker/locks/ros-arm64-09.txt b/docker/locks/ros-arm64-09.txt new file mode 100644 index 00000000..270dd98e --- /dev/null +++ b/docker/locks/ros-arm64-09.txt @@ -0,0 +1,9 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# ros-amd64-09.txt; edit the amd64 lock and rerun the script. +# Constraints for RosDockerfile: diffusers. huggingface-hub 0.25.2: diffusers +# 0.11.1 imports cached_download, removed in 0.26, and transformers 4.47.1 +# accepts 0.25.2. +-c ros-arm64.txt +huggingface-hub==0.25.2 +numpy==1.26.4 +psutil==5.9.0 diff --git a/docker/locks/ros-arm64-10.txt b/docker/locks/ros-arm64-10.txt new file mode 100644 index 00000000..67069d18 --- /dev/null +++ b/docker/locks/ros-arm64-10.txt @@ -0,0 +1,8 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# ros-amd64-10.txt; edit the amd64 lock and rerun the script. +# Constraints for RosDockerfile: viser. psutil 5.9.8: viser 0.2.23 needs +# psutil>=5.9.5. +-c ros-arm64.txt +huggingface-hub==0.25.2 +numpy==1.26.4 +psutil==5.9.8 diff --git a/docker/locks/ros-arm64-11.txt b/docker/locks/ros-arm64-11.txt new file mode 100644 index 00000000..1f8a07e7 --- /dev/null +++ b/docker/locks/ros-arm64-11.txt @@ -0,0 +1,6 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# ros-amd64-11.txt; edit the amd64 lock and rerun the script. +# Constraints for RosDockerfile: onnxruntime, which runs HOMIE's walking +# policy in golem_lowerbody_rl. +-c ros-arm64.txt +onnxruntime==1.23.2 diff --git a/docker/locks/ros-arm64.txt b/docker/locks/ros-arm64.txt new file mode 100644 index 00000000..484eba20 --- /dev/null +++ b/docker/locks/ros-arm64.txt @@ -0,0 +1,304 @@ +# Generated by docker/mac/derive_arm64_locks.sh from +# ros-amd64.txt; edit the amd64 lock and rerun the script. +# Common constraint set for every pip step in docker/RosDockerfile, at the +# versions of the validated image (provenance: SOURCES.md). Each numbered +# ros-amd64-NN.txt includes it with -c and pins the packages whose version +# changes between steps (huggingface-hub, numpy, psutil, setuptools, wheel), +# which this set leaves out. +# NumPy stays 1.26 for the apt scipy / pinocchio ABI, which fixes the +# kinematics closure at Pinocchio 2.7 / Boost 1.83 / eigenpy 3.5.1 / +# hpp-fcl 2.4.4. mujoco is golem_base's (mink's dependency); no step moves it. +absl-py==2.5.0 +addict==2.4.0 +aiohappyeyeballs==2.7.1 +aiohttp==3.14.3 +aiosignal==1.4.0 +annotated-types==0.8.0 +antlr4-python3-runtime==4.9.3 +anyio==4.15.1 +appdirs==1.4.4 +argcomplete==1.8.1 +asttokens==3.0.2 +async-timeout==5.0.1 +attrs==26.1.0 +beniget==0.4.1 +black==26.5.1 +blinker==1.9.0 +braceexpand==0.1.7 +brotli==1.0.9 +catkin-pkg-modules==1.1.1 +certifi==2026.7.22 +cffi==2.1.1 +chardet==7.6.0 +charset-normalizer==3.5.1 +click==8.5.0 +cloudpickle==3.1.2 +cmeel==0.61.0 +cmeel-assimp==5.4.3.1 +cmeel-boost==1.83.0 +cmeel-console-bridge==1.0.2.3 +cmeel-octomap==1.10.0 +cmeel-qhull==8.0.2.1 +cmeel-tinyxml==2.6.2.3 +cmeel-tinyxml2==11.0.0 +cmeel-urdfdom==3.1.1.1 +cmeel-zlib==1.3.2 +colcon-argcomplete==0.3.3 +colcon-bash==0.5.0 +colcon-cd==0.2.1 +colcon-cmake==0.2.30 +colcon-common-extensions==0.3.0 +colcon-core==0.21.2 +colcon-defaults==0.2.9 +colcon-devtools==0.3.0 +colcon-library-path==0.2.1 +colcon-metadata==0.3.1 +colcon-notification==0.3.2 +colcon-output==0.2.14 +colcon-package-information==0.4.1 +colcon-package-selection==0.2.10 +colcon-parallel-executor==0.3.0 +colcon-pkg-config==0.1.0 +colcon-powershell==0.5.0 +colcon-python-setup-py==0.2.9 +colcon-recursive-crawl==0.2.3 +colcon-ros==0.5.0 +colcon-test-result==0.3.8 +colcon-zsh==0.5.0 +coloredlogs==15.0.1 +colorlog==6.12.0 +comm==0.2.3 +configargparse==1.7.7 +contourpy==1.3.2 +cryptography==50.0.1 +cycler==0.12.1 +cyclonedds==0.10.2 +cython==3.3.0 +daqp==0.9.1 +dash==4.4.1 +dbus-python==1.2.18 +decorator==5.3.1 +delegator-py==0.1.1 +diffusers==0.11.1 +distlib==0.3.4 +distro==1.7.0 +docstring-parser==0.18.0 +docutils==0.17.1 +eigenpy==3.5.1 +einops==0.8.0 +embreex==4.4.0 +empy==3.3.4 +etils==1.13.0 +exceptiongroup==1.3.1 +executing==2.2.1 +fastjsonschema==2.22.2 +filelock==3.32.3 +flake8==4.0.1 +flask==3.1.3 +flatbuffers==25.12.19 +fonttools==4.65.0 +frozenlist==1.8.0 +fs==2.4.12 +fsspec==2026.7.0 +ftfy==6.1.1 +gast==0.5.2 +glfw==2.10.2 +glob2==0.7 +google-auth==2.58.0 +google-genai==1.30.0 +h11==0.16.0 +h5py==3.16.0 +hpp-fcl==2.4.4 +httpcore==1.0.9 +httplib2==0.20.2 +httpx==0.28.1 +humanfriendly==10.0 +hydra-core==1.3.7 +idna==3.19 +imageio==2.37.4 +importlib-metadata==9.0.1 +importlib-resources==7.1.0 +iniconfig==1.1.1 +iopath==0.1.10 +ipython==8.39.0 +ipywidgets==8.1.9 +isort==9.0.1 +itsdangerous==2.2.0 +janus==2.0.0 +jedi==0.20.0 +jeepney==0.7.1 +jinja2==3.1.6 +joblib==1.6.0 +jsonschema==4.26.0 +jsonschema-specifications==2025.9.1 +jupyter-core==5.9.1 +jupyterlab-widgets==3.0.17 +keyring==23.5.0 +kiwisolver==1.5.1 +lark==1.1.1 +launchpadlib==1.10.16 +lazr-restfulclient==0.14.4 +lazr-uri==1.0.6 +lazy-loader==0.5 +loop-rate-limiters==1.2.0 +lxml==4.8.0 +lz4==3.1.3+dfsg +manifold3d==3.5.3 +mapbox-earcut==2.1.0 +markdown-it-py==4.2.0 +markupsafe==3.0.3 +matplotlib==3.9.3 +matplotlib-inline==0.2.2 +mccabe==0.6.1 +mdurl==0.1.2 +meshcat==0.3.2 +meshcat-shapes==1.0.0 +mink==1.3.0 +more-itertools==8.10.0 +mpi4py==3.1.3 +mpmath==1.3.0 +msgspec==0.21.1 +mujoco==3.13.0 +multidict==6.8.0 +mypy-extensions==1.1.0 +narwhals==2.26.0 +nbformat==5.11.1 +nest-asyncio==1.6.0 +netifaces==0.11.0 +networkx==3.4.2 +nodeenv==1.10.0 +notify2==0.3 +oauthlib==3.2.0 +omegaconf==2.3.1 +ompl==2.0.1 +onnxruntime==1.23.2 +open3d==0.18.0 +opencv-python==4.10.0.84 +opencv-python-headless==4.10.0.84 +orjson==3.12.0 +packaging==26.3 +pandas==2.3.3 +parso==0.8.7 +pathspec==1.1.1 +pexpect==4.9.0 +pillow==11.0.0 +pin==2.7.0 +pin-pink==4.4.0 +pink==0.8.1 +platformdirs==4.11.9 +plotly==7.1.0 +pluggy==0.13.0 +ply==3.11 +plyfile==1.1.3 +portalocker==4.3.2 +prompt-toolkit==3.0.53 +propcache==0.5.4 +protobuf==7.36.1 +proxsuite==0.7.3 +ptyprocess==0.7.0 +pure-eval==0.2.4 +py==1.10.0 +py-cpuinfo==9.0.0 +pyasn1==0.6.4 +pyasn1-modules==0.4.2 +pycairo==1.20.1 +pycocotools==2.0.8 +pycodestyle==2.8.0 +pycollada==0.9.3 +pycparser==3.0 +pydantic==2.13.5 +pydantic-core==2.46.5 +pydocstyle==6.1.1 +pydot==1.4.2 +pyflakes==2.4.0 +pygments==2.21.0 +pygobject==3.42.1 +pyjwt==2.3.0 +pyngrok==8.1.2 +pyopengl==3.1.10 +pyparsing==3.3.2 +pyqt5==5.15.6 +pyqt5-sip==12.9.1 +pyquaternion==0.9.9 +pytest==6.2.5 +python-apt==2.4.0+ubuntu4.1 +python-dateutil==2.9.0.post0 +python-fcl==0.7.0.11 +pythran==0.10.0 +pytokens==0.4.1 +pytz==2026.3.post1 +pyvers==0.2.3 +pyyaml==6.0.3 +pyzmq==27.2.0 +qpsolvers==4.13.0 +quadprog==0.1.13 +referencing==0.37.0 +regex==2024.11.6 +requests==2.34.2 +retrying==1.4.2 +rich==15.0.0 +rich-click==1.9.9 +roman==3.3 +rosdep==0.27.0 +rosdep-modules==0.27.0 +rosdistro-modules==1.1.0 +rospkg-modules==1.6.3 +rpds-py==0.30.0 +rtree==1.4.1 +safetensors==0.8.0 +scikit-image==0.25.2 +scikit-learn==1.7.2 +scipy==1.15.3 +seaborn==0.13.2 +secretstorage==3.3.1 +shapely==2.1.2 +sharedarray==3.2.4 +six==1.17.0 +snowballstemmer==2.2.0 +stack-data==0.6.3 +svg-path==7.1 +sympy==1.14.0 +tenacity==9.1.4 +tensorboardx==2.6.5 +tensordict==0.14.2 +threadpoolctl==3.7.0 +tifffile==2025.5.10 +timm==1.0.17 +tokenizers==0.21.4 +toml==0.10.2 +tomli==2.4.1 +torch==2.14.0+cpu +torch-geometric==2.8.0.post1 +torchvision==0.29.0+cpu +tornado==6.5.10 +tqdm==4.70.1 +traitlets==5.16.1 +transformers==4.47.1 +transforms3d==0.3.1 +trimesh==4.5.3 +typeguard==4.6.0 +typing-extensions==4.16.0 +typing-inspection==0.4.4 +tyro==1.0.16 +tzdata==2026.4 +u-msgpack-python==2.8.0 +ufolib2==0.13.1 +ultralytics==8.3.52 +ultralytics-thop==2.1.6 +unicodedata2==14.0.0 +urllib3==2.8.0 +vcstool==0.3.0 +vhacdx==0.0.10 +viser==0.2.23 +wadllib==1.3.6 +wcwidth==0.8.3 +webdataset==1.0.2 +websockets==15.0.1 +werkzeug==3.1.8 +widgetsnbextension==4.0.16 +xatlas==0.0.11 +xxhash==4.0.1 +yapf==0.40.1 +yarl==1.25.1 +yourdfpy==0.0.56 +zipp==4.1.0 diff --git a/docker/mac/BaseDockerfile b/docker/mac/BaseDockerfile new file mode 100644 index 00000000..229e287c --- /dev/null +++ b/docker/mac/BaseDockerfile @@ -0,0 +1,138 @@ +# golem_base:arm64: the Mac (Apple Silicon) twin of docker/BaseDockerfile, the +# shared foundation of the Mac golem_ros (mac/RosDockerfile) and +# golem_sim_robocasa (mac/RobocasaDockerfile) images. Same stages and pins as +# the x86 base, on plain Ubuntu 22.04 for linux/arm64 instead of the CUDA image, +# with PyTorch's CPU build, the arm64 locks (locks/*-arm64*.txt, derived by +# mac/derive_arm64_locks.sh) and the Unitree SDK's CycloneDDS under its own +# soname (below). docker/scripts/docker_build.sh builds it on a Mac +# (docs/MAC.md); the x86 images never read this file. + +# Ubuntu 22.04 (Jammy, the platform ROS 2 Humble targets) of 2026-09-01, the +# last image older than the apt snapshot (a newer one carries packages newer +# than the snapshot, which apt cannot satisfy), pinned by the digest +# of its multi-arch index; docker_build.sh selects linux/arm64 from it. +FROM ubuntu:jammy-20260901.2@sha256:b8b6ee6aa931ecd9d0d952abc34dc0e5f7c6a30c6bb71b079fe399fde0329c02 +# The Python constraint files and the dated apt snapshot sources: the x86 +# base's, whose Ubuntu snapshot also serves arm64. The snapshot is HTTPS-only +# and plain ubuntu:22.04, unlike the CUDA image, ships without +# ca-certificates, so it comes first from the image's own ports.ubuntu.com +# lists (the one package not resolved against the snapshot). +COPY docker/locks/base-arm64*.txt docker/locks/apt-sources.sh docker/locks/ros-snapshot.asc /opt/golem-locks/ +RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates \ + && rm -rf /var/lib/apt/lists/* \ + && sh /opt/golem-locks/apt-sources.sh + +ENV DEBIAN_FRONTEND=noninteractive +ENV TZ=America/Denver +ENV LANG=C.UTF-8 +ENV ROS_DISTRO=humble +# Every container talks ROS over CycloneDDS, the same DDS the Unitree SDK uses. +ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp + +# Optional build-time proxies; cleared at the end of this file. +ARG http_proxy +ARG https_proxy +ENV http_proxy=${http_proxy} +ENV https_proxy=${https_proxy} + +# The x86 base's packages: gcc-12 / g++-12 (made the default compilers), cmake, +# git and git-lfs, Python 3.10 as `python`, the X11 / GL runtime libraries +# MuJoCo loads, and the locale. add-apt-repository rewrites sources.list, so +# apt-sources.sh runs again afterwards to put the dated snapshots back. +RUN apt-get update && apt-get install -y --no-install-recommends \ + curl gnupg locales software-properties-common \ + gcc-12 g++-12 cmake build-essential git git-lfs wget unzip \ + python3 python3-dev python3-pip python-is-python3 \ + libglu1-mesa-dev \ + libx11-6 libxext6 libxrender1 libxi6 libxrandr2 libxcursor1 libxinerama1 \ + libgl1-mesa-glx libglib2.0-0 libsm6 libxt6 libxkbcommon-x11-0 \ + libegl1-mesa-dev \ + && locale-gen en_US en_US.UTF-8 && update-locale LC_ALL=C.UTF-8 LANG=C.UTF-8 \ + && add-apt-repository universe \ + && sh /opt/golem-locks/apt-sources.sh \ + && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 \ + && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100 \ + && rm -rf /var/lib/apt/lists/* + +# The ROS 2 Humble apt source: the 2026-08-07 snapshot (it has arm64), verified +# with the vendored snapshot key. +RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/opt/golem-locks/ros-snapshot.asc] http://snapshots.ros.org/humble/2026-08-07/ubuntu jammy main" \ + > /etc/apt/sources.list.d/ros2.list + +# ROS 2 Humble for the simulators' ROS side, as in the x86 base. +RUN apt-get update && apt-get install -y --no-install-recommends \ + ros-humble-ros-base \ + ros-humble-rmw-cyclonedds-cpp \ + ros-humble-sensor-msgs-py \ + ros-humble-tf2-ros \ + ros-humble-tf2-ros-py \ + ros-humble-geometry-msgs \ + ros-humble-rosgraph-msgs \ + ros-humble-cv-bridge \ + && rm -rf /var/lib/apt/lists/* + +# uv 0.12.15 into /usr/local/bin. The installer URL names the version. +RUN curl -LsSf https://astral.sh/uv/0.12.15/install.sh | env UV_INSTALL_DIR=/usr/local/bin sh \ + && uv --version + +# CycloneDDS 0.10.x from source, at the x86 base's commit, for the Unitree +# SDK's Python binding (PyPI cyclonedds 0.10.2; see docker/BaseDockerfile). +# The sims run it beside ROS's own CycloneDDS in one process, each creating +# the same DDS domain, which needs two separate libddsc copies. On arm64 the +# binding's C extension would bind to ROS's copy by their shared soname +# (libddsc.so.0) once rclpy has loaded it, its first topic would fail against +# the participant its Python side made in this copy, and cyclonedds-python +# 0.10.2's error path then segfaults. So this copy's soname is +# libddsc_unitree.so.0 (patchelf), and the binding's extension needs it by +# that name from this directory (next step). +RUN apt-get update && apt-get install -y --no-install-recommends patchelf \ + && rm -rf /var/lib/apt/lists/* +RUN git clone https://github.com/eclipse-cyclonedds/cyclonedds /cyclonedds && \ + git -C /cyclonedds checkout --quiet 5041f3560c088c99e5088b2b8520b69169621196 && \ + cd /cyclonedds && mkdir build install && cd build && \ + cmake .. -DCMAKE_INSTALL_PREFIX=../install && \ + cmake --build . --target install && \ + rm -rf /cyclonedds/build && \ + cd /cyclonedds/install/lib && \ + patchelf --set-soname libddsc_unitree.so.0 "$(readlink -f libddsc.so)" && \ + ln -s "$(basename "$(readlink -f libddsc.so)")" libddsc_unitree.so.0 + +ENV CYCLONEDDS_HOME=/cyclonedds/install + +# The Unitree Python SDK from the repo's submodule. The whole package tree is +# copied over the installed one for its native CRC libraries (utils/lib); the +# SDK loads crc_aarch64.so on this platform. cyclonedds builds from source +# (--no-binary) against CYCLONEDDS_HOME; its _clayer extension is then pointed +# at libddsc_unitree.so.0 in /cyclonedds/install/lib (one patchelf call per +# change: patchelf 0.14 mangles combined ones). check_unitree_dds.py fails the +# build if the SDK and a ROS node cannot share a domain in one process. +COPY unitree_sdk2_python /home/code/unitree_sdk2_python +COPY docker/mac/check_unitree_dds.py /opt/golem-checks/ +RUN cd /home/code/unitree_sdk2_python && \ + uv pip install -c /opt/golem-locks/base-arm64-01.txt --system --no-binary cyclonedds . && \ + SP=$(python3 -c "import site; print(site.getsitepackages()[0])") && \ + for so in "$SP"/cyclonedds/_clayer*.so; do \ + patchelf --replace-needed libddsc.so.0 libddsc_unitree.so.0 "$so" && \ + patchelf --set-rpath /cyclonedds/install/lib "$so"; \ + done && \ + cp -r /home/code/unitree_sdk2_python/unitree_sdk2py/* "$SP/unitree_sdk2py/" && \ + python3 -c "from unitree_sdk2py.utils.crc import CRC; CRC()" && \ + python3 /opt/golem-checks/check_unitree_dds.py && \ + bash -c 'source /opt/ros/humble/setup.bash && python3 /opt/golem-checks/check_unitree_dds.py --ros' + +# PyTorch and torchvision, CPU builds for linux/aarch64 (the TorchScript leg +# policies run on the CPU on every platform). +RUN UV_HTTP_TIMEOUT=600 uv pip install -c /opt/golem-locks/base-arm64-02.txt --system --no-cache \ + torch torchvision \ + --index-url https://download.pytorch.org/whl/cpu + +# Kinematics libraries: `pin` (pinocchio) and the pink and mink IK wrappers. +RUN uv pip install -c /opt/golem-locks/base-arm64-03.txt --system --no-cache pin pink mink + +RUN echo 'source /opt/ros/humble/setup.bash' >> /root/.bashrc + +# Clear the build-time proxies (see the ARGs above). +ENV http_proxy= +ENV https_proxy= + +WORKDIR /home/code diff --git a/docker/mac/RobocasaDockerfile b/docker/mac/RobocasaDockerfile new file mode 100644 index 00000000..4bf5d6d6 --- /dev/null +++ b/docker/mac/RobocasaDockerfile @@ -0,0 +1,121 @@ +# golem_sim_robocasa:arm64: the Mac (Apple Silicon) twin of +# docker/RobocasaDockerfile, the MuJoCo / RoboCasa simulator of both robots, on +# golem_base:arm64 (mac/BaseDockerfile). Same stages, commits, patches and +# kitchen-asset digest as the x86 image, with the arm64 locks and OSMesa as the +# renderer: the Mac has no NVIDIA GPU, so the sims run with GOLEM_RENDER=cpu, +# which draws the cameras in software and has no MID-360 (docs/MAC.md). The +# simulator source (golem_robocasa) is bind-mounted at runtime. +FROM golem_base:arm64 +COPY docker/locks/robocasa-arm64*.txt docker/locks/robocasa-assets.digest /opt/golem-locks/ + +# Optional build-time proxies (golem_base clears its own). +ARG http_proxy +ARG https_proxy +ENV http_proxy=${http_proxy} +ENV https_proxy=${https_proxy} + +# Software rendering for the RGBD cameras in the sims and in shells. +# launch_robocasa.sh sets MUJOCO_GL from GOLEM_RENDER as well +# (docker-compose.mac.yml sets cpu). +ENV MUJOCO_GL=osmesa + +# MuJoCo's runtime rendering libraries: EGL and OSMesa for headless rendering. +RUN apt-get update && apt-get install -y --no-install-recommends \ + libegl1-mesa libosmesa6 \ + && rm -rf /var/lib/apt/lists/* + +# The MuJoCo Python bindings and Pillow; 3.3.1 first because RoboCasa's +# setup.py pins it, and the last step replaces it with 3.17.0 (as on x86). +RUN uv pip install -c /opt/golem-locks/robocasa-arm64-01.txt --system --no-cache \ + "mujoco==3.3.1" \ + "numpy>=2.2.6" \ + "Pillow>=10.0" + +# robosuite and RoboCasa at the x86 image's commits, editable. RoboCasa's +# lerobot pins torch 2.7.1, which replaces base's CPU torch in this image. +RUN git clone https://github.com/ARISE-Initiative/robosuite /opt/robosuite && \ + git -C /opt/robosuite checkout --quiet 5ce6643f3092639d08f7b0f90ed1c6a84f50552c && \ + uv pip install -c /opt/golem-locks/robocasa-arm64-02.txt --system --no-cache -e /opt/robosuite + +RUN git clone https://github.com/robocasa/robocasa /opt/robocasa && \ + git -C /opt/robocasa checkout --quiet 4f8a2980def75a55dff96b990745b83540425f09 && \ + uv pip install -c /opt/golem-locks/robocasa-arm64-03.txt --system --no-cache -e /opt/robocasa + +# robosuite's and RoboCasa's private macro files; without them both warn on +# every import. +RUN python /opt/robosuite/robosuite/scripts/setup_macros.py && \ + python /opt/robocasa/robocasa/scripts/setup_macros.py + +# Optional robosuite / RoboCasa dependencies, installed only to silence their +# "not installed" import warnings (see docker/RobocasaDockerfile). +RUN git clone https://github.com/ARISE-Initiative/robosuite_models /opt/robosuite_models && \ + git -C /opt/robosuite_models checkout --quiet 2d63a6b4319bda772420daf10594ce0de5bd793d && \ + uv pip install -c /opt/golem-locks/robocasa-arm64-04.txt --system --no-cache -e /opt/robosuite_models && \ + git clone https://github.com/NVlabs/mimicgen /opt/mimicgen && \ + git -C /opt/mimicgen checkout --quiet 72bd767c255545f462e7ccfb2731f2e5d4c1d9bb && \ + uv pip install -c /opt/golem-locks/robocasa-arm64-04.txt --system --no-cache -e /opt/mimicgen && \ + uv pip install -c /opt/golem-locks/robocasa-arm64-04.txt --system --no-cache --no-deps "mink==0.0.5" + +# RoboCasa's kitchen assets (about 10 GB), baked in; `echo y` answers the +# download script's one prompt. +RUN echo y | python -m robocasa.scripts.download_kitchen_assets --type all +# Check the downloaded tree against the committed digest (locks/SOURCES.md). +RUN cd /opt/robocasa/robocasa/models && \ + find assets -type f -print0 | LC_ALL=C sort -z | xargs -0 sha256sum | \ + sha256sum --check --quiet /opt/golem-locks/robocasa-assets.digest + +WORKDIR /home/code/golem_robocasa + +# A shell; docker-compose.yml's command runs launch_robocasa.sh instead. +CMD ["/bin/bash"] + +# The msgs_ws toolchain, so launch_robocasa.sh can build the message-only +# workspace (magpie_msgs, custom_ros_messages) at every container start. +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3-colcon-common-extensions \ + ros-humble-ament-cmake \ + ros-humble-ament-cmake-auto \ + ros-humble-ament-cmake-python \ + ros-humble-rosidl-default-generators \ + && rm -rf /var/lib/apt/lists/* + +# The mount point of core_ws/src/{magpie_msgs,custom_ros_messages}. +RUN mkdir -p /home/code/msgs_ws/src + +# Livox-SDK2 at the commit every image uses (tests/docker/test_source_pins.py), +# so the images agree on the CustomMsg wire format. The Mac sims publish no +# lidar, but the sensor modules import livox_ros_driver2's CustomMsg. +RUN git clone https://github.com/Livox-SDK/Livox-SDK2.git /tmp/Livox-SDK2 && \ + git -C /tmp/Livox-SDK2 checkout --quiet 08f523c930b2f0ba1e98a6afaa8d7476bf479908 && \ + cd /tmp/Livox-SDK2 && mkdir build && cd build && \ + cmake .. -DCMAKE_POLICY_VERSION_MINIMUM=3.5 && make -j"$(nproc)" && make install && \ + ldconfig && \ + rm -rf /tmp/Livox-SDK2 + +# livox_ros_driver2's C++ build dependencies (its package_ROS2.xml). +RUN apt-get update && apt-get install -y --no-install-recommends \ + libpcl-dev libapr1-dev \ + ros-humble-pcl-conversions ros-humble-pcl-ros \ + ros-humble-rclcpp-components ros-humble-rcl-interfaces \ + ros-humble-rosbag2 \ + ros-humble-sensor-msgs ros-humble-std-msgs \ + && rm -rf /var/lib/apt/lists/* + +# livox_ros_driver2 at /opt/livox_ws (copied, not mounted: its build.sh rewrites +# its own tree; see docker/RobocasaDockerfile). build.sh exits 0 even when its +# colcon build fails (CLAUDE.md §8), so the import check fails the image +# instead. +COPY core_ws/src/livox_ros_driver2 /opt/livox_ws/src/livox_ros_driver2 +RUN bash -c "source /opt/ros/humble/setup.bash && \ + cd /opt/livox_ws/src/livox_ros_driver2 && \ + ./build.sh humble && \ + source /opt/livox_ws/install/setup.bash && \ + python3 -c 'from livox_ros_driver2.msg import CustomMsg'" + +# MuJoCo 3.17.0 over RoboCasa's 3.3.1 and the patches robosuite and RoboCasa +# need for it, as on x86 (docker/patches/; each file says why). +COPY docker/patches/robosuite-mujoco-3.17.0.patch docker/patches/robocasa-mujoco-3.17.0.patch /opt/golem-patches/ +RUN uv pip install -c /opt/golem-locks/robocasa-arm64-05.txt --system --no-cache "mujoco==3.17.0" && \ + git -C /opt/robosuite apply /opt/golem-patches/robosuite-mujoco-3.17.0.patch && \ + git -C /opt/robocasa apply /opt/golem-patches/robocasa-mujoco-3.17.0.patch && \ + cd / && python -c "import mujoco, robosuite, robocasa; assert mujoco.__version__ == '3.17.0', mujoco.__version__" diff --git a/docker/mac/RosDockerfile b/docker/mac/RosDockerfile new file mode 100644 index 00000000..070d4d87 --- /dev/null +++ b/docker/mac/RosDockerfile @@ -0,0 +1,161 @@ +# golem_ros:arm64: the Mac (Apple Silicon) twin of docker/RosDockerfile, the +# ROS 2 workspace image, on golem_base:arm64 (mac/BaseDockerfile). +# +# It has the x86 image's build toolchain, C++ libraries, Livox-SDK2, the Pink +# IK / OMPL stack, Nav2 / SLAM / OctoMap, the RealSense driver and the G1's +# onnxruntime, with the arm64 locks. It leaves out the model_server ML stack +# (transformers, CLIP, SAM3, YOLO, GraspGenX): the Mac sim bringups +# (h12_mac_sim, g1_mac_sim) start no model server, and GraspGenX has no CPU +# path. core_ws still builds whole; those servers fail at import if started. +# launch_ros.sh colcon-builds the bind-mounted core_ws at every container start. +# Step numbers follow docker/RosDockerfile. +FROM golem_base:arm64 +COPY docker/locks/ros-arm64*.txt /opt/golem-locks/ + +# Optional build-time proxies (golem_base clears its own). +ARG http_proxy +ARG https_proxy +ENV http_proxy=${http_proxy} +ENV https_proxy=${https_proxy} + +# 1. apt: build tooling, system Python C-extensions and the ROS packages core_ws +# builds against (docker/RosDockerfile step 1 has a comment per group). +RUN apt-get update && apt-get install -y --no-install-recommends \ + pkg-config \ + python3-colcon-common-extensions \ + python3-rosdep \ + python3-vcstool \ + python3-numpy python3-scipy python3-yaml python3-transforms3d \ + libpcl-dev libeigen3-dev libyaml-cpp-dev libopencv-dev \ + ros-humble-ament-cmake \ + ros-humble-ament-cmake-auto \ + ros-humble-ament-cmake-python \ + ros-humble-ament-lint-auto \ + ros-humble-rosidl-default-generators \ + ros-humble-rosidl-generator-dds-idl \ + ros-humble-image-transport \ + ros-humble-vision-msgs \ + ros-humble-nav-msgs \ + ros-humble-std-msgs \ + ros-humble-std-srvs \ + ros-humble-visualization-msgs \ + ros-humble-xacro \ + ros-humble-robot-state-publisher \ + ros-humble-joint-state-publisher \ + ros-humble-launch-ros \ + ros-humble-launch-xml \ + ros-humble-pcl-ros \ + ros-humble-pcl-conversions \ + ros-humble-tf2-eigen \ + ros-humble-tf2-tools \ + ros-humble-rclcpp \ + ros-humble-rclcpp-components \ + ros-humble-rviz2 \ + ros-humble-pinocchio \ + && rm -rf /var/lib/apt/lists/* + +# 2. Livox-SDK2, which livox_ros_driver2 in core_ws links, at the commit every +# image uses (tests/docker/test_source_pins.py). +RUN git clone https://github.com/Livox-SDK/Livox-SDK2.git /tmp/Livox-SDK2 && \ + git -C /tmp/Livox-SDK2 checkout --quiet 08f523c930b2f0ba1e98a6afaa8d7476bf479908 && \ + cd /tmp/Livox-SDK2 && mkdir build && cd build && \ + cmake .. -DCMAKE_POLICY_VERSION_MINIMUM=3.5 && make -j"$(nproc)" && make install && \ + ldconfig && \ + rm -rf /tmp/Livox-SDK2 + +# 3. Python: golem_upper_ik's controller stack and open3d (0.18.0 here: 0.19.0 +# has no linux/aarch64 wheel). Base's NumPy-2 pinocchio closure goes first, +# as on x86 (docker/RosDockerfile step 3 says why). +RUN pip uninstall -y pin libpinocchio coal libcoal eigenpy \ + cmeel cmeel-assimp cmeel-boost cmeel-console-bridge cmeel-octomap \ + cmeel-qhull cmeel-tinyxml2 cmeel-urdfdom cmeel-zlib +RUN pip install -c /opt/golem-locks/ros-arm64-01.txt --no-cache-dir --ignore-installed blinker \ + "numpy<2" \ + "scikit-learn>=1.4" \ + pin-pink \ + qpsolvers \ + quadprog \ + proxsuite \ + "ompl==2.0.1" \ + meshcat \ + meshcat-shapes \ + pyquaternion \ + tqdm \ + open3d + +# 7. Interactive shells source the core_ws overlay once launch_ros.sh has built +# it (base's .bashrc already sources /opt/ros/humble). +RUN echo '[ -f /home/code/core_ws/install/setup.bash ] && source /home/code/core_ws/install/setup.bash' >> /root/.bashrc + +WORKDIR /home/code/core_ws + +# Build core_ws, then a shell (launch_ros.sh); bringup is a manual step. +CMD ["/home/code/h12_sim_scripts/launch_ros.sh"] + +# Tkinter, for golem_bringup's slider_debugger.py. +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3-tk \ + && rm -rf /var/lib/apt/lists/* + +# Navigation, SLAM and debugging tools: golem_slam builds against them, though +# the Mac sims have no lidar to run them on (docker/RosDockerfile has a comment +# per group). +RUN apt-get update && apt-get install -y --no-install-recommends \ + ros-humble-navigation2 \ + ros-humble-nav2-bringup \ + ros-humble-slam-toolbox \ + ros-humble-pointcloud-to-laserscan \ + ros-humble-rqt \ + ros-humble-rqt-common-plugins \ + ros-humble-rqt-graph \ + ros-humble-rqt-tf-tree \ + ros-humble-rqt-reconfigure \ + ros-humble-teleop-twist-keyboard \ + ros-humble-teleop-twist-joy \ + ros-humble-rosbag2 \ + ros-humble-rosbag2-storage-default-plugins \ + ros-humble-diagnostic-updater \ + ros-humble-foxglove-bridge \ + && rm -rf /var/lib/apt/lists/* + +# The RealSense ROS driver and the image transports (cl_realsense's launch +# files name them). +RUN apt-get update && apt-get install -y --no-install-recommends \ + ros-humble-realsense2-camera \ + ros-humble-image-transport-plugins \ + && rm -rf /var/lib/apt/lists/* + +# OctoMap for golem_slam's navigation.launch.py. +RUN apt-get update && apt-get install -y --no-install-recommends \ + ros-humble-octomap-server \ + ros-humble-octomap-rviz-plugins \ + && rm -rf /var/lib/apt/lists/* + +# The G1's additions: joint_state_publisher_gui (golem_ros2_models' +# display.launch.py) and onnxruntime 1.23.2, which runs HOMIE's walking policy +# in golem_lowerbody_rl. +RUN apt-get update && apt-get install -y --no-install-recommends \ + ros-humble-joint-state-publisher-gui \ + && rm -rf /var/lib/apt/lists/* +RUN pip install -c /opt/golem-locks/ros-arm64-11.txt --no-cache-dir onnxruntime==1.23.2 \ + && python3 -c "import onnxruntime" + +# pyserial (estop's exec_depend): estop_node reads the H1-2 sims' socket:// +# estop box with it. +RUN apt-get update && apt-get install -y --no-install-recommends python3-serial \ + && rm -rf /var/lib/apt/lists/* \ + && python3 -c "import serial; serial.serial_for_url('loop://')" + +# 6. Clamp numpy, setuptools and wheel to what colcon and the ABI need, last, so +# it covers every pip step above (docker/RosDockerfile steps 6 and 8 say +# why each pin, and why the stale files are deleted first). +RUN rm -rf /usr/local/lib/python3.10/dist-packages/setuptools \ + /usr/local/lib/python3.10/dist-packages/setuptools-*.dist-info \ + /usr/local/lib/python3.10/dist-packages/pkg_resources \ + /usr/local/lib/python3.10/dist-packages/pkg_resources-*.dist-info \ + /usr/local/lib/python3.10/dist-packages/_distutils_hack \ + /usr/local/lib/python3.10/dist-packages/wheel \ + /usr/local/lib/python3.10/dist-packages/wheel-*.dist-info \ + && pip install -c /opt/golem-locks/ros-arm64-06.txt --no-cache-dir --no-deps "numpy<2" "setuptools==59.6.0" "wheel<0.44" \ + && rm -f /usr/local/lib/python3.10/dist-packages/distutils-precedence.pth \ + && python3 -c "import setuptools, wheel, numpy; assert setuptools.__version__ == '59.6.0', setuptools.__version__; assert numpy.__version__.startswith('1.'), numpy.__version__; print('clamp ok:', setuptools.__version__, wheel.__version__, numpy.__version__)" diff --git a/docker/mac/check_unitree_dds.py b/docker/mac/check_unitree_dds.py new file mode 100644 index 00000000..07fa8b26 --- /dev/null +++ b/docker/mac/check_unitree_dds.py @@ -0,0 +1,45 @@ +"""Check the Unitree SDK's DDS and a ROS node can share one DDS domain in one process. + +Usage: python3 check_unitree_dds.py [--ros] + Without --ros: open a Unitree rt/lowstate publisher (the SDK's own CycloneDDS). + --ros (ROS sourced): import rclpy first, as the sims do, then open the Unitree + publisher and create a ROS node with a publisher on the same domain, as the sims' + sensor bridge does. +Run by docker/mac/BaseDockerfile, so an image whose two CycloneDDS copies collide +(a segfault in the first Unitree topic, or a ROS domain the SDK already holds) +fails its build. Exit status: 0 when every step works; otherwise the failing +step's error or signal. +""" +import faulthandler +import os +import sys + +# A domain no sim or real robot uses, so a build host's DDS traffic is not joined. +DOMAIN = 232 + + +def main() -> None: + """Run the steps; raise on the first that fails.""" + faulthandler.enable() + ros = "--ros" in sys.argv[1:] + if ros: + os.environ["ROS_DOMAIN_ID"] = str(DOMAIN) + import rclpy + from rclpy.node import Node + from std_msgs.msg import Empty + from unitree_sdk2py.core.channel import ChannelFactoryInitialize, ChannelPublisher + from unitree_sdk2py.idl.unitree_hg.msg.dds_ import LowState_ + + ChannelFactoryInitialize(DOMAIN) + ChannelPublisher("rt/lowstate", LowState_).Init() + if ros: + rclpy.init() + node = Node("check_unitree_dds") + node.create_publisher(Empty, "check_unitree_dds", 1) + node.destroy_node() + rclpy.shutdown() + print(f"check_unitree_dds: ok{' (with a ROS node)' if ros else ''}") + + +if __name__ == "__main__": + main() diff --git a/docker/mac/derive_arm64_locks.sh b/docker/mac/derive_arm64_locks.sh new file mode 100755 index 00000000..15c50c98 --- /dev/null +++ b/docker/mac/derive_arm64_locks.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# Derive the Mac images' arm64 Python locks (docker/locks/*-arm64*.txt) from the +# x86 images' amd64 locks, so the two platforms resolve the same versions. +# +# Usage: docker/mac/derive_arm64_locks.sh +# Rewrites every docker/locks/{base,robocasa,ros}-arm64*.txt from its amd64 +# twin. Run it after any amd64 lock changes, then rebuild the Mac images +# (docker/scripts/docker_build.sh on the Mac) to check the result resolves. +# The rewrite, line by line: +# - drops the CUDA-only wheels (nvidia-*, cuda-*, triton): the Mac images +# run torch on the CPU; +# - turns torch's and torchvision's +cu130 local version into +cpu (the +# CPU index, download.pytorch.org/whl/cpu, has the same versions for +# linux/aarch64); +# - pins open3d 0.18.0: 0.19.0 has no linux/aarch64 wheel for Python 3.10; +# - renames the -c references to the arm64 files. +# Exit status: 0, or 1 when an amd64 lock is missing. +set -euo pipefail +LOCKS=$(cd "$(dirname "$0")/../locks" && pwd) +for src in "$LOCKS"/{base,robocasa,ros}-amd64*.txt; do + [ -f "$src" ] || { echo "ERROR: no amd64 locks in $LOCKS" >&2; exit 1; } + dst=${src/-amd64/-arm64} + { + echo '# Generated by docker/mac/derive_arm64_locks.sh from' + echo "# $(basename "$src"); edit the amd64 lock and rerun the script." + grep -vE '^(nvidia-[a-z0-9-]+|cuda-[a-z0-9-]+|triton)==' "$src" \ + | sed -e 's/^\(torch\(vision\)\{0,1\}==[^+]*\)+cu130$/\1+cpu/' \ + -e 's/^open3d==0\.19\.0$/open3d==0.18.0/' \ + -e 's/^-c \(.*\)-amd64\.txt$/-c \1-arm64.txt/' + } > "$dst" +done diff --git a/docker/scripts/docker_build.sh b/docker/scripts/docker_build.sh index c76a7004..7f57678e 100755 --- a/docker/scripts/docker_build.sh +++ b/docker/scripts/docker_build.sh @@ -2,8 +2,10 @@ # Build the GOLEM images (docker/BUILD.md). # # Usage: docker_build.sh [--pull] [--no-cache] [isaac|robocasa|ros ...] -# isaac, robocasa, ros the images to build; none: all three. robocasa and -# ros build golem_base first. +# isaac, robocasa, ros the images to build; none: all three (on the Mac, +# robocasa and ros). robocasa and ros build golem_base +# first. On the Mac (GOLEM_PLATFORM=mac) every image is +# the arm64 build of docker/mac/ (docs/MAC.md). # --pull refresh the public base images (CUDA, Isaac Sim) # --no-cache rebuild every layer # Environment: docker/.env and the shell as in docker_common.sh. @@ -24,7 +26,9 @@ for arg in "$@"; do *) validate_service "$arg"; SERVICES+=("$arg");; esac done -[ ${#SERVICES[@]} -gt 0 ] || SERVICES=(robocasa ros isaac) +if [ ${#SERVICES[@]} -eq 0 ]; then + if [ "$GOLEM_PLATFORM" = mac ]; then SERVICES=(robocasa ros); else SERVICES=(robocasa ros isaac); fi +fi # Check the COPY sources before building anything. NEEDS_BASE=0 for service in "${SERVICES[@]}"; do @@ -33,9 +37,14 @@ for service in "${SERVICES[@]}"; do esac if [ "$service" = robocasa ]; then require_file core_ws/src/livox_ros_driver2/package_ROS2.xml; fi done -# golem_base first, under the local tag the children's FROM names. +# golem_base first, under the local tag the children's FROM names: the x86 +# image, or on the Mac the arm64 one of docker/mac/ (golem_base:arm64). if [ "$NEEDS_BASE" = 1 ]; then - docker build --platform linux/amd64 "${BUILD_FLAGS[@]}" -t golem_base:latest -f docker/BaseDockerfile . + if [ "$GOLEM_PLATFORM" = mac ]; then + docker build --platform linux/arm64 "${BUILD_FLAGS[@]}" -t golem_base:arm64 -f docker/mac/BaseDockerfile . + else + docker build --platform linux/amd64 "${BUILD_FLAGS[@]}" -t golem_base:latest -f docker/BaseDockerfile . + fi fi # Isaac has a public base, so it gets --pull. The children build on the local # golem_base just built: --pull there would try to download golem_base from diff --git a/docker/scripts/docker_common.sh b/docker/scripts/docker_common.sh index bea4099f..a037393e 100755 --- a/docker/scripts/docker_common.sh +++ b/docker/scripts/docker_common.sh @@ -16,9 +16,12 @@ # sim and the efficiency cores for ros; unset otherwise # GOLEM_SYSFS_ROOT prefix of the /sys files configure_cpus reads (default # empty; the host-script tests set it) +# GOLEM_PLATFORM linux or mac (default: mac on Darwin arm64, else linux); +# mac runs the arm64 images of docker/mac/ (docs/MAC.md) # docker/.env any of the above; exported shell values win # Globals set: GOLEM_ROOT, COMPOSE (the docker compose command line, extended -# by configure_robot, configure_display and configure_cpus), ENV_FILE, +# by configure_platform, configure_robot, configure_display and +# configure_cpus), GOLEM_PLATFORM, ENV_FILE, # ROBOT_FLAG, WRAPPER_ARGS; GOLEM_SIM_CPUSET and GOLEM_ROS_CPUSET are set or # unset by configure_cpus. # Every check fails through fail(): an "ERROR:" line on stderr and exit 1. @@ -66,14 +69,41 @@ load_config() { ENV_FILE="$GOLEM_ROOT/docker/.env" [ -f "$ENV_FILE" ] || ENV_FILE=/dev/null COMPOSE=(docker compose --env-file "$ENV_FILE" -f "$GOLEM_ROOT/docker/docker-compose.yml") + configure_platform } -# Fail unless $1 is a service: robocasa, ros or isaac. +# Select the host platform and export it as GOLEM_PLATFORM: the shell's or +# docker/.env's GOLEM_PLATFORM, else mac on Darwin arm64 (Apple Silicon), else +# linux. linux leaves COMPOSE as load_config made it (the x86 / NVIDIA images). +# mac adds docker-compose.mac.yml (the arm64 images of docker/mac/, no NVIDIA +# runtime, the sims on CPU rendering), exports GOLEM_LIDAR=0 unless set (the +# Mac sims have no lidar caster) and headless unless GOLEM_DISPLAY is set +# (there is no X server). Called by load_config. +configure_platform() { + local platform=${GOLEM_PLATFORM:-} + if [ -z "$platform" ]; then + if [ "$(uname -s)" = Darwin ] && [ "$(uname -m)" = arm64 ]; then platform=mac; else platform=linux; fi + fi + case "$platform" in + linux) ;; + mac) + COMPOSE+=(-f "$GOLEM_ROOT/docker/docker-compose.mac.yml") + export GOLEM_LIDAR="${GOLEM_LIDAR:-0}" + export GOLEM_DISPLAY="${GOLEM_DISPLAY:-headless}" + ;; + *) fail "GOLEM_PLATFORM must be linux or mac, not '$platform'.";; + esac + export GOLEM_PLATFORM=$platform +} + +# Fail unless $1 is a service: robocasa, ros or isaac (not isaac on the Mac, +# which has no NVIDIA GPU). Call it after load_config. validate_service() { case "$1" in robocasa|ros|isaac) ;; *) fail "Unknown service '$1'; use robocasa, ros, or isaac.";; esac + [ "$1" != isaac ] || [ "${GOLEM_PLATFORM:-linux}" != mac ] || fail 'The Isaac simulator needs an NVIDIA GPU and does not run on the Mac; use robocasa.' } # Split the robot selectors --g1 / --h12 out of the arguments, wherever they diff --git a/docker/scripts/docker_run.sh b/docker/scripts/docker_run.sh index 6cb48a64..f0581dea 100755 --- a/docker/scripts/docker_run.sh +++ b/docker/scripts/docker_run.sh @@ -32,6 +32,8 @@ else configure_robot "$SIM" echo "robot: $GOLEM_ROBOT" >&2 fi +# The Mac runs the arm64 images (configure_platform); Linux prints nothing here. +[ "$GOLEM_PLATFORM" != mac ] || echo 'platform: mac (arm64, CPU rendering, no lidar)' >&2 RESTART=0 if [ "${1:-}" = --restart ]; then RESTART=1; shift; fi # Pin the container to its CPUs (robocasa, ros; not the Isaac simulator). Before the diff --git a/docker/scripts/docker_stack.sh b/docker/scripts/docker_stack.sh index 670ef3cf..633932e8 100755 --- a/docker/scripts/docker_stack.sh +++ b/docker/scripts/docker_stack.sh @@ -11,7 +11,8 @@ # --g1 / --h12 the robot (anywhere in the arguments) # The ros container builds core_ws, waits in wait_for_sim.py for a fresh # rt/lowstate from a simulator of the selected robot, then starts its bringup -# (docker-compose.stack.yml): h12_sim.launch.py, or g1_sim.launch.py for the G1. +# (docker-compose.stack.yml): h12_sim.launch.py, or g1_sim.launch.py for the G1; +# on the Mac (GOLEM_PLATFORM=mac) h12_mac_sim.launch.py or g1_mac_sim.launch.py. # Environment: GOLEM_ROBOT=h12|g1, GOLEM_DISPLAY, GOLEM_SIM_TIMEOUT (s, the # wait), GOLEM_USE_RVIZ (true|false; default true when DISPLAY is set), # GOLEM_CPU_PINNING, GOLEM_SIM_CPUSET and GOLEM_ROS_CPUSET (the CPUs the RoboCasa @@ -49,10 +50,15 @@ fi if [ "$ACTION" = logs ]; then exec "${COMPOSE[@]}" logs -f "$SIM" ros; fi configure_robot "$SIM" echo "robot: $GOLEM_ROBOT" >&2 -if [ "$GOLEM_ROBOT" = g1 ]; then - # Read by docker-compose.stack.yml. Set here, from the selected robot, - # because a value left in the shell or docker/.env would start the H1-2 - # bringup against the G1 sim. +# The Mac runs the arm64 images (configure_platform); Linux prints nothing here. +[ "$GOLEM_PLATFORM" != mac ] || echo 'platform: mac (arm64, CPU rendering, no lidar)' >&2 +# Read by docker-compose.stack.yml. Set here, from the selected robot and +# platform, because a value left in the shell or docker/.env would start the +# other robot's bringup. The Mac runs the mac_sim bringups (no lidar, +# navigation or vision models; docs/MAC.md). +if [ "$GOLEM_PLATFORM" = mac ]; then + export GOLEM_BRINGUP_LAUNCH=${GOLEM_ROBOT}_mac_sim.launch.py +elif [ "$GOLEM_ROBOT" = g1 ]; then export GOLEM_BRINGUP_LAUNCH=g1_sim.launch.py fi check_domain "$SIM" diff --git a/docker/scripts/launch_robocasa.sh b/docker/scripts/launch_robocasa.sh index b105892b..735edf00 100755 --- a/docker/scripts/launch_robocasa.sh +++ b/docker/scripts/launch_robocasa.sh @@ -6,8 +6,10 @@ # e.g. --headless or --layout 9 --style 9 --seed 42. Without a DISPLAY, # --headless is added (no passive viewer). # Environment: ROS_DOMAIN_ID (1..232, 1 when unset), DISPLAY, -# GOLEM_PREPARE_ONLY=1 (build msgs_ws and exit 0; docker_stack.sh), and the -# simulator's own knobs (docker-compose.yml, docker-compose.g1.yml). +# GOLEM_PREPARE_ONLY=1 (build msgs_ws and exit 0; docker_stack.sh), +# GOLEM_RENDER=gpu|cpu (MUJOCO_GL egl or osmesa; default gpu), and the +# simulator's own knobs (docker-compose.yml, docker-compose.g1.yml, +# docker-compose.mac.yml). # The simulator's topics are listed by its sensor modules (h12_sensors.py and # magpie_hand_bridge.py, or g1/g1_sensors.py) and CLAUDE.md §8. # Exit status: 1 on a refused domain; colcon's status when the msgs_ws build @@ -44,8 +46,14 @@ esac # EGL renders the RGBD cameras and the MID-360's rays offscreen on the GPU, needs # no display, and can render on the sensors' worker threads; the passive viewer -# opens its own GLFW window. -export MUJOCO_GL=egl +# opens its own GLFW window. GOLEM_RENDER=cpu (the Mac images, +# docker-compose.mac.yml) renders the cameras through OSMesa instead +# (sim_common.require_renderer). +if [ "${GOLEM_RENDER:-gpu}" = cpu ]; then + export MUJOCO_GL=osmesa +else + export MUJOCO_GL=egl +fi cd /home/code/golem_robocasa # -u: Compose reads stdout through a pipe, which would block-buffer print() and diff --git a/docs/MAC.md b/docs/MAC.md new file mode 100644 index 00000000..f8c22a79 --- /dev/null +++ b/docs/MAC.md @@ -0,0 +1,117 @@ +# The Mac (Apple Silicon) + +The stack's platform is x86 Linux with an NVIDIA GPU. An Apple Silicon Mac runs +a reduced RoboCasa sim of either robot: the command path (`golem_safety`, +`golem_upper_ik`), the legs (`golem_lowerbody_rl`) and walking on `/cmd_vel`. +It has no lidar, no navigation, no model servers or skills, and no Isaac sim. +Use it to develop and check controllers and bringup away from the lab +machines; the closed-loop tests (`tests/sim`, `tests/g1`) stay x86 gates. + +## What differs from x86 + +| | x86 + NVIDIA | Mac | +|---|---|---| +| Images | `golem_*:latest`, `docker/*Dockerfile` | `golem_*:arm64`, `docker/mac/*Dockerfile`, native arm64 | +| Python locks | `docker/locks/*-amd64*.txt` | `docker/locks/*-arm64*.txt`, derived from the amd64 locks by `docker/mac/derive_arm64_locks.sh` (CPU torch, no CUDA wheels, open3d 0.18.0) | +| Compose | `docker/docker-compose.yml` | the same, plus `docker/docker-compose.mac.yml` (no NVIDIA runtime) | +| Sim rendering | EGL on the GPU (`GOLEM_RENDER=gpu`) | OSMesa on the CPU (`GOLEM_RENDER=cpu`); cameras off by default (`GOLEM_CAMERAS=0`) | +| MID-360 lidar | on | none (`GOLEM_LIDAR=0`): its caster renders on the GPU | +| Bringup | `h12_sim`, `g1_sim` | `h12_mac_sim`, `g1_mac_sim`: the sim bringups without navigation, model servers or skills | +| Not available | — | Isaac, navigation and SLAM, `golem_skills`, the model servers (GraspGenX has no CPU path) | + +The wrappers pick the Mac by themselves on Darwin arm64 (`GOLEM_PLATFORM=mac`; +`GOLEM_PLATFORM=linux` forces the x86 path) and print +`platform: mac (arm64, CPU rendering, no lidar)` beside `robot:`. Nothing on +Linux changes: there the wrappers make the same docker calls as before. + +## Setup + +- [OrbStack](https://orbstack.dev) or Docker Desktop (4.34 or later, host + networking turned on), Compose 2.24 or later. Both containers share the Linux + VM's network, so DDS works between them; the macOS host is not on it, so run + `ros2` inside `golem_ros`. +- Submodules and LFS as in [Setup](SETUP.md) §1; `docker/.env` as in §2 + (`GEMINI_API_KEY` is not needed). +- About 70 GB of disk for the images (the RoboCasa image holds about 10 GB of + kitchen assets) and 8 GB of memory for the VM. + +```bash +docker/scripts/docker_build.sh # golem_base, golem_sim_robocasa, golem_ros, all :arm64 (about 35 min) +``` + +## Running + +```bash +# The G1: the sim plus g1_mac_sim; the leg node releases the band by itself +GOLEM_SPAWN_BACKOFF=2.0 docker/scripts/docker_stack.sh up robocasa --g1 +docker/scripts/docker_stack.sh logs robocasa # wait for "elastic band released" + +# The H1-2: the sim plus h12_mac_sim; the legs hold until the operator confirms +GOLEM_SPAWN_BACKOFF=2.0 docker/scripts/docker_stack.sh up robocasa --h12 +docker exec -it golem_ros bash +source /opt/ros/humble/setup.bash && source /home/code/core_ws/install/setup.bash +ros2 service call /lowerbody/confirm_engage std_srvs/srv/Trigger +ros2 topic pub -r 20 /cmd_vel geometry_msgs/msg/Twist "{linear: {x: 0.3}}" +ros2 action send_goal /named_config custom_ros_messages/action/NamedConfig \ + "{config_name: t_pose, plan: false, duration: {sec: 15, nanosec: 0}}" +``` + +`docker_stack.sh` runs a random kitchen task; with the arms out (`t_pose`) the +robot can touch a fixture, and the goal then fails its steady-state hold. The +three-terminal flow of [Running the stack](RUNNING.md) works too +(`docker_run.sh robocasa --g1 --task Blank`, then `ros2 launch golem_bringup +g1_mac_sim.launch.py` in `golem_ros`). + +## Measured speed + +Measured 2026-11-18 on a MacBook Air M3 (4 performance + 4 efficiency cores, +16 GB), OrbStack with 8 CPUs and 8 GB, headless, one run each. The real-time +factor (RTF) is sim seconds per wall second: the G1's from its +`[g1_mujoco] ... real-time factor` lines, the H1-2's from `--timing`, the +stacks' from `/clock` against wall time in `golem_ros`. + +**The sim alone** (no stack: motors off, unpaced, `GOLEM_SIM_RATE=max`): + +| Scene | G1 | H1-2 | +|---|---|---| +| Blank, no sensors | 9.1-10.0x | — | +| Kitchen (layout 9, style 9, seed 42), no sensors | 5.6x | 7.4x | +| Kitchen, cameras on (software rendering) | 5.3x (head camera drops frames due while one renders: about 10 frames per wall s) | 0.25x (three RGBD cameras, about 72 ms per colour render; the H1-2 sim waits for them) | + +**The whole stack at real time** (`docker_stack.sh`, `GOLEM_SIM_RATE` unset): + +| | G1 (`g1_mac_sim`) | H1-2 (`h12_mac_sim`) | +|---|---|---| +| RTF | 1.00 (sim loop idle 60-74%) | 0.95-0.99 | +| `/lowstate` | 500 Hz, largest gap 10-19 ms | 470-490 Hz, gaps up to 180 ms | +| Start-up | safety, legs pre-posed, arms, policy, band released: all as on x86 | safety, estop, legs pre-posed, arms, confirm, band released | +| Walking | 0.3 m/s forward, turning, arms moving while walking: no fall, no fault | stood 53 s after release, then fell: the estop latched (below) | +| Arms (`/named_config`, 15 s) | Blank scene: 8 of 8 goals succeed, standing and walking | not measured | +| CPU | sim about 0.4 core, ros about 1.8 cores | sim about 0.25 core, ros about 1.85 cores | + +For comparison, the x86 lab machine (i7-14700F, RTX 5070 Ti, sensors and +navigation on) runs the full stack at 0.83x (H1-2) and 1.00x (G1) +(`docs/superpowers/specs/2026-11-05-sim-speed-results.md`). + +**The H1-2 stack is not yet usable on the Mac.** Its stack stalls for up to +about 180 ms of wall time now and then. `estop_node` declares the sim's estop +stream stale after 0.1 s (`line_stale_timeout_sec`, the real robot's value), so +a stall latches `golem_safety`'s estop, the legs stop and the robot falls; in +the measured run that came 53 s after the band's release. The G1 has no estop +node and its stack's worst gap was 19 ms. Where the stalls come from (the VM's +scheduling or the heavier H1-2 ROS side) is not measured. + +## Image notes + +- The Mac base starts from a dated Ubuntu image older than the apt snapshot + (`ubuntu:jammy-20260901.2`): a newer one carries packages newer than the + snapshot, which apt cannot install over. +- The sims run the Unitree SDK's CycloneDDS beside ROS's in one process, each + creating the same DDS domain, which needs two separate `libddsc` copies. On + arm64 the SDK's binding would bind to ROS's copy by their shared soname and + segfault in its first topic, so the Mac base renames the SDK's copy + (`libddsc_unitree.so.0`) and checks the pair at build time + (`docker/mac/check_unitree_dds.py`). +- `core_ws/cyclonedds.xml` requires 16 MB UDP receive buffers, which the VM's + default `net.core.rmem_max` refuses (every node then fails to create its + domain); the Mac overlay's `CYCLONEDDS_URI` drops that minimum. diff --git a/docs/index.md b/docs/index.md index 54031a97..f3170959 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,6 +17,7 @@ including the `README.md` and `CLAUDE.md` developer guide, is at |---|---|---| | Unitree H1-2 (the default) | [Setup](SETUP.md), then [Running the stack](RUNNING.md) | x86 Linux with an NVIDIA GPU | | Unitree G1 | [The G1](g1/index.md), then [First real session](g1/first-session.md) for the real robot | x86 Linux with an NVIDIA GPU, RoboCasa simulator only | +| Either robot on an Apple Silicon Mac | [The Mac](MAC.md) | a reduced RoboCasa sim: no lidar, navigation or model servers | Both robots use the same images and the same setup. The wrappers in `docker/scripts/` run the H1-2 unless `--g1` or `GOLEM_ROBOT=g1` selects the G1. @@ -24,7 +25,7 @@ Both robots use the same images and the same setup. The wrappers in ## Pages - **Install and run:** [Setup](SETUP.md), [Running the stack](RUNNING.md), - [Navigation demo](NAVIGATION_DEMO.md). + [Navigation demo](NAVIGATION_DEMO.md), [The Mac](MAC.md). - **Debugging and testing:** [DDS tuning](DDS_TUNING.md), [Docker testing](DOCKER_TESTING.md). - **The G1:** [overview](g1/index.md), [packages](g1/packages.md), diff --git a/golem_robocasa/g1/g1_mujoco.py b/golem_robocasa/g1/g1_mujoco.py index ad1fd3b4..1e4773e6 100644 --- a/golem_robocasa/g1/g1_mujoco.py +++ b/golem_robocasa/g1/g1_mujoco.py @@ -296,8 +296,9 @@ def main(argv): args = sim_common.parse_args(parser, argv, "g1") task = sim_common.select_task(parser, args, tag="g1_mujoco", own_tasks=battery_env.TASKS + blank_env.TASKS, no_kitchen=blank_env.TASKS) - # The camera and the lidar's rays render through EGL on the GPU: stop here without one. - sim_common.require_gpu() + # The camera and the lidar's rays render through EGL on the GPU: stop here + # without one, unless GOLEM_RENDER=cpu renders on the CPU with no lidar. + sim_common.require_renderer() sim_loop(task, viewer=not args.headless, layout=args.layout, style=args.style, seed=args.seed, duration=args.duration) diff --git a/golem_robocasa/h12_mujoco.py b/golem_robocasa/h12_mujoco.py index 79bacd1b..a2fd414a 100644 --- a/golem_robocasa/h12_mujoco.py +++ b/golem_robocasa/h12_mujoco.py @@ -4,8 +4,9 @@ [--style N] [--seed N] [--timing | --duration S]. The robot is chosen (sim_common.select_robot) before the H1-2's imports, and --g1 hands the whole command line to g1.g1_mujoco.main. Each runner parses its command line, then -checks the GPU (sim_common.require_gpu: either sim stops there without one), so ---help and a usage error need no GPU; the H1-2 does both before its imports. The +checks the GPU (sim_common.require_renderer: either sim stops there without one, +unless GOLEM_RENDER=cpu renders on the CPU without the lidar), so --help and a +usage error need no GPU; the H1-2 does both before its imports. The H1-2's loop is sim_loop below. """ import argparse @@ -38,7 +39,7 @@ def _parser() -> argparse.ArgumentParser: sys.exit(g1_mujoco.main(sys.argv[1:])) _PARSER = _parser() _ARGS = sim_common.parse_args(_PARSER, sys.argv[1:], "h12") - sim_common.require_gpu() + sim_common.require_renderer() import os import threading @@ -287,6 +288,10 @@ def sim_loop(task, viewer=True, layout=None, style=None, seed=None, timing=False _hand_res = tuple(int(v) for v in (os.environ.get('GOLEM_HAND_CAMERA_RES', '').strip() or '256x256').lower().split('x')) _cameras = realsense_profile.camera_specs(model, _camera_names, _profile, _camera_scale, _hand_res) + # GOLEM_LIDAR=0 drops the MID-360 (/livox/*), as on the G1; GOLEM_RENDER=cpu + # needs it off (sim_common.require_renderer). + _lidar_on = sim_common.env_flag('GOLEM_LIDAR', True) + print(f"[h12_mujoco] MID-360 lidar {'ON' if _lidar_on else 'OFF (GOLEM_LIDAR=0)'}") _depth_on = sim_common.env_flag('GOLEM_CAMERA_DEPTH', True) _cloud_on = sim_common.env_flag('GOLEM_CAMERA_POINTCLOUD', True) print(f"[h12_mujoco] RGBD cameras {'ON' if _cameras_on else 'OFF (GOLEM_CAMERAS=0)'}" @@ -319,6 +324,7 @@ def sim_loop(task, viewer=True, layout=None, style=None, seed=None, timing=False lidar_self_prefixes=( (pfx, "gripper0_") if sim_common.env_flag("GOLEM_LIDAR_SELF_FILTER", True) else () ), + lidar=_lidar_on, sim_lock=sim_lock, timings=timings, ), @@ -370,8 +376,9 @@ def sim_loop(task, viewer=True, layout=None, style=None, seed=None, timing=False executor_thread = threading.Thread(target=executor.spin, daemon=True, name="ros_bridge_exec") executor_thread.start() print("[h12_mujoco] ROS bridges up: rt/lowstate+rt/lowcmd, /clock, " - "RGBD /realsense/{head,left_hand,right_hand}, livox lidar+imu, " - "/{left,right}/gripper/*, /elastic_band/toggle") + "RGBD /realsense/{head,left_hand,right_hand}, " + + ("livox lidar+imu, " if _lidar_on else "") + + "/{left,right}/gripper/*, /elastic_band/toggle") try: while True: if viewer and not handle.is_running(): diff --git a/golem_robocasa/h12_sensors.py b/golem_robocasa/h12_sensors.py index 6ace6e95..01b9f24f 100644 --- a/golem_robocasa/h12_sensors.py +++ b/golem_robocasa/h12_sensors.py @@ -304,6 +304,7 @@ def __init__( imu_acc_sensor: str = "livox_imu_acc", imu_rate_hz: float = 100.0, lidar_self_prefixes: tuple = (), + lidar: bool = True, sim_lock=None, timings=None, ): @@ -316,7 +317,9 @@ def __init__( lidar_exclude_body is the body it rides in, whose geoms the rays pass through; geoms of bodies named with a lidar_self_prefixes prefix give no return. The lidar's GPU caster raises RuntimeError when EGL fails to - render. Rates are Hz of sim time. + render. lidar False drops the MID-360 (/livox/lidar, /livox/pointcloud, + /livox/imu), as GOLEM_LIDAR=0 does, and makes no GPU caster. Rates are + Hz of sim time. """ self.node = node self.model = model @@ -358,20 +361,11 @@ def __init__( self._static_tf.sendTransform( [self._tf_msg(e, _sim_time_to_msg(float(data.time))) for e in self._camera_tf]) self._camera_tf_broadcaster = TransformBroadcaster(self.node) + self.lidar = bool(lidar) # Reliable, as FAST-LIO subscribes (laserMapping.cpp); a best-effort - # publisher would not match it. - self.pub_lidar = self.node.create_publisher( - CustomMsg, "/livox/lidar", - QoSProfile(reliability=ReliabilityPolicy.RELIABLE, - history=HistoryPolicy.KEEP_LAST, depth=20)) - self.pub_pc2 = self.node.create_publisher( - PointCloud2, "/livox/pointcloud", - QoSProfile(reliability=ReliabilityPolicy.RELIABLE, - history=HistoryPolicy.KEEP_LAST, depth=20)) - self.pub_imu = self.node.create_publisher( - Imu, "/livox/imu", - QoSProfile(reliability=ReliabilityPolicy.RELIABLE, - history=HistoryPolicy.KEEP_LAST, depth=10)) + # publisher would not match it. Without the lidar none is made. + if self.lidar: + self._make_livox_publishers() self.imu_period = 1.0 / imu_rate_hz self.imu_quat_adr, self.imu_quat_dim = self._sensor_adr(imu_quat_sensor) @@ -386,18 +380,34 @@ def __init__( self._last_imu_sim_t = 0.0 # The scan thread publishes both lidar topics; its GPU caster makes its # EGL context here, before the passive viewer's window exists. - self._lidar = _LidarScans(model, self.lidar_body_id, self.lidar_exclude_body_id, - self.geom_is_robot, LIVOX_FRAME, - self.pub_lidar.publish, self.pub_pc2.publish, - self.timings, sim_lock) - # The cameras render on a worker thread, through EGL, while physics runs. + self._lidar = (_LidarScans(model, self.lidar_body_id, self.lidar_exclude_body_id, + self.geom_is_robot, LIVOX_FRAME, + self.pub_lidar.publish, self.pub_pc2.publish, + self.timings, sim_lock) + if self.lidar else None) + # The cameras render on a worker thread, through MUJOCO_GL's backend, while physics runs. self._camera_worker = ThreadPoolExecutor(max_workers=1, thread_name_prefix="camera") self._camera_pending = None if self.cameras: - # Make the EGL context now: once the passive viewer's GLFW window + # Make the GL context now: once the passive viewer's GLFW window # exists, a new EGL context can no longer be made current. self._camera_worker.submit(self._ensure_renderer).result() + def _make_livox_publishers(self) -> None: + """Make the MID-360's /livox/lidar, /livox/pointcloud and /livox/imu publishers.""" + self.pub_lidar = self.node.create_publisher( + CustomMsg, "/livox/lidar", + QoSProfile(reliability=ReliabilityPolicy.RELIABLE, + history=HistoryPolicy.KEEP_LAST, depth=20)) + self.pub_pc2 = self.node.create_publisher( + PointCloud2, "/livox/pointcloud", + QoSProfile(reliability=ReliabilityPolicy.RELIABLE, + history=HistoryPolicy.KEEP_LAST, depth=20)) + self.pub_imu = self.node.create_publisher( + Imu, "/livox/imu", + QoSProfile(reliability=ReliabilityPolicy.RELIABLE, + history=HistoryPolicy.KEEP_LAST, depth=10)) + def _make_camera_pub(self, spec) -> _CameraPub: """Return a camera's MuJoCo ids, camera_info and publishers for the streams switched on.""" ids = [] @@ -491,7 +501,7 @@ def tick(self, sim_t: float, stamp: TimeMsg) -> None: with the state time, one physics step before sim_t (module docstring). Call it without holding sim_lock, on the thread that steps the physics. """ - if sim_t - self._last_imu_sim_t >= self.imu_period: + if self.lidar and sim_t - self._last_imu_sim_t >= self.imu_period: self._last_imu_sim_t = sim_t try: self._publish_imu(stamp) @@ -510,6 +520,8 @@ def tick(self, sim_t: float, stamp: TimeMsg) -> None: except Exception as e: self.get_logger().warn(f"camera publish failed: {e}") + if self._lidar is None: + return try: self._lidar.tick(self.data, sim_t - self.model.opt.timestep) except Exception as e: diff --git a/golem_robocasa/sim_common.py b/golem_robocasa/sim_common.py index db3cfb52..879649b8 100644 --- a/golem_robocasa/sim_common.py +++ b/golem_robocasa/sim_common.py @@ -1,4 +1,4 @@ -"""Select the robot, check the GPU, parse the command line and the sims' knobs, resolve tasks and frame the viewer for both sims. +"""Select the robot, check the renderer, parse the command line and the sims' knobs, resolve tasks and frame the viewer for both sims. It imports only the standard library at module level (mujoco and robocasa inside the functions that need them): h12_mujoco.py picks the robot and checks @@ -30,6 +30,10 @@ GPU_REQUIRED = "the RoboCasa sims need an NVIDIA GPU, rendering through EGL (MUJOCO_GL=egl)" # GL_RENDERER substrings of software rasterisers, which EGL falls back to without a GPU. SOFTWARE_RENDERERS = ("llvmpipe", "softpipe", "swrast", "software", "swiftshader") +# GOLEM_RENDER's values: gpu (the default) checks for the GPU above; cpu renders the +# cameras through OSMesa and has no MID-360, whose caster (mid360.GpuCaster) is EGL-only. +# The Mac images set cpu (docker/docker-compose.mac.yml). +RENDER_MODES = ("gpu", "cpu") def add_robot_args(parser: argparse.ArgumentParser) -> None: @@ -96,6 +100,37 @@ def require_gpu(probe: Callable[[], str] = egl_renderer) -> str: return renderer +def render_mode(env: Mapping[str, str] = os.environ) -> str: + """Return GOLEM_RENDER, gpu or cpu in any case; unset or empty is gpu. Exits for any other value.""" + raw = env.get("GOLEM_RENDER", "") + mode = raw.strip().lower() or "gpu" + if mode not in RENDER_MODES: + sys.exit(f"GOLEM_RENDER must be gpu or cpu, not {raw!r}") + return mode + + +def require_renderer(env: Mapping[str, str] = os.environ, + probe: Callable[[], str] = egl_renderer) -> str: + """Check the sim can render as GOLEM_RENDER asks, logging how; return the mode. + + gpu: require_gpu(probe), which exits without an NVIDIA GPU on EGL. cpu: exits unless + MUJOCO_GL is osmesa and GOLEM_LIDAR is off, since the MID-360 casts its rays on the GPU. + """ + mode = render_mode(env) + if mode == "gpu": + require_gpu(probe) + return mode + backend = env.get("MUJOCO_GL", "") + if backend.strip().lower() != "osmesa": + sys.exit(f"GOLEM_RENDER=cpu renders through OSMesa: MUJOCO_GL must be osmesa, not {backend!r}") + if env_flag("GOLEM_LIDAR", True, env): + sys.exit("GOLEM_RENDER=cpu has no MID-360 (its rays render through EGL on a GPU): " + "set GOLEM_LIDAR=0") + print("[sim_common] rendering on the CPU through OSMesa (GOLEM_RENDER=cpu); no MID-360", + flush=True) + return mode + + def env_flag(name: str, default: bool, env: Mapping[str, str] = os.environ) -> bool: """Return the on/off knob name: default when unset or empty, off for 0/off/false/no in any case, else on.""" raw = env.get(name, "").strip().lower() diff --git a/mkdocs.yml b/mkdocs.yml index 6b6ca4a0..5734e774 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -57,6 +57,7 @@ nav: - Setup: SETUP.md - Running the stack: RUNNING.md - Navigation demo: NAVIGATION_DEMO.md + - The Mac: MAC.md - Debugging and testing: - DDS tuning: DDS_TUNING.md - Docker testing: DOCKER_TESTING.md diff --git a/tests/docker/test_source_pins.py b/tests/docker/test_source_pins.py index 2e494e52..882249a5 100644 --- a/tests/docker/test_source_pins.py +++ b/tests/docker/test_source_pins.py @@ -1,10 +1,14 @@ """Check that every image builds from pinned inputs: base digests, commits and locked Python packages.""" from pathlib import Path import re +import shutil +import subprocess +import tempfile import unittest ROOT = Path(__file__).resolve().parents[2] -FILES = sorted((ROOT / 'docker').glob('*Dockerfile')) +# The x86 images' Dockerfiles and the Mac (arm64) twins of docker/mac/. +FILES = sorted((ROOT / 'docker').glob('*Dockerfile')) + sorted((ROOT / 'docker/mac').glob('*Dockerfile')) class SourcePinTests(unittest.TestCase): """Check the Dockerfiles' base images, clones and downloads are pinned.""" @@ -38,7 +42,8 @@ def test_every_image_builds_livox_sdk2_at_one_commit(self): if 'Livox-SDK2.git' in run: pin = re.search(r'checkout(?: --quiet)? ([0-9a-f]{40})\b', run) refs[path.relative_to(ROOT).as_posix()] = pin and pin.group(1) - self.assertLessEqual({'docker/RosDockerfile', 'docker/RobocasaDockerfile'}, set(refs)) + self.assertLessEqual({'docker/RosDockerfile', 'docker/RobocasaDockerfile', + 'docker/mac/RosDockerfile', 'docker/mac/RobocasaDockerfile'}, set(refs)) self.assertEqual(len(set(refs.values())), 1, refs) def test_robocasa_patches_name_the_pinned_checkouts(self): @@ -105,6 +110,42 @@ def test_downloaded_scripts_do_not_follow_moving_refs(self): self.assertNotIn('https://astral.sh/uv/install.sh', text, str(path)) self.assertNotIn('ros/rosdistro/master/ros.key', text, str(path)) +class MacImageTests(unittest.TestCase): + """Check the Mac images keep to the arm64 locks and match the x86 images' pins.""" + + def test_each_platform_installs_through_its_own_locks(self): + """The x86 Dockerfiles name only amd64 locks and the Mac ones only arm64 locks.""" + for path in FILES: + arch = 'arm64' if path.parent.name == 'mac' else 'amd64' + other = 'amd64' if arch == 'arm64' else 'arm64' + text = path.read_text() + self.assertNotIn(f'-{other}', ''.join(re.findall(r'docker/locks/\S+|/opt/golem-locks/\S+', text)), + str(path)) + + def test_mac_images_check_out_the_x86_commits(self): + """Each Mac Dockerfile clones the same commits as its x86 twin, the GPU-only clones of the ROS image aside.""" + for name in ('BaseDockerfile', 'RosDockerfile', 'RobocasaDockerfile'): + x86 = set(re.findall(r'\b[0-9a-f]{40}\b', (ROOT / 'docker' / name).read_text())) + mac = set(re.findall(r'\b[0-9a-f]{40}\b', (ROOT / 'docker/mac' / name).read_text())) + self.assertLessEqual(mac, x86, name) + + def test_arm64_locks_are_derived_from_the_amd64_locks(self): + """Every arm64 lock is what docker/mac/derive_arm64_locks.sh writes from its amd64 twin.""" + with tempfile.TemporaryDirectory() as tmp: + locks = Path(tmp) / 'docker/locks' + shutil.copytree(ROOT / 'docker/locks', locks) + for path in locks.glob('*-arm64*.txt'): + path.unlink() + (Path(tmp) / 'docker/mac').mkdir() + shutil.copy(ROOT / 'docker/mac/derive_arm64_locks.sh', Path(tmp) / 'docker/mac') + subprocess.run(['bash', str(Path(tmp) / 'docker/mac/derive_arm64_locks.sh')], check=True) + derived = sorted(p.name for p in locks.glob('*-arm64*.txt')) + committed = sorted(p.name for p in (ROOT / 'docker/locks').glob('*-arm64*.txt')) + self.assertEqual(derived, committed) + for name in derived: + self.assertEqual((locks / name).read_text(), (ROOT / 'docker/locks' / name).read_text(), name) + + class PythonLockTests(unittest.TestCase): """Check every pip install goes through a committed lock file of exact pins.""" diff --git a/tests/docker/test_workflows.py b/tests/docker/test_workflows.py index 4d3600ba..bcb48efc 100644 --- a/tests/docker/test_workflows.py +++ b/tests/docker/test_workflows.py @@ -55,6 +55,9 @@ def setUp(self): self.env.update(PATH=str(self.bin) + ':' + os.environ['PATH'], CALLS=str(self.root / 'calls'), DISPLAY='') # The host's own CPUs must not change what a test sees; the pinning tests turn it on. self.env['GOLEM_CPU_PINNING'] = '0' + # Nor the host's platform: every test runs the Linux path but the Mac ones, which + # set GOLEM_PLATFORM=mac. + self.env['GOLEM_PLATFORM'] = 'linux' def run_script(self, path, *args, **env): """Run a script of the fixture checkout with `env` added to the environment.""" @@ -692,6 +695,91 @@ def test_stack_g1_selects_the_g1_sim_launch(self): 'GOLEM_BRINGUP_LAUNCH': 'g1_sim.launch.py'}) self.assertEqual(r.stderr.count('robot: g1'), 1) + def mac_overlay(self): + """Return the fixture's Mac compose overlay path.""" + return str(self.root / 'docker/docker-compose.mac.yml') + + def test_linux_never_adds_the_mac_overlay(self): + """On Linux no wrapper adds docker-compose.mac.yml or prints a platform line.""" + for args in (('docker/scripts/docker_run.sh', 'robocasa'), ('docker/scripts/docker_run.sh', 'ros'), + ('docker/scripts/docker_stack.sh', 'up', 'robocasa', '--headless'), + ('docker/scripts/docker_build.sh', 'robocasa', 'ros')): + with self.subTest(args=args): + r = self.run_script(*args) + self.assertEqual(r.returncode, 0, r.stderr) + self.assertFalse(any(self.mac_overlay() in c for c in self.calls())) + self.assertNotIn('platform:', r.stderr) + + def test_mac_adds_the_mac_overlay_to_every_compose_call(self): + """On the Mac every compose call of docker_run.sh carries docker-compose.mac.yml, after the base file.""" + for service in ('robocasa', 'ros'): + with self.subTest(service=service): + r = self.run_script('docker/scripts/docker_run.sh', service, GOLEM_PLATFORM='mac') + self.assertEqual(r.returncode, 0, r.stderr) + files = self.compose_files(self.run_calls()[-1]) + self.assertEqual(files[:2], [str(self.root / 'docker/docker-compose.yml'), self.mac_overlay()]) + self.assertIn('platform: mac', r.stderr) + + def test_mac_detected_from_the_host(self): + """Without GOLEM_PLATFORM the wrappers pick mac on Darwin arm64 and linux elsewhere.""" + uname = self.bin / 'uname' + uname.write_text('#!/bin/sh\ncase "$1" in -s) echo "$FAKE_S";; -m) echo "$FAKE_M";; esac\n') + uname.chmod(0o755) + env = {k: v for k, v in self.env.items() if k != 'GOLEM_PLATFORM'} + for system, machine, mac in (('Darwin', 'arm64', True), ('Darwin', 'x86_64', False), + ('Linux', 'x86_64', False), ('Linux', 'aarch64', False)): + with self.subTest(system=system, machine=machine): + (self.root / 'calls').unlink(missing_ok=True) + r = subprocess.run(['bash', str(self.root / 'docker/scripts/docker_run.sh'), 'ros'], + cwd='/tmp', env=dict(env, FAKE_S=system, FAKE_M=machine), + text=True, capture_output=True) + self.assertEqual(r.returncode, 0, r.stderr) + self.assertEqual(self.mac_overlay() in self.compose_files(self.run_calls()[-1]), mac) + + def test_mac_refuses_isaac(self): + """The Mac refuses the Isaac sim in every wrapper, before compose or a build runs.""" + for args in (('docker/scripts/docker_run.sh', 'isaac'), + ('docker/scripts/docker_stack.sh', 'up', 'isaac', '--headless'), + ('docker/scripts/docker_build.sh', 'isaac')): + with self.subTest(args=args): + r = self.run_script(*args, GOLEM_PLATFORM='mac') + self.assertNotEqual(r.returncode, 0) + self.assertIn('Isaac', r.stderr) + self.assertFalse(self.calls()) + + def test_mac_builds_the_arm64_base_and_no_isaac(self): + """docker_build.sh on the Mac builds golem_base:arm64 from docker/mac/ and, by default, robocasa and ros only.""" + r = self.run_script('docker/scripts/docker_build.sh', GOLEM_PLATFORM='mac') + self.assertEqual(r.returncode, 0, r.stderr) + builds = [c for c in self.calls() if 'build' in c] + self.assertIn('linux/arm64', builds[0]) + self.assertIn('golem_base:arm64', builds[0]) + self.assertIn('docker/mac/BaseDockerfile', builds[0]) + self.assertEqual(builds[-1][-2:], ['robocasa', 'ros']) + self.assertIn(self.mac_overlay(), self.compose_files(builds[-1])) + + def test_mac_stack_starts_the_mac_bringups(self): + """docker_stack.sh on the Mac starts h12_mac_sim.launch.py, or g1_mac_sim.launch.py with --g1.""" + self.install_env_recording_docker() + for flag, robot in (('--h12', 'h12'), ('--g1', 'g1')): + with self.subTest(robot=robot): + for name in ('calls', 'calls.env'): + (self.root / name).unlink(missing_ok=True) + r = self.run_script('docker/scripts/docker_stack.sh', 'up', 'robocasa', flag, + GOLEM_PLATFORM='mac', GOLEM_BRINGUP_LAUNCH='h12_sim.launch.py') + self.assertEqual(r.returncode, 0, r.stderr) + self.assertEqual(self.stack_up_env(), {'GOLEM_ROBOT': robot, + 'GOLEM_BRINGUP_LAUNCH': f'{robot}_mac_sim.launch.py'}) + for call in self.compose_calls(): + self.assertIn(self.mac_overlay(), self.compose_files(call)) + + def test_bad_platform_is_refused(self): + """A GOLEM_PLATFORM other than linux or mac is refused before compose runs.""" + r = self.run_script('docker/scripts/docker_run.sh', 'ros', GOLEM_PLATFORM='windows') + self.assertNotEqual(r.returncode, 0) + self.assertIn('GOLEM_PLATFORM must be linux or mac', r.stderr) + self.assertFalse(self.calls()) + def test_stack_g1_overrides_leftover_bringup_selection(self): """--g1 starts g1_sim.launch.py even when the shell and docker/.env name the H1-2's launch.""" self.install_env_recording_docker() diff --git a/tests/robocasa/test_gpu_required.py b/tests/robocasa/test_gpu_required.py index 2a0c5145..69f212b9 100644 --- a/tests/robocasa/test_gpu_required.py +++ b/tests/robocasa/test_gpu_required.py @@ -1,5 +1,8 @@ """Check that the RoboCasa sims stop at start, with one message, without a GPU to render on through EGL. +GOLEM_RENDER=cpu (the Mac images) is the one way past the check: it renders through OSMesa +and needs GOLEM_LIDAR=0 (RenderModeTests). + sim_common.egl_renderer() is the probe and sim_common.require_gpu() the stop. The probe is made to fail three ways: a failing probe passed in, MuJoCo not on EGL (MUJOCO_GL=osmesa) and Mesa's software EGL in place of NVIDIA's, the last two in h12_mujoco.py run as a subprocess for each @@ -49,6 +52,48 @@ def test_the_probe_refuses_mujoco_off_egl(self): sim_common.egl_renderer({"MUJOCO_GL": value}) +class RenderModeTests(unittest.TestCase): + """Check GOLEM_RENDER: gpu (the default) keeps the GPU check; cpu needs OSMesa and no lidar.""" + + def test_unset_or_empty_is_gpu(self): + """GOLEM_RENDER unset, empty or blank is gpu, the default.""" + for env in ({}, {"GOLEM_RENDER": ""}, {"GOLEM_RENDER": " "}): + with self.subTest(env=env): + self.assertEqual(sim_common.render_mode(env), "gpu") + + def test_a_bad_value_stops_the_sim(self): + """A GOLEM_RENDER other than gpu or cpu stops the sim, naming the knob.""" + with self.assertRaises(SystemExit) as caught: + sim_common.render_mode({"GOLEM_RENDER": "metal"}) + self.assertIn("GOLEM_RENDER must be gpu or cpu", caught.exception.code) + + def test_gpu_mode_still_requires_the_gpu(self): + """By default require_renderer() runs the GPU check, and a failing probe still stops the sim.""" + def probe(): + """Fail as the probe does with MuJoCo off EGL.""" + raise RuntimeError("MUJOCO_GL is 'osmesa', not 'egl'") + + with self.assertRaises(SystemExit) as caught: + sim_common.require_renderer({"MUJOCO_GL": "osmesa"}, probe) + self.assertTrue(caught.exception.code.startswith(sim_common.GPU_REQUIRED)) + + def test_cpu_mode_needs_osmesa_and_no_lidar(self): + """GOLEM_RENDER=cpu passes with MUJOCO_GL=osmesa and GOLEM_LIDAR=0, and refuses either missing.""" + def probe(): + """Fail: cpu mode must not probe the GPU.""" + raise AssertionError("probed the GPU") + + ok = {"GOLEM_RENDER": "CPU", "MUJOCO_GL": "osmesa", "GOLEM_LIDAR": "0"} + self.assertEqual(sim_common.require_renderer(ok, probe), "cpu") + for change, reason in (({"MUJOCO_GL": "egl"}, "MUJOCO_GL must be osmesa"), + ({"GOLEM_LIDAR": ""}, "GOLEM_LIDAR=0"), + ({"GOLEM_LIDAR": "1"}, "GOLEM_LIDAR=0")): + with self.subTest(change=change): + with self.assertRaises(SystemExit) as caught: + sim_common.require_renderer(dict(ok, **change), probe) + self.assertIn(reason, caught.exception.code) + + class SimStartTests(unittest.TestCase): """Run each robot's sim with the probe made to fail and check it stops at start.""" @@ -58,8 +103,11 @@ def start(self, robot, *args, **env): Returns the CompletedProcess. """ args = args or ("--headless", "--task", "Blank") + # The render knobs are the test's own: the Mac images set GOLEM_RENDER=cpu and + # GOLEM_LIDAR=0 (docker-compose.mac.yml), and these tests check the default, gpu. + base = {k: v for k, v in os.environ.items() if k not in ("GOLEM_RENDER", "GOLEM_LIDAR")} r = subprocess.run([sys.executable, "-u", SIM, f"--{robot}", *args], - capture_output=True, text=True, env=dict(os.environ, **env), + capture_output=True, text=True, env=dict(base, **env), timeout=START_TIMEOUT_S, cwd=os.path.dirname(SIM)) print(f"\n {robot}: exit {r.returncode}: {r.stderr.strip().splitlines()[-1:] or r.stdout[-300:]}") return r @@ -92,6 +140,15 @@ def test_without_egl_both_sims_stop_at_start(self): with self.subTest(robot=robot): self.assert_refused(self.start(robot, MUJOCO_GL="osmesa"), "MUJOCO_GL is 'osmesa'") + def test_cpu_rendering_with_the_lidar_on_stops_both_sims_at_start(self): + """GOLEM_RENDER=cpu without GOLEM_LIDAR=0 stops either robot's sim at start, before its kitchen.""" + for robot in ("h12", "g1"): + with self.subTest(robot=robot): + r = self.start(robot, MUJOCO_GL="osmesa", GOLEM_RENDER="cpu", GOLEM_LIDAR="1") + self.assertEqual(r.returncode, 1, (r.stdout + r.stderr)[-2000:]) + self.assertIn("set GOLEM_LIDAR=0", r.stderr.strip().splitlines()[-1]) + self.assertNotIn("RoboCasa task", r.stdout) + def test_on_mesas_software_egl_both_sims_stop_at_start(self): """With only Mesa's EGL, which renders in software, either robot's sim stops at start.""" if not os.path.exists(MESA_EGL_VENDOR): From 812d04c48a01162d426c963b010e757c4601ee8c Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 18 Nov 2026 20:05:54 -0700 Subject: [PATCH 2/7] Cast the MID-360 on the CPU on the Mac, so both robots navigate there GOLEM_RENDER=cpu (the Mac images) now casts the lidar's rays exactly on the CPU with mid360.CpuCaster (mj_multiRay, restored from before fb3c033) instead of refusing the lidar; mid360.make_caster picks the caster by GOLEM_RENDER, and gpu, the default, still builds GpuCaster. The Mac keeps the lidar off by default (GOLEM_LIDAR=0); GOLEM_LIDAR=1 turns it on in the sim, and h12_mac_sim and g1_mac_sim default use_nav to it, so FAST-LIO, SLAM and Nav2 run exactly when the sim has a lidar. Tests: test_mid360_cpu.py (CpuCaster against mj_ray, ray for ray; make_caster), the cpu render mode with the lidar on, and the mac bringups' navigation with and without GOLEM_LIDAR. docs/MAC.md records both robots reaching Nav2 goals on an M3. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 12 +- .../launch/g1/g1_mac_sim.launch.py | 19 ++- .../launch/h12/h12_mac_sim.launch.py | 21 ++- .../src/golem_bringup/test/test_sim_time.py | 17 ++- docker/docker-compose.mac.yml | 16 ++- docker/mac/RobocasaDockerfile | 2 +- docker/scripts/docker_common.sh | 2 +- docker/scripts/docker_run.sh | 2 +- docker/scripts/docker_stack.sh | 6 +- docs/MAC.md | 35 ++++- golem_robocasa/g1/g1_lidar.py | 10 +- golem_robocasa/g1/g1_sensors.py | 5 +- golem_robocasa/h12_sensors.py | 9 +- golem_robocasa/mid360.py | 135 +++++++++++++++++- golem_robocasa/sim_common.py | 13 +- tests/robocasa/test_gpu_required.py | 31 ++-- tests/robocasa/test_mid360_cpu.py | 113 +++++++++++++++ 17 files changed, 368 insertions(+), 80 deletions(-) create mode 100644 tests/robocasa/test_mid360_cpu.py diff --git a/CLAUDE.md b/CLAUDE.md index 404a4324..f8d0808a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -34,8 +34,8 @@ against its sim and the real robot, so code moves between them unchanged. The G1 runs in Unitree's debug mode: Unitree's own controller is released, and the stack drives every motor on `rt/lowcmd`, as on the H1-2. The stack runs on one platform, x86 Linux with an NVIDIA GPU. An Apple Silicon Mac runs a reduced -RoboCasa sim of either robot (no lidar, navigation, model servers or Isaac): -`docs/MAC.md`. +RoboCasa sim of either robot (no model servers or Isaac; the lidar, cast on the +CPU, and navigation only with `GOLEM_LIDAR=1`): `docs/MAC.md`. The H1-2 is the default everywhere. `GOLEM_ROBOT=g1` or `--g1` on a simulator or stack wrapper selects the G1 where the attached robot matters: the sim and @@ -94,7 +94,7 @@ launch bringup**. `docker/scripts/docker_common.sh` owns this, and the platform too: on Darwin arm64 (or `GOLEM_PLATFORM=mac`) every wrapper adds `docker-compose.mac.yml` (the arm64 images of `docker/mac/`, no NVIDIA runtime, `GOLEM_RENDER=cpu`, -`GOLEM_LIDAR=0`), refuses Isaac, and `docker_stack.sh` starts `h12_mac_sim` or +`GOLEM_LIDAR=0` unless set), refuses Isaac, and `docker_stack.sh` starts `h12_mac_sim` or `g1_mac_sim`; on Linux nothing changes (`docs/MAC.md`). On simulator and stack wrappers, the robot is `--g1`/`--h12` on the wrapper, else `GOLEM_ROBOT` from the shell, else from `docker/.env`, else `h12`. The selection means "which robot is @@ -526,9 +526,9 @@ sims render their cameras and the MID-360's rays through EGL on an NVIDIA GPU: without one (MuJoCo not on EGL, no EGL device, a software renderer) the sim stops at start, once its command line is parsed and before it builds a scene or starts ROS or DDS, with one message (`sim_common.require_gpu`). The one way past -it is the Mac images' opt-in `GOLEM_RENDER=cpu` (OSMesa, and only with -`GOLEM_LIDAR=0`, which the H1-2 sim honours as the G1's does; -`sim_common.require_renderer`). The H1-2 +it is the Mac images' opt-in `GOLEM_RENDER=cpu` (OSMesa for the cameras, the +MID-360 cast exactly on the CPU by `mid360.CpuCaster`; `sim_common.require_renderer`, +`mid360.make_caster`). The H1-2 sim honours `GOLEM_LIDAR=0` as the G1's does. The H1-2 stays the default, and nothing on the G1 path may change its behaviour. The robots share `sim_common.py`, `measurement_bridge.py`, the pacer in `sim_timing.py` (its `--timing` report is the H1-2's only) and the `mujoco_sensors` node in diff --git a/core_ws/src/golem_bringup/launch/g1/g1_mac_sim.launch.py b/core_ws/src/golem_bringup/launch/g1/g1_mac_sim.launch.py index b1847334..1a4486bc 100644 --- a/core_ws/src/golem_bringup/launch/g1/g1_mac_sim.launch.py +++ b/core_ws/src/golem_bringup/launch/g1/g1_mac_sim.launch.py @@ -1,10 +1,12 @@ """ -Start the G1 against the Mac's RoboCasa sim: g1_sim without navigation or skills. +Start the G1 against the Mac's RoboCasa sim: g1_sim without skills. ros2 launch golem_bringup g1_mac_sim.launch.py [use_hands:=false] [use_rviz:=false] -The Mac sim (docker/docker-compose.mac.yml, docs/MAC.md) renders on the CPU and has no -MID-360, so this includes g1_sim.launch.py with use_nav and use_skills false. Everything +The Mac sim (docker/docker-compose.mac.yml, docs/MAC.md) renders on the CPU and casts its +MID-360 on the CPU only with GOLEM_LIDAR=1, so this includes g1_sim.launch.py with +use_skills false and use_nav as given: by default GOLEM_LIDAR (0 or 1, from +docker-compose.mac.yml), so navigation runs exactly when the sim has its lidar. Everything else is g1_sim's: g1_core with sim:=true (golem_safety and the controller on sim_split, the leg node running HOMIE, which releases the sim's elastic band once the policy runs), the Dex3-1 hand driver (use_hands) and, with use_rviz, RViz. @@ -16,21 +18,26 @@ from golem_bringup.include import include from launch import LaunchDescription from launch.actions import DeclareLaunchArgument -from launch.substitutions import LaunchConfiguration +from launch.substitutions import EnvironmentVariable, LaunchConfiguration def generate_launch_description(): - """Declare the Mac bringup's arguments and include g1_sim without nav or skills.""" + """Declare the Mac bringup's arguments and include g1_sim without skills.""" return LaunchDescription([ DeclareLaunchArgument('use_rviz', default_value='false', description='true: start RViz (needs a display in golem_ros)'), DeclareLaunchArgument('use_hands', default_value='true', description='true: start dex3_hands, the Dex3-1 hand driver'), + DeclareLaunchArgument('use_nav', default_value=EnvironmentVariable('GOLEM_LIDAR', + default_value='0'), + description="true or 1: golem_slam's FAST-LIO, SLAM and Nav2 " + "on the sim's CPU-cast MID-360 (needs GOLEM_LIDAR=1 " + 'on the sim); default: GOLEM_LIDAR, else 0'), # The whole G1 sim bringup, without the parts the Mac cannot run. include('golem_bringup', 'g1/g1_sim.launch.py', { 'use_rviz': LaunchConfiguration('use_rviz'), 'use_hands': LaunchConfiguration('use_hands'), - 'use_nav': 'false', + 'use_nav': LaunchConfiguration('use_nav'), 'use_skills': 'false', }), ]) diff --git a/core_ws/src/golem_bringup/launch/h12/h12_mac_sim.launch.py b/core_ws/src/golem_bringup/launch/h12/h12_mac_sim.launch.py index 2260f7c4..94d82a1f 100644 --- a/core_ws/src/golem_bringup/launch/h12/h12_mac_sim.launch.py +++ b/core_ws/src/golem_bringup/launch/h12/h12_mac_sim.launch.py @@ -1,11 +1,13 @@ """ -Start the H1-2 against the Mac's RoboCasa sim: h12_sim without navigation or model servers. +Start the H1-2 against the Mac's RoboCasa sim: h12_sim without model servers or skills. ros2 launch golem_bringup h12_mac_sim.launch.py [policy:=almi] [use_rviz:=false] -The Mac sim (docker/docker-compose.mac.yml, docs/MAC.md) renders on the CPU and has no -MID-360, and the Mac's golem_ros image has no model-server stack, so this includes -h12_sim.launch.py with use_nav, use_vision and use_skills false. Everything else is +The Mac sim (docker/docker-compose.mac.yml, docs/MAC.md) renders on the CPU and casts its +MID-360 on the CPU only with GOLEM_LIDAR=1, and the Mac's golem_ros image has no +model-server stack, so this includes h12_sim.launch.py with use_vision and use_skills false +and use_nav as given: by default GOLEM_LIDAR (0 or 1, from docker-compose.mac.yml), so +navigation runs exactly when the sim has its lidar. Everything else is h12_sim's, in its order: the leg node's check first, then the state publishers, the command path (estop_node on the sim's estop box, safety_node, frame_task_server), the legs and, with use_rviz, RViz. @@ -22,22 +24,27 @@ from golem_bringup.include import include from launch import LaunchDescription from launch.actions import DeclareLaunchArgument -from launch.substitutions import LaunchConfiguration +from launch.substitutions import EnvironmentVariable, LaunchConfiguration def generate_launch_description(): - """Declare the Mac bringup's arguments and include h12_sim without nav or vision.""" + """Declare the Mac bringup's arguments and include h12_sim without vision.""" return LaunchDescription([ DeclareLaunchArgument('use_rviz', default_value='false', description='true: start RViz (needs a display in golem_ros)'), DeclareLaunchArgument('policy', default_value='almi', description='The policy golem_lowerbody_rl runs on the legs: ' 'almi, fame or walk; any other is refused'), + DeclareLaunchArgument('use_nav', default_value=EnvironmentVariable('GOLEM_LIDAR', + default_value='0'), + description="true or 1: golem_slam's FAST-LIO, SLAM and Nav2 " + "on the sim's CPU-cast MID-360 (needs GOLEM_LIDAR=1 " + 'on the sim); default: GOLEM_LIDAR, else 0'), # The whole H1-2 sim bringup, without the parts the Mac cannot run. include('golem_bringup', 'h12/h12_sim.launch.py', { 'use_rviz': LaunchConfiguration('use_rviz'), 'policy': LaunchConfiguration('policy'), - 'use_nav': 'false', + 'use_nav': LaunchConfiguration('use_nav'), 'use_vision': 'false', 'use_skills': 'false', }), diff --git a/core_ws/src/golem_bringup/test/test_sim_time.py b/core_ws/src/golem_bringup/test/test_sim_time.py index ada592b3..eb7ca9e6 100644 --- a/core_ws/src/golem_bringup/test/test_sim_time.py +++ b/core_ws/src/golem_bringup/test/test_sim_time.py @@ -32,8 +32,8 @@ ('lmg_sim.launch.py', {'start_position_verified': 'true', 'use_slam': 'true', 'use_skills': 'true'}, True), ('g1_sim.launch.py', {'use_skills': 'true', 'use_nav': 'true', 'use_rviz': 'true'}, True), - ('h12_mac_sim.launch.py', {'use_rviz': 'true'}, True), - ('g1_mac_sim.launch.py', {'use_rviz': 'true'}, True), + ('h12_mac_sim.launch.py', {'use_rviz': 'true', 'use_nav': 'true'}, True), + ('g1_mac_sim.launch.py', {'use_rviz': 'true', 'use_nav': 'true'}, True), ('h12_real_robot.launch.py', {'start_position_verified': 'true'}, False), ('lmg_real.launch.py', {'start_position_verified': 'true'}, False), ('h12_real_desktop.launch.py', {'use_hand_cameras': 'true'}, False), @@ -155,8 +155,9 @@ def _packages(launch_file, args): ]) def test_mac_sim_is_the_sim_bringup_without_nav_or_vision(mac_file, sim_file, sim_args, core, monkeypatch): - """A Mac sim bringup starts its sim bringup's command path and legs, no nav or vision node.""" + """Without GOLEM_LIDAR a Mac sim bringup starts its command path and legs, no nav or vision.""" monkeypatch.setenv('ROS_DOMAIN_ID', SIM_DOMAIN) + monkeypatch.delenv('GOLEM_LIDAR', raising=False) mac = _packages(mac_file, {}) assert core <= mac, mac assert mac.isdisjoint(NAV_AND_VISION), mac & set(NAV_AND_VISION) @@ -169,3 +170,13 @@ def test_h12_sim_defaults_keep_nav_and_vision(monkeypatch): monkeypatch.setenv('ROS_DOMAIN_ID', SIM_DOMAIN) packages = _packages('h12_sim.launch.py', {}) assert {'fast_lio', 'model_server', 'golem_skills'} <= packages, packages + + +@pytest.mark.parametrize('mac_file', ['h12_mac_sim.launch.py', 'g1_mac_sim.launch.py']) +def test_mac_sim_navigates_when_the_sim_has_its_lidar(mac_file, monkeypatch): + """GOLEM_LIDAR=1 (the sim casts its MID-360 on the CPU) adds navigation, still no vision.""" + monkeypatch.setenv('ROS_DOMAIN_ID', SIM_DOMAIN) + monkeypatch.setenv('GOLEM_LIDAR', '1') + packages = _packages(mac_file, {}) + assert {'fast_lio', 'golem_slam', 'slam_toolbox'} <= packages, packages + assert packages.isdisjoint({'model_server', 'golem_skills'}), packages diff --git a/docker/docker-compose.mac.yml b/docker/docker-compose.mac.yml index ccbc6ff4..85a0e3d4 100644 --- a/docker/docker-compose.mac.yml +++ b/docker/docker-compose.mac.yml @@ -7,7 +7,8 @@ # OrbStack or Docker Desktop (host networking on) both containers share the # Linux VM's network, so DDS between them works; the macOS host is not on it, # so ros2 and RViz run inside golem_ros. docs/MAC.md has the flow and what the -# Mac sims leave out (lidar, navigation, the GPU vision models, Isaac). +# Mac sims leave out (the GPU vision models, Isaac; the lidar and navigation +# only with GOLEM_LIDAR=1). services: robocasa: build: @@ -19,12 +20,13 @@ services: # 2 GB of /dev/shm: the base file's 16 GB exceeds a laptop VM's memory. shm_size: 2g environment: - # gpu (the sims' default, an NVIDIA GPU over EGL) or cpu (OSMesa, no - # MID-360): golem_robocasa/sim_common.py. The Mac has only cpu. + # gpu (the sims' default, an NVIDIA GPU over EGL) or cpu (OSMesa, the + # MID-360 on the CPU): golem_robocasa/sim_common.py. The Mac has only cpu. GOLEM_RENDER: cpu - # Both robots' MID-360: the Mac has no lidar caster, so 0 (1 stops the - # sim at start with GOLEM_RENDER=cpu). configure_platform exports the - # same default, so docker-compose.g1.yml's GOLEM_LIDAR agrees. + # Both robots' MID-360, off by default: GOLEM_LIDAR=1 casts its rays + # exactly on the CPU (mid360.CpuCaster), much slower than the x86 GPU, + # and the Mac bringups then run navigation. configure_platform exports + # the same default, so docker-compose.g1.yml's GOLEM_LIDAR agrees. GOLEM_LIDAR: ${GOLEM_LIDAR:-0} # Software-rendered cameras cost the most per step: off unless asked for. GOLEM_CAMERAS: ${GOLEM_CAMERAS:-0} @@ -36,6 +38,8 @@ services: runtime: !reset null shm_size: 2g environment: + # The sim's lidar knob: h12_mac_sim and g1_mac_sim default use_nav to it. + GOLEM_LIDAR: ${GOLEM_LIDAR:-0} # core_ws/cyclonedds.xml, then an override of its 16 MB minimum UDP # receive buffer: the minimum makes every ROS node fail to create its # domain unless the kernel's net.core.rmem_max allows it, which the diff --git a/docker/mac/RobocasaDockerfile b/docker/mac/RobocasaDockerfile index 4bf5d6d6..1e3a72be 100644 --- a/docker/mac/RobocasaDockerfile +++ b/docker/mac/RobocasaDockerfile @@ -3,7 +3,7 @@ # golem_base:arm64 (mac/BaseDockerfile). Same stages, commits, patches and # kitchen-asset digest as the x86 image, with the arm64 locks and OSMesa as the # renderer: the Mac has no NVIDIA GPU, so the sims run with GOLEM_RENDER=cpu, -# which draws the cameras in software and has no MID-360 (docs/MAC.md). The +# which draws the cameras in software and casts the MID-360 on the CPU (docs/MAC.md). The # simulator source (golem_robocasa) is bind-mounted at runtime. FROM golem_base:arm64 COPY docker/locks/robocasa-arm64*.txt docker/locks/robocasa-assets.digest /opt/golem-locks/ diff --git a/docker/scripts/docker_common.sh b/docker/scripts/docker_common.sh index a037393e..9f28ffb5 100755 --- a/docker/scripts/docker_common.sh +++ b/docker/scripts/docker_common.sh @@ -77,7 +77,7 @@ load_config() { # linux. linux leaves COMPOSE as load_config made it (the x86 / NVIDIA images). # mac adds docker-compose.mac.yml (the arm64 images of docker/mac/, no NVIDIA # runtime, the sims on CPU rendering), exports GOLEM_LIDAR=0 unless set (the -# Mac sims have no lidar caster) and headless unless GOLEM_DISPLAY is set +# CPU lidar is slow; 1 adds it and navigation) and headless unless GOLEM_DISPLAY is set # (there is no X server). Called by load_config. configure_platform() { local platform=${GOLEM_PLATFORM:-} diff --git a/docker/scripts/docker_run.sh b/docker/scripts/docker_run.sh index f0581dea..4e74f85f 100755 --- a/docker/scripts/docker_run.sh +++ b/docker/scripts/docker_run.sh @@ -33,7 +33,7 @@ else echo "robot: $GOLEM_ROBOT" >&2 fi # The Mac runs the arm64 images (configure_platform); Linux prints nothing here. -[ "$GOLEM_PLATFORM" != mac ] || echo 'platform: mac (arm64, CPU rendering, no lidar)' >&2 +[ "$GOLEM_PLATFORM" != mac ] || echo "platform: mac (arm64, CPU rendering, lidar $([ "$GOLEM_LIDAR" = 1 ] && echo 'on the CPU' || echo off))" >&2 RESTART=0 if [ "${1:-}" = --restart ]; then RESTART=1; shift; fi # Pin the container to its CPUs (robocasa, ros; not the Isaac simulator). Before the diff --git a/docker/scripts/docker_stack.sh b/docker/scripts/docker_stack.sh index 633932e8..dd8a54aa 100755 --- a/docker/scripts/docker_stack.sh +++ b/docker/scripts/docker_stack.sh @@ -51,11 +51,11 @@ if [ "$ACTION" = logs ]; then exec "${COMPOSE[@]}" logs -f "$SIM" ros; fi configure_robot "$SIM" echo "robot: $GOLEM_ROBOT" >&2 # The Mac runs the arm64 images (configure_platform); Linux prints nothing here. -[ "$GOLEM_PLATFORM" != mac ] || echo 'platform: mac (arm64, CPU rendering, no lidar)' >&2 +[ "$GOLEM_PLATFORM" != mac ] || echo "platform: mac (arm64, CPU rendering, lidar $([ "$GOLEM_LIDAR" = 1 ] && echo 'on the CPU' || echo off))" >&2 # Read by docker-compose.stack.yml. Set here, from the selected robot and # platform, because a value left in the shell or docker/.env would start the -# other robot's bringup. The Mac runs the mac_sim bringups (no lidar, -# navigation or vision models; docs/MAC.md). +# other robot's bringup. The Mac runs the mac_sim bringups (navigation only +# with GOLEM_LIDAR=1, no vision models; docs/MAC.md). if [ "$GOLEM_PLATFORM" = mac ]; then export GOLEM_BRINGUP_LAUNCH=${GOLEM_ROBOT}_mac_sim.launch.py elif [ "$GOLEM_ROBOT" = g1 ]; then diff --git a/docs/MAC.md b/docs/MAC.md index f8c22a79..0f155315 100644 --- a/docs/MAC.md +++ b/docs/MAC.md @@ -2,8 +2,9 @@ The stack's platform is x86 Linux with an NVIDIA GPU. An Apple Silicon Mac runs a reduced RoboCasa sim of either robot: the command path (`golem_safety`, -`golem_upper_ik`), the legs (`golem_lowerbody_rl`) and walking on `/cmd_vel`. -It has no lidar, no navigation, no model servers or skills, and no Isaac sim. +`golem_upper_ik`), the legs (`golem_lowerbody_rl`) and walking on `/cmd_vel`, +and with `GOLEM_LIDAR=1` the MID-360 cast on the CPU and navigation (FAST-LIO, +SLAM, Nav2) on it. It has no model servers or skills, and no Isaac sim. Use it to develop and check controllers and bringup away from the lab machines; the closed-loop tests (`tests/sim`, `tests/g1`) stay x86 gates. @@ -15,13 +16,13 @@ machines; the closed-loop tests (`tests/sim`, `tests/g1`) stay x86 gates. | Python locks | `docker/locks/*-amd64*.txt` | `docker/locks/*-arm64*.txt`, derived from the amd64 locks by `docker/mac/derive_arm64_locks.sh` (CPU torch, no CUDA wheels, open3d 0.18.0) | | Compose | `docker/docker-compose.yml` | the same, plus `docker/docker-compose.mac.yml` (no NVIDIA runtime) | | Sim rendering | EGL on the GPU (`GOLEM_RENDER=gpu`) | OSMesa on the CPU (`GOLEM_RENDER=cpu`); cameras off by default (`GOLEM_CAMERAS=0`) | -| MID-360 lidar | on | none (`GOLEM_LIDAR=0`): its caster renders on the GPU | -| Bringup | `h12_sim`, `g1_sim` | `h12_mac_sim`, `g1_mac_sim`: the sim bringups without navigation, model servers or skills | -| Not available | — | Isaac, navigation and SLAM, `golem_skills`, the model servers (GraspGenX has no CPU path) | +| MID-360 lidar | on, cast on the GPU (`mid360.GpuCaster`) | off by default; `GOLEM_LIDAR=1` casts it exactly on the CPU (`mid360.CpuCaster`) | +| Bringup | `h12_sim`, `g1_sim` | `h12_mac_sim`, `g1_mac_sim`: the sim bringups without model servers or skills, navigation exactly when `GOLEM_LIDAR=1` | +| Not available | — | Isaac, `golem_skills`, the model servers (GraspGenX has no CPU path) | The wrappers pick the Mac by themselves on Darwin arm64 (`GOLEM_PLATFORM=mac`; `GOLEM_PLATFORM=linux` forces the x86 path) and print -`platform: mac (arm64, CPU rendering, no lidar)` beside `robot:`. Nothing on +`platform: mac (arm64, CPU rendering, lidar off|on the CPU)` beside `robot:`. Nothing on Linux changes: there the wrappers make the same docker calls as before. ## Setup @@ -56,6 +57,10 @@ ros2 action send_goal /named_config custom_ros_messages/action/NamedConfig \ "{config_name: t_pose, plan: false, duration: {sec: 15, nanosec: 0}}" ``` +Navigation: add `GOLEM_LIDAR=1` to either `up` (the bringups then start +`golem_slam`), wait for Nav2's lifecycle nodes, and send `/navigate_to_pose` +goals in `map`, as on x86 ([Navigation demo](NAVIGATION_DEMO.md)). + `docker_stack.sh` runs a random kitchen task; with the arms out (`t_pose`) the robot can touch a fixture, and the goal then fails its steady-state hold. The three-terminal flow of [Running the stack](RUNNING.md) works too @@ -89,6 +94,21 @@ stacks' from `/clock` against wall time in `golem_ros`. | Arms (`/named_config`, 15 s) | Blank scene: 8 of 8 goals succeed, standing and walking | not measured | | CPU | sim about 0.4 core, ros about 1.8 cores | sim about 0.25 core, ros about 1.85 cores | +**Navigation** (`GOLEM_LIDAR=1`, the MID-360's 20,000 points a frame cast on +the CPU; layout 9, style 9, seed 42, the spawn backed off 2.0 m, as +`tests/sim`; a Nav2 goal 1.5 m ahead, then one back to the start): + +| | G1 | H1-2 | +|---|---|---| +| Sim alone with the CPU lidar, unpaced | 1.48x | not measured | +| 1.5 m goal ahead | succeeded in 6.5 s of sim time, 0.25 m from it by SLAM (twice) | succeeded in 3.7 s, 0.25 m from it | +| Goal back to the start | not finished: the recording ended mid-goal | succeeded in 17.6 s, 0.26 m from it | +| RTF while recording the viewer | 0.40-0.48 | 0.27-0.31 | + +These runs had the sim's viewer open on a virtual display, recorded with ffmpeg, +which takes much of the CPU; without the recording the stack's RTF with the lidar +is not measured. The H1-2 run had no estop latch over its 360 s. + For comparison, the x86 lab machine (i7-14700F, RTX 5070 Ti, sensors and navigation on) runs the full stack at 0.83x (H1-2) and 1.00x (G1) (`docs/superpowers/specs/2026-11-05-sim-speed-results.md`). @@ -112,6 +132,9 @@ scheduling or the heavier H1-2 ROS side) is not measured. segfault in its first topic, so the Mac base renames the SDK's copy (`libddsc_unitree.so.0`) and checks the pair at build time (`docker/mac/check_unitree_dds.py`). +- `GOLEM_RENDER=cpu` casts the MID-360 with `mid360.CpuCaster` (`mj_multiRay`, + exact, a quarter of the cores at most 4 threads) in place of the GPU's depth + renders; the x86 default (`gpu`) is unchanged. - `core_ws/cyclonedds.xml` requires 16 MB UDP receive buffers, which the VM's default `net.core.rmem_max` refuses (every node then fails to create its domain); the Mac overlay's `CYCLONEDDS_URI` drops that minimum. diff --git a/golem_robocasa/g1/g1_lidar.py b/golem_robocasa/g1/g1_lidar.py index e6ba8c9b..20ddf3be 100644 --- a/golem_robocasa/g1/g1_lidar.py +++ b/golem_robocasa/g1/g1_lidar.py @@ -103,13 +103,15 @@ def pose(self, data): return (data.site_xpos[self.site_id].copy(), data.site_xmat[self.site_id].reshape(3, 3).copy()) - def make_caster(self): - """Return a mid360.GpuCaster through torso_link, visual geoms only. + def make_caster(self, render="gpu"): + """Return render's caster (mid360.make_caster) through torso_link, visual geoms only. - Rays whose first hit is another robot geom give no return. The caster casts on its own + render is GOLEM_RENDER's value: gpu a mid360.GpuCaster, cpu a mid360.CpuCaster. Rays + whose first hit is another robot geom give no return. The caster casts on its own copy of the model; close() it when done. Raises RuntimeError when EGL fails to render. """ - return mid360.GpuCaster(self.model, self.torso_id, GEOM_GROUPS, robot_geoms=self.robot_geom) + return mid360.make_caster(self.model, self.torso_id, GEOM_GROUPS, render, + robot_geoms=self.robot_geom) def imu(self, data, point=IMU_IN_LIDAR): """Return (angular velocity rad/s, specific force g) at point, in livox_frame axes. diff --git a/golem_robocasa/g1/g1_sensors.py b/golem_robocasa/g1/g1_sensors.py index e4285178..fac9493a 100644 --- a/golem_robocasa/g1/g1_sensors.py +++ b/golem_robocasa/g1/g1_sensors.py @@ -207,11 +207,12 @@ def __init__(self, model, prefix, config, publish): Raises RuntimeError when EGL fails to render. """ self.mid360 = g1_lidar.Mid360(model, prefix) - caster = self.mid360.make_caster() + render = sim_common.render_mode() + caster = self.mid360.make_caster(render) # s of sim time between casts: the caster's batch, or each frame's period when that # is shorter, so that every frame is cast from a pose of its own. interval = min(caster.batch_s, 1.0 / config.lidar_hz) - _log(f"lidar rays cast on the GPU every {interval * 1e3:g} ms of sim time") + _log(f"lidar rays cast on the {render.upper()} every {interval * 1e3:g} ms of sim time") super().__init__(g1_lidar.make_scanner(caster, config.lidar_points, config.lidar_hz), model, self.mid360.pose, lambda frame: publish(sm.livox_custom_msg_cdr(frame)), interval, log=_log) diff --git a/golem_robocasa/h12_sensors.py b/golem_robocasa/h12_sensors.py index 01b9f24f..fd1f4f0c 100644 --- a/golem_robocasa/h12_sensors.py +++ b/golem_robocasa/h12_sensors.py @@ -78,6 +78,7 @@ from tf2_ros import StaticTransformBroadcaster, TransformBroadcaster import mid360 +import sim_common import realsense_profile from mujoco_ros_bridge import _sim_time_to_msg @@ -192,7 +193,7 @@ class _LidarScans(mid360.ScanRing): def __init__(self, model, body_id, exclude_body_id, robot_geoms, frame_id, publish_lidar, publish_cloud, timings=None, sim_lock=None): - """Build the GPU caster and start the thread. + """Build the caster GOLEM_RENDER picks (mid360.make_caster) and start the thread. The sensor's pose is body body_id's; the rays pass through body exclude_body_id's geoms, and a ray whose first hit is in the bool mask robot_geoms (ngeom,) gives no @@ -204,8 +205,10 @@ def __init__(self, model, body_id, exclude_body_id, robot_geoms, frame_id, self._frame_id = frame_id self._publish_lidar = publish_lidar self._publish_cloud = publish_cloud - caster = mid360.GpuCaster(model, exclude_body_id, LIDAR_GEOM_GROUPS, robot_geoms=robot_geoms) - _log(f"lidar rays cast on the GPU every {caster.batch_s * 1e3:g} ms of sim time") + render = sim_common.render_mode() + caster = mid360.make_caster(model, exclude_body_id, LIDAR_GEOM_GROUPS, render, + robot_geoms=robot_geoms) + _log(f"lidar rays cast on the {render.upper()} every {caster.batch_s * 1e3:g} ms of sim time") super().__init__(mid360.Mid360Scanner(caster), model, lambda data: (data.xpos[body], data.xmat[body].reshape(3, 3)), self._publish_frame, caster.batch_s, sim_lock, timings, _log) diff --git a/golem_robocasa/mid360.py b/golem_robocasa/mid360.py index 19660d9f..5ca173cc 100644 --- a/golem_robocasa/mid360.py +++ b/golem_robocasa/mid360.py @@ -41,10 +41,12 @@ MuJoCo's ray functions also skip geoms with alpha 0 (RoboCasa's placement regions and hidden collision boxes). -Caster. GpuCaster reads the ranges from depth images the GPU renders around the sensor +Casters. GpuCaster reads the ranges from depth images the GPU renders around the sensor (EGL), under MuJoCo's ray rules (see its docstring for how close its ranges come to MuJoCo's -exact mj_ray). The sims check at start that they render on a GPU (sim_common.require_gpu). -Mid360Scanner and ScanRing take any caster with GpuCaster's cast(), close() and batch_s. +exact mj_ray). The sims check at start that they render on a GPU (sim_common.require_gpu), +unless GOLEM_RENDER=cpu (the Mac images): then CpuCaster casts every ray exactly with +mj_multiRay on the CPU, much more slowly. make_caster() picks one by GOLEM_RENDER. +Mid360Scanner and ScanRing take any caster with cast(), close() and batch_s. """ import atexit import copy @@ -52,6 +54,7 @@ import os import queue import threading +from concurrent.futures import ThreadPoolExecutor, wait from typing import NamedTuple import mujoco @@ -66,6 +69,12 @@ PATTERN_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "third_party", "mujoco_lidar", "mid360.npy") +# Worker threads of a CpuCaster: a quarter of the cores, at most 4, so the casts leave the +# physics and the cameras their cores. +DEFAULT_THREADS = max(1, min(4, (os.cpu_count() or 1) // 4)) +# Rays below which another thread is not used: handing a chunk to a thread costs tens of us, +# the work of about 10 rays in a kitchen. +_MIN_RAYS_PER_THREAD = 250 _EPS_T = 1e-9 # s, tolerance on accumulated sim time _SLOT_POLL_S = 1.0 # wall s between checks that the scan thread lives, while waiting @@ -125,6 +134,110 @@ def directions(pattern, start, count): axis=-1) +class CpuCaster: + """Cast rays exactly with mj_multiRay, split over threads. + + Threads. cast() clears model.body_bvhadr for its duration, and mj_step's collision + reads it: give the caster a model no other thread steps or casts on while it runs (as + make_caster() does, with a copy of the model), and call cast() from one thread at a + time. The extra threads cast on scratch MjData of their own, since mj_multiRay + allocates on the MjData it is given. + """ + + batch_s = 0.01 # s of sim time between the scanner's update() calls + + def __init__(self, model, exclude_body, geomgroup, threads=DEFAULT_THREADS, + robot_geoms=None): + """Cast on model, through the geoms of body id exclude_body (-1: none). + + geomgroup is the 6 flags of the geom groups the rays hit. threads is how many + threads cast at once, the calling one included. robot_geoms is a bool mask + (ngeom,) of geoms whose first hit gives no return; by default every geom of + exclude_body's root subtree (the robot the sensor is on), none with exclude_body -1. + """ + self.model = model + self.exclude_body = int(exclude_body) + self._geomgroup = np.array(geomgroup, dtype=np.uint8).reshape(6, 1) + if robot_geoms is not None: + self.robot_geoms = np.asarray(robot_geoms, dtype=bool) + elif self.exclude_body >= 0: + root = model.body_rootid[self.exclude_body] + self.robot_geoms = model.body_rootid[model.geom_bodyid] == root + else: + self.robot_geoms = np.zeros(model.ngeom, dtype=bool) + # The scratch MjData carry geom poses only, so a model with flexes casts on the + # caller's MjData alone. + self.threads = 1 if model.nflex else max(1, int(threads)) + self._scratch = [mujoco.MjData(model) for _ in range(self.threads - 1)] + self._pool = (ThreadPoolExecutor(self.threads - 1, thread_name_prefix="mid360_cast") + if self.threads > 1 else None) + + def close(self): + """Stop the worker threads.""" + if self._pool is not None: + self._pool.shutdown(wait=True) + self._pool = None + + def _cast_chunk(self, d, source, origin, world, geomid, dist, lo, hi): + """Cast rays lo..hi on d, after copying source's geom poses into it unless source is d.""" + if source is not d: + np.copyto(d.geom_xpos, source.geom_xpos) + np.copyto(d.geom_xmat, source.geom_xmat) + # The binding releases the GIL while it casts; None skips the surface normals. + mujoco.mj_multiRay(self.model, d, origin, world[lo:hi].reshape(-1, 1), self._geomgroup, + 1, self.exclude_body, geomid[lo:hi].reshape(-1, 1), + dist[lo:hi].reshape(-1, 1), None, hi - lo, MAX_RANGE) + + def cast(self, origin, rotation, directions, data, geom_alpha=None, mat_alpha=None): + """Return the distance (m) along each unit direction (n, 3) to its first hit, NaN for none. + + origin (3,) m and rotation (3, 3) sensor -> world are the sensor's pose; directions + are in its own frame; data holds the geom poses. geom_alpha (ngeom,) and mat_alpha + (nmat,) are written into the model's geom_rgba and mat_rgba alpha first (Snapshot's + fields; None leaves them). NaN where nothing is hit within MAX_RANGE or the robot is + hit first. + """ + if geom_alpha is not None: + self.model.geom_rgba[:, 3] = geom_alpha + if mat_alpha is not None: + self.model.mat_rgba[:, 3] = mat_alpha + n = len(directions) + dist = np.empty(n) + geomid = np.empty(n, dtype=np.int32) + if n == 0: + return dist + world = np.ascontiguousarray(np.asarray(directions) @ np.asarray(rotation).T, + dtype=np.float64) + origin = np.array(origin, dtype=np.float64).reshape(3, 1) + chunks = min(self.threads, max(1, n // _MIN_RAYS_PER_THREAD)) + bounds = np.linspace(0, n, chunks + 1).astype(int) + # mj_multiRay culls a body through its BVH, which it places with the body's pose, + # but the scratch MjData and the scan thread's snapshot carry only geom poses: with + # the BVH in place their casts miss geoms (121 of the 2,000 rays + # test_cpu_caster_matches_mj_ray casts in tests/robocasa/test_mid360.py's _KITCHEN, + # cast on a fresh MjData given only the geom poses). MuJoCo skips the BVH for bodies + # without one, so for this call none has one, and each geom is tested from its own + # pose: the result is mj_ray's, ray for ray. Cleared once around every thread's + # cast, and restored only once they have all finished. + bvhadr = self.model.body_bvhadr.copy() + self.model.body_bvhadr[:] = -1 + futures = [] + try: + for k, scratch in enumerate(self._scratch[:chunks - 1], start=1): + futures.append(self._pool.submit(self._cast_chunk, scratch, data, origin, world, + geomid, dist, bounds[k], bounds[k + 1])) + self._cast_chunk(data, data, origin, world, geomid, dist, bounds[0], bounds[1]) + for future in futures: + future.result() + finally: + wait(futures) + self.model.body_bvhadr[:] = bvhadr + hit = geomid >= 0 + robot = hit & self.robot_geoms[np.where(hit, geomid, 0)] + dist[~hit | robot] = np.nan + return dist + + class GpuCaster: """Read each ray's range from depth images rendered on the GPU around the sensor (EGL). @@ -378,6 +491,22 @@ def _log(text): print(text, flush=True) +def make_caster(model, exclude_body, geomgroup, render="gpu", robot_geoms=None): + """Return the caster for render, GOLEM_RENDER's value (sim_common.render_mode). + + gpu, the default: a GpuCaster on model. cpu (the Mac images, which have no GPU): a + CpuCaster on its own copy of model, since it edits the model it casts on (its + docstring), so the physics may step model while it casts; runtime edits of model reach + its casts only through the snapshot (poses, alpha). ValueError for any other render. + geomgroup and robot_geoms are the casters' own. + """ + if render == "gpu": + return GpuCaster(model, exclude_body, geomgroup, robot_geoms=robot_geoms) + if render == "cpu": + return CpuCaster(copy.copy(model), exclude_body, geomgroup, robot_geoms=robot_geoms) + raise ValueError(f"render must be gpu or cpu, got {render!r}") + + class Mid360Scanner: """Fire the MID-360's pattern through a caster and assemble its 10 Hz frames.""" diff --git a/golem_robocasa/sim_common.py b/golem_robocasa/sim_common.py index 879649b8..f0206309 100644 --- a/golem_robocasa/sim_common.py +++ b/golem_robocasa/sim_common.py @@ -31,8 +31,8 @@ # GL_RENDERER substrings of software rasterisers, which EGL falls back to without a GPU. SOFTWARE_RENDERERS = ("llvmpipe", "softpipe", "swrast", "software", "swiftshader") # GOLEM_RENDER's values: gpu (the default) checks for the GPU above; cpu renders the -# cameras through OSMesa and has no MID-360, whose caster (mid360.GpuCaster) is EGL-only. -# The Mac images set cpu (docker/docker-compose.mac.yml). +# cameras through OSMesa and casts the MID-360's rays exactly on the CPU (mid360.CpuCaster), +# much more slowly. The Mac images set cpu (docker/docker-compose.mac.yml). RENDER_MODES = ("gpu", "cpu") @@ -114,7 +114,8 @@ def require_renderer(env: Mapping[str, str] = os.environ, """Check the sim can render as GOLEM_RENDER asks, logging how; return the mode. gpu: require_gpu(probe), which exits without an NVIDIA GPU on EGL. cpu: exits unless - MUJOCO_GL is osmesa and GOLEM_LIDAR is off, since the MID-360 casts its rays on the GPU. + MUJOCO_GL is osmesa; the cameras then render through OSMesa and the MID-360 casts its + rays on the CPU (mid360.make_caster). """ mode = render_mode(env) if mode == "gpu": @@ -123,10 +124,8 @@ def require_renderer(env: Mapping[str, str] = os.environ, backend = env.get("MUJOCO_GL", "") if backend.strip().lower() != "osmesa": sys.exit(f"GOLEM_RENDER=cpu renders through OSMesa: MUJOCO_GL must be osmesa, not {backend!r}") - if env_flag("GOLEM_LIDAR", True, env): - sys.exit("GOLEM_RENDER=cpu has no MID-360 (its rays render through EGL on a GPU): " - "set GOLEM_LIDAR=0") - print("[sim_common] rendering on the CPU through OSMesa (GOLEM_RENDER=cpu); no MID-360", + lidar = "the MID-360's rays cast on the CPU" if env_flag("GOLEM_LIDAR", True, env) else "no MID-360" + print(f"[sim_common] rendering on the CPU through OSMesa (GOLEM_RENDER=cpu); {lidar}", flush=True) return mode diff --git a/tests/robocasa/test_gpu_required.py b/tests/robocasa/test_gpu_required.py index 69f212b9..2a214f0d 100644 --- a/tests/robocasa/test_gpu_required.py +++ b/tests/robocasa/test_gpu_required.py @@ -1,7 +1,7 @@ """Check that the RoboCasa sims stop at start, with one message, without a GPU to render on through EGL. GOLEM_RENDER=cpu (the Mac images) is the one way past the check: it renders through OSMesa -and needs GOLEM_LIDAR=0 (RenderModeTests). +and casts the lidar on the CPU (RenderModeTests). sim_common.egl_renderer() is the probe and sim_common.require_gpu() the stop. The probe is made to fail three ways: a failing probe passed in, MuJoCo not on EGL (MUJOCO_GL=osmesa) and Mesa's @@ -77,21 +77,19 @@ def probe(): sim_common.require_renderer({"MUJOCO_GL": "osmesa"}, probe) self.assertTrue(caught.exception.code.startswith(sim_common.GPU_REQUIRED)) - def test_cpu_mode_needs_osmesa_and_no_lidar(self): - """GOLEM_RENDER=cpu passes with MUJOCO_GL=osmesa and GOLEM_LIDAR=0, and refuses either missing.""" + def test_cpu_mode_needs_osmesa(self): + """GOLEM_RENDER=cpu passes with MUJOCO_GL=osmesa, lidar on or off, and refuses another MUJOCO_GL.""" def probe(): """Fail: cpu mode must not probe the GPU.""" raise AssertionError("probed the GPU") - ok = {"GOLEM_RENDER": "CPU", "MUJOCO_GL": "osmesa", "GOLEM_LIDAR": "0"} - self.assertEqual(sim_common.require_renderer(ok, probe), "cpu") - for change, reason in (({"MUJOCO_GL": "egl"}, "MUJOCO_GL must be osmesa"), - ({"GOLEM_LIDAR": ""}, "GOLEM_LIDAR=0"), - ({"GOLEM_LIDAR": "1"}, "GOLEM_LIDAR=0")): - with self.subTest(change=change): - with self.assertRaises(SystemExit) as caught: - sim_common.require_renderer(dict(ok, **change), probe) - self.assertIn(reason, caught.exception.code) + for lidar in ("0", "1", ""): + with self.subTest(GOLEM_LIDAR=lidar): + env = {"GOLEM_RENDER": "CPU", "MUJOCO_GL": "osmesa", "GOLEM_LIDAR": lidar} + self.assertEqual(sim_common.require_renderer(env, probe), "cpu") + with self.assertRaises(SystemExit) as caught: + sim_common.require_renderer({"GOLEM_RENDER": "cpu", "MUJOCO_GL": "egl"}, probe) + self.assertIn("MUJOCO_GL must be osmesa", caught.exception.code) class SimStartTests(unittest.TestCase): @@ -140,15 +138,6 @@ def test_without_egl_both_sims_stop_at_start(self): with self.subTest(robot=robot): self.assert_refused(self.start(robot, MUJOCO_GL="osmesa"), "MUJOCO_GL is 'osmesa'") - def test_cpu_rendering_with_the_lidar_on_stops_both_sims_at_start(self): - """GOLEM_RENDER=cpu without GOLEM_LIDAR=0 stops either robot's sim at start, before its kitchen.""" - for robot in ("h12", "g1"): - with self.subTest(robot=robot): - r = self.start(robot, MUJOCO_GL="osmesa", GOLEM_RENDER="cpu", GOLEM_LIDAR="1") - self.assertEqual(r.returncode, 1, (r.stdout + r.stderr)[-2000:]) - self.assertIn("set GOLEM_LIDAR=0", r.stderr.strip().splitlines()[-1]) - self.assertNotIn("RoboCasa task", r.stdout) - def test_on_mesas_software_egl_both_sims_stop_at_start(self): """With only Mesa's EGL, which renders in software, either robot's sim stops at start.""" if not os.path.exists(MESA_EGL_VENDOR): diff --git a/tests/robocasa/test_mid360_cpu.py b/tests/robocasa/test_mid360_cpu.py new file mode 100644 index 00000000..10c8b782 --- /dev/null +++ b/tests/robocasa/test_mid360_cpu.py @@ -0,0 +1,113 @@ +"""Check mid360.CpuCaster, the Mac's lidar caster (GOLEM_RENDER=cpu), against MuJoCo's exact mj_ray. + +The reference is exact_rays.ExactCaster (one mj_ray per ray). The scene is a small MJCF: a +closed room, a box obstacle, a hidden (alpha 0) box, and a robot body the sensor rides in, with +an arm the rays may hit first. Needs no GPU: +ROS_DOMAIN_ID=231 tests/robocasa/run_in_container.sh -p test_mid360_cpu.py +""" +import unittest + +import mujoco +import numpy as np + +import mid360 +from exact_rays import ExactCaster + +VISUAL = (0, 1, 0, 0, 0, 0) # geomgroup: visual geoms only, as the G1 casts + +SCENE = """ + + + + + + + + + + + + + + + + + + + +""" + + +def _scene(): + """Return (model, data, torso body id) of SCENE after mj_forward.""" + model = mujoco.MjModel.from_xml_string(SCENE) + data = mujoco.MjData(model) + mujoco.mj_forward(model, data) + return model, data, mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_BODY, "robot") + + +def _directions(n, seed=0): + """Return n random unit directions (n, 3).""" + d = np.random.default_rng(seed).normal(size=(n, 3)) + return d / np.linalg.norm(d, axis=1, keepdims=True) + + +class CpuCasterTests(unittest.TestCase): + """Check CpuCaster's ranges, robot returns and threading against ExactCaster.""" + + def test_matches_mj_ray_ray_for_ray(self): + """Every ray's range matches mj_ray's to 1e-9 m, and the same rays give no return.""" + model, data, torso = _scene() + rays = _directions(4000) + rotation = np.diag([1.0, -1.0, -1.0]) # upside down, as both robots hang the sensor + expected = ExactCaster(model, torso, VISUAL).cast(np.zeros(3), rotation, rays, data) + for threads in (1, 3): + with self.subTest(threads=threads): + caster = mid360.CpuCaster(mujoco.MjModel.from_xml_string(SCENE), torso, VISUAL, + threads=threads) + try: + got = caster.cast(np.zeros(3), rotation, rays, data) + finally: + caster.close() + np.testing.assert_array_equal(np.isnan(got), np.isnan(expected)) + np.testing.assert_allclose(got[~np.isnan(got)], expected[~np.isnan(expected)], + atol=1e-9) + + def test_robot_hits_and_hidden_geoms_give_no_return(self): + """A ray that meets the robot's arm first, or only a hidden geom then nothing, gives NaN.""" + model, data, torso = _scene() + caster = mid360.CpuCaster(model, torso, VISUAL, threads=1) + try: + arm = np.array([[0.0, 1.0, -0.15]]) / np.linalg.norm([0.0, 1.0, -0.15]) + wall = np.array([[1.0, 0.0, 0.0]]) + hidden = np.array([[0.0, -1.0, 0.0]]) + got = caster.cast(np.zeros(3), np.eye(3), np.vstack([arm, wall, hidden]), data) + finally: + caster.close() + self.assertTrue(np.isnan(got[0]), got) + self.assertAlmostEqual(got[1], 3.0, places=9) # the +x wall's inner face + self.assertAlmostEqual(got[2], 3.0, places=9) # through the hidden box to the -y wall + + +class MakeCasterTests(unittest.TestCase): + """Check make_caster picks the caster by GOLEM_RENDER's value.""" + + def test_cpu_builds_a_cpu_caster_on_a_copy_of_the_model(self): + """render cpu gives a CpuCaster casting on its own copy, so the physics may step the original.""" + model, _, torso = _scene() + caster = mid360.make_caster(model, torso, VISUAL, "cpu") + try: + self.assertIsInstance(caster, mid360.CpuCaster) + self.assertIsNot(caster.model, model) + finally: + caster.close() + + def test_an_unknown_render_is_refused(self): + """A render other than gpu or cpu raises ValueError, naming it.""" + model, _, torso = _scene() + with self.assertRaisesRegex(ValueError, "metal"): + mid360.make_caster(model, torso, VISUAL, "metal") + + +if __name__ == "__main__": + unittest.main() From 9f957828fc05c9e3d18ade94038f964b66064734 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 18 Nov 2026 22:40:42 -0700 Subject: [PATCH 3/7] Add GOLEM_LIDAR_THREADS for the CPU lidar caster; record the Mac's limits mid360.threads_from_env reads GOLEM_LIDAR_THREADS, the CpuCaster's thread count (default unchanged: a quarter of the CPUs, at most 4), and make_caster takes it; the Mac overlay passes it through. Measured on an M3: more threads speed the G1 sim alone (1.48x at 2 to 2.10x at 6) but not the navigation stack, which stays at 0.80-0.89x because the VM is CPU-bound (ros about 3.75 cores, the sim about 2.4). docs/MAC.md records this, and that the Mac's GPU reaches a Podman libkrun container only as Vulkan, not the OpenGL/EGL MuJoCo needs. Co-Authored-By: Claude Opus 5.5 --- docker/docker-compose.mac.yml | 3 +++ docs/MAC.md | 24 ++++++++++++++++++++++-- golem_robocasa/mid360.py | 25 ++++++++++++++++++++++--- tests/robocasa/test_mid360_cpu.py | 16 ++++++++++++++++ 4 files changed, 63 insertions(+), 5 deletions(-) diff --git a/docker/docker-compose.mac.yml b/docker/docker-compose.mac.yml index 85a0e3d4..ad30dd93 100644 --- a/docker/docker-compose.mac.yml +++ b/docker/docker-compose.mac.yml @@ -28,6 +28,9 @@ services: # and the Mac bringups then run navigation. configure_platform exports # the same default, so docker-compose.g1.yml's GOLEM_LIDAR agrees. GOLEM_LIDAR: ${GOLEM_LIDAR:-0} + # Threads the CPU lidar casts on (mid360.threads_from_env); empty: a + # quarter of the VM's CPUs, at most 4. + GOLEM_LIDAR_THREADS: ${GOLEM_LIDAR_THREADS:-} # Software-rendered cameras cost the most per step: off unless asked for. GOLEM_CAMERAS: ${GOLEM_CAMERAS:-0} ros: diff --git a/docs/MAC.md b/docs/MAC.md index 0f155315..f75fea3d 100644 --- a/docs/MAC.md +++ b/docs/MAC.md @@ -106,8 +106,28 @@ the CPU; layout 9, style 9, seed 42, the spawn backed off 2.0 m, as | RTF while recording the viewer | 0.40-0.48 | 0.27-0.31 | These runs had the sim's viewer open on a virtual display, recorded with ffmpeg, -which takes much of the CPU; without the recording the stack's RTF with the lidar -is not measured. The H1-2 run had no estop latch over its 360 s. +which takes much of the CPU. The H1-2 run had no estop latch over its 360 s. + +Without the recording, the G1's navigation stack (same scene and goals) runs at +0.80-0.89x, `/lowstate` at 500 Hz of sim time with gaps up to 40 ms of wall time, +no fault; the goal ahead succeeds (6.3-6.5 s, 0.21-0.28 m off), and the goal back +to the start aborted both times, about 0.85 m short. The VM is CPU-bound there: +`golem_ros` takes about 3.75 cores (FAST-LIO, SLAM, OctoMap, Nav2, the leg policy, +the arm controller) and the sim about 2.4 of the M3's 8. + +**Lidar threads.** The CPU caster's thread count is `GOLEM_LIDAR_THREADS` (default +a quarter of the VM's CPUs, at most 4: 2 on an 8-CPU VM). It speeds the sim on its +own, but not the navigation stack, where every core is busy: + +| Threads | 1 | 2 | 4 | 6 | 8 | +|---|---|---|---|---|---| +| G1 sim alone, kitchen, CPU lidar, unpaced | 0.82x | 1.48x | 1.96x | 2.10x | 1.90x | +| G1 navigation stack at real time | — | 0.80-0.89x | 0.80-0.82x | — | — | + +The Mac's GPU is not a way out: in a Podman libkrun VM a container reaches it +through Vulkan 1.2 (Venus over MoltenVK, with a patched Mesa), but not through +OpenGL/EGL, which MuJoCo's renderer and `mid360.GpuCaster` need (Zink needs a +Vulkan feature MoltenVK lacks; krunkit has no virgl GL on macOS). For comparison, the x86 lab machine (i7-14700F, RTX 5070 Ti, sensors and navigation on) runs the full stack at 0.83x (H1-2) and 1.00x (G1) diff --git a/golem_robocasa/mid360.py b/golem_robocasa/mid360.py index 5ca173cc..72c055e2 100644 --- a/golem_robocasa/mid360.py +++ b/golem_robocasa/mid360.py @@ -491,19 +491,38 @@ def _log(text): print(text, flush=True) -def make_caster(model, exclude_body, geomgroup, render="gpu", robot_geoms=None): +def threads_from_env(env=os.environ): + """Return GOLEM_LIDAR_THREADS, the CpuCaster's thread count: unset or empty is DEFAULT_THREADS. + + Raises ValueError, naming the knob, for anything but an integer of at least 1. + """ + raw = env.get("GOLEM_LIDAR_THREADS", "") + if not raw.strip(): + return DEFAULT_THREADS + try: + threads = int(raw) + except ValueError: + threads = 0 + if threads < 1: + raise ValueError(f"GOLEM_LIDAR_THREADS must be an integer of at least 1, got {raw!r}") + return threads + + +def make_caster(model, exclude_body, geomgroup, render="gpu", robot_geoms=None, threads=None): """Return the caster for render, GOLEM_RENDER's value (sim_common.render_mode). gpu, the default: a GpuCaster on model. cpu (the Mac images, which have no GPU): a CpuCaster on its own copy of model, since it edits the model it casts on (its docstring), so the physics may step model while it casts; runtime edits of model reach - its casts only through the snapshot (poses, alpha). ValueError for any other render. + its casts only through the snapshot (poses, alpha). threads is the CpuCaster's thread + count (None: GOLEM_LIDAR_THREADS, threads_from_env). ValueError for any other render. geomgroup and robot_geoms are the casters' own. """ if render == "gpu": return GpuCaster(model, exclude_body, geomgroup, robot_geoms=robot_geoms) if render == "cpu": - return CpuCaster(copy.copy(model), exclude_body, geomgroup, robot_geoms=robot_geoms) + return CpuCaster(copy.copy(model), exclude_body, geomgroup, robot_geoms=robot_geoms, + threads=threads_from_env() if threads is None else threads) raise ValueError(f"render must be gpu or cpu, got {render!r}") diff --git a/tests/robocasa/test_mid360_cpu.py b/tests/robocasa/test_mid360_cpu.py index 10c8b782..da67df97 100644 --- a/tests/robocasa/test_mid360_cpu.py +++ b/tests/robocasa/test_mid360_cpu.py @@ -102,6 +102,22 @@ def test_cpu_builds_a_cpu_caster_on_a_copy_of_the_model(self): finally: caster.close() + def test_cpu_casts_on_golem_lidar_threads(self): + """GOLEM_LIDAR_THREADS sets the CpuCaster's threads; unset or empty is DEFAULT_THREADS; bad values raise.""" + self.assertEqual(mid360.threads_from_env({}), mid360.DEFAULT_THREADS) + self.assertEqual(mid360.threads_from_env({"GOLEM_LIDAR_THREADS": " "}), mid360.DEFAULT_THREADS) + self.assertEqual(mid360.threads_from_env({"GOLEM_LIDAR_THREADS": "4"}), 4) + for bad in ("0", "-2", "four", "1.5"): + with self.subTest(GOLEM_LIDAR_THREADS=bad): + with self.assertRaisesRegex(ValueError, "GOLEM_LIDAR_THREADS"): + mid360.threads_from_env({"GOLEM_LIDAR_THREADS": bad}) + model, _, torso = _scene() + caster = mid360.make_caster(model, torso, VISUAL, "cpu", threads=3) + try: + self.assertEqual(caster.threads, 3) + finally: + caster.close() + def test_an_unknown_render_is_refused(self): """A render other than gpu or cpu raises ValueError, naming it.""" model, _, torso = _scene() From fd1bbd011b51f5c35b5d1b1685010a912e55577b Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 19 Nov 2026 09:56:33 -0700 Subject: [PATCH 4/7] Add GOLEM_LIDAR_POINTS to the H1-2 sim; measure both robots' nav stacks at 1x on the Mac The H1-2 sim's MID-360 takes its points per frame from GOLEM_LIDAR_POINTS (mid360.points_from_env; empty is the real 20,000), as the G1's does. Only docker-compose.mac.yml passes it to the H1-2, so x86 runs are unchanged. Measured on the M3 (navigation stack, kitchen 9/9/42, no recording): the H1-2 holds 1.00x at 6,000 points (0.55x at 20,000, 0.88-0.95x at 10,000), the G1 1.00x at 10,000 with use_hands:=false; every Nav2 goal succeeded, no faults. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015EG7pDNJLWR31eQmyKaWhr --- CLAUDE.md | 2 +- docker/docker-compose.mac.yml | 3 +++ docs/MAC.md | 19 +++++++++++++++++++ golem_robocasa/h12_mujoco.py | 7 ++++++- golem_robocasa/h12_sensors.py | 14 ++++++++++---- golem_robocasa/mid360.py | 18 ++++++++++++++++++ tests/robocasa/test_mid360_cpu.py | 10 ++++++++++ 7 files changed, 67 insertions(+), 6 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index f8d0808a..be772716 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -559,7 +559,7 @@ with a valid CRC, `mode_machine` 6, `mode_pr` 0 and finite values (other frames are dropped); after that, `GOLEM_CMD_TIMEOUT` of silence turns every motor off until frames return. Its MID-360 is the model both robots share (`golem_robocasa/mid360.py`): the real scan pattern, 20,000 points a 10 Hz -frame on lines 0-3, each point's `offset_time` the time of the pose it was cast +frame (`GOLEM_LIDAR_POINTS`, which only the Mac's compose file passes to it) on lines 0-3, each point's `offset_time` the time of the pose it was cast from, and each ray without a return a point at (0, 0, 0), as the real driver publishes it; `/livox/lidar` and `/livox/pointcloud` carry the same frame. Its rays are read from depth images rendered on the GPU (`mid360.GpuCaster`, as on the G1), diff --git a/docker/docker-compose.mac.yml b/docker/docker-compose.mac.yml index ad30dd93..a09dc9fe 100644 --- a/docker/docker-compose.mac.yml +++ b/docker/docker-compose.mac.yml @@ -31,6 +31,9 @@ services: # Threads the CPU lidar casts on (mid360.threads_from_env); empty: a # quarter of the VM's CPUs, at most 4. GOLEM_LIDAR_THREADS: ${GOLEM_LIDAR_THREADS:-} + # Both robots' MID-360 points per frame (empty: the real 20,000); + # 10000 halves the CPU lidar's cost (docs/MAC.md). + GOLEM_LIDAR_POINTS: ${GOLEM_LIDAR_POINTS:-} # Software-rendered cameras cost the most per step: off unless asked for. GOLEM_CAMERAS: ${GOLEM_CAMERAS:-0} ros: diff --git a/docs/MAC.md b/docs/MAC.md index f75fea3d..bcf2d1cc 100644 --- a/docs/MAC.md +++ b/docs/MAC.md @@ -124,6 +124,25 @@ own, but not the navigation stack, where every core is busy: | G1 sim alone, kitchen, CPU lidar, unpaced | 0.82x | 1.48x | 1.96x | 2.10x | 1.90x | | G1 navigation stack at real time | — | 0.80-0.89x | 0.80-0.82x | — | — | +**Fewer lidar points.** `GOLEM_LIDAR_POINTS` (both robots; empty is the real +20,000 a frame) sets the rays a 10 Hz frame fires, and the CPU lidar's cost falls +with it. Navigation stack at real time, same scene and goals, no recording: + +| | Points a frame | RTF | `/lowstate` largest gap | Casts that waited for the lidar | Goal ahead / back to start | +|---|---|---|---|---|---| +| G1 (`use_hands:=false`) | 10,000 | 1.00 (sim loop idle 26%) | 24 ms | 2% | succeeded (0.27 m off) / not run | +| H1-2 | 20,000 | 0.55-0.57 | 46 ms | 99% | succeeded (0.18 m) / succeeded (0.04 m) | +| H1-2 | 10,000 | 0.88-0.95 | 25 ms | 87% | succeeded (0.23 m) / succeeded (0.04 m) | +| H1-2 | 6,000 | 1.00 | 17 ms | 22% | succeeded (0.27 m) / succeeded (0.11 m) | + +No fault or estop latch in any of these runs. The H1-2 needs fewer points than +the G1 because its rays hit every geom group, the kitchen's collision geoms +included (`h12_sensors.LIDAR_GEOM_GROUPS`), where the G1's hit the visual geoms +only. A sparser scan than the real sensor's has not been checked for SLAM +quality beyond these goals. For real time on an 8-core Mac: +`GOLEM_LIDAR=1 GOLEM_LIDAR_POINTS=6000` (H1-2) or `10000` (G1, with +`use_hands:=false` on `g1_mac_sim`). + The Mac's GPU is not a way out: in a Podman libkrun VM a container reaches it through Vulkan 1.2 (Venus over MoltenVK, with a patched Mesa), but not through OpenGL/EGL, which MuJoCo's renderer and `mid360.GpuCaster` need (Zink needs a diff --git a/golem_robocasa/h12_mujoco.py b/golem_robocasa/h12_mujoco.py index a2fd414a..39781496 100644 --- a/golem_robocasa/h12_mujoco.py +++ b/golem_robocasa/h12_mujoco.py @@ -51,6 +51,7 @@ def _parser() -> argparse.ArgumentParser: from mujoco_ros_bridge import init_ros, shutdown_ros import h1_2_robosuite # registers H1_2 and the MAGPIE grippers +import mid360 import realsense_profile import robosuite_common import battery_env # registers the Battery env @@ -291,7 +292,10 @@ def sim_loop(task, viewer=True, layout=None, style=None, seed=None, timing=False # GOLEM_LIDAR=0 drops the MID-360 (/livox/*), as on the G1; GOLEM_RENDER=cpu # needs it off (sim_common.require_renderer). _lidar_on = sim_common.env_flag('GOLEM_LIDAR', True) - print(f"[h12_mujoco] MID-360 lidar {'ON' if _lidar_on else 'OFF (GOLEM_LIDAR=0)'}") + # GOLEM_LIDAR_POINTS: points per 10 Hz frame, default the real sensor's 20,000. + _lidar_points = mid360.points_from_env() + print(f"[h12_mujoco] MID-360 lidar " + f"{f'ON, {_lidar_points} points a frame' if _lidar_on else 'OFF (GOLEM_LIDAR=0)'}") _depth_on = sim_common.env_flag('GOLEM_CAMERA_DEPTH', True) _cloud_on = sim_common.env_flag('GOLEM_CAMERA_POINTCLOUD', True) print(f"[h12_mujoco] RGBD cameras {'ON' if _cameras_on else 'OFF (GOLEM_CAMERAS=0)'}" @@ -325,6 +329,7 @@ def sim_loop(task, viewer=True, layout=None, style=None, seed=None, timing=False (pfx, "gripper0_") if sim_common.env_flag("GOLEM_LIDAR_SELF_FILTER", True) else () ), lidar=_lidar_on, + lidar_points=_lidar_points, sim_lock=sim_lock, timings=timings, ), diff --git a/golem_robocasa/h12_sensors.py b/golem_robocasa/h12_sensors.py index fd1f4f0c..c0da575c 100644 --- a/golem_robocasa/h12_sensors.py +++ b/golem_robocasa/h12_sensors.py @@ -192,13 +192,15 @@ class _LidarScans(mid360.ScanRing): """Cast the MID-360's scans on the mid360_scan thread (a mid360.ScanRing) and publish both lidar topics.""" def __init__(self, model, body_id, exclude_body_id, robot_geoms, frame_id, - publish_lidar, publish_cloud, timings=None, sim_lock=None): + publish_lidar, publish_cloud, timings=None, sim_lock=None, + points_per_frame=None): """Build the caster GOLEM_RENDER picks (mid360.make_caster) and start the thread. The sensor's pose is body body_id's; the rays pass through body exclude_body_id's geoms, and a ray whose first hit is in the bool mask robot_geoms (ngeom,) gives no return (a zero point). Each frame goes to publish_lidar(CustomMsg CDR bytes) and publish_cloud(PointCloud2) in frame_id. sim_lock is held for the snapshot copies only. + points_per_frame is the rays a 10 Hz frame fires; None is the real sensor's 20,000. Raises RuntimeError when EGL fails to render. """ body = int(body_id) @@ -209,7 +211,9 @@ def __init__(self, model, body_id, exclude_body_id, robot_geoms, frame_id, caster = mid360.make_caster(model, exclude_body_id, LIDAR_GEOM_GROUPS, render, robot_geoms=robot_geoms) _log(f"lidar rays cast on the {render.upper()} every {caster.batch_s * 1e3:g} ms of sim time") - super().__init__(mid360.Mid360Scanner(caster), model, + rate = (mid360.POINTS_PER_SECOND if points_per_frame is None + else points_per_frame * mid360.FRAME_RATE_HZ) + super().__init__(mid360.Mid360Scanner(caster, points_per_second=rate), model, lambda data: (data.xpos[body], data.xmat[body].reshape(3, 3)), self._publish_frame, caster.batch_s, sim_lock, timings, _log) @@ -308,6 +312,7 @@ def __init__( imu_rate_hz: float = 100.0, lidar_self_prefixes: tuple = (), lidar: bool = True, + lidar_points=None, sim_lock=None, timings=None, ): @@ -321,7 +326,8 @@ def __init__( through; geoms of bodies named with a lidar_self_prefixes prefix give no return. The lidar's GPU caster raises RuntimeError when EGL fails to render. lidar False drops the MID-360 (/livox/lidar, /livox/pointcloud, - /livox/imu), as GOLEM_LIDAR=0 does, and makes no GPU caster. Rates are + /livox/imu), as GOLEM_LIDAR=0 does, and makes no GPU caster; + lidar_points is its points per frame (None, the real 20,000). Rates are Hz of sim time. """ self.node = node @@ -386,7 +392,7 @@ def __init__( self._lidar = (_LidarScans(model, self.lidar_body_id, self.lidar_exclude_body_id, self.geom_is_robot, LIVOX_FRAME, self.pub_lidar.publish, self.pub_pc2.publish, - self.timings, sim_lock) + self.timings, sim_lock, lidar_points) if self.lidar else None) # The cameras render on a worker thread, through MUJOCO_GL's backend, while physics runs. self._camera_worker = ThreadPoolExecutor(max_workers=1, thread_name_prefix="camera") diff --git a/golem_robocasa/mid360.py b/golem_robocasa/mid360.py index 72c055e2..61fe3065 100644 --- a/golem_robocasa/mid360.py +++ b/golem_robocasa/mid360.py @@ -508,6 +508,24 @@ def threads_from_env(env=os.environ): return threads +def points_from_env(env=os.environ): + """Return GOLEM_LIDAR_POINTS, the points per frame: unset or empty is the real sensor's. + + The real sensor's is POINTS_PER_SECOND / FRAME_RATE_HZ (20,000). Raises ValueError, naming + the knob, for anything but an integer of at least 1. + """ + raw = env.get("GOLEM_LIDAR_POINTS", "") + if not raw.strip(): + return int(round(POINTS_PER_SECOND / FRAME_RATE_HZ)) + try: + points = int(raw) + except ValueError: + points = 0 + if points < 1: + raise ValueError(f"GOLEM_LIDAR_POINTS must be an integer of at least 1, got {raw!r}") + return points + + def make_caster(model, exclude_body, geomgroup, render="gpu", robot_geoms=None, threads=None): """Return the caster for render, GOLEM_RENDER's value (sim_common.render_mode). diff --git a/tests/robocasa/test_mid360_cpu.py b/tests/robocasa/test_mid360_cpu.py index da67df97..d820ee2a 100644 --- a/tests/robocasa/test_mid360_cpu.py +++ b/tests/robocasa/test_mid360_cpu.py @@ -118,6 +118,16 @@ def test_cpu_casts_on_golem_lidar_threads(self): finally: caster.close() + def test_points_come_from_golem_lidar_points(self): + """GOLEM_LIDAR_POINTS sets the points per frame; unset or empty is the real 20,000; bad values raise.""" + self.assertEqual(mid360.points_from_env({}), 20000) + self.assertEqual(mid360.points_from_env({"GOLEM_LIDAR_POINTS": ""}), 20000) + self.assertEqual(mid360.points_from_env({"GOLEM_LIDAR_POINTS": "10000"}), 10000) + for bad in ("0", "-5", "many", "1e4"): + with self.subTest(GOLEM_LIDAR_POINTS=bad): + with self.assertRaisesRegex(ValueError, "GOLEM_LIDAR_POINTS"): + mid360.points_from_env({"GOLEM_LIDAR_POINTS": bad}) + def test_an_unknown_render_is_refused(self): """A render other than gpu or cpu raises ValueError, naming it.""" model, _, torso = _scene() From d2a4dfe27dc29ed90e56bb34f66b99c0849c8176 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 19 Nov 2026 11:51:29 -0700 Subject: [PATCH 5/7] Trim the Mac port to what real time needs; make the lean lidar the Mac default Navigation is always on on the Mac, at the most lidar points each robot holds real time with on an 8-core M3: configure_robot exports GOLEM_LIDAR_POINTS 6000 (H1-2) or 10000 (G1) unless set, and g1_mac_sim leaves the Dex3-1 hand driver out by default (use_hands:=true adds it). Removed as not needed for that: GOLEM_LIDAR_THREADS (more threads did not speed the stack), the H1-2's GOLEM_LIDAR=0 knob and h12_sim's use_nav, the Mac's GOLEM_LIDAR default and use_nav-from-GOLEM_LIDAR in the Mac bringups, the wrappers' platform line, and check_unitree_dds.py (the same check now runs inline in docker/mac/BaseDockerfile). docs/MAC.md keeps the setup, the run flow and the measurements. Measured on the defaults, nothing set in the shell: both navigation stacks at 1.00x, every goal ahead reached, no faults or estop latches. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015EG7pDNJLWR31eQmyKaWhr --- .dockerignore | 4 - CLAUDE.md | 8 +- .../launch/g1/g1_mac_sim.launch.py | 29 ++-- .../launch/h12/h12_mac_sim.launch.py | 22 +-- .../launch/h12/h12_sim.launch.py | 13 +- .../src/golem_bringup/test/test_sim_time.py | 44 +++-- docker/docker-compose.mac.yml | 24 +-- docker/mac/BaseDockerfile | 15 +- docker/mac/check_unitree_dds.py | 45 ------ docker/scripts/docker_common.sh | 19 ++- docker/scripts/docker_run.sh | 2 - docker/scripts/docker_stack.sh | 6 +- docs/MAC.md | 153 +++++------------- golem_robocasa/g1/g1_mujoco.py | 2 +- golem_robocasa/h12_mujoco.py | 16 +- golem_robocasa/h12_sensors.py | 56 +++---- golem_robocasa/mid360.py | 21 +-- golem_robocasa/sim_common.py | 5 +- tests/docker/test_workflows.py | 4 +- tests/robocasa/test_gpu_required.py | 16 +- tests/robocasa/test_mid360_cpu.py | 23 ++- 21 files changed, 166 insertions(+), 361 deletions(-) delete mode 100644 docker/mac/check_unitree_dds.py diff --git a/.dockerignore b/.dockerignore index 7d8f7895..98f5b7ae 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,7 +7,6 @@ # docker/scripts/package_humble_runtime.py IsaacDockerfile # docker/locks/** every Dockerfile # docker/patches/** RobocasaDockerfile -# docker/mac/check_unitree_dds.py mac/BaseDockerfile # Their .git entries stay out. * !core_ws @@ -31,6 +30,3 @@ docker/scripts/* !docker/locks/** !docker/patches !docker/patches/** -!docker/mac -docker/mac/* -!docker/mac/check_unitree_dds.py diff --git a/CLAUDE.md b/CLAUDE.md index be772716..a54657c8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -34,8 +34,8 @@ against its sim and the real robot, so code moves between them unchanged. The G1 runs in Unitree's debug mode: Unitree's own controller is released, and the stack drives every motor on `rt/lowcmd`, as on the H1-2. The stack runs on one platform, x86 Linux with an NVIDIA GPU. An Apple Silicon Mac runs a reduced -RoboCasa sim of either robot (no model servers or Isaac; the lidar, cast on the -CPU, and navigation only with `GOLEM_LIDAR=1`): `docs/MAC.md`. +RoboCasa sim of either robot at real time (no model servers or Isaac; the lidar +cast on the CPU, with fewer points): `docs/MAC.md`. The H1-2 is the default everywhere. `GOLEM_ROBOT=g1` or `--g1` on a simulator or stack wrapper selects the G1 where the attached robot matters: the sim and @@ -94,7 +94,7 @@ launch bringup**. `docker/scripts/docker_common.sh` owns this, and the platform too: on Darwin arm64 (or `GOLEM_PLATFORM=mac`) every wrapper adds `docker-compose.mac.yml` (the arm64 images of `docker/mac/`, no NVIDIA runtime, `GOLEM_RENDER=cpu`, -`GOLEM_LIDAR=0` unless set), refuses Isaac, and `docker_stack.sh` starts `h12_mac_sim` or +`GOLEM_LIDAR_POINTS` 6000 for the H1-2 and 10000 for the G1 unless set), refuses Isaac, and `docker_stack.sh` starts `h12_mac_sim` or `g1_mac_sim`; on Linux nothing changes (`docs/MAC.md`). On simulator and stack wrappers, the robot is `--g1`/`--h12` on the wrapper, else `GOLEM_ROBOT` from the shell, else from `docker/.env`, else `h12`. The selection means "which robot is @@ -528,7 +528,7 @@ stops at start, once its command line is parsed and before it builds a scene or starts ROS or DDS, with one message (`sim_common.require_gpu`). The one way past it is the Mac images' opt-in `GOLEM_RENDER=cpu` (OSMesa for the cameras, the MID-360 cast exactly on the CPU by `mid360.CpuCaster`; `sim_common.require_renderer`, -`mid360.make_caster`). The H1-2 sim honours `GOLEM_LIDAR=0` as the G1's does. The H1-2 +`mid360.make_caster`). The H1-2 stays the default, and nothing on the G1 path may change its behaviour. The robots share `sim_common.py`, `measurement_bridge.py`, the pacer in `sim_timing.py` (its `--timing` report is the H1-2's only) and the `mujoco_sensors` node in diff --git a/core_ws/src/golem_bringup/launch/g1/g1_mac_sim.launch.py b/core_ws/src/golem_bringup/launch/g1/g1_mac_sim.launch.py index 1a4486bc..3d1052a1 100644 --- a/core_ws/src/golem_bringup/launch/g1/g1_mac_sim.launch.py +++ b/core_ws/src/golem_bringup/launch/g1/g1_mac_sim.launch.py @@ -1,15 +1,14 @@ """ -Start the G1 against the Mac's RoboCasa sim: g1_sim without skills. +Start the G1 against the Mac's RoboCasa sim: g1_sim without skills or the hand driver. - ros2 launch golem_bringup g1_mac_sim.launch.py [use_hands:=false] [use_rviz:=false] + ros2 launch golem_bringup g1_mac_sim.launch.py [use_hands:=true] [use_rviz:=true] The Mac sim (docker/docker-compose.mac.yml, docs/MAC.md) renders on the CPU and casts its -MID-360 on the CPU only with GOLEM_LIDAR=1, so this includes g1_sim.launch.py with -use_skills false and use_nav as given: by default GOLEM_LIDAR (0 or 1, from -docker-compose.mac.yml), so navigation runs exactly when the sim has its lidar. Everything -else is g1_sim's: g1_core with sim:=true (golem_safety and the controller on sim_split, -the leg node running HOMIE, which releases the sim's elastic band once the policy runs), -the Dex3-1 hand driver (use_hands) and, with use_rviz, RViz. +MID-360 on the CPU, and an 8-core Mac holds real time only without the Dex3-1 hand +driver, so this includes g1_sim.launch.py with use_skills false and use_hands false by +default. Everything else is g1_sim's: g1_core with sim:=true (golem_safety and the +controller on sim_split, the leg node running HOMIE, which releases the sim's elastic band +once the policy runs), navigation (golem_slam on FAST-LIO) and, with use_rviz, RViz. Start the simulator first; every node joins the launching shell's ROS_DOMAIN_ID, which must be a sim domain (safety_node refuses sim:=true on domain 0). @@ -18,7 +17,7 @@ from golem_bringup.include import include from launch import LaunchDescription from launch.actions import DeclareLaunchArgument -from launch.substitutions import EnvironmentVariable, LaunchConfiguration +from launch.substitutions import LaunchConfiguration def generate_launch_description(): @@ -26,18 +25,14 @@ def generate_launch_description(): return LaunchDescription([ DeclareLaunchArgument('use_rviz', default_value='false', description='true: start RViz (needs a display in golem_ros)'), - DeclareLaunchArgument('use_hands', default_value='true', - description='true: start dex3_hands, the Dex3-1 hand driver'), - DeclareLaunchArgument('use_nav', default_value=EnvironmentVariable('GOLEM_LIDAR', - default_value='0'), - description="true or 1: golem_slam's FAST-LIO, SLAM and Nav2 " - "on the sim's CPU-cast MID-360 (needs GOLEM_LIDAR=1 " - 'on the sim); default: GOLEM_LIDAR, else 0'), + DeclareLaunchArgument('use_hands', default_value='false', + description='true: start dex3_hands, the Dex3-1 hand driver ' + '(about a quarter of a core: the stack then falls ' + 'below real time on an 8-core Mac)'), # The whole G1 sim bringup, without the parts the Mac cannot run. include('golem_bringup', 'g1/g1_sim.launch.py', { 'use_rviz': LaunchConfiguration('use_rviz'), 'use_hands': LaunchConfiguration('use_hands'), - 'use_nav': LaunchConfiguration('use_nav'), 'use_skills': 'false', }), ]) diff --git a/core_ws/src/golem_bringup/launch/h12/h12_mac_sim.launch.py b/core_ws/src/golem_bringup/launch/h12/h12_mac_sim.launch.py index 94d82a1f..41f336d9 100644 --- a/core_ws/src/golem_bringup/launch/h12/h12_mac_sim.launch.py +++ b/core_ws/src/golem_bringup/launch/h12/h12_mac_sim.launch.py @@ -3,14 +3,12 @@ ros2 launch golem_bringup h12_mac_sim.launch.py [policy:=almi] [use_rviz:=false] -The Mac sim (docker/docker-compose.mac.yml, docs/MAC.md) renders on the CPU and casts its -MID-360 on the CPU only with GOLEM_LIDAR=1, and the Mac's golem_ros image has no -model-server stack, so this includes h12_sim.launch.py with use_vision and use_skills false -and use_nav as given: by default GOLEM_LIDAR (0 or 1, from docker-compose.mac.yml), so -navigation runs exactly when the sim has its lidar. Everything else is -h12_sim's, in its order: the leg node's check first, then the state publishers, the -command path (estop_node on the sim's estop box, safety_node, frame_task_server), the -legs and, with use_rviz, RViz. +The Mac's golem_ros image has no model-server stack (docker/mac/RosDockerfile, +docs/MAC.md), so this includes h12_sim.launch.py with use_vision and use_skills false. +Everything else is h12_sim's, in its order: the leg node's check first, then the state +publishers, the command path (estop_node on the sim's estop box, safety_node, +frame_task_server), the legs, navigation (golem_slam on FAST-LIO, on the MID-360 the Mac +sim casts on the CPU) and, with use_rviz, RViz. SAFETY: the operator gates are h12_sim's: the sim's estop box (ENTER on the sim's terminal; golem_safety then latches until restart), and the leg policy holds its @@ -24,7 +22,7 @@ from golem_bringup.include import include from launch import LaunchDescription from launch.actions import DeclareLaunchArgument -from launch.substitutions import EnvironmentVariable, LaunchConfiguration +from launch.substitutions import LaunchConfiguration def generate_launch_description(): @@ -35,16 +33,10 @@ def generate_launch_description(): DeclareLaunchArgument('policy', default_value='almi', description='The policy golem_lowerbody_rl runs on the legs: ' 'almi, fame or walk; any other is refused'), - DeclareLaunchArgument('use_nav', default_value=EnvironmentVariable('GOLEM_LIDAR', - default_value='0'), - description="true or 1: golem_slam's FAST-LIO, SLAM and Nav2 " - "on the sim's CPU-cast MID-360 (needs GOLEM_LIDAR=1 " - 'on the sim); default: GOLEM_LIDAR, else 0'), # The whole H1-2 sim bringup, without the parts the Mac cannot run. include('golem_bringup', 'h12/h12_sim.launch.py', { 'use_rviz': LaunchConfiguration('use_rviz'), 'policy': LaunchConfiguration('policy'), - 'use_nav': LaunchConfiguration('use_nav'), 'use_vision': 'false', 'use_skills': 'false', }), diff --git a/core_ws/src/golem_bringup/launch/h12/h12_sim.launch.py b/core_ws/src/golem_bringup/launch/h12/h12_sim.launch.py index 20bfd36b..be496410 100644 --- a/core_ws/src/golem_bringup/launch/h12/h12_sim.launch.py +++ b/core_ws/src/golem_bringup/launch/h12/h12_sim.launch.py @@ -9,10 +9,9 @@ (h12_control as on the real robot: the safety/controller pairing check before any node, then estop_node on the sim's estop box, safety_node and frame_task_server with the real robot's configs and delays), the leg controller (h12_lowerbody, with the start pose taken -as verified), the model servers and golem_skills (golem_vision_models; use_vision), -navigation (use_nav), the static camera_link -> camera_color_optical_frame TF and RViz -(use_rviz). use_vision and use_nav default to true; h12_mac_sim.launch.py turns both off -for the Mac sim, which has no lidar and no GPU for the model servers. +as verified), the model servers and golem_skills (golem_vision_models; use_vision, +default true, which h12_mac_sim.launch.py turns off: the Mac has no GPU for them), +navigation, the static camera_link -> camera_color_optical_frame TF and RViz (use_rviz). SAFETY: the sim runs the real robot's operator gates: the estop box the sim serves (ENTER on the sim's terminal or viewer presses it; golem_safety then latches until restart), and @@ -81,9 +80,6 @@ def generate_launch_description(): description='true: start the model servers (gemini, sam, and ' 'with use_skills graspgen and golem_skills); ' 'false: none of them, use_skills included'), - DeclareLaunchArgument('use_nav', default_value='true', - description="true: golem_slam's FAST-LIO, SLAM and Nav2 on the " - "sim's MID-360; false: no navigation"), # SAFETY: first, so a refused policy or run config starts no node: the leg # block, which checks them too, is included after the others. @@ -113,8 +109,7 @@ def generate_launch_description(): 'record_runs': LaunchConfiguration('record_runs'), }, condition=IfCondition(LaunchConfiguration('use_vision'))), # SLAM and Nav2, driving the legs on /cmd_vel. - include('golem_slam', 'navigation.launch.py', {**sim_time, 'robot': 'h12'}, - condition=IfCondition(LaunchConfiguration('use_nav'))), + include('golem_slam', 'navigation.launch.py', {**sim_time, 'robot': 'h12'}), # For Isaac: its head camera's images are stamped # camera_color_optical_frame (CL_isaaclab_sim's ros_sensor_bridge.py, diff --git a/core_ws/src/golem_bringup/test/test_sim_time.py b/core_ws/src/golem_bringup/test/test_sim_time.py index eb7ca9e6..6251082e 100644 --- a/core_ws/src/golem_bringup/test/test_sim_time.py +++ b/core_ws/src/golem_bringup/test/test_sim_time.py @@ -32,8 +32,8 @@ ('lmg_sim.launch.py', {'start_position_verified': 'true', 'use_slam': 'true', 'use_skills': 'true'}, True), ('g1_sim.launch.py', {'use_skills': 'true', 'use_nav': 'true', 'use_rviz': 'true'}, True), - ('h12_mac_sim.launch.py', {'use_rviz': 'true', 'use_nav': 'true'}, True), - ('g1_mac_sim.launch.py', {'use_rviz': 'true', 'use_nav': 'true'}, True), + ('h12_mac_sim.launch.py', {'use_rviz': 'true'}, True), + ('g1_mac_sim.launch.py', {'use_rviz': 'true', 'use_hands': 'true'}, True), ('h12_real_robot.launch.py', {'start_position_verified': 'true'}, False), ('lmg_real.launch.py', {'start_position_verified': 'true'}, False), ('h12_real_desktop.launch.py', {'use_hand_cameras': 'true'}, False), @@ -136,10 +136,9 @@ def test_every_node_runs_on_its_bringups_clock(launch_file, args, sim_time, monk assert wrong == [], f'{launch_file}: nodes not on use_sim_time {sim_time}: {wrong}' -# Packages of the nodes the Mac sim bringups leave out: navigation (no lidar on the Mac -# sim) and the model servers and skills (no GPU stack in the Mac's golem_ros). -NAV_AND_VISION = ('fast_lio', 'golem_slam', 'slam_toolbox', 'octomap_server', - 'pointcloud_to_laserscan', 'model_server', 'golem_skills') +# Packages of the nodes the Mac sim bringups leave out: the model servers and skills (no +# GPU stack in the Mac's golem_ros). +VISION = ('model_server', 'golem_skills') def _packages(launch_file, args): @@ -149,34 +148,29 @@ def _packages(launch_file, args): @pytest.mark.parametrize('mac_file, sim_file, sim_args, core', [ ('h12_mac_sim.launch.py', 'h12_sim.launch.py', {'use_rviz': 'false'}, - {'golem_safety', 'golem_upper_ik', 'golem_lowerbody_rl', 'estop'}), + {'golem_safety', 'golem_upper_ik', 'golem_lowerbody_rl', 'estop', 'fast_lio', 'golem_slam'}), ('g1_mac_sim.launch.py', 'g1_sim.launch.py', {'use_rviz': 'false'}, - {'golem_safety', 'golem_upper_ik', 'golem_lowerbody_rl', 'dex_3'}), + {'golem_safety', 'golem_upper_ik', 'golem_lowerbody_rl', 'fast_lio', 'golem_slam'}), ]) -def test_mac_sim_is_the_sim_bringup_without_nav_or_vision(mac_file, sim_file, sim_args, core, - monkeypatch): - """Without GOLEM_LIDAR a Mac sim bringup starts its command path and legs, no nav or vision.""" +def test_mac_sim_is_the_sim_bringup_without_vision(mac_file, sim_file, sim_args, core, + monkeypatch): + """A Mac sim bringup starts the command path, legs and navigation, and no model server or skill.""" monkeypatch.setenv('ROS_DOMAIN_ID', SIM_DOMAIN) - monkeypatch.delenv('GOLEM_LIDAR', raising=False) mac = _packages(mac_file, {}) assert core <= mac, mac - assert mac.isdisjoint(NAV_AND_VISION), mac & set(NAV_AND_VISION) - assert not [package for package in mac if package.startswith('nav2_')], mac + assert mac.isdisjoint(VISION), mac & set(VISION) assert mac <= _packages(sim_file, sim_args), mac -def test_h12_sim_defaults_keep_nav_and_vision(monkeypatch): - """h12_sim.launch.py with its defaults still starts navigation and the model servers.""" +def test_g1_mac_sim_leaves_the_hand_driver_out(monkeypatch): + """g1_mac_sim starts no dex3_hands by default, and does with use_hands:=true.""" monkeypatch.setenv('ROS_DOMAIN_ID', SIM_DOMAIN) - packages = _packages('h12_sim.launch.py', {}) - assert {'fast_lio', 'model_server', 'golem_skills'} <= packages, packages + assert 'dex_3' not in _packages('g1_mac_sim.launch.py', {}) + assert 'dex_3' in _packages('g1_mac_sim.launch.py', {'use_hands': 'true'}) -@pytest.mark.parametrize('mac_file', ['h12_mac_sim.launch.py', 'g1_mac_sim.launch.py']) -def test_mac_sim_navigates_when_the_sim_has_its_lidar(mac_file, monkeypatch): - """GOLEM_LIDAR=1 (the sim casts its MID-360 on the CPU) adds navigation, still no vision.""" +def test_h12_sim_defaults_keep_vision(monkeypatch): + """h12_sim.launch.py with its defaults still starts the model servers and skills.""" monkeypatch.setenv('ROS_DOMAIN_ID', SIM_DOMAIN) - monkeypatch.setenv('GOLEM_LIDAR', '1') - packages = _packages(mac_file, {}) - assert {'fast_lio', 'golem_slam', 'slam_toolbox'} <= packages, packages - assert packages.isdisjoint({'model_server', 'golem_skills'}), packages + packages = _packages('h12_sim.launch.py', {}) + assert {'fast_lio', 'model_server', 'golem_skills'} <= packages, packages diff --git a/docker/docker-compose.mac.yml b/docker/docker-compose.mac.yml index a09dc9fe..643f84a8 100644 --- a/docker/docker-compose.mac.yml +++ b/docker/docker-compose.mac.yml @@ -7,8 +7,7 @@ # OrbStack or Docker Desktop (host networking on) both containers share the # Linux VM's network, so DDS between them works; the macOS host is not on it, # so ros2 and RViz run inside golem_ros. docs/MAC.md has the flow and what the -# Mac sims leave out (the GPU vision models, Isaac; the lidar and navigation -# only with GOLEM_LIDAR=1). +# Mac leaves out (the GPU vision models, Isaac). services: robocasa: build: @@ -21,18 +20,12 @@ services: shm_size: 2g environment: # gpu (the sims' default, an NVIDIA GPU over EGL) or cpu (OSMesa, the - # MID-360 on the CPU): golem_robocasa/sim_common.py. The Mac has only cpu. + # MID-360 cast exactly on the CPU): golem_robocasa/sim_common.py. The + # Mac has only cpu. GOLEM_RENDER: cpu - # Both robots' MID-360, off by default: GOLEM_LIDAR=1 casts its rays - # exactly on the CPU (mid360.CpuCaster), much slower than the x86 GPU, - # and the Mac bringups then run navigation. configure_platform exports - # the same default, so docker-compose.g1.yml's GOLEM_LIDAR agrees. - GOLEM_LIDAR: ${GOLEM_LIDAR:-0} - # Threads the CPU lidar casts on (mid360.threads_from_env); empty: a - # quarter of the VM's CPUs, at most 4. - GOLEM_LIDAR_THREADS: ${GOLEM_LIDAR_THREADS:-} - # Both robots' MID-360 points per frame (empty: the real 20,000); - # 10000 halves the CPU lidar's cost (docs/MAC.md). + # Both robots' MID-360 points per frame. configure_robot exports the + # Mac's default per robot (6000 for the H1-2, 10000 for the G1: the + # most each holds real time with on an 8-core M3, docs/MAC.md). GOLEM_LIDAR_POINTS: ${GOLEM_LIDAR_POINTS:-} # Software-rendered cameras cost the most per step: off unless asked for. GOLEM_CAMERAS: ${GOLEM_CAMERAS:-0} @@ -44,12 +37,9 @@ services: runtime: !reset null shm_size: 2g environment: - # The sim's lidar knob: h12_mac_sim and g1_mac_sim default use_nav to it. - GOLEM_LIDAR: ${GOLEM_LIDAR:-0} # core_ws/cyclonedds.xml, then an override of its 16 MB minimum UDP # receive buffer: the minimum makes every ROS node fail to create its # domain unless the kernel's net.core.rmem_max allows it, which the # OrbStack / Docker Desktop VM does not by default (docs/DDS_TUNING.md - # raises it on Linux hosts). The Mac sims stream no lidar or cameras by - # default, the bursts the large buffer absorbs. + # raises it on Linux hosts). CYCLONEDDS_URI: "file:///home/code/cyclonedds.xml," diff --git a/docker/mac/BaseDockerfile b/docker/mac/BaseDockerfile index 229e287c..ccf5672a 100644 --- a/docker/mac/BaseDockerfile +++ b/docker/mac/BaseDockerfile @@ -104,10 +104,11 @@ ENV CYCLONEDDS_HOME=/cyclonedds/install # SDK loads crc_aarch64.so on this platform. cyclonedds builds from source # (--no-binary) against CYCLONEDDS_HOME; its _clayer extension is then pointed # at libddsc_unitree.so.0 in /cyclonedds/install/lib (one patchelf call per -# change: patchelf 0.14 mangles combined ones). check_unitree_dds.py fails the -# build if the SDK and a ROS node cannot share a domain in one process. +# change: patchelf 0.14 mangles combined ones). The last step fails the build +# if the SDK and a ROS node cannot share one process, as the sims do: with two +# libddsc.so.0 the first Unitree topic after rclpy segfaults. Domain 232: no +# sim or robot uses it. COPY unitree_sdk2_python /home/code/unitree_sdk2_python -COPY docker/mac/check_unitree_dds.py /opt/golem-checks/ RUN cd /home/code/unitree_sdk2_python && \ uv pip install -c /opt/golem-locks/base-arm64-01.txt --system --no-binary cyclonedds . && \ SP=$(python3 -c "import site; print(site.getsitepackages()[0])") && \ @@ -117,8 +118,12 @@ RUN cd /home/code/unitree_sdk2_python && \ done && \ cp -r /home/code/unitree_sdk2_python/unitree_sdk2py/* "$SP/unitree_sdk2py/" && \ python3 -c "from unitree_sdk2py.utils.crc import CRC; CRC()" && \ - python3 /opt/golem-checks/check_unitree_dds.py && \ - bash -c 'source /opt/ros/humble/setup.bash && python3 /opt/golem-checks/check_unitree_dds.py --ros' + bash -c 'source /opt/ros/humble/setup.bash && ROS_DOMAIN_ID=232 python3 -X faulthandler -c "\ +import rclpy; \ +from unitree_sdk2py.core.channel import ChannelFactoryInitialize, ChannelPublisher; \ +from unitree_sdk2py.idl.unitree_hg.msg.dds_ import LowState_; \ +ChannelFactoryInitialize(232); ChannelPublisher(\"rt/lowstate\", LowState_).Init(); \ +rclpy.init(); rclpy.create_node(\"check_unitree_dds\").destroy_node(); rclpy.shutdown()"' # PyTorch and torchvision, CPU builds for linux/aarch64 (the TorchScript leg # policies run on the CPU on every platform). diff --git a/docker/mac/check_unitree_dds.py b/docker/mac/check_unitree_dds.py deleted file mode 100644 index 07fa8b26..00000000 --- a/docker/mac/check_unitree_dds.py +++ /dev/null @@ -1,45 +0,0 @@ -"""Check the Unitree SDK's DDS and a ROS node can share one DDS domain in one process. - -Usage: python3 check_unitree_dds.py [--ros] - Without --ros: open a Unitree rt/lowstate publisher (the SDK's own CycloneDDS). - --ros (ROS sourced): import rclpy first, as the sims do, then open the Unitree - publisher and create a ROS node with a publisher on the same domain, as the sims' - sensor bridge does. -Run by docker/mac/BaseDockerfile, so an image whose two CycloneDDS copies collide -(a segfault in the first Unitree topic, or a ROS domain the SDK already holds) -fails its build. Exit status: 0 when every step works; otherwise the failing -step's error or signal. -""" -import faulthandler -import os -import sys - -# A domain no sim or real robot uses, so a build host's DDS traffic is not joined. -DOMAIN = 232 - - -def main() -> None: - """Run the steps; raise on the first that fails.""" - faulthandler.enable() - ros = "--ros" in sys.argv[1:] - if ros: - os.environ["ROS_DOMAIN_ID"] = str(DOMAIN) - import rclpy - from rclpy.node import Node - from std_msgs.msg import Empty - from unitree_sdk2py.core.channel import ChannelFactoryInitialize, ChannelPublisher - from unitree_sdk2py.idl.unitree_hg.msg.dds_ import LowState_ - - ChannelFactoryInitialize(DOMAIN) - ChannelPublisher("rt/lowstate", LowState_).Init() - if ros: - rclpy.init() - node = Node("check_unitree_dds") - node.create_publisher(Empty, "check_unitree_dds", 1) - node.destroy_node() - rclpy.shutdown() - print(f"check_unitree_dds: ok{' (with a ROS node)' if ros else ''}") - - -if __name__ == "__main__": - main() diff --git a/docker/scripts/docker_common.sh b/docker/scripts/docker_common.sh index 9f28ffb5..421b8795 100755 --- a/docker/scripts/docker_common.sh +++ b/docker/scripts/docker_common.sh @@ -76,9 +76,8 @@ load_config() { # docker/.env's GOLEM_PLATFORM, else mac on Darwin arm64 (Apple Silicon), else # linux. linux leaves COMPOSE as load_config made it (the x86 / NVIDIA images). # mac adds docker-compose.mac.yml (the arm64 images of docker/mac/, no NVIDIA -# runtime, the sims on CPU rendering), exports GOLEM_LIDAR=0 unless set (the -# CPU lidar is slow; 1 adds it and navigation) and headless unless GOLEM_DISPLAY is set -# (there is no X server). Called by load_config. +# runtime, the sims on CPU rendering) and exports headless unless GOLEM_DISPLAY +# is set (there is no X server). Called by load_config. configure_platform() { local platform=${GOLEM_PLATFORM:-} if [ -z "$platform" ]; then @@ -88,7 +87,6 @@ configure_platform() { linux) ;; mac) COMPOSE+=(-f "$GOLEM_ROOT/docker/docker-compose.mac.yml") - export GOLEM_LIDAR="${GOLEM_LIDAR:-0}" export GOLEM_DISPLAY="${GOLEM_DISPLAY:-headless}" ;; *) fail "GOLEM_PLATFORM must be linux or mac, not '$platform'.";; @@ -126,7 +124,8 @@ parse_robot_flags() { # Select the robot of simulator service $1 and export it as GOLEM_ROBOT (h12 or # g1): ROBOT_FLAG, else the shell's or docker/.env's GOLEM_ROBOT, else h12. The -# G1 adds docker-compose.g1.yml and runs only with RoboCasa. +# G1 adds docker-compose.g1.yml and runs only with RoboCasa. On the Mac it also +# exports the robot's GOLEM_LIDAR_POINTS default. configure_robot() { local service=$1 robot robot=$(printf '%s' "${ROBOT_FLAG:-${GOLEM_ROBOT:-h12}}" | tr '[:upper:]' '[:lower:]') @@ -139,6 +138,16 @@ configure_robot() { *) fail "GOLEM_ROBOT must be h12 or g1, not '$robot'.";; esac export GOLEM_ROBOT=$robot + # The Mac casts the MID-360 on the CPU: fewer points than the real 20,000 a + # frame keep the sim and the navigation stack at real time on an 8-core M3 + # (docs/MAC.md). A shell or docker/.env value wins. + if [ "${GOLEM_PLATFORM:-linux}" = mac ]; then + if [ "$robot" = g1 ]; then + export GOLEM_LIDAR_POINTS=${GOLEM_LIDAR_POINTS:-10000} + else + export GOLEM_LIDAR_POINTS=${GOLEM_LIDAR_POINTS:-6000} + fi + fi } # SAFETY: domain 0 is the real robots' command bus. Refuse it for every service diff --git a/docker/scripts/docker_run.sh b/docker/scripts/docker_run.sh index 4e74f85f..6cb48a64 100755 --- a/docker/scripts/docker_run.sh +++ b/docker/scripts/docker_run.sh @@ -32,8 +32,6 @@ else configure_robot "$SIM" echo "robot: $GOLEM_ROBOT" >&2 fi -# The Mac runs the arm64 images (configure_platform); Linux prints nothing here. -[ "$GOLEM_PLATFORM" != mac ] || echo "platform: mac (arm64, CPU rendering, lidar $([ "$GOLEM_LIDAR" = 1 ] && echo 'on the CPU' || echo off))" >&2 RESTART=0 if [ "${1:-}" = --restart ]; then RESTART=1; shift; fi # Pin the container to its CPUs (robocasa, ros; not the Isaac simulator). Before the diff --git a/docker/scripts/docker_stack.sh b/docker/scripts/docker_stack.sh index dd8a54aa..e61dec0d 100755 --- a/docker/scripts/docker_stack.sh +++ b/docker/scripts/docker_stack.sh @@ -50,12 +50,10 @@ fi if [ "$ACTION" = logs ]; then exec "${COMPOSE[@]}" logs -f "$SIM" ros; fi configure_robot "$SIM" echo "robot: $GOLEM_ROBOT" >&2 -# The Mac runs the arm64 images (configure_platform); Linux prints nothing here. -[ "$GOLEM_PLATFORM" != mac ] || echo "platform: mac (arm64, CPU rendering, lidar $([ "$GOLEM_LIDAR" = 1 ] && echo 'on the CPU' || echo off))" >&2 # Read by docker-compose.stack.yml. Set here, from the selected robot and # platform, because a value left in the shell or docker/.env would start the -# other robot's bringup. The Mac runs the mac_sim bringups (navigation only -# with GOLEM_LIDAR=1, no vision models; docs/MAC.md). +# other robot's bringup. The Mac runs the mac_sim bringups (no vision models; +# docs/MAC.md). if [ "$GOLEM_PLATFORM" = mac ]; then export GOLEM_BRINGUP_LAUNCH=${GOLEM_ROBOT}_mac_sim.launch.py elif [ "$GOLEM_ROBOT" = g1 ]; then diff --git a/docs/MAC.md b/docs/MAC.md index bcf2d1cc..b8d182b5 100644 --- a/docs/MAC.md +++ b/docs/MAC.md @@ -1,12 +1,12 @@ # The Mac (Apple Silicon) The stack's platform is x86 Linux with an NVIDIA GPU. An Apple Silicon Mac runs -a reduced RoboCasa sim of either robot: the command path (`golem_safety`, -`golem_upper_ik`), the legs (`golem_lowerbody_rl`) and walking on `/cmd_vel`, -and with `GOLEM_LIDAR=1` the MID-360 cast on the CPU and navigation (FAST-LIO, -SLAM, Nav2) on it. It has no model servers or skills, and no Isaac sim. -Use it to develop and check controllers and bringup away from the lab -machines; the closed-loop tests (`tests/sim`, `tests/g1`) stay x86 gates. +a reduced RoboCasa sim of either robot at real time: the command path +(`golem_safety`, `golem_upper_ik`), the legs (`golem_lowerbody_rl`), and +navigation (FAST-LIO, SLAM, Nav2) on a MID-360 cast on the CPU. It has no model +servers or skills, and no Isaac sim. Use it to develop and check controllers, +bringup and navigation away from the lab machines; the closed-loop tests +(`tests/sim`, `tests/g1`) stay x86 gates. ## What differs from x86 @@ -16,14 +16,13 @@ machines; the closed-loop tests (`tests/sim`, `tests/g1`) stay x86 gates. | Python locks | `docker/locks/*-amd64*.txt` | `docker/locks/*-arm64*.txt`, derived from the amd64 locks by `docker/mac/derive_arm64_locks.sh` (CPU torch, no CUDA wheels, open3d 0.18.0) | | Compose | `docker/docker-compose.yml` | the same, plus `docker/docker-compose.mac.yml` (no NVIDIA runtime) | | Sim rendering | EGL on the GPU (`GOLEM_RENDER=gpu`) | OSMesa on the CPU (`GOLEM_RENDER=cpu`); cameras off by default (`GOLEM_CAMERAS=0`) | -| MID-360 lidar | on, cast on the GPU (`mid360.GpuCaster`) | off by default; `GOLEM_LIDAR=1` casts it exactly on the CPU (`mid360.CpuCaster`) | -| Bringup | `h12_sim`, `g1_sim` | `h12_mac_sim`, `g1_mac_sim`: the sim bringups without model servers or skills, navigation exactly when `GOLEM_LIDAR=1` | +| MID-360 lidar | cast on the GPU (`mid360.GpuCaster`), 20,000 points a frame | cast exactly on the CPU (`mid360.CpuCaster`); `GOLEM_LIDAR_POINTS` 6,000 (H1-2) or 10,000 (G1) a frame by default | +| Bringup | `h12_sim`, `g1_sim` | `h12_mac_sim`, `g1_mac_sim`: the sim bringups without model servers or skills; the G1's without the hand driver (`use_hands:=true` adds it) | | Not available | — | Isaac, `golem_skills`, the model servers (GraspGenX has no CPU path) | The wrappers pick the Mac by themselves on Darwin arm64 (`GOLEM_PLATFORM=mac`; -`GOLEM_PLATFORM=linux` forces the x86 path) and print -`platform: mac (arm64, CPU rendering, lidar off|on the CPU)` beside `robot:`. Nothing on -Linux changes: there the wrappers make the same docker calls as before. +`GOLEM_PLATFORM=linux` forces the x86 path). Nothing on Linux changes: there the +wrappers make the same docker calls as before. ## Setup @@ -34,7 +33,7 @@ Linux changes: there the wrappers make the same docker calls as before. - Submodules and LFS as in [Setup](SETUP.md) §1; `docker/.env` as in §2 (`GEMINI_API_KEY` is not needed). - About 70 GB of disk for the images (the RoboCasa image holds about 10 GB of - kitchen assets) and 8 GB of memory for the VM. + kitchen assets), and every core and 8 GB of memory for the VM. ```bash docker/scripts/docker_build.sh # golem_base, golem_sim_robocasa, golem_ros, all :arm64 (about 35 min) @@ -52,113 +51,39 @@ GOLEM_SPAWN_BACKOFF=2.0 docker/scripts/docker_stack.sh up robocasa --h12 docker exec -it golem_ros bash source /opt/ros/humble/setup.bash && source /home/code/core_ws/install/setup.bash ros2 service call /lowerbody/confirm_engage std_srvs/srv/Trigger -ros2 topic pub -r 20 /cmd_vel geometry_msgs/msg/Twist "{linear: {x: 0.3}}" -ros2 action send_goal /named_config custom_ros_messages/action/NamedConfig \ - "{config_name: t_pose, plan: false, duration: {sec: 15, nanosec: 0}}" ``` -Navigation: add `GOLEM_LIDAR=1` to either `up` (the bringups then start -`golem_slam`), wait for Nav2's lifecycle nodes, and send `/navigate_to_pose` -goals in `map`, as on x86 ([Navigation demo](NAVIGATION_DEMO.md)). - -`docker_stack.sh` runs a random kitchen task; with the arms out (`t_pose`) the -robot can touch a fixture, and the goal then fails its steady-state hold. The -three-terminal flow of [Running the stack](RUNNING.md) works too -(`docker_run.sh robocasa --g1 --task Blank`, then `ros2 launch golem_bringup -g1_mac_sim.launch.py` in `golem_ros`). +Then send `/navigate_to_pose` goals in `map` once Nav2's lifecycle nodes are up, +as on x86 ([Navigation demo](NAVIGATION_DEMO.md)). The three-terminal flow of +[Running the stack](RUNNING.md) works too (`docker_run.sh robocasa --g1`, then +`ros2 launch golem_bringup g1_mac_sim.launch.py` in `golem_ros`). ## Measured speed -Measured 2026-11-18 on a MacBook Air M3 (4 performance + 4 efficiency cores, -16 GB), OrbStack with 8 CPUs and 8 GB, headless, one run each. The real-time -factor (RTF) is sim seconds per wall second: the G1's from its -`[g1_mujoco] ... real-time factor` lines, the H1-2's from `--timing`, the -stacks' from `/clock` against wall time in `golem_ros`. - -**The sim alone** (no stack: motors off, unpaced, `GOLEM_SIM_RATE=max`): - -| Scene | G1 | H1-2 | -|---|---|---| -| Blank, no sensors | 9.1-10.0x | — | -| Kitchen (layout 9, style 9, seed 42), no sensors | 5.6x | 7.4x | -| Kitchen, cameras on (software rendering) | 5.3x (head camera drops frames due while one renders: about 10 frames per wall s) | 0.25x (three RGBD cameras, about 72 ms per colour render; the H1-2 sim waits for them) | - -**The whole stack at real time** (`docker_stack.sh`, `GOLEM_SIM_RATE` unset): - -| | G1 (`g1_mac_sim`) | H1-2 (`h12_mac_sim`) | -|---|---|---| -| RTF | 1.00 (sim loop idle 60-74%) | 0.95-0.99 | -| `/lowstate` | 500 Hz, largest gap 10-19 ms | 470-490 Hz, gaps up to 180 ms | -| Start-up | safety, legs pre-posed, arms, policy, band released: all as on x86 | safety, estop, legs pre-posed, arms, confirm, band released | -| Walking | 0.3 m/s forward, turning, arms moving while walking: no fall, no fault | stood 53 s after release, then fell: the estop latched (below) | -| Arms (`/named_config`, 15 s) | Blank scene: 8 of 8 goals succeed, standing and walking | not measured | -| CPU | sim about 0.4 core, ros about 1.8 cores | sim about 0.25 core, ros about 1.85 cores | - -**Navigation** (`GOLEM_LIDAR=1`, the MID-360's 20,000 points a frame cast on -the CPU; layout 9, style 9, seed 42, the spawn backed off 2.0 m, as -`tests/sim`; a Nav2 goal 1.5 m ahead, then one back to the start): - -| | G1 | H1-2 | -|---|---|---| -| Sim alone with the CPU lidar, unpaced | 1.48x | not measured | -| 1.5 m goal ahead | succeeded in 6.5 s of sim time, 0.25 m from it by SLAM (twice) | succeeded in 3.7 s, 0.25 m from it | -| Goal back to the start | not finished: the recording ended mid-goal | succeeded in 17.6 s, 0.26 m from it | -| RTF while recording the viewer | 0.40-0.48 | 0.27-0.31 | - -These runs had the sim's viewer open on a virtual display, recorded with ffmpeg, -which takes much of the CPU. The H1-2 run had no estop latch over its 360 s. - -Without the recording, the G1's navigation stack (same scene and goals) runs at -0.80-0.89x, `/lowstate` at 500 Hz of sim time with gaps up to 40 ms of wall time, -no fault; the goal ahead succeeds (6.3-6.5 s, 0.21-0.28 m off), and the goal back -to the start aborted both times, about 0.85 m short. The VM is CPU-bound there: -`golem_ros` takes about 3.75 cores (FAST-LIO, SLAM, OctoMap, Nav2, the leg policy, -the arm controller) and the sim about 2.4 of the M3's 8. - -**Lidar threads.** The CPU caster's thread count is `GOLEM_LIDAR_THREADS` (default -a quarter of the VM's CPUs, at most 4: 2 on an 8-CPU VM). It speeds the sim on its -own, but not the navigation stack, where every core is busy: - -| Threads | 1 | 2 | 4 | 6 | 8 | -|---|---|---|---|---|---| -| G1 sim alone, kitchen, CPU lidar, unpaced | 0.82x | 1.48x | 1.96x | 2.10x | 1.90x | -| G1 navigation stack at real time | — | 0.80-0.89x | 0.80-0.82x | — | — | +Measured 2026-11-19 on a MacBook Air M3 (4 performance + 4 efficiency cores, +16 GB), OrbStack with 8 CPUs and 8 GB, headless, one run each: the whole +navigation stack (`*_mac_sim`), kitchen layout 9, style 9, seed 42, the spawn +backed off 2.0 m, a Nav2 goal 1.5 m ahead and one back to the start. The +real-time factor (RTF) is `/clock` against wall time in `golem_ros`. -**Fewer lidar points.** `GOLEM_LIDAR_POINTS` (both robots; empty is the real -20,000 a frame) sets the rays a 10 Hz frame fires, and the CPU lidar's cost falls -with it. Navigation stack at real time, same scene and goals, no recording: - -| | Points a frame | RTF | `/lowstate` largest gap | Casts that waited for the lidar | Goal ahead / back to start | +| | Points a frame | RTF | `/lowstate` largest gap | Lidar casts the sim waited for | Goal ahead / back to start | |---|---|---|---|---|---| -| G1 (`use_hands:=false`) | 10,000 | 1.00 (sim loop idle 26%) | 24 ms | 2% | succeeded (0.27 m off) / not run | +| G1, hand driver on | 20,000 | 0.80-0.89 | 40 ms | 80% | succeeded / aborted 0.85 m short | +| G1 (default) | 10,000 | 1.00 (sim loop idle 26%) | 24 ms | 2% | succeeded (0.27 m off) / not run | | H1-2 | 20,000 | 0.55-0.57 | 46 ms | 99% | succeeded (0.18 m) / succeeded (0.04 m) | | H1-2 | 10,000 | 0.88-0.95 | 25 ms | 87% | succeeded (0.23 m) / succeeded (0.04 m) | -| H1-2 | 6,000 | 1.00 | 17 ms | 22% | succeeded (0.27 m) / succeeded (0.11 m) | - -No fault or estop latch in any of these runs. The H1-2 needs fewer points than -the G1 because its rays hit every geom group, the kitchen's collision geoms -included (`h12_sensors.LIDAR_GEOM_GROUPS`), where the G1's hit the visual geoms -only. A sparser scan than the real sensor's has not been checked for SLAM -quality beyond these goals. For real time on an 8-core Mac: -`GOLEM_LIDAR=1 GOLEM_LIDAR_POINTS=6000` (H1-2) or `10000` (G1, with -`use_hands:=false` on `g1_mac_sim`). - -The Mac's GPU is not a way out: in a Podman libkrun VM a container reaches it -through Vulkan 1.2 (Venus over MoltenVK, with a patched Mesa), but not through -OpenGL/EGL, which MuJoCo's renderer and `mid360.GpuCaster` need (Zink needs a -Vulkan feature MoltenVK lacks; krunkit has no virgl GL on macOS). - -For comparison, the x86 lab machine (i7-14700F, RTX 5070 Ti, sensors and -navigation on) runs the full stack at 0.83x (H1-2) and 1.00x (G1) -(`docs/superpowers/specs/2026-11-05-sim-speed-results.md`). - -**The H1-2 stack is not yet usable on the Mac.** Its stack stalls for up to -about 180 ms of wall time now and then. `estop_node` declares the sim's estop -stream stale after 0.1 s (`line_stale_timeout_sec`, the real robot's value), so -a stall latches `golem_safety`'s estop, the legs stop and the robot falls; in -the measured run that came 53 s after the band's release. The G1 has no estop -node and its stack's worst gap was 19 ms. Where the stalls come from (the VM's -scheduling or the heavier H1-2 ROS side) is not measured. +| H1-2 (default) | 6,000 | 1.00 | 17 ms | 22% | succeeded (0.27 m) / succeeded (0.11 m) | + +No fault or estop latch in these runs. The VM is CPU-bound: `golem_ros` takes +about 4 cores and the sim about 2. The H1-2 needs fewer points than the G1 +because its rays hit every geom group, the kitchen's collision geoms included +(`h12_sensors.LIDAR_GEOM_GROUPS`), where the G1's hit the visual geoms only. +The sparser scans have not been checked for SLAM quality beyond these goals. A +Mac with more cores holds real time with more points (`GOLEM_LIDAR_POINTS`). + +The H1-2's `estop_node` declares the sim's estop stream stale after 0.1 s, so a +VM stall longer than that latches `golem_safety`'s estop and the robot falls; it +happened once, in an earlier run with the VM overloaded. ## Image notes @@ -169,11 +94,9 @@ scheduling or the heavier H1-2 ROS side) is not measured. creating the same DDS domain, which needs two separate `libddsc` copies. On arm64 the SDK's binding would bind to ROS's copy by their shared soname and segfault in its first topic, so the Mac base renames the SDK's copy - (`libddsc_unitree.so.0`) and checks the pair at build time - (`docker/mac/check_unitree_dds.py`). -- `GOLEM_RENDER=cpu` casts the MID-360 with `mid360.CpuCaster` (`mj_multiRay`, - exact, a quarter of the cores at most 4 threads) in place of the GPU's depth - renders; the x86 default (`gpu`) is unchanged. + (`libddsc_unitree.so.0`) and checks the pair at build time. +- The Mac's GPU is out of reach: a container gets no OpenGL/EGL on macOS, which + MuJoCo's renderer and `mid360.GpuCaster` need. - `core_ws/cyclonedds.xml` requires 16 MB UDP receive buffers, which the VM's default `net.core.rmem_max` refuses (every node then fails to create its domain); the Mac overlay's `CYCLONEDDS_URI` drops that minimum. diff --git a/golem_robocasa/g1/g1_mujoco.py b/golem_robocasa/g1/g1_mujoco.py index 1e4773e6..27574059 100644 --- a/golem_robocasa/g1/g1_mujoco.py +++ b/golem_robocasa/g1/g1_mujoco.py @@ -297,7 +297,7 @@ def main(argv): task = sim_common.select_task(parser, args, tag="g1_mujoco", own_tasks=battery_env.TASKS + blank_env.TASKS, no_kitchen=blank_env.TASKS) # The camera and the lidar's rays render through EGL on the GPU: stop here - # without one, unless GOLEM_RENDER=cpu renders on the CPU with no lidar. + # without one, unless GOLEM_RENDER=cpu renders on the CPU. sim_common.require_renderer() sim_loop(task, viewer=not args.headless, diff --git a/golem_robocasa/h12_mujoco.py b/golem_robocasa/h12_mujoco.py index 39781496..dc81e617 100644 --- a/golem_robocasa/h12_mujoco.py +++ b/golem_robocasa/h12_mujoco.py @@ -5,8 +5,8 @@ (sim_common.select_robot) before the H1-2's imports, and --g1 hands the whole command line to g1.g1_mujoco.main. Each runner parses its command line, then checks the GPU (sim_common.require_renderer: either sim stops there without one, -unless GOLEM_RENDER=cpu renders on the CPU without the lidar), so --help and a -usage error need no GPU; the H1-2 does both before its imports. The +unless GOLEM_RENDER=cpu renders on the CPU), so --help and a usage error need no +GPU; the H1-2 does both before its imports. The H1-2's loop is sim_loop below. """ import argparse @@ -289,13 +289,9 @@ def sim_loop(task, viewer=True, layout=None, style=None, seed=None, timing=False _hand_res = tuple(int(v) for v in (os.environ.get('GOLEM_HAND_CAMERA_RES', '').strip() or '256x256').lower().split('x')) _cameras = realsense_profile.camera_specs(model, _camera_names, _profile, _camera_scale, _hand_res) - # GOLEM_LIDAR=0 drops the MID-360 (/livox/*), as on the G1; GOLEM_RENDER=cpu - # needs it off (sim_common.require_renderer). - _lidar_on = sim_common.env_flag('GOLEM_LIDAR', True) # GOLEM_LIDAR_POINTS: points per 10 Hz frame, default the real sensor's 20,000. _lidar_points = mid360.points_from_env() - print(f"[h12_mujoco] MID-360 lidar " - f"{f'ON, {_lidar_points} points a frame' if _lidar_on else 'OFF (GOLEM_LIDAR=0)'}") + print(f"[h12_mujoco] MID-360 lidar: {_lidar_points} points a frame") _depth_on = sim_common.env_flag('GOLEM_CAMERA_DEPTH', True) _cloud_on = sim_common.env_flag('GOLEM_CAMERA_POINTCLOUD', True) print(f"[h12_mujoco] RGBD cameras {'ON' if _cameras_on else 'OFF (GOLEM_CAMERAS=0)'}" @@ -328,7 +324,6 @@ def sim_loop(task, viewer=True, layout=None, style=None, seed=None, timing=False lidar_self_prefixes=( (pfx, "gripper0_") if sim_common.env_flag("GOLEM_LIDAR_SELF_FILTER", True) else () ), - lidar=_lidar_on, lidar_points=_lidar_points, sim_lock=sim_lock, timings=timings, @@ -381,9 +376,8 @@ def sim_loop(task, viewer=True, layout=None, style=None, seed=None, timing=False executor_thread = threading.Thread(target=executor.spin, daemon=True, name="ros_bridge_exec") executor_thread.start() print("[h12_mujoco] ROS bridges up: rt/lowstate+rt/lowcmd, /clock, " - "RGBD /realsense/{head,left_hand,right_hand}, " - + ("livox lidar+imu, " if _lidar_on else "") - + "/{left,right}/gripper/*, /elastic_band/toggle") + "RGBD /realsense/{head,left_hand,right_hand}, livox lidar+imu, " + "/{left,right}/gripper/*, /elastic_band/toggle") try: while True: if viewer and not handle.is_running(): diff --git a/golem_robocasa/h12_sensors.py b/golem_robocasa/h12_sensors.py index c0da575c..96d46a28 100644 --- a/golem_robocasa/h12_sensors.py +++ b/golem_robocasa/h12_sensors.py @@ -311,7 +311,6 @@ def __init__( imu_acc_sensor: str = "livox_imu_acc", imu_rate_hz: float = 100.0, lidar_self_prefixes: tuple = (), - lidar: bool = True, lidar_points=None, sim_lock=None, timings=None, @@ -325,10 +324,8 @@ def __init__( lidar_exclude_body is the body it rides in, whose geoms the rays pass through; geoms of bodies named with a lidar_self_prefixes prefix give no return. The lidar's GPU caster raises RuntimeError when EGL fails to - render. lidar False drops the MID-360 (/livox/lidar, /livox/pointcloud, - /livox/imu), as GOLEM_LIDAR=0 does, and makes no GPU caster; - lidar_points is its points per frame (None, the real 20,000). Rates are - Hz of sim time. + render. lidar_points is its points per frame (None, the real 20,000). + Rates are Hz of sim time. """ self.node = node self.model = model @@ -370,11 +367,20 @@ def __init__( self._static_tf.sendTransform( [self._tf_msg(e, _sim_time_to_msg(float(data.time))) for e in self._camera_tf]) self._camera_tf_broadcaster = TransformBroadcaster(self.node) - self.lidar = bool(lidar) # Reliable, as FAST-LIO subscribes (laserMapping.cpp); a best-effort - # publisher would not match it. Without the lidar none is made. - if self.lidar: - self._make_livox_publishers() + # publisher would not match it. + self.pub_lidar = self.node.create_publisher( + CustomMsg, "/livox/lidar", + QoSProfile(reliability=ReliabilityPolicy.RELIABLE, + history=HistoryPolicy.KEEP_LAST, depth=20)) + self.pub_pc2 = self.node.create_publisher( + PointCloud2, "/livox/pointcloud", + QoSProfile(reliability=ReliabilityPolicy.RELIABLE, + history=HistoryPolicy.KEEP_LAST, depth=20)) + self.pub_imu = self.node.create_publisher( + Imu, "/livox/imu", + QoSProfile(reliability=ReliabilityPolicy.RELIABLE, + history=HistoryPolicy.KEEP_LAST, depth=10)) self.imu_period = 1.0 / imu_rate_hz self.imu_quat_adr, self.imu_quat_dim = self._sensor_adr(imu_quat_sensor) @@ -389,34 +395,18 @@ def __init__( self._last_imu_sim_t = 0.0 # The scan thread publishes both lidar topics; its GPU caster makes its # EGL context here, before the passive viewer's window exists. - self._lidar = (_LidarScans(model, self.lidar_body_id, self.lidar_exclude_body_id, - self.geom_is_robot, LIVOX_FRAME, - self.pub_lidar.publish, self.pub_pc2.publish, - self.timings, sim_lock, lidar_points) - if self.lidar else None) - # The cameras render on a worker thread, through MUJOCO_GL's backend, while physics runs. + self._lidar = _LidarScans(model, self.lidar_body_id, self.lidar_exclude_body_id, + self.geom_is_robot, LIVOX_FRAME, + self.pub_lidar.publish, self.pub_pc2.publish, + self.timings, sim_lock, lidar_points) + # The cameras render on a worker thread, through EGL, while physics runs. self._camera_worker = ThreadPoolExecutor(max_workers=1, thread_name_prefix="camera") self._camera_pending = None if self.cameras: - # Make the GL context now: once the passive viewer's GLFW window + # Make the EGL context now: once the passive viewer's GLFW window # exists, a new EGL context can no longer be made current. self._camera_worker.submit(self._ensure_renderer).result() - def _make_livox_publishers(self) -> None: - """Make the MID-360's /livox/lidar, /livox/pointcloud and /livox/imu publishers.""" - self.pub_lidar = self.node.create_publisher( - CustomMsg, "/livox/lidar", - QoSProfile(reliability=ReliabilityPolicy.RELIABLE, - history=HistoryPolicy.KEEP_LAST, depth=20)) - self.pub_pc2 = self.node.create_publisher( - PointCloud2, "/livox/pointcloud", - QoSProfile(reliability=ReliabilityPolicy.RELIABLE, - history=HistoryPolicy.KEEP_LAST, depth=20)) - self.pub_imu = self.node.create_publisher( - Imu, "/livox/imu", - QoSProfile(reliability=ReliabilityPolicy.RELIABLE, - history=HistoryPolicy.KEEP_LAST, depth=10)) - def _make_camera_pub(self, spec) -> _CameraPub: """Return a camera's MuJoCo ids, camera_info and publishers for the streams switched on.""" ids = [] @@ -510,7 +500,7 @@ def tick(self, sim_t: float, stamp: TimeMsg) -> None: with the state time, one physics step before sim_t (module docstring). Call it without holding sim_lock, on the thread that steps the physics. """ - if self.lidar and sim_t - self._last_imu_sim_t >= self.imu_period: + if sim_t - self._last_imu_sim_t >= self.imu_period: self._last_imu_sim_t = sim_t try: self._publish_imu(stamp) @@ -529,8 +519,6 @@ def tick(self, sim_t: float, stamp: TimeMsg) -> None: except Exception as e: self.get_logger().warn(f"camera publish failed: {e}") - if self._lidar is None: - return try: self._lidar.tick(self.data, sim_t - self.model.opt.timestep) except Exception as e: diff --git a/golem_robocasa/mid360.py b/golem_robocasa/mid360.py index 61fe3065..19330cc2 100644 --- a/golem_robocasa/mid360.py +++ b/golem_robocasa/mid360.py @@ -491,23 +491,6 @@ def _log(text): print(text, flush=True) -def threads_from_env(env=os.environ): - """Return GOLEM_LIDAR_THREADS, the CpuCaster's thread count: unset or empty is DEFAULT_THREADS. - - Raises ValueError, naming the knob, for anything but an integer of at least 1. - """ - raw = env.get("GOLEM_LIDAR_THREADS", "") - if not raw.strip(): - return DEFAULT_THREADS - try: - threads = int(raw) - except ValueError: - threads = 0 - if threads < 1: - raise ValueError(f"GOLEM_LIDAR_THREADS must be an integer of at least 1, got {raw!r}") - return threads - - def points_from_env(env=os.environ): """Return GOLEM_LIDAR_POINTS, the points per frame: unset or empty is the real sensor's. @@ -533,14 +516,14 @@ def make_caster(model, exclude_body, geomgroup, render="gpu", robot_geoms=None, CpuCaster on its own copy of model, since it edits the model it casts on (its docstring), so the physics may step model while it casts; runtime edits of model reach its casts only through the snapshot (poses, alpha). threads is the CpuCaster's thread - count (None: GOLEM_LIDAR_THREADS, threads_from_env). ValueError for any other render. + count (None: DEFAULT_THREADS). ValueError for any other render. geomgroup and robot_geoms are the casters' own. """ if render == "gpu": return GpuCaster(model, exclude_body, geomgroup, robot_geoms=robot_geoms) if render == "cpu": return CpuCaster(copy.copy(model), exclude_body, geomgroup, robot_geoms=robot_geoms, - threads=threads_from_env() if threads is None else threads) + threads=DEFAULT_THREADS if threads is None else threads) raise ValueError(f"render must be gpu or cpu, got {render!r}") diff --git a/golem_robocasa/sim_common.py b/golem_robocasa/sim_common.py index f0206309..68a9ca17 100644 --- a/golem_robocasa/sim_common.py +++ b/golem_robocasa/sim_common.py @@ -124,9 +124,8 @@ def require_renderer(env: Mapping[str, str] = os.environ, backend = env.get("MUJOCO_GL", "") if backend.strip().lower() != "osmesa": sys.exit(f"GOLEM_RENDER=cpu renders through OSMesa: MUJOCO_GL must be osmesa, not {backend!r}") - lidar = "the MID-360's rays cast on the CPU" if env_flag("GOLEM_LIDAR", True, env) else "no MID-360" - print(f"[sim_common] rendering on the CPU through OSMesa (GOLEM_RENDER=cpu); {lidar}", - flush=True) + print("[sim_common] rendering on the CPU through OSMesa (GOLEM_RENDER=cpu); " + "the MID-360's rays cast on the CPU", flush=True) return mode diff --git a/tests/docker/test_workflows.py b/tests/docker/test_workflows.py index bcb48efc..218463a0 100644 --- a/tests/docker/test_workflows.py +++ b/tests/docker/test_workflows.py @@ -700,7 +700,7 @@ def mac_overlay(self): return str(self.root / 'docker/docker-compose.mac.yml') def test_linux_never_adds_the_mac_overlay(self): - """On Linux no wrapper adds docker-compose.mac.yml or prints a platform line.""" + """On Linux no wrapper adds docker-compose.mac.yml.""" for args in (('docker/scripts/docker_run.sh', 'robocasa'), ('docker/scripts/docker_run.sh', 'ros'), ('docker/scripts/docker_stack.sh', 'up', 'robocasa', '--headless'), ('docker/scripts/docker_build.sh', 'robocasa', 'ros')): @@ -708,7 +708,6 @@ def test_linux_never_adds_the_mac_overlay(self): r = self.run_script(*args) self.assertEqual(r.returncode, 0, r.stderr) self.assertFalse(any(self.mac_overlay() in c for c in self.calls())) - self.assertNotIn('platform:', r.stderr) def test_mac_adds_the_mac_overlay_to_every_compose_call(self): """On the Mac every compose call of docker_run.sh carries docker-compose.mac.yml, after the base file.""" @@ -718,7 +717,6 @@ def test_mac_adds_the_mac_overlay_to_every_compose_call(self): self.assertEqual(r.returncode, 0, r.stderr) files = self.compose_files(self.run_calls()[-1]) self.assertEqual(files[:2], [str(self.root / 'docker/docker-compose.yml'), self.mac_overlay()]) - self.assertIn('platform: mac', r.stderr) def test_mac_detected_from_the_host(self): """Without GOLEM_PLATFORM the wrappers pick mac on Darwin arm64 and linux elsewhere.""" diff --git a/tests/robocasa/test_gpu_required.py b/tests/robocasa/test_gpu_required.py index 2a214f0d..59320a7c 100644 --- a/tests/robocasa/test_gpu_required.py +++ b/tests/robocasa/test_gpu_required.py @@ -53,7 +53,7 @@ def test_the_probe_refuses_mujoco_off_egl(self): class RenderModeTests(unittest.TestCase): - """Check GOLEM_RENDER: gpu (the default) keeps the GPU check; cpu needs OSMesa and no lidar.""" + """Check GOLEM_RENDER: gpu (the default) keeps the GPU check; cpu needs OSMesa.""" def test_unset_or_empty_is_gpu(self): """GOLEM_RENDER unset, empty or blank is gpu, the default.""" @@ -78,15 +78,13 @@ def probe(): self.assertTrue(caught.exception.code.startswith(sim_common.GPU_REQUIRED)) def test_cpu_mode_needs_osmesa(self): - """GOLEM_RENDER=cpu passes with MUJOCO_GL=osmesa, lidar on or off, and refuses another MUJOCO_GL.""" + """GOLEM_RENDER=cpu passes with MUJOCO_GL=osmesa and refuses another MUJOCO_GL.""" def probe(): """Fail: cpu mode must not probe the GPU.""" raise AssertionError("probed the GPU") - for lidar in ("0", "1", ""): - with self.subTest(GOLEM_LIDAR=lidar): - env = {"GOLEM_RENDER": "CPU", "MUJOCO_GL": "osmesa", "GOLEM_LIDAR": lidar} - self.assertEqual(sim_common.require_renderer(env, probe), "cpu") + env = {"GOLEM_RENDER": "CPU", "MUJOCO_GL": "osmesa"} + self.assertEqual(sim_common.require_renderer(env, probe), "cpu") with self.assertRaises(SystemExit) as caught: sim_common.require_renderer({"GOLEM_RENDER": "cpu", "MUJOCO_GL": "egl"}, probe) self.assertIn("MUJOCO_GL must be osmesa", caught.exception.code) @@ -101,9 +99,9 @@ def start(self, robot, *args, **env): Returns the CompletedProcess. """ args = args or ("--headless", "--task", "Blank") - # The render knobs are the test's own: the Mac images set GOLEM_RENDER=cpu and - # GOLEM_LIDAR=0 (docker-compose.mac.yml), and these tests check the default, gpu. - base = {k: v for k, v in os.environ.items() if k not in ("GOLEM_RENDER", "GOLEM_LIDAR")} + # GOLEM_RENDER is the test's own: the Mac images set cpu (docker-compose.mac.yml), + # and these tests check the default, gpu. + base = {k: v for k, v in os.environ.items() if k != "GOLEM_RENDER"} r = subprocess.run([sys.executable, "-u", SIM, f"--{robot}", *args], capture_output=True, text=True, env=dict(base, **env), timeout=START_TIMEOUT_S, cwd=os.path.dirname(SIM)) diff --git a/tests/robocasa/test_mid360_cpu.py b/tests/robocasa/test_mid360_cpu.py index d820ee2a..7a3897e4 100644 --- a/tests/robocasa/test_mid360_cpu.py +++ b/tests/robocasa/test_mid360_cpu.py @@ -102,21 +102,16 @@ def test_cpu_builds_a_cpu_caster_on_a_copy_of_the_model(self): finally: caster.close() - def test_cpu_casts_on_golem_lidar_threads(self): - """GOLEM_LIDAR_THREADS sets the CpuCaster's threads; unset or empty is DEFAULT_THREADS; bad values raise.""" - self.assertEqual(mid360.threads_from_env({}), mid360.DEFAULT_THREADS) - self.assertEqual(mid360.threads_from_env({"GOLEM_LIDAR_THREADS": " "}), mid360.DEFAULT_THREADS) - self.assertEqual(mid360.threads_from_env({"GOLEM_LIDAR_THREADS": "4"}), 4) - for bad in ("0", "-2", "four", "1.5"): - with self.subTest(GOLEM_LIDAR_THREADS=bad): - with self.assertRaisesRegex(ValueError, "GOLEM_LIDAR_THREADS"): - mid360.threads_from_env({"GOLEM_LIDAR_THREADS": bad}) + def test_cpu_casts_on_the_threads_given(self): + """make_caster's threads sets the CpuCaster's thread count; None is DEFAULT_THREADS.""" model, _, torso = _scene() - caster = mid360.make_caster(model, torso, VISUAL, "cpu", threads=3) - try: - self.assertEqual(caster.threads, 3) - finally: - caster.close() + for threads, expected in ((3, 3), (None, mid360.DEFAULT_THREADS)): + with self.subTest(threads=threads): + caster = mid360.make_caster(model, torso, VISUAL, "cpu", threads=threads) + try: + self.assertEqual(caster.threads, expected) + finally: + caster.close() def test_points_come_from_golem_lidar_points(self): """GOLEM_LIDAR_POINTS sets the points per frame; unset or empty is the real 20,000; bad values raise.""" From e0dfbcb3bdce1774b48656868d22d5f2cb5e8d2a Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 19 Nov 2026 12:02:17 -0700 Subject: [PATCH 6/7] Point BUILD.md at the Mac images; fix two stale Mac notes Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015EG7pDNJLWR31eQmyKaWhr --- docker/BUILD.md | 7 +++++++ docker/mac/RosDockerfile | 6 +++--- docs/index.md | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/docker/BUILD.md b/docker/BUILD.md index 1f65f2cb..5583fe05 100644 --- a/docker/BUILD.md +++ b/docker/BUILD.md @@ -72,6 +72,13 @@ nvcr.io/nvidia/isaac-sim:5.1.0 Its bundled interpreter and ROS bridge are separate from the Humble/Python 3.10 stack in `golem_base`. The Dockerfile also installs ROS Jazzy tooling. +On an Apple Silicon Mac the wrappers build the same graph's arm64 twins +instead, `golem_base:arm64`, `golem_ros:arm64` and `golem_sim_robocasa:arm64`, +from `docker/mac/*Dockerfile` on `ubuntu:jammy` with the `*-arm64*` locks (no +CUDA, no Isaac, no model-server stack; `docs/MAC.md`). Keep their commits and +pins in step with the x86 Dockerfiles: `tests/docker/test_source_pins.py` +checks it. + All containers interoperate over **CycloneDDS on one ROS domain** (default `ROS_DOMAIN_ID=1`; domain `0` is reserved for the real robots), one robot stack per domain. diff --git a/docker/mac/RosDockerfile b/docker/mac/RosDockerfile index 070d4d87..dd024b03 100644 --- a/docker/mac/RosDockerfile +++ b/docker/mac/RosDockerfile @@ -97,9 +97,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ python3-tk \ && rm -rf /var/lib/apt/lists/* -# Navigation, SLAM and debugging tools: golem_slam builds against them, though -# the Mac sims have no lidar to run them on (docker/RosDockerfile has a comment -# per group). +# Navigation, SLAM and debugging tools: golem_slam builds against them and the +# Mac bringups run them on the sims' CPU-cast MID-360 (docker/RosDockerfile has +# a comment per group). RUN apt-get update && apt-get install -y --no-install-recommends \ ros-humble-navigation2 \ ros-humble-nav2-bringup \ diff --git a/docs/index.md b/docs/index.md index f3170959..dfe0f7f9 100644 --- a/docs/index.md +++ b/docs/index.md @@ -17,7 +17,7 @@ including the `README.md` and `CLAUDE.md` developer guide, is at |---|---|---| | Unitree H1-2 (the default) | [Setup](SETUP.md), then [Running the stack](RUNNING.md) | x86 Linux with an NVIDIA GPU | | Unitree G1 | [The G1](g1/index.md), then [First real session](g1/first-session.md) for the real robot | x86 Linux with an NVIDIA GPU, RoboCasa simulator only | -| Either robot on an Apple Silicon Mac | [The Mac](MAC.md) | a reduced RoboCasa sim: no lidar, navigation or model servers | +| Either robot on an Apple Silicon Mac | [The Mac](MAC.md) | a reduced RoboCasa sim at real time, navigation included; no model servers or Isaac | Both robots use the same images and the same setup. The wrappers in `docker/scripts/` run the H1-2 unless `--g1` or `GOLEM_ROBOT=g1` selects the G1. From 7277ddfbe6246337e38961757a93def3a61303d7 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 19 Nov 2026 12:06:15 -0700 Subject: [PATCH 7/7] Shorten a golem_bringup test docstring to flake8's 99 columns Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015EG7pDNJLWR31eQmyKaWhr --- core_ws/src/golem_bringup/test/test_sim_time.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core_ws/src/golem_bringup/test/test_sim_time.py b/core_ws/src/golem_bringup/test/test_sim_time.py index 6251082e..fb60ca4a 100644 --- a/core_ws/src/golem_bringup/test/test_sim_time.py +++ b/core_ws/src/golem_bringup/test/test_sim_time.py @@ -154,7 +154,7 @@ def _packages(launch_file, args): ]) def test_mac_sim_is_the_sim_bringup_without_vision(mac_file, sim_file, sim_args, core, monkeypatch): - """A Mac sim bringup starts the command path, legs and navigation, and no model server or skill.""" + """A Mac sim bringup starts the command path, legs and navigation, but no model server.""" monkeypatch.setenv('ROS_DOMAIN_ID', SIM_DOMAIN) mac = _packages(mac_file, {}) assert core <= mac, mac