pub_head.cpp
Go to the documentation of this file.
00001 #include <rosbag/bag.h>
00002 #include <rosbag/view.h>
00003 #include <rosbag/message_instance.h>
00004 
00005 #include <hrl_phri_2011/pcl_basic.h>
00006 
00007 int main(int argc, char **argv)
00008 {
00009     ros::init(argc, argv, "pub_head", ros::init_options::AnonymousName);
00010     if(argc < 2 || argc > 5) {
00011         printf("Usage pub_head bag_file [topic] [frame] [rate]\n");
00012         return 1;
00013     }
00014 
00015     // Load bag
00016     rosbag::Bag bag;
00017     bag.open(std::string(argv[1]), rosbag::bagmode::Read);
00018     rosbag::View view(bag);
00019 
00020     PCRGB::Ptr pc_head(new PCRGB());
00021     bool found_topic = false;
00022     BOOST_FOREACH(rosbag::MessageInstance const m, view) {
00023         sensor_msgs::PointCloud2::Ptr pc2 = m.instantiate<sensor_msgs::PointCloud2>();
00024         pcl::fromROSMsg(*pc2, *pc_head);
00025         if(argc == 2) {
00026             found_topic = true;
00027             break;
00028         } else if (m.getTopic() == argv[2]) {
00029             found_topic = true;
00030             break;
00031         }
00032     }
00033     if(!found_topic) {
00034         printf("Topic %s not found in bag!", argv[2]);
00035         return -1;
00036     }
00037 
00038     if(argc == 2)
00039         pubLoop(*pc_head, "/stitched_head");
00040     else if(argc == 3)
00041         pubLoop(*pc_head, std::string(argv[2]));
00042     else if(argc == 4) {
00043         pc_head->header.frame_id = std::string(argv[3]);
00044         pubLoop(*pc_head, std::string(argv[2]));
00045     }
00046     else if(argc == 5) {
00047         pc_head->header.frame_id = std::string(argv[3]);
00048         pubLoop(*pc_head, std::string(argv[2]), atof(argv[4]));
00049     }
00050 
00051     return 0;
00052 }


hrl_phri_2011
Author(s): Kelsey Hawkins
autogenerated on Wed Nov 27 2013 12:22:40