Ask Your Question
0

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

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

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

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;

    ros::spinOnce();
  }
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

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

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

Comments

Generic answer was enough! Thanks!

tiagoantunes14@gmail.com gravatar imagetiagoantunes14@gmail.com ( 2017-03-04 19:19:24 -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

Stats

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

Seen: 42 times

Last updated: Mar 04 '17