ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Check on a rostopic programatically?

asked 2014-09-17 15:32:06 -0500

an gravatar image

updated 2014-09-17 15:32:21 -0500

I've tried searching for this but have been unsuccessful so far.

Is it possible to see a topic's value, programatically? Basically, I need the functionality of rostopic echo, but I need to add it to my code.

It's a topic that I created myself, so I can't just create a client and call a service... And I also do not want to subscribe to the topic and create a callback function. I just want to know the topic's value at a given point in my code.

Is this possible?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-09-17 15:50:06 -0500

ahendrix gravatar image

In C++, you can use ros::topic::waitForMessage() :

Note that this will be slow, because internally it creates a subscriber, waits for it to connect, waits for the first message, and then removes the subscriber.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2014-09-17 15:32:06 -0500

Seen: 515 times

Last updated: Sep 17 '14