Ask Your Question

How to get laser points in a specific time of a bag

asked 2017-03-04 14:22:35 -0600

updated 2017-03-04 19:20:13 -0600

I have some code that get the messages and break after there is something inside, but laser ranges data change every time I execute my code. This happens probably cause I get the msg in different periodo of time. I want set a specific time to get it, I mean get the ranges always at the same time.

This how I'm doing now.

while(ros::ok()) {
    for (i = 0; i < 540; i++) {
      if (!clustersScan.laserMsg.ranges.empty()) {
        RANGES[i] = clustersScan.laserMsg.ranges[i];

    if(!clustersScan.laserMsg.ranges.empty()) break;

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-03-04 17:48:46 -0600

ahendrix gravatar image

There's a lot missing from your code (how are you getting messages? is there a subscriber? why do you want a specific timestamp? how are you reading the bag file?) , so the best I can do is a generic answer:

rosbag has a C++ API that can be used to read all of the messages from a bag file, in order. You can use this to get the first (or Nth) message from a bag file, or you can compare the header timestamps if you want a message with a specific timestamp.

edit flag offensive delete link more


Generic answer was enough! Thanks! gravatar image  ( 2017-03-04 19:19:24 -0600 )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


Asked: 2017-03-04 14:22:35 -0600

Seen: 60 times

Last updated: Mar 04 '17