Reading different bag files yeilds the same data
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 ...