Home · What it can build · Writing requests · Architecture · Benchmarks · Fine-tuning · Results · GitHub
Writing requests
The agent works alone until it is done, so anything a request leaves open gets guessed. Exact names and numbers also let the agent test its own work. Short requests are fine for simple packages; add detail for C++, services, actions, lifecycle, components, parameters, logic, launch files and anything other code depends on.
Template
ROS 2 <Humble|Jazzy|Kilted|Lyrical>. Create a <Python|C++> package `<package_name>`.
Executable `<executable>` with a node named `<node_name>` that:
- subscribes to <msg type> on <topic>
- publishes <msg type> on <topic> at <rate> Hz, containing <exact content>
- offers service <name> of type <srv type> that <exact behaviour>
- declares parameter <name> (<type>, default <value>); changing it at runtime must <effect>; reject <invalid values>
Also include: <launch/x.launch.py that ...> / <config/params.yaml with ...> / <custom msg/srv/action with fields>.
When done, run ./tools/ros2check, then prove it works: <a concrete test>.
Example
ROS 2 Jazzy. Create a C++ package `battery_monitor`.
Executable `monitor` with a node named `battery_monitor` that:
- subscribes to sensor_msgs/msg/BatteryState on /battery
- publishes std_msgs/msg/Bool on /battery_low at 1 Hz: true when percentage is below the threshold
- declares a double parameter `threshold` (default 0.2); ros2 param set takes effect immediately; reject values outside 0.0-1.0
- offers /reset_alarm of type std_srvs/srv/Trigger that returns success = true
Also include launch/monitor.launch.py that starts the node with config/params.yaml setting threshold to 0.25.
Keep every publisher, subscription, timer and service as a class member, and in main keep the node in a
variable before adding it to the executor.
When done, run ./tools/ros2check, then prove it works: publish percentage 0.1 on /battery and show
/battery_low is true; set threshold to 0.05 and show it becomes false; show ros2 launch loads the file.
Short form
ROS 2 Jazzy, C++ package `battery_monitor`: subscribe to sensor_msgs/msg/BatteryState on /battery,
publish std_msgs/msg/Bool on /battery_low (true below 20%) at 1 Hz. Prove it works by publishing 10%
and showing /battery_low is true.
What each part buys
| Part | Why |
|---|---|
| Distro first | APIs and launch syntax differ; the agent searches that distro’s references |
| Exact names and full message types | Guessed names were a common failure; exact ones are testable |
| Numbers (rates, defaults, limits) | “5 Hz” can be checked, “regularly” cannot |
| Edge cases (“reject negatives”, “ignore out-of-range values”) | Most fine-tuned-model failures were wrong behaviour that still compiled |
| A lifetime hint for C++ | Its most common C++ bug: nodes and broadcasters destroyed too early |
| “Prove it works: …” | Makes the agent run the node and compare, instead of stopping at “it builds” |
One package per request (or one package plus its interface package) works best.