publish_to_topic
Publish a message to any ROS2 topic by specifying the topic name, message type, and data as JSON.
Instructions
Publish a message to any ROS2 topic.
This tool allows publishing to any ROS2 topic with the appropriate message type. Use 'get_topic_info' to discover the message type for a topic.
Examples:
Publish twist: publish_to_topic("/cmd_vel", "geometry_msgs/msg/Twist", {"linear": {"x": 1.0}, "angular": {"z": 0.5}})
Publish initial pose: publish_to_topic("/initialpose", "geometry_msgs/msg/PoseWithCovarianceStamped", {...})
Returns:
success: Whether the publish succeeded
error: Error message if publish failed
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"topic_name": "<topic_name>",
"message_type": "<message_type>",
"message": "<message>"
},
"name": "publish_to_topic"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message | Yes | Message data to publish as JSON | |
| topic_name | Yes | Topic name to publish to | |
| message_type | Yes | Message type (e.g., geometry_msgs/msg/Twist) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||