get_topic_snapshot
Capture a snapshot of recent messages from any ROS 2 topic by subscribing briefly, collecting a specified number of messages, and automatically unsubscribing.
Instructions
Read live data from a topic: subscribe, collect up to count
messages (or until timeout seconds elapse), then unsubscribe.
Args: topic: Topic name including leading slash, e.g. "/scan" or "/odom". count: How many messages to collect (default 1, clamped to at most 100). Use more to observe a value changing over time. timeout: Max seconds to wait (default 5.0, clamped to at most 60.0). The tool never blocks longer than this, even on a silent topic. msg_type: Optional full message type, e.g. "sensor_msgs/msg/LaserScan". Usually omit it; rosbridge resolves the type of existing topics.
Returns {"topic", "requested", "received", "messages": [...], "timed_out", "timeout_s"}. If "timed_out" is true, nothing (or not enough) was published within the timeout — the topic may be silent, misspelled, or not exist. If the rosbridge connection drops mid-collection, the tool returns immediately with {"error", "connection_lost": true} instead of waiting out the timeout.
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": "<topic>"
},
"name": "get_topic_snapshot"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No | ||
| topic | Yes | ||
| timeout | No | ||
| msg_type | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||