00001 /**************************************************************** 00002 * 00003 * Copyright (c) 2011 00004 * 00005 * Fraunhofer Institute for Manufacturing Engineering 00006 * and Automation (IPA) 00007 * 00008 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00009 * 00010 * Project name: care-o-bot 00011 * ROS stack name: cob_environment_perception 00012 * ROS package name: cob_3d_mapping_geometry_map 00013 * Description: 00014 * 00015 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00016 * 00017 * Author: Georg Arbeiter, email:georg.arbeiter@ipa.fhg.de 00018 * Supervised by: Georg Arbeiter, email:georg.arbeiter@ipa.fhg.de 00019 * 00020 * Date of creation: 10/2012 00021 * ToDo: 00022 * 00023 * 00024 * 00025 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00026 * 00027 * Redistribution and use in source and binary forms, with or without 00028 * modification, are permitted provided that the following conditions are met: 00029 * 00030 * * Redistributions of source code must retain the above copyright 00031 * notice, this list of conditions and the following disclaimer. 00032 * * Redistributions in binary form must reproduce the above copyright 00033 * notice, this list of conditions and the following disclaimer in the 00034 * documentation and/or other materials provided with the distribution. 00035 * * Neither the name of the Fraunhofer Institute for Manufacturing 00036 * Engineering and Automation (IPA) nor the names of its 00037 * contributors may be used to endorse or promote products derived from 00038 * this software without specific prior written permission. 00039 * 00040 * This program is free software: you can redistribute it and/or modify 00041 * it under the terms of the GNU Lesser General Public License LGPL as 00042 * published by the Free Software Foundation, either version 3 of the 00043 * License, or (at your option) any later version. 00044 * 00045 * This program is distributed in the hope that it will be useful, 00046 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00047 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00048 * GNU Lesser General Public License LGPL for more details. 00049 * 00050 * You should have received a copy of the GNU Lesser General Public 00051 * License LGPL along with this program. 00052 * If not, see <http://www.gnu.org/licenses/>. 00053 * 00054 ****************************************************************/ 00055 00056 //################## 00057 //#### includes #### 00058 00059 // ROS includes 00060 #include <ros/ros.h> 00061 #include <rosbag/bag.h> 00062 #include <rosbag/view.h> 00063 00064 // ROS message includes 00065 #include <cob_3d_mapping_msgs/ShapeArray.h> 00066 #include <cob_3d_mapping_msgs/SetGeometryMap.h> 00067 00068 00069 00070 00071 int main (int argc, char **argv) 00072 { 00073 if(argc<1) { 00074 ROS_ERROR("Please specify output file\nrosrun cob_3d_mapping_geometry_map set_map_client myfile.bag"); 00075 return -1; 00076 } 00077 ros::init(argc, argv, "geometry_map_node"); 00078 ros::NodeHandle nh; 00079 00080 cob_3d_mapping_msgs::SetGeometryMap::Request req; 00081 cob_3d_mapping_msgs::SetGeometryMap::Response res; 00082 std::string file_path; 00083 ros::param::get("~file_path", file_path); 00084 cob_3d_mapping_msgs::ShapeArray::ConstPtr sa; 00085 rosbag::Bag bag; 00086 bag.open(argv[1]/*file_path*/, rosbag::bagmode::Read); 00087 rosbag::View view(bag, rosbag::TopicQuery("/geometry_map/map_array")); 00088 if(!view.size()) 00089 { 00090 ROS_ERROR("Bagfile does not contain a topic named /geometry_map/map_array, aborting."); 00091 return 0; 00092 } 00093 rosbag::MessageInstance m = *(view.begin()); 00094 if(!m.isType<cob_3d_mapping_msgs::ShapeArray>()) 00095 { 00096 ROS_ERROR("Bagfile does not contain a valid message, aborting."); 00097 return 0; 00098 } 00099 sa = m.instantiate<cob_3d_mapping_msgs::ShapeArray>(); 00100 bag.close(); 00101 00102 req.map = *sa; 00103 ros::ServiceClient set_map_client = nh.serviceClient<cob_3d_mapping_msgs::SetGeometryMap>("/geometry_map/set_map"); 00104 if(!set_map_client.call(req,res)) 00105 { 00106 ROS_ERROR("Failed to call service set_map"); 00107 return 0; 00108 } 00109 00110 return 0; 00111 }