Adding a New Robot — Quick Reference#
This guide is a checklist + reference for adding a new robot to EmbodiChain. For the full step-by-step walkthrough with code examples, see /tutorial/add_robot.
The protocol#
Every robot config subclasses RobotCfg and
overrides two hooks:
_build_defaults(self, init_dict=None)— populateurdf_cfg,control_parts,solver_cfg,drive_prosandattrsfrom variant fields read out ofinit_dict.build_pk_serial_chain(self, device=...)— return a{control_part: pk.SerialChain}mapping, reading the PK URDF from a single_pk_urdf_pathsource (so it cannot drift from the sim URDF).
The from_dict is a 3-line template (do not reimplement it):
cfg = cls()
cfg._build_defaults(init_dict)
return merge_robot_cfg(cfg, init_dict)
Serialization (to_dict / to_string / save_to_file) is inherited from
RobotCfg and round-trips: RobotCfg.from_dict(cfg.to_dict()) reproduces the cfg.
Checklist#
Prepare the URDF — place the URDF (+ meshes) in the assets directory.
Override
_build_defaults(self, init_dict=None)— set variant fields frominit_dict, then populateurdf_cfg/control_parts/solver_cfg/drive_pros/attrs.Define control parts — group joints into logical sets (e.g.
arm,gripper).Configure the IK solver —
OPWSolverCfg(6-DOF),SRSSolverCfg(7-DOF), or a genericSolverCfg.Set drive properties — stiffness/damping/max_effort per joint group.
Implement
build_pk_serial_chainreading from_pk_urdf_path.Keep
from_dictas the 3-line template — do not reimplement.Register in
embodichain/lab/sim/robots/__init__.py(and set__all__).Add documentation —
docs/source/resources/robot/<name>.md+ updateresources/robot/index.rst.Test — a
__main__smoke test + the DOF drift guard +preview-assetCLI.
Approaches#
Single-file (variant-less robots): one
my_robot.pywith everything.Package (robots with variants — versions/arm-kinds/hand-brands): a directory with
types.py(enums),cfg.py(a variant-aware_build_defaults), optionalparams.py/utils.pyhelpers, and__init__.py.
Key parameters#
Parameter |
Type |
Description |
|---|---|---|
|
str |
Unique robot identifier |
|
URDFCfg |
URDF file and components |
|
Dict[str, List[str]] |
Joint groups for control |
|
Dict[str, SolverCfg] |
IK solver configurations |
|
JointDrivePropertiesCfg |
Joint stiffness, damping, force |
|
RigidBodyAttributesCfg |
Rigid-body physics attributes |
variant fields |
enum / str / bool |
Optional subclass fields
(e.g. |
|
property or method → str |
URDF for the FK/IK serial chain |
Common mistakes#
See Also#
/tutorial/add_robot — Full step-by-step tutorial
Simulating a Robot — Using robots in simulation
Solvers — IK solver reference
Supported Robots — Existing robot documentation