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

Reading different bag files yeilds the same data

asked 2011-11-22 08:56:55 -0500

Paul0nc gravatar image

updated 2011-11-23 02:17:29 -0500

I'm trying to use the rosbag API to read from several pre-recorded bag files. The bag files show themselves to be different in rxbag. However, when I try to print a single data field (kinect skeleton left_hand x coordinate), the data is always the same for a given sample. The code I'm using is below. I'm using electric on ubuntu 10.4.

Thanks for any assistance. Paul.

printf("File: %s, representation being generated. \n", bagFileName);

  gesture_bag.open(bagFileName, rosbag::bagmode::Read);
  double x = 0.0;

  rosbag::View view(gesture_bag, rosbag::TopicQuery("Skeletons"));

  BOOST_FOREACH(rosbag::MessageInstance const m, view) {
    body_msgs::Skeletons::ConstPtr s = m.instantiate<body_msgs::Skeletons>();
    if (s != NULL) {
      x = s->skeletons[0].left_hand.position.x;
      printf("x = %f \n", x);
    }
  }

EDIT:

Adding an example program execution transcript for two bag files. These bag files can be seen in their entirety at: https://media.wcu.edu/groups/wcuee222studentwork. (note - this is not course work. just reusing a course website to post my bag files.).

Press <return> to begin collecting to Paul_1.bag.
File: Paul_1.bag, saved.
File: Paul_1.bag, representation being generated.
x = -0.165174
x = -0.169588
x = -0.169613
x = -0.169891
x = -0.170148
x = -0.170124
x = -0.169971
x = -0.169847
x = -0.169541
x = -0.169788
Press <return> to continue.

Press <return> to begin collecting to Paul_2.bag.
File: Paul_2.bag, saved.
File: Paul_2.bag, representation being generated.
x = -0.165174
x = -0.169588
x = -0.169613
x = -0.169891
x = -0.170148
x = -0.170124
x = -0.169971
x = -0.169847
x = -0.169541
x = -0.169788
Press <return> to continue.  ^C

Adding rosbag filter info for the same program execution:

^Mjunk.bag                                      0%   0.0 KB /  12.9 KB --:-- ETA MATCH Skeletons @ 1322060405.655579954: -0.16517427063
^Mjunk.bag                                      3%   0.5 KB /  12.9 KB 00:40 ETA MATCH Skeletons @ 1322060405.655769731: -0.169587921143
MATCH Skeletons @ 1322060405.655794001: -0.169612945557
MATCH Skeletons @ 1322060405.655817728: -0.16989100647
MATCH Skeletons @ 1322060405.662843791: -0.170148040771
MATCH Skeletons @ 1322060405.697162109: -0.170123809814
MATCH Skeletons @ 1322060405.729331279: -0.169971343994
MATCH Skeletons @ 1322060405.770241581: -0.16984703064
MATCH Skeletons @ 1322060405.789512869: -0.16954119873
MATCH Skeletons @ 1322060405.825295207: -0.169788131714
^Mjunk.bag                                    100%             12.9 KB 00:01
^Mjunk.bag                                      0%   0.0 KB /  12.9 KB --:-- ETA MATCH Skeletons @ 1322060409.990274185: -0.1686847229
^Mjunk.bag                                      3%   0.5 KB /  12.9 KB 00:42 ETA MATCH Skeletons @ 1322060409.990326913: -0.171818161011
MATCH Skeletons @ 1322060409.990342712: -0.171740097046
MATCH Skeletons @ 1322060409.990359413: -0.171201141357
MATCH Skeletons @ 1322060410.29273650: -0.171574584961
MATCH Skeletons @ 1322060410.59427515: -0.171567443848
MATCH Skeletons @ 1322060410.96649801: -0.171443496704
MATCH Skeletons @ 1322060410.133197640: -0.171264755249
MATCH Skeletons @ 1322060410.162194287: -0.170930633545
MATCH Skeletons @ 1322060410.194114200: -0.171098449707
^Mjunk.bag                                    100%             12.9 KB 00:01

Adding source code showing generation of the bag files. The program output repeatedly shows the contents of the first bag file generated despite the fact that the filename of a newly generated bag file is passed successfully to the ... (more)

edit retag flag offensive close merge delete

Comments

Can you please share the bags somehow and some of your output as you run this? Also, can you show the definition of gesture_bag?
Dimitar Simeonov gravatar image Dimitar Simeonov  ( 2011-11-22 09:20:55 -0500 )edit
The link for the bags doesn't open for me. Can you post the code of genRep_dynamicInstants(fname) . Are you sure it is using the fname supplied?
Dimitar Simeonov gravatar image Dimitar Simeonov  ( 2011-11-23 07:58:43 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2011-11-23 03:16:17 -0500

Paul0nc gravatar image

Separating the declarations (rosbag::Bag gesture_bag vs. rosbag::Bag read_bag) for read vs. write bags and moving the read bag declaration to the read function solved this problem. Interestingly, moving the declaration for the write bag to the write function did not work. That one had to remain in the class prototype. Any explanation as to why either of these is true would be helpful.

Paul.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-11-22 08:56:55 -0500

Seen: 430 times

Last updated: Nov 23 '11