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

How do I know when rosbag finished? (by code - without looking at the terminal)

asked 2016-04-27 04:00:42 -0500

Ariel gravatar image

updated 2016-04-27 04:08:53 -0500

mgruhler gravatar image

Hello,

I'm writing a node to convert from a rosbag to a .mat file using matlab's api for this. I am subscribing to the topics contained in the rosbag and via a callback function I can read the respective topic only when there is new data. The issue might be that I need to know when the rosbag ended so I can close the .mat file. Is there any way to know when the rosbag finished? I was not able to find any topic for example that might tell me the status of the rosbag.

Thanks for the help.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
3

answered 2016-04-27 04:06:49 -0500

mgruhler gravatar image

I'd say it is easier to use the rosbag API for the conversion instead of playing a rosbag, subcribing to the topic and writing it to a .mat file...

This would acutally solve your question because you are reading the rosbag directly and don't have to start it on the command line.

There is also a cookbook with several examploes.

edit flag offensive delete link more

Comments

That's exactly what I needed. Thanks a lot for the answer.

Ariel gravatar image Ariel  ( 2016-04-27 07:21:50 -0500 )edit

@Ariel, please accept the answer instead of closing the question. Thanks!

Martin Günther gravatar image Martin Günther  ( 2016-04-27 07:35:01 -0500 )edit

Now its done

Ariel gravatar image Ariel  ( 2016-04-27 07:54:19 -0500 )edit

One more thing....the cookbok shows how I can access data from that topic. For example, I have this: nav_msgs::Odometry::ConstPtr odometry = m.instantiate<nav_msgs::Odometry>(); and I can access odometry->pose.pose.position.x. Continued...

Ariel gravatar image Ariel  ( 2016-04-27 10:41:43 -0500 )edit

How can I push_back the entire topic to an How can I push_back the entire topic to std::vector<nav_msgs::odometry> ? I could populate nav_msgs::Odometry odometryTmp with the each value from the topic and the push_back(odometryTmp), but looks kind of ugly. Is there a better way?

Ariel gravatar image Ariel  ( 2016-04-27 10:42:06 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-04-27 04:00:42 -0500

Seen: 1,692 times

Last updated: Apr 27 '16