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

[Python][Rosbag] Written rosbag has same start and end dates - All topics are published at the end

asked 2019-02-01 10:24:05 -0500

GH gravatar image

Hello everyone,

I've been running around code APIs, forums and other wells of knowledge but I can't find the solution to my problem. Here's what I want to do:

  • open a .mat file (Done)
  • read the structure and fetch the data (Done)
  • create a rosbag with a topic for each message in the mat file (Fail)

I can write to the bag file with

for t in range(MESSAGE_SIZE):
     ros_msg.data = MESSAGE[t]    
     t_msg.secs = t_vec.sec
     t_msg.nsecs = t_vec.nsec 
     bag.write("/topic", ros_msg, t_msg)

Where t_vec is an array, filled with timestamps of said messages. It's under the same format as the ROS time. Execution of the code is done smoothly. However, when I try to replay the bag to check what has been written down in it, I got these issues:

  • rosbag info tells me that bag duration is 0.0s
  • rosbag info tells me that the start and end date are the same (final value of the time vector used in the bag creation)
  • when I play the bag, the duration displayed in the terminal is 17s, whereas the time vector is 89 seconds long.
  • all messages of all topics are published only when the bag reaches its end.
  • the /clock topic is well published and its time is correct.

I honestly don't know where to look now...

Any help would be greatly appreciated. Thanks in advance!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-02-01 11:56:02 -0500

ahendrix gravatar image

It looks like you are using the same timestamp (same value of t_vec and therefore same t_msg) for every message you write into the bag file. (or perhaps there's some relevant code that you aren't showing us)

edit flag offensive delete link more

Comments

You're right, I overly simplified the code, but I do specify the index t when fetching the value. What's even weirder is that when I read back the bag immediately in the same python script, the timestamp of each message is correct!

GH gravatar image GH  ( 2019-02-01 12:02:38 -0500 )edit

If you're going to post simplified code, please test it before you post, to make sure that it exhibits the same problem as your full code. Otherwise, just post the full code.

ahendrix gravatar image ahendrix  ( 2019-02-01 12:58:47 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2019-02-01 10:24:05 -0500

Seen: 582 times

Last updated: Feb 01 '19