Generate ROS 2 custom message (.msg) and service (.srv) interface definitions for educational content. This skill should be used when creating lessons that teach interface design, writing exercises involving custom data types, or generating worked examples for robotics communication protocols.
Purpose: Generate accurate, educational ROS 2 custom message and service interface definitions following official ROS 2 Humble patterns for the Physical AI textbook.
CRITICAL: Before generating any code, fetch current ROS 2 documentation using Context7 MCP:
Tool: mcp__context7__resolve-library-id
libraryName: "ros2 custom interfaces"
Then:
Tool: mcp__context7__get-library-docs
context7CompatibleLibraryID: [resolved ID]
topic: "custom msg srv interfaces"
This ensures interface patterns match current ROS 2 Humble conventions.
# File: msg/RobotStatus.msg
# Custom message for robot status reporting
# Header with timestamp
builtin_interfaces/Time stamp
# Robot identification
string robot_name
int32 robot_id
# Status information
bool is_active
float64 battery_level # 0.0 to 100.0
float64[] joint_positions # Array of joint angles in radians
# Nested message (from geometry_msgs)
geometry_msgs/Pose current_pose
# File: srv/MoveRobot.srv
# Custom service for robot movement commands
# Request
string target_frame
geometry_msgs/Point target_position
float64 speed_factor # 0.0 to 1.0
---
# Response
bool success
string message
float64 time_to_reach # Estimated seconds
my_robot_interfaces/
├── CMakeLists.txt
├── package.xml
├── msg/
│ ├── RobotStatus.msg
│ └── SensorData.msg
└── srv/
├── MoveRobot.srv
└── GetStatus.srv
cmake_minimum_required(VERSION 3.8)
project(my_robot_interfaces)
find_package(ament_cmake REQUIRED)
find_package(builtin_interfaces REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(rosidl_default_generators REQUIRED)
rosidl_generate_interfaces(${PROJECT_NAME}
"msg/RobotStatus.msg"
"msg/SensorData.msg"
"srv/MoveRobot.srv"
"srv/GetStatus.srv"
DEPENDENCIES builtin_interfaces geometry_msgs
)
ament_package()
<?xml version="1.0"?>
<package format="3">
<name>my_robot_interfaces</name>
<version>0.1.0</version>
<description>Custom interfaces for robot communication</description>
<maintainer email="you@example.com">Your Name</maintainer>
<license>Apache-2.0</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>rosidl_default_generators</buildtool_depend>
<depend>builtin_interfaces</depend>
<depend>geometry_msgs</depend>
<member_of_group>rosidl_interface_packages</member_of_group>
</package>
| Type | Description | Python Equivalent | |------|-------------|-------------------| | bool | Boolean | bool | | byte | 8-bit unsigned | int | | char | 8-bit char | str (single char) | | float32 | 32-bit float | float | | float64 | 64-bit float | float | | int8/16/32/64 | Signed integers | int | | uint8/16/32/64 | Unsigned integers | int | | string | UTF-8 string | str |
| Syntax | Description |
|--------|-------------|
| float64[] | Unbounded array |
| float64[3] | Fixed-size array (3 elements) |
| float64[<=10] | Bounded array (max 10) |
std_msgs/String, std_msgs/Int32, std_msgs/Boolgeometry_msgs/Point, geometry_msgs/Pose, geometry_msgs/Twistsensor_msgs/Image, sensor_msgs/LaserScan, sensor_msgs/JointStatebuiltin_interfaces/Time, builtin_interfaces/DurationNote: Interface packages require compilation with colcon.
Build commands:
cd ~/ros2_ws
colcon build --packages-select my_robot_interfaces
source install/setup.bash
rosidl_interface_packagesCreate Custom Message When:
Use Standard Messages When:
All patterns verified against: https://docs.ros.org/en/humble/Tutorials/Beginner-Client-Libraries/Custom-ROS2-Interfaces.html
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer