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

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;

    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 -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

Comments

Generic answer was enough! Thanks!

tiagoantunes14@gmail.com gravatar image tiagoantunes14@gmail.com  ( 2017-03-04 19:19:24 -0600 )edit

Question Tools

Stats

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

Seen: 152 times

Last updated: Mar 04 '17