Ask Your Question
1

Recieve last Message on topic after subscription

asked 2014-09-26 09:56:57 -0500

JW gravatar image

Hey guys,

i am developing a Plugin for rviz, and I want to have the last message that was sent on a topic when i subscribe to this topic.

The idea is, that I am in rosbag replay and i want to evaluate the values of my sensors when the replay is stopped.

The way to achieve this is - in my eyes - to request the last message that has been sent on the topic.

Is there any way to do that? BTW, i am using c++

Happy Coding,

Johannes

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-09-26 15:04:06 -0500

bvbdort gravatar image

Receive all messages and take last message based on sequence number or timestamp from message header.

edit flag offensive delete link more

Comments

I have around 50 Topics, all of them are activly sent - so this will not work. So ROS does not have a standard way to do this?

JW gravatar image JW  ( 2014-09-26 15:24:55 -0500 )edit

you can use timestamp. but still can you write more on what exactly you are trying to do

bvbdort gravatar image bvbdort  ( 2014-09-26 16:09:39 -0500 )edit

I start a replay with Rosbag (~50 recorded Topics), I start rviz, I recognize an error so i stop rosbag, then I want to evaluate the Data in rviz - without unpausing rosbag!

JW gravatar image JW  ( 2014-09-26 16:46:52 -0500 )edit

Have you tried running rviz from the beginning? All the data should be there when you pause playback.

tfoote gravatar image tfoote  ( 2014-09-26 17:14:57 -0500 )edit

then the question is: How can i access this data?

JW gravatar image JW  ( 2014-09-26 17:48:14 -0500 )edit

What do you mean, all the data should be buffered and displayed in rviz already. Use the standard plugins to view the data. When time pauses, due to the bag stopping playback it will all be right there.

tfoote gravatar image tfoote  ( 2014-09-26 18:15:26 -0500 )edit

I cannot use the standard plugins for all of my data, so i have written my own. And when I subscribe to a topic, then I want to have the last message on any topic - topics that i was not subscribed to, when this message came.

JW gravatar image JW  ( 2014-09-27 03:53:09 -0500 )edit

you can try http://wiki.ros.org/rosbag/Code%20API to access data in rosbag

bvbdort gravatar image bvbdort  ( 2014-09-27 05:06:16 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-09-26 09:56:57 -0500

Seen: 145 times

Last updated: Sep 26 '14