Robotics StackExchange | Archived questions

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

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:

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:

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

Any help would be greatly appreciated. Thanks in advance!

Asked by GH on 2019-02-01 11:24:05 UTC

Comments

Answers

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)

Asked by ahendrix on 2019-02-01 12:56:02 UTC

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!

Asked by GH on 2019-02-01 13:02:38 UTC

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.

Asked by ahendrix on 2019-02-01 13:58:47 UTC