Nodes
The rosetta_ros package installs four executables. Three are nodes and are
described on this page: episode_recorder_node, policy_runner_node and
episode_keyboard_node. The fourth, rosetta_port, ports bags into datasets
and has its own page, rosetta_port. The human-in-the-loop
manager, hil_manager_node, is in
rosetta_ros_hil.
The message, service and action fields are on Interfaces.
Every launch file prints its arguments and defaults:
ros2 launch rosetta_ros episode_recorder_launch.py --show-args
Parameter layering
episode_recorder_launch.py and policy_runner_launch.py build the node’s
parameters from three layers. A later layer wins.
The package params file,
params/episode_recorder.yamlorparams/policy_runner.yaml.The file given as
params_file. It only needs the keys it changes.The launch arguments. An empty launch argument keeps the value from the files.
contract_pathis always passed.
A params file can hold sections keyed /**, /**/<node>, <node> (or
/<node>) and /<namespace>/<node>. Every section that names the node
applies, merged in that order, so the more specific key wins. A file that has
sections but none for the node fails the launch with no section applies to node. The layers are passed as dictionaries, so both launch files also work
when another launch file includes them under a namespace.
ros2 launch rejects an empty value (contract_path:= is a malformed launch
argument), so these launch files always load a contract file. The checkpoint
fallback for an empty contract_path is only reachable with ros2 run.
Lifecycle
episode_recorder_node and policy_runner_node are lifecycle nodes.
episode_keyboard_node is a plain node. Both lifecycle launch files take
configure and activate (both default true), which drive those
transitions at start.
Transition |
Effect |
|---|---|
|
Load the contract and create subscriptions, inactive publishers, the action server and the services. On any error the node tears down what it built and returns to |
|
Activate publishers, then accept work. |
|
Stop accepting work, stop work in progress (waiting up to 5 s), publish the safety action, then deactivate publishers. The recorder has no safety action. |
|
Fails while work is in progress. Otherwise releases everything |
|
Stop, wait, publish the safety action, release. |
Ctrl+C runs the shutdown transition before the process exits, so an open bag
is closed and the safety action is published.
A node runs one piece of work at a time, started by an action goal or by its
start service. Work requested while busy or while the node is not active is
rejected. A rejected start service returns accepted: false with message: Rejected: already busy or Rejected: node not active.
The goal’s terminal state follows its termination_reason:
|
Goal state |
|---|---|
any, after a client cancel |
|
|
|
|
|
Each node has a ~/start_* service that starts the same work without a goal,
and a ~/cancel_* service. For goal-started work the cancel service sends a
cancel to the node’s own action server, so the goal ends CANCELED exactly as
if an action client had cancelled it. For service-started work it stops the
work with termination_reason: cancelled. A cancel service with nothing
running returns success: false.
Work started by a service has no goal, so it has no action feedback or result.
Its progress is on ~/status and its result on ~/result, which every node
publishes however the work started.
episode_recorder_node
Records bags. Node name episode_recorder. Launch file
episode_recorder_launch.py.
Parameter |
Type |
Default |
Meaning |
|---|---|---|---|
|
string |
|
Contract file. Required: configure fails with |
|
string |
|
Directory for bags. Relative paths resolve against the current directory. |
|
string |
|
rosbag2 storage plugin, passed unchecked. Read-only. |
|
bool |
|
Also record every other topic on the graph, discovered at each recording start. Read-only. |
|
string[] |
|
Regexes, |
|
string[] |
|
Regexes. Discovered topics that match are recorded despite |
|
string |
|
Prompt used when a goal or service call leaves |
|
double |
|
Seconds. Used when the goal’s |
|
double |
|
Hz, 0.1 to 1000. Rate of action feedback and |
|
bool |
|
Copy the contract file’s text, comments included, into each bag’s |
|
bool |
|
Stamp messages with sim time and record |
Launch arguments: params_file, contract_path, bag_base_dir,
storage_id, use_sim_time, log_level, configure, activate.
params/episode_recorder.yaml sets the same values as the defaults in the
table.
Name |
Kind |
Type |
|---|---|---|
|
action server |
|
|
service |
|
|
service |
|
|
service |
|
|
publisher |
|
|
publisher |
|
contract topics |
subscriptions |
The types the contract declares, with its QoS |
discovered topics |
subscriptions |
With |
With the default namespace these are /record_episode and
/episode_recorder/....
~/delete_last_bag deletes the last recording’s bag directory, including a
failed partial bag. Called during a recording, it marks that recording for
deletion when it ends. It returns success: false with No bag to delete
when there is none. Starting a new recording makes the previous bag no longer
deletable.
~/status carries the feedback fields at feedback_rate_hz while a recording
runs. ~/result carries the result fields once per recording, and a late
subscriber gets the last one.
Recorded topics
Contract topics are every source in every frame section, the
teleopinputandfeedbackchannels, thetasksandadjunctchannels, and/clockunderuse_sim_time.teleop.eventsis not a contract topic. A topic declared twice with different types or QoS fails configure.The recorder subscribes to contract topics at configure, so a recording captures them from its first instant. A type that does not import fails configure. Transient-local contract topics, such as
/tf_static, are the exception: they are subscribed at each recording start instead, so their latched messages land in every bag, and a type that does not import fails that recording.A contract topic with no messages is marked
(!)in the per-topic summary logged when a recording ends. Nothing stops a recording from starting without it.When an observation or action topic has no messages, the summary is logged as a warning and the result’s
messagenames the topics, asno messages on: /joint_states. The termination reason and the goal state are unchanged, and the bag is kept. A recording that ends in an error, or whose bag was deleted, reports its error or nothing instead.With
record_all, topics on the graph that are not contract topics are discovered at each recording start./rosoutand/parameter_eventsare skipped unlessinclude_topicsmatches them. A topic whose type does not import is skipped with a warning. The subscription QoS is reliable or transient-local only when every publisher offers it.Each camera records one stream. For a raw
sensor_msgs/msg/Imagetopic and itsimage_transportre-encodings, a stream named in the contract or matchinginclude_topicswins. Otherwise the first stream not excluded, in the order/compressed,/zstd,/theora,/compressedDepth, raw.
Bags
Each recording is one bag directory,
<bag_base_dir>/<seconds>_<nanoseconds>, named from the wall clock at start and zero-padded to ten and nine digits.The bag timestamp of each message is the node clock at receipt. Under
use_sim_timethat is sim time. The message’s ownheader.stampis unchanged.After the bag closes,
metadata.yamlgetscustom_datakeys:lerobot.operator_promptwhen the prompt is non-empty,rosetta.contract_yamlwithembed_contract, androsetta.goal_id(the goal UUID) for goal-started recordings.A failed bag write ends the recording with
termination_reason: errorand the failure inmessage.termination_reasonis one ofstopped,timeout,cancelled,node_deactivated,error.bag_pathis set on every path, including errors.
episode_keyboard_node
Drives the recorder’s RecordEpisode action from a terminal. Node name
episode_keyboard.
Launch file episode_keyboard_launch.py. It needs an interactive terminal.
Without one it exits with Failed to enable raw terminal mode. Are you running in an interactive terminal?
Parameter |
Type |
Default |
Meaning |
|---|---|---|---|
|
string |
|
The recorder’s |
|
string |
|
The recorder node’s full name. The keyboard calls |
|
string |
|
Initial prompt for recordings. The |
Launch arguments: recorder_action_name, recorder_ns, default_prompt.
Key |
Action |
|---|---|
|
Send a goal with the current prompt and |
|
Cancel the goal. The bag is kept, and the recording ends with |
|
Call |
|
Edit the prompt. Enter applies, Esc cancels. |
|
Print the key help. |
|
Quit. |
When a goal’s result arrives, the keyboard prints the message count and bag
path, or the error. A recording that ends on its time limit adds (time limit), one ended by a deactivate adds (recorder deactivated), and one
the recorder stopped for no named reason adds (stopped by the recorder). A
non-empty message on a kept bag is printed with a reminder that d deletes
it. A recording d deletes prints only the deletion, unless it ended in an
error. Recordings other clients start are not reported.
Letter keys also work in upper case. Beyond the topics and services every
rclpy node has, the node has one action client, for recorder_action_name,
and one service client, for delete_last_bag.
policy_runner_node
Runs a policy on the live robot through a policy runner. Node name
policy_runner. Launch file policy_runner_launch.py.
Parameter |
Type |
Default |
Meaning |
|---|---|---|---|
|
string |
|
Contract file. Empty resolves it from |
|
string |
|
Checkpoint, a local path or a Hugging Face Hub repo ID. Read by the adapter and by the contract fallback. Read-only. |
|
string |
|
Policy runner, by its name in the |
|
bool |
|
Publish the contract’s |
|
string |
|
Comma-separated rosidl buffer backends that subscriptions accept, such as |
|
string |
|
Task used when a goal or service call leaves |
|
double |
|
Seconds. Used when the goal’s |
|
double |
|
Hz, 0.1 to 1000. Rate of action feedback and |
|
bool |
|
Use the |
Launch arguments: params_file, contract_path,
pretrained_name_or_path, policy_type, policy_device, buffer_backends,
server_address, launch_local_server, use_sim_time, output_prefix,
log_level, configure, activate.
Name |
Kind |
Type |
|---|---|---|
|
action server |
|
|
service |
|
|
service |
|
|
publisher |
|
|
publisher |
|
action topics |
publishers |
The contract’s |
observation topics |
subscriptions |
The contract’s |
With the default namespace these are /run_policy and /policy_runner/....
Under rosetta_ros_hil’s hil_launch.py the runner is in namespace
robot_policy, so the action is /robot_policy/run_policy.
output_prefix publishes every contract action and reward topic under a
prefix: with so_101.yaml, output_prefix:=/policy publishes
/leader_arm/joint_states as /policy/leader_arm/joint_states. The launch
file reads the topics from contract_path, so a prefix needs a contract file.
Route commands through a mux covers the uses.
While the node is active, a watchdog publishes each action channel’s safety
command (zeros, hold, or nothing for none) when no action has been
published for two frame periods on the node clock. It disarms after firing
until the next action. A contract whose actions are all safety: none has no
watchdog.
The run ends with termination_reason:
completedwhen the adapter’s run ends on its own without error.timeout,cancelledornode_deactivatedwhen the node stopped it for that reason.errorwhen the adapter raised or reported a failure, with the detail inmessage.
Contract fallback
With an empty contract_path, configure asks the framework’s policy
runner where pretrained_name_or_path keeps its contract. The lerobot
runner follows the checkpoint to its train_config.json, then to the
training dataset’s root, then to meta/rosetta_contract.yaml there. When
root has no contract, as on a robot that isn’t the training machine, it
tries the dataset’s repo_id instead.
root is a local directory. A relative root resolves against the current
directory, as it was typed at training, and root is never fetched from the
Hub. A repo_id that names an existing local directory is read from it, and
is fetched from the Hub otherwise. When no link finds a contract, one warning
lists each attempt, such as dataset.root 'lerobot/gz_reach' (relative) is not a directory under <cwd>, and configure fails. Each inline decoder: or
encoder: in a contract found this way logs a warning before the contract
loads, because loading it imports that code. A non-empty contract_path is
used as given and never compared with the checkpoint’s contract.
LeRobot adapter parameters
The lerobot adapter declares these at configure, so ros2 param list shows
them only on a configured node. A value from the launch layers takes effect
when the adapter declares the parameter. The second column is the adapter’s
default and the third is what params/policy_runner.yaml sets.
Parameter |
Adapter default |
Params file |
Meaning |
|---|---|---|---|
|
|
|
Checkpoint. Empty starts the server without a model, which then loads on the first run. With |
|
|
|
Policy type sent to the server, one of LeRobot’s |
|
|
|
Torch device, such as |
|
|
|
|
|
|
|
Start a policy server on |
|
|
|
Seconds configure waits for the local server to accept connections. The server loads the model before it listens, so this covers the model load and any download. Read-only. |
|
|
|
Actions requested per inference. Read at each run start. |
|
|
|
Fraction, 0 to 1. Queue fill at which the next observation is sent. Read at each run start. |
|
|
|
How an overlapping chunk merges with the queue: |
The adapter refuses a contract at configure when it has more than one
numeric observation key, more than one action key, or a numeric stream
without select. LeRobot’s live path merges all numeric values into one
observation.state and one action, and names them from select.
The local server runs lerobot_rosetta.policy_server, or
lerobot_rosetta.classifier_server with is_classifier. It writes to the
node’s own stdout and stderr. policy_runner_launch.py starts the node with
output: both, so the server’s output shows in the terminal and is kept in
the launch’s log directory (~/.ros/log/<run>/launch.log by default). A
server that exits during startup fails configure, with its output just before
the error. A server
that died is started again at the next run. Cleanup and shutdown stop it. A
run that cannot reach the server ends with Failed to connect to policy server at <server_address>.
Nodes inside the LeRobot plugins
The LeRobot Robot and Teleoperator plugins start their own lifecycle
nodes when a LeRobot tool connects them:
Plugin |
Node name |
|---|---|
|
|
|
|
The robot plugin’s node subscribes to the observation topics and publishes the
action topics. The teleop plugin’s node subscribes to the teleop input and
events topics and publishes the feedback topics. Neither node has Rosetta
services or actions, only the standard lifecycle, parameter and logger
services. Inside policy_runner_node, the robot
plugin uses the runner’s node and starts none of its own.