Home › ROS 2 (robotics) › ROS 2 robotics workspace CLAUDE.md

ROS 2 robotics workspace CLAUDE.md

CLAUDE.md for ROS 2 workspaces: colcon builds, rclcpp/rclpy nodes, launch files, parameters, QoS, interfaces packages, and launch_testing.

Claude Code (CLAUDE.md)ROS 2 (robotics)

How to use

Save this as CLAUDE.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

CLAUDE.mdDownload  
# CLAUDE.md: ROS 2 workspace

## Build & test
- Source the distro first: `source /opt/ros/$ROS_DISTRO/setup.bash` (check `README`/Dockerfile for the distro; don't assume one).
- `rosdep install --from-paths src --ignore-src -y` · `colcon build --symlink-install --packages-select <pkg>` · `source install/setup.bash`
- `colcon test --packages-select <pkg> && colcon test-result --verbose`
- Run: `ros2 launch <pkg> <file>.launch.py`; inspect with `ros2 topic list/echo/hz`, `ros2 node info`, `ros2 param list`.

## Code map
`src/<pkg>/` each with `package.xml` and `CMakeLists.txt` (ament_cmake) or `setup.py` (ament_python). Custom messages/services/actions live in a separate `<name>_interfaces` package.

## Conventions
- Nodes are classes (`rclcpp::Node` / `rclpy.node.Node`), one responsibility each. Prefer components (`rclcpp_components`) for C++ nodes that may be composed.
- Declare every parameter with a default and description (`declare_parameter`); load values from YAML in `config/` via the launch file. Validate with a parameter callback.
- Choose QoS deliberately: sensor data uses `SensorDataQoS` (best effort); commands and state use reliable. Publishers and subscribers must be compatible.
- Never block in callbacks (no `sleep`, no long loops). Use timers, and a `MultiThreadedExecutor` with callback groups when callbacks must run concurrently.
- Use actions for long-running goals with feedback and cancellation; services only for quick request/response.
- Units and frames follow REP 103/105: SI units, `base_link`/`odom`/`map`; publish transforms with `tf2_ros`, don't hard-code offsets.
- Log with the node logger (`RCLCPP_INFO`, `self.get_logger()`), throttled in hot paths.
- Launch files in Python (`launch.py`) with arguments for `use_sim_time` and config paths.

## Tests
`ament_lint_auto` linters, gtest/pytest for logic, `launch_testing` for node integration.

## Don't
Don't edit generated code in `build/` or `install/`, or commit those directories. Don't drive real hardware from tests.

More: all ROS 2 (robotics) rules · all Claude Code (CLAUDE.md) rules

Related rules

ESP32 ESP-IDF firmware CLAUDE.md

CLAUDE.md for ESP32 firmware on ESP-IDF 5.x in C: components, FreeRTOS tasks, error handling, and logging.

Claude Code (CLAUDE.md)Embedded / firmware

Solana Anchor programs CLAUDE.md

CLAUDE.md for Solana programs built with Anchor: account validation, PDAs and bumps, checked math, CPI safety, and local-validator tests.

Claude Code (CLAUDE.md)Solana / Anchor

Solidity smart contract security CLAUDE.md

CLAUDE.md for reviewing and writing Solidity contracts safely: threat checklist, Foundry tests, and no-deploy rules.

Claude Code (CLAUDE.md)Solidity / smart contracts

Modern C++ with CMake rules

Cursor rules for modern C++ (C++20/23) projects built with CMake presets: RAII, ownership, warnings, and tests.

CursorC++

CUDA C++ kernels Cursor rules

Cursor rules for CUDA C++: error checking every API call, coalesced memory access, launch configuration, streams, and correctness tests before tuning.

CursorCUDA / GPU

Embedded C (bare metal / RTOS) AGENTS.md

AGENTS.md for embedded C firmware (bare metal, Zephyr, FreeRTOS): safety-minded C rules, memory, and hardware access.

AGENTS.mdEmbedded / firmware

Get the best new AI prompts every week

One short email a week: the best new prompts and rules for ChatGPT, Claude, Gemini, Midjourney, Cursor and more, plus what changed in the tools. Free, unsubscribe anytime.

Finishes on our newsletter page at beehiiv (opens in a new tab). Or subscribe directly.