ros ros2
via PatrickJS/awesome-cursorrules
ROS and ROS2 best practices for packages, nodes, interfaces, timing, and testing.
What is ros ros2?
Guidance for structuring ROS/ROS2 packages, designing composable nodes with clear interfaces, managing frames and timing, and building reliable multi-node systems. Use this rule when developing robot software with ROS or ROS2.
- Enforce package organization: launch files, configs, messages, services, and actions in standard directories
- Guide node design: keep nodes small and composable, use parameters, prefer standard message types
- Manage timing and transforms: use ROS time for simulation, tf2 for frames, set QoS profiles intentionally
- Prevent common mistakes: avoid hardcoded paths and absolute topic names, validate command assumptions, catch QoS mismatches
- Structure build and test: use colcon, run linters, add launch and integration tests with simulation or recorded fixtures
Applies to
File patterns this rule matches.
Rule definition (reference)
Source of truth, from the repository.
ROS and ROS2 Rules
Package Structure
- Keep packages focused on one robot capability or integration boundary.
- Use
package.xmlandCMakeLists.txtorsetup.pyconsistently with the package type. - Keep launch files under
launch/, configs underconfig/, messages undermsg/, services undersrv/, and actions underaction/. - Use namespaces and remapping instead of hardcoded topic names when nodes may be reused.
Nodes and Interfaces
- Keep nodes small and composable.
- Use parameters for tunable behavior; declare ROS2 parameters explicitly.
- Prefer messages for state streams, services for quick request/response operations, and actions for long-running goals with feedback.
- Use standard message types before creating custom interfaces.
- Document topic, service, action, frame, and parameter contracts.
Timing and Frames
- Use ROS time when simulation or bag replay matters.
- Use
tf2for frame transforms and document frame names. - Avoid blocking callbacks; move long work to timers, worker threads, or actions.
- Set QoS profiles intentionally for sensor data, latched-like config, and reliable command paths.
Build and Test
- Use
colcon buildand keep package dependencies explicit. - Run linters and formatters used by the workspace.
- Add launch tests or integration tests for multi-node behavior.
- Use simulation, bags, or recorded fixtures for repeatable sensor scenarios.
- Test failure cases such as missing transforms, stale sensor data, and unavailable services.
Common Mistakes
- Do not hardcode absolute paths; use package share directories.
- Do not publish commands without validating frame, units, and timestamp assumptions.
- Do not create custom messages when a standard message fits.
- Do not ignore QoS mismatches between publishers and subscribers.
Related rules
Build RTL-ready apps with logical CSS, Tailwind utilities, and automated auditing.

Rust best practices for Solana smart contract development using Anchor framework and Solana SDK
General Rust rules for safe, idiomatic application and library development
Senior Salesforce Apex development guide with design patterns, testability, and best practices.
Scala and Kafka development practices with clean code, functional patterns, and testing guidelines.

security devsecops ssdls appsec
Secure coding, secret handling, dependency hygiene, and compliance for DevSecOps and SSDLC.