How to generate a production-ready ROS2 node from a spec
Quand l'utiliser : You're about to write a new node and want clean lifecycle + tests from the start.
Déroulement
-
Describe the nodeCreate a ROS2 Humble node that subscribes to /scan (LaserScan), filters obstacles, and publishes /cmd_vel using a state machine.✓ Copié→ Node with clear class separation, lifecycle hooks, param declarations
-
Ask for testsWrite pytest unit tests for the filter logic and a launch_test for the integration.✓ Copié→ Tests runnable via colcon test
-
PackageProduce package.xml and CMakeLists.txt with correct dependencies.✓ Copié→ colcon build succeeds
Résultat : A ROS2 package that passes colcon build + test with meaningful coverage.
Pièges
- Claude mixes ROS1 and ROS2 APIs — State version explicitly in the prompt every time — 'ROS2 Humble'
- Node lacks shutdown handling — Ask for on_shutdown hooks and SIGTERM cleanup specifically