clean_odom_tf.cpp
Go to the documentation of this file.
00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 #include <ros/ros.h>
00003 #include <rosbag/bag.h>
00004 #include <rosbag/view.h>
00005 #include <rosbag/message_instance.h>
00006 
00007 #include <boost/foreach.hpp>
00008 
00009 #include <tf/tfMessage.h>
00010 
00011 int main(int argc, char **argv)
00012 {
00013     if (argc != 2)
00014     {
00015         std::cout << "Usage: clean_odom_tf <input.bag>" << std::endl;
00016         exit(-1);
00017     }
00018 
00019     rosbag::Bag bag;
00020     rosbag::Bag output("output.bag", rosbag::bagmode::Write);
00021 
00022     int i = 0;
00023     bag.open(argv[1], rosbag::bagmode::Read);
00024 
00025     rosbag::View view(bag);
00026 
00027     BOOST_FOREACH(rosbag::MessageInstance const m, view)
00028     {
00029         if (m.getTopic() == "/tf")
00030         {
00031             tf::tfMessage::ConstPtr tf = m.instantiate<tf::tfMessage>();
00032             if (tf->transforms[0].header.frame_id == "/odom")
00033             {
00034                 i++;
00035                 continue;
00036             }
00037         }
00038         output.write(m.getTopic(),m.getTime(),m);
00039     }
00040 
00041     bag.close();
00042 
00043     std::cout << "Total number of tfs removed: " << i << std::endl;
00044     return 1;
00045 }


teo_rosbag_filters
Author(s): Jose Luis Rivero (jrivero@iri.upc.edu)
autogenerated on Sat Dec 7 2013 00:02:28