Safety layer for H1-2 that filters commands, monitors joint states, and enforces clipping and active-stop logic before forwarding to Unitree topics.
- This repo depends on Unitree Python SDK to communicate with the robot.
- We rely on this fork for easy integration with
uv. - The
mainbranch is meant to be compatible with Humanoid Simulation, so place Unitree SDK at../../../unitree_sdk2_python. - The dev branch is for local testing.
-
Easiest way to run scripts in this repo is to use
uv -
Commands:
uv sync # install dependencies for this repo including unitree sdk uv run PATH_TO_SCRIPT
-
requirements.txtlists dependencies that can be installed bypip. -
Commands:
pip install -r requirements.txt # install dependencies for this repo including unitree sdk
config/: YAML configuration files.docs/: detailed documentation.h12_safety_layer/: source codes.core/: core implementation of the safety layer.chunk_logger.pyprovides logger of robot states and commands.config.pyparses and loads YAML configuration files.joint_limits.pydefines joint names and joint limits according to the URDF.safety_checks.pydefines several safety checks of robot states and commands.safety_layer.pyimplements the safety layer that relays commands, checks safety and logs in the background.
script/: runnable scripts.safety_layer_main.pylaunches the safety layer.
unsafe/: unsafe debugging scripts.send_fixed_positions.pysends a fixed position command for 1 second.send_random_positions.pysends random position commands for 1 second.
utility/: utility scripts.combine_chunks.pycombines chunked logs.record_limits.pyrecords joint limits to tweak YAML configuration files.publisher.pyis a dummy publisher.subscriber.pyis a dummy subscriber.
-
In Full-Body Mode, the safety layer relays a single
low_cmdto the robot with clipping and safety checks.topics: low_cmd_in: rt/safety/lowcmd_in low_cmd_out: rt/lowcmd low_state: rt/lowstate
-
In Split Mode, the safety layer relays two
low_cmd, one for lower-body and one for upper-body, with clipping and safety checks.topics: low_cmd_lower_in: rt/safety/lowcmd_lower_in low_cmd_upper_in: rt/safety/lowcmd_upper_in low_cmd_out: rt/lowcmd low_state: rt/lowstate
-
External E-Stop monitoring is configured with a top-level
estopsection. Iftriggered: trueorplugged_in: falseis received onestop_topic, the safety layer enters estop. For simulation where hardware estop is not required, setenabled: false.estop: enabled: true estop_topic: h12/estop_status_raw poll_hz: 500.0
-
Full-Body Mode
-
Run safety-layer in full-body mode with default safety limits:
uv run h12_safety_layer/script/safety_layer_main.py --config default_safety_full.yaml
-
Run safety-layer in full-body mode with tight safety limits:
uv run h12_safety_layer/script/safety_layer_main.py --config tight_safety_full.yaml
-
-
Split Mode
-
Run safety-layer in split mode with default safety limits:
uv run h12_safety_layer/script/safety_layer_main.py --config default_safety_split.yaml
-
Run safety-layer in split mode with tight safety limits:
uv run h12_safety_layer/script/safety_layer_main.py --config tight_safety_split.yaml
-
-
Console entry point is exposed as
safety_nodeand runsh12_safety_layer/ros2/safety_node.py -
Build and source your ROS2 workspace first:
colcon build source install/setup.bash -
Full-Body Mode
-
Run with default safety limits:
ros2 run h12_safety_layer safety_node --config default_safety_full.yaml
-
Run with tight safety limits:
ros2 run h12_safety_layer safety_node --config tight_safety_full.yaml
-
-
Split Mode
-
Run with default safety limits:
ros2 run h12_safety_layer safety_node --config default_safety_split.yaml
-
Run with tight safety limits:
ros2 run h12_safety_layer safety_node --config tight_safety_split.yaml
-
-
--configcan be a bare config name (resolved from installed package shareconfig/) or an absolute path