Spec From URDF
Usage
metrical spec from-urdf [OPTIONS] <URDF_FILE>
command = "spec-from-urdf"
input-urdf = "{{variables.urdf}}"
output = "{{auto}}"
topic-prefix = "/"
strip-prefix = "robot_"
Purpose
metrical spec from-urdf converts a ROS
URDF file into a
system specification JSON file. It extracts the
fixed-joint transforms from the URDF to populate the mechanical_layout, and optionally sets
camera_bases and camera_field_of_view for specified camera links.
This is useful when your sensor rig is already described in a URDF; rather than transcribing
transforms by hand, you can generate a system specification directly and then pass it to
metrical plex learn.
What gets extracted
- Fixed joints only: Only URDF joints of type
fixedare included in the output. Revolute, prismatic, and other movable joint types are skipped, since they do not represent rigid mechanical relationships. - Translation and rotation: The
<origin xyz="..." rpy="..."/>element on each fixed joint is converted into a translation vector and a unit quaternion. The URDF RPY (Roll-Pitch-Yaw) Euler convention is handled automatically. - Directionality: Each fixed joint produces a
mechanical_layoutentry wherefromis the child link andtois the parent link.
Topic name mapping
URDF link names often differ from the topic names used in your dataset. The --strip-prefix,
--topic-prefix, and --remap options let you transform URDF link names into the topic names that
MetriCal expects.
The transformation pipeline for each link name is:
- If the link has an explicit
--remapentry, use the remapped name directly (skip steps 2 and 3). - If
--strip-prefixis set and the link name starts with that prefix, remove it. - If
--topic-prefixis set, prepend it to the (possibly stripped) name.
After all names are resolved, the command validates that no two URDF links map to the same topic name.
Camera properties
URDFs do not distinguish cameras from other sensor types, so MetriCal cannot automatically detect
which links are cameras. Use the --camera flag to specify camera links along with their coordinate
basis and optional diagonal field of view. These values populate the camera_bases and
camera_field_of_view sections of the output.
ROS URDFs often define two links per camera: a physical mount link (e.g. camera_link, typically
in the FLU convention) and an optical frame link (e.g. camera_optical_frame, rotated to RDF).
Point --camera at whichever link you want in your system specification and set the basis to match
that frame's convention. If --camera is omitted for a camera link,
metrical plex learn defaults to RDF.
Examples
Basic conversion
metrical spec from-urdf robot.urdf -o system_spec.json
With camera properties and topic prefix
metrical spec from-urdf robot.urdf \
--camera left_cam:FLU:90 \
--camera right_cam:RDF \
--topic-prefix / \
-o system_spec.json
Strip a common prefix from URDF link names
metrical spec from-urdf robot.urdf \
--strip-prefix robot_ \
--topic-prefix /sensors/ \
-o system_spec.json
This transforms a URDF link named robot_left_camera into the topic name /sensors/left_camera.
Remap specific links
metrical spec from-urdf robot.urdf \
--remap imu_link:/imu/main \
--remap cam_front:/camera/front \
--topic-prefix / \
-o system_spec.json
Remapped links bypass --strip-prefix and --topic-prefix entirely; non-remapped links still go
through the normal transformation pipeline.
Pipe the output into plex learn
metrical spec from-urdf robot.urdf \
--camera left_cam:FLU:90 \
--strip-prefix robot_ \
--topic-prefix / \
-o system_spec.json
metrical plex learn \
-S system_spec.json \
--dataset data.mcap \
-m '*camera*:opencv-radtan' \
-m '*lidar*:lidar' \
-o plex.json
Arguments
<URDF_FILE>
The path to the input URDF file. The file must be valid URDF XML.
Options
Global Arguments
As with every command, all global arguments are supported (though not all may be used).
-o, --output [OUTPUT]
The path to output the resulting system specification JSON file. Defaults to
system_spec.json.
-c, --camera [LINK:BASIS[:DFOV]]
Specifies a URDF link to treat as a camera, along with its coordinate basis and an optional diagonal field of view in degrees.
The format is
LINK:BASISorLINK:BASIS:DFOV, where:
LINKis the URDF link name (before any prefix stripping or remapping).BASISis a three-character coordinate basis string (e.g.FLU,RDF). Seecamera_basesfor the full list of valid bases.DFOV(optional) is the nominal diagonal field of view in degrees.This flag can be repeated for multiple cameras:
--camera left:FLU:90 --camera right:RDFThe specified link must exist in the URDF and must be part of a fixed joint. If a camera link appears more than once, the command will return an error.
--topic-prefix [PREFIX]
A string to prepend to each URDF link name when generating topic names. For example,
--topic-prefix /transforms the link nameleft_camerainto/left_camera.Applied after
--strip-prefixbut skipped for links that have an explicit--remapentry.
--strip-prefix [PREFIX]
A prefix to remove from each URDF link name before applying
--topic-prefix. For example,--strip-prefix robot_transforms the link namerobot_leftintoleft.If a link name does not start with the given prefix, it is left unchanged. Skipped for links that have an explicit
--remapentry.
-r, --remap [OLD:NEW]
Remaps an individual URDF link name to a specific topic name. The format is
OLD:NEW, whereOLDis the original URDF link name andNEWis the desired topic name.When a link matches a remap entry, the remapped name is used directly;
--strip-prefixand--topic-prefixare not applied to that link.This flag can be repeated for multiple remaps:
--remap robot_cam:left_camera --remap robot_lidar:/sensors/lidarThe
OLDname must match an existing link in the URDF. After all remaps are applied, the command validates that no two links resolve to the same topic name.