Runner Internals
Process Management
runner.process_manager
Process management utilities for orchestrating ROS 2 and simulator processes.
This module provides robust process lifecycle management with proper signal handling and process group management for clean shutdown of complex process trees.
ManagedProcess
dataclass
Container for a managed subprocess with associated metadata.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Human-readable identifier for the process |
popen |
Popen
|
The subprocess.Popen instance |
log_path |
Path
|
Path to the log file capturing stdout/stderr |
Source code in runner/process_manager.py
ProcessManager
Manages the lifecycle of multiple subprocesses with centralized logging.
This class handles starting, monitoring, and gracefully stopping process trees. It uses process groups (via os.setsid) to ensure child processes are properly terminated when the parent is stopped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logs_dir
|
str
|
Directory where process logs will be written |
required |
Source code in runner/process_manager.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
is_running(name)
Check if a managed process is still running.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Process identifier |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the process is running, False otherwise |
Source code in runner/process_manager.py
start(name, cmd, env=None, cwd=None)
Start a new managed process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Unique identifier for this process |
required |
cmd
|
list[str]
|
Command and arguments as a list |
required |
env
|
dict[str, str] | None
|
Optional environment variables to merge with os.environ |
None
|
cwd
|
str | None
|
Optional working directory for the process |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If a process with this name already exists |
Source code in runner/process_manager.py
stop(name, sigint_timeout_s=8.0, sigterm_timeout_s=4.0)
Gracefully stop a managed process with escalating signals.
Attempts to stop the process using a three-stage approach: 1. SIGINT (ROS 2 friendly) - wait up to sigint_timeout_s 2. SIGTERM - wait up to sigterm_timeout_s 3. SIGKILL - forceful termination
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Process identifier |
required |
sigint_timeout_s
|
float
|
Seconds to wait after SIGINT before escalating |
8.0
|
sigterm_timeout_s
|
float
|
Seconds to wait after SIGTERM before SIGKILL |
4.0
|
Source code in runner/process_manager.py
stop_all()
Stop all managed processes.
Iterates through all processes and attempts to stop them gracefully. Exceptions during individual process stops are silently ignored.
Source code in runner/process_manager.py
Data Recording
runner.bag_recorder
Configuration and command building for ROS 2 bag recording.
This module provides utilities to configure and generate rosbag2 record commands with various options like compression, storage format, and topic filtering.
RosbagConfig
dataclass
Configuration for rosbag2 recording.
Attributes:
| Name | Type | Description |
|---|---|---|
storage_id |
str
|
Storage backend ("sqlite3" or "mcap") |
compression |
Optional[str]
|
Optional compression format ("zstd" or "lz4") |
max_bag_size_mb |
Optional[int]
|
Maximum size per bag file in megabytes |
include_hidden_topics |
bool
|
Whether to record hidden topics (e.g., /rosout) |
qos_overrides_path |
Optional[str]
|
Path to QoS profile overrides YAML |
topics |
list[str]
|
List of topic names to record |
Source code in runner/bag_recorder.py
build_rosbag_cmd(output_dir, cfg)
Build a ros2 bag record command from configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
str
|
Directory where the bag will be saved |
required |
cfg
|
RosbagConfig
|
RosbagConfig with recording options |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Command as a list of strings ready for subprocess.Popen |
Example
cfg = RosbagConfig(topics=["/scan", "/odom"], compression="zstd") cmd = build_rosbag_cmd("/tmp/mybag", cfg)
cmd = ["ros2", "bag", "record", "-o", "/tmp/mybag", ...]
Source code in runner/bag_recorder.py
Probes
runner.probes.ros_probes
ROS 2 probes for verifying system readiness before benchmark execution.
This module provides a suite of probes to verify that ROS 2 nodes, topics, services, and transforms are available and functioning correctly before starting a benchmark run.
NodePresentProbe
Bases: Probe
Probe that verifies a ROS 2 node is running.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_name
|
str
|
Name of the node to check for |
required |
timeout_s
|
float
|
Maximum time to wait (default: 10.0) |
10.0
|
Source code in runner/probes/ros_probes.py
ServiceAvailableProbe
Bases: Probe
Probe that verifies a ROS 2 service is available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
service
|
str
|
Service name (e.g., "/map_server/load_map") |
required |
srv_type
|
str
|
Service type string (e.g., "nav2_msgs/srv/LoadMap") |
required |
timeout_s
|
float
|
Maximum time to wait (default: 10.0) |
10.0
|
Source code in runner/probes/ros_probes.py
TfAvailableProbe
Bases: Probe
Probe that verifies a TF transform is available.
Checks if a transform between two frames exists in the TF tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_frame
|
str
|
Source frame (e.g., "odom") |
required |
to_frame
|
str
|
Target frame (e.g., "base_link") |
required |
timeout_s
|
float
|
Maximum time to wait (default: 10.0) |
10.0
|
Source code in runner/probes/ros_probes.py
TopicHzTypedProbe
Bases: Probe
Probe that verifies a topic is publishing at a minimum frequency.
Measures the publication rate over a sliding window and ensures it meets the minimum Hz requirement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
topic
|
str
|
Topic name |
required |
msg_type
|
str
|
Message type string |
required |
min_hz
|
float
|
Minimum required frequency in Hz |
required |
window_s
|
float
|
Time window for frequency calculation (default: 5.0) |
5.0
|
timeout_s
|
float
|
Maximum time to wait (default: 20.0) |
20.0
|
Source code in runner/probes/ros_probes.py
TopicPublishProbe
Bases: Probe
Deprecated probe - use TopicPublishTypedProbe instead.
This probe requires explicit message type specification.
Source code in runner/probes/ros_probes.py
TopicPublishTypedProbe
Bases: Probe
Probe that verifies a topic is publishing messages.
Subscribes to a topic and waits for a minimum number of messages to be received.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
topic
|
str
|
Topic name (e.g., "/scan") |
required |
msg_type
|
str
|
Message type string (e.g., "sensor_msgs/msg/LaserScan") |
required |
min_messages
|
int
|
Minimum number of messages to receive (default: 1) |
1
|
timeout_s
|
float
|
Maximum time to wait in seconds (default: 10.0) |
10.0
|