How do I check only one message from a topic?
I can continuously print messages from a topic using ros2 topic echo <topic_name>
. Instead, I want to save to file exactly one message from the topic to examine it. It doesn't matter what message I save, e.g. there are 10 messages per second and it doesn't matter which one to save. How to I do it?
In my opinion, you can create a callback function that writes a topic message in a file. At the end of the callback you can create a if statement ( if file is not empty) you can shut the node down. Basic Subscriber , you can refer this link you will need to change topic name and listener_callback function.