ros2-robotics
БесплатноБез исполняемых скриптовНе проверенBest practices for ROS 2 robotics development, covering package structure, nodes, topics/services/actions, launch files, QoS, tf2 transforms, and testing. Use…
от Mindrally★ 323 звезды на GitHubОб этом скилле
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 (`sel
Установить ros2-robotics в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл ros2-robotics?
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.
Как установить скилл ros2-robotics?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ros2-robotics запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic