ros2-robotics
Skill266 starsChanged 10 months agoApache-2.0View on GitHub
Best practices for ROS 2 robotics development, covering package structure, nodes, topics/services/actions, launch files, QoS, tf2 transforms, and testing. Use when creating ROS 2 packages, writing nodes in rclpy or rclcpp, defining custom messages/services/actions, writing launch files, configuring QoS profiles, working with tf2 transforms, or building and testing a colcon workspace.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- ZeroTokenClaw/agents-skillstheir own version, first seen Sep 21, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- ZeroTokenClaw/agents-skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository264 other files it gives its agents.
- accessibility-a11ySkill
- alpine-jsSkill
- analytics-data-analysisSkill
- android-developmentSkill
- angular-developmentSkill
- angularSkill
- anime-jsSkill
- anthropic-claude-developmentSkill
- api-developmentSkill
- apollo-graphqlSkill
- aspnet-coreSkill
- astroSkill
- auth0-authenticationSkill
- autogen-developmentSkill
- automl-hyperparameter-optimizationSkill
- aws-developmentSkill
- azureSkill
- backend-developmentSkill
- bash-scriptingSkill
- beautifulsoup-parsingSkill
- bitbucket-workflowSkill
- blazorSkill
- blender-python-addonSkill
- blockchainSkill
- bootstrapSkill
- business-central-developmentSkill
- cheerio-parsingSkill
- chrome-extension-developmentSkill
- ci-cd-best-practicesSkill
- clean-architectureSkill
- clean-codeSkill
- clerk-authenticationSkill
- cloudflare-developmentSkill
- computer-vision-opencvSkill
- convexSkill
- cppSkill
- c-sharpSkill
- cssSkill
- cypressSkill
- data-analysis-jupyterSkill
- data-analystSkill
- data-jupyter-pythonSkill
- deep-learning-pythonSkill
- deep-learning-pytorchSkill
- deep-learningSkill
- deno-typescriptSkill
- design-systemsSkill
- devopsSkill
- django-pythonSkill
- django-rest-api-developmentSkill
- dockerSkill
- dotnetSkill
- drizzle-ormSkill
- drupal-developmentSkill
- elasticsearch-best-practicesSkill
- electron-developmentSkill
- elixirSkill
- embedded-stm32Skill
- esbuild-bundlerSkill
- ethereumSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 4 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 23
Keep each package focused on one robot capability or integration boundary (e.g., lidar_driver, path_planner, arm_controller) rather than a …
- Very specific: line 24
Use package.xml consistently with the build type declared in it, and either CMakeLists.txt (ament_cmake, C++) or setup.py/setup.cfg …
- Distinctive: line 26
Use namespaces and topic remapping instead of hardcoded topic names whenever a node might run multiple times (e.g., multi-robot setups) or …
- Very specific: line 31
Keep nodes small and composable — one node per logical responsibility, wired together via topics/services/actions rather than one giant …
- Distinctive: line 33
Prefer messages (topics) for continuous state streams, services for quick, blocking request/response operations, and actions for …
- Very specific: line 34
Use standard message types (geometry_msgs/Twist, sensor_msgs/LaserScan, nav_msgs/Odometry) before creating custom interfaces — custom types …
- Distinctive: line 35
Document topic, service, action, frame, and parameter contracts (name, type, units, frame_id, update rate) in the package README or node …
- Very specific: line 92
Use ROS time (self.get_clock().now(), and use_sim_time when a simulation clock is in play) instead of wall-clock time whenever simulation …
- Very specific: line 93
Use tf2 (tf2_ros.Buffer + TransformListener) for all frame transforms.
- Very specific: line 94
Document frame names (base_link, odom, map, sensor frames) and their conventions (REP-103 for axis orientation, REP-105 for the …
- Very specific: line 95
Avoid blocking callbacks in a node's executor thread — move long-running work to timers, a MultiThreadedExecutor, worker threads, or …
- Very specific: line 100
Use colcon build (typically --symlink-install during development) and keep inter-package dependencies explicit in package.xml.
- Very specific: line 101
Run the linters and formatters the workspace already uses — ament_flake8, ament_pep257 for Python.
- Very specific: line 102
Add launch_testing-based integration tests for multi-node behavior (e.g., "does node A receive what node B publishes within N seconds").
- Distinctive: line 103
Use simulation (Gazebo/Ignition), recorded rosbags, or fixture data for repeatable sensor scenarios instead of relying on live hardware for …
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
ROS 2 Robotics Development
This skill covers building ROS 2 packages and nodes, including package structure, communication patterns (topics, services, actions), timing and frames, build/test workflows with colcon, and common pitfalls in robotics software.
Workflow for Building a ROS 2 Package
- Scaffold the package — Run
ros2 pkg create --build-type ament_python <name>(Python) or--build-type ament_cmake <name>(C++) inside a colcon workspace'ssrc/directory. - Define interfaces — Add custom
.msg,.srv, or.actionfiles undermsg/,srv/,action/only when a standard interface (std_msgs,geometry_msgs,sensor_msgs,nav_msgs) doesn't fit. - Implement nodes — Write focused, composable nodes; declare parameters explicitly; choose topics for streams, services for quick request/response, and actions for long-running goals with feedback and cancellation.
- Write launch files — Compose nodes, parameters, and remappings in a
launch/*.launch.pyfile usinglaunch_ros.actions.Node. - Set QoS profiles intentionally — Match publisher/subscriber QoS (reliability, durability, history depth) for sensor data vs. command/control paths.
- Build the workspace — Run
colcon build --symlink-installfrom the workspace root, thensource install/setup.bash. - Test — Add unit tests (
pytestfor Python,gtest/launch_testingfor C++/integration) and runcolcon test. - Run and inspect — Use
ros2 run,ros2 launch,ros2 topic echo,ros2 node info, andros2 doctorto verify runtime behavior.
Package Structure
- Keep each package focused on one robot capability or integration boundary (e.g.,
lidar_driver,path_planner,arm_controller) rather than a monolithic package. - Use
package.xmlconsistently with the build type declared in it, and eitherCMakeLists.txt(ament_cmake, C++) orsetup.py/setup.cfg(ament_python). - Organize files with
launch/for launch scripts,config/for YAML parameter files,msg/for message definitions,srv/for services,action/for actions, andurdf//xacro/for robot descriptions. - Use namespaces and topic remapping instead of hardcoded topic names whenever a node might run multiple times (e.g., multi-robot setups) or be reused across projects.
- Declare all dependencies explicitly in
package.xml(<depend>,<exec_depend>,<build_depend>) so the workspace builds reproducibly.
Nodes and Interfaces
- Keep nodes small and composable — one node per logical responsibility, wired together via topics/services/actions rather than one giant node doing everything.
- Declare ROS 2 parameters explicitly with
self.declare_parameter('rate_hz', 10.0)and read them withself.get_parameter('rate_hz').value; never rely on undeclared parameters. - Prefer messages (topics) for continuous state streams, services for quick, blocking request/response operations, and actions for long-running goals that report feedback and support cancellation/preemption.
- Use standard message types (
geometry_msgs/Twist,sensor_msgs/LaserScan,nav_msgs/Odometry) before creating custom interfaces — custom types fragment the ecosystem and lose compatibility with existing tools. - Document topic, service, action, frame, and parameter contracts (name, type, units, frame_id, update rate) in the package README or node docstring.
Example: A Minimal rclpy Publisher Node
import rclpy
from rclpy.node import Node
from rclpy.qos import QoSProfile, ReliabilityPolicy, HistoryPolicy
from geometry_msgs.msg import Twist
class SafeVelocityPublisher(Node):
"""Publishes bounded velocity commands at a fixed rate."""
def __init__(self) -> None:
super().__init__("safe_velocity_publisher")
self.declare_parameter("rate_hz", 10.0)
self.declare_parameter("max_linear_speed", 0.5)
rate_hz = self.get_parameter("rate_hz").value
self._max_linear = self.get_parameter("max_linear_speed").value
# Reliable QoS for a low-rate command topic; sensor streams would
# typically use BEST_EFFORT with a shallow history instead.
qos = QoSProfile(
reliability=ReliabilityPolicy.RELIABLE,
history=HistoryPolicy.KEEP_LAST,
depth=10,
)
self._publisher = self.create_publisher(Twist, "cmd_vel", qos)
self._timer = self.create_timer(1.0 / rate_hz, self._on_timer)
self._target_linear = 0.0
def _on_timer(self) -> None:
msg = Twist()
msg.linear.x = max(-self._max_linear, min(self._max_linear, self._target_linear))
self._publisher.publish(msg)
def main(args: list | None = None) -> None:
rclpy.init(args=args)
node = SafeVelocityPublisher()
try:
rclpy.spin(node)
except KeyboardInterrupt:
pass
finally:
node.destroy_node()
rclpy.shutdown()
if __name__ == "__main__":
main()Timing and Frames
- Use ROS time (
self.get_clock().now(), anduse_sim_timewhen a simulation clock is in play) instead of wall-clock time whenever simulation or bag replay matters. - Use
tf2(tf2_ros.Buffer+TransformListener) for all frame transforms; never hand-roll coordinate transforms between named frames. - Document frame names (
base_link,odom,map, sensor frames) and their conventions (REP-103 for axis orientation, REP-105 for themap→odom→base_linktree). - Avoid blocking callbacks in a node's executor thread — move long-running work to timers, a
MultiThreadedExecutor, worker threads, or actions so the node keeps servicing other callbacks. - Set QoS profiles intentionally:
BEST_EFFORT/volatile for high-rate sensor data where dropped samples are acceptable,RELIABLE/TRANSIENT_LOCALfor latched-like configuration topics, andRELIABLE/volatile for command paths.
Build and Test
- Use
colcon build(typically--symlink-installduring development) and keep inter-package dependencies explicit inpackage.xml. - Run the linters and formatters the workspace already uses —
ament_flake8,ament_pep257for Python;ament_cpplint,ament_uncrustifyfor C++ — viacolcon test. - Add
launch_testing-based integration tests for multi-node behavior (e.g., "does node A receive what node B publishes within N seconds"). - Use simulation (Gazebo/Ignition), recorded rosbags, or fixture data for repeatable sensor scenarios instead of relying on live hardware for every test run.
- Explicitly test failure cases: missing/late transforms (
tf2.LookupException), stale sensor data, and services or actions that are unavailable when called.
Common Mistakes
- Hardcoding absolute filesystem paths instead of resolving them via
ament_index_python.packages.get_package_share_directory. - Publishing velocity or actuator commands without validating frame_id, units, and timestamp freshness — a stale or wrong-frame command can move a robot unsafely.
- Creating a custom message/service/action type when an existing standard interface already models the data.
- Ignoring QoS incompatibility warnings between a publisher and subscriber (e.g., a
BEST_EFFORTpublisher with aRELIABLEsubscriber) — the connection silently never delivers data. - Doing significant work inside a subscription callback without offloading it, starving the executor and delaying other callbacks (including safety-critical ones).
- Forgetting
use_sim_time:=truewhen running against a simulator, causing timestamps andtf2lookups to disagree with the simulated clock.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

