00001 /****************************************************************************** 00002 STDR Simulator - Simple Two DImensional Robot Simulator 00003 Copyright (C) 2013 STDR Simulator 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation; either version 3 of the License, or 00007 (at your option) any later version. 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 You should have received a copy of the GNU General Public License 00013 along with this program; if not, write to the Free Software Foundation, 00014 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00015 00016 Authors : 00017 * Manos Tsardoulias, etsardou@gmail.com 00018 * Aris Thallas, aris.thallas@gmail.com 00019 * Chris Zalidis, zalidis@gmail.com 00020 ******************************************************************************/ 00021 00022 #include "ros/ros.h" 00023 #include "tf/tf.h" 00024 #include "tf/transform_broadcaster.h" 00025 #include "nav_msgs/MapMetaData.h" 00026 #include "nav_msgs/OccupancyGrid.h" 00027 #include "stdr_server/map_loader.h" 00028 00033 namespace stdr_server { 00034 00039 class MapServer 00040 { 00041 public: 00042 00048 explicit MapServer(const std::string& fname); 00049 00055 explicit MapServer(const nav_msgs::OccupancyGrid& map); 00056 00057 private: 00058 00063 void publishData(); 00064 00070 void publishTransform(const ros::TimerEvent& ev); 00071 00072 private: 00073 00075 ros::NodeHandle n; 00077 ros::Publisher map_pub; 00079 ros::Publisher metadata_pub; 00081 ros::Timer tfTimer; 00083 tf::TransformBroadcaster tfBroadcaster; 00085 nav_msgs::MapMetaData meta_data_message_; 00087 nav_msgs::OccupancyGrid map_; 00088 00089 }; 00090 } // namespace stdr_server