ROS2 Bridge¶
RoboCI can run closed-loop scenarios against a ROS2 system with:
roboci run --suite examples/suites/smoke.yaml --agent examples/agents/rule_based_agent.py --sim ros2
The bridge uses std_msgs/msg/String with JSON payloads. This keeps RoboCI independent from robot-specific message packages while still allowing a ROS2 launch file or adapter node to translate into native topics.
Topics¶
Defaults:
- reset publisher:
/roboci/reset - action publisher:
/roboci/action - observation subscriber:
/roboci/observation
On reset, RoboCI publishes the scenario JSON to the reset topic. On each step, RoboCI publishes the agent action JSON to the action topic:
{"steer": 0.0, "throttle": 0.4, "brake": 0.0}
The ROS2 side must publish observations using RoboCI's episode frame schema:
{
"t": 0.1,
"ego": {"x": 0.5, "y": 0.0, "yaw": 0.0, "speed": 5.0},
"actors": [],
"action": {"steer": 0.0, "throttle": 0.4, "brake": 0.0},
"events": [],
"done": false
}
Set done: true to stop the episode. RoboCI also treats goal_reached, collision, offroad, and timeout events as terminal when the scenario failure criteria allow it.
Configuration¶
You can configure topics per scenario under environment.ros2:
environment:
ros2:
action_topic: /ego/control_json
observation_topic: /ego/observation_json
reset_topic: /scenario/reset_json
timeout_seconds: 10.0
spin_period_seconds: 0.05
qos_profile: 10
Environment variables are also supported:
ROBOCI_ROS2_ACTION_TOPIC=/ego/control_json \
ROBOCI_ROS2_OBSERVATION_TOPIC=/ego/observation_json \
ROBOCI_ROS2_RESET_TOPIC=/scenario/reset_json \
ROBOCI_ROS2_TIMEOUT_SECONDS=10 \
roboci run --suite examples/suites/smoke.yaml --agent examples/agents/rule_based_agent.py --sim ros2
Before running, source your ROS2 environment so rclpy and std_msgs are importable in the Python environment that runs RoboCI.
Reference Application¶
A runnable sample ROS2-side bridge lives in examples/ros2_bridge/. Start the reference node in one terminal, then run RoboCI against the included suite:
python examples/ros2_bridge/reference_bridge_node.py
roboci run --suite examples/ros2_bridge/suite.yaml --agent examples/agents/rule_based_agent.py --sim ros2
The reference node implements a tiny deterministic ego-only world. Use it as a smoke test for the bridge contract or as a template for adapting a real simulator or robot stack.