Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <stdr_server/map_server.h>
00023
00024 namespace stdr_server {
00025
00031 MapServer::MapServer(const std::string& fname)
00032 {
00033
00034 map_ = map_loader::loadMap(fname);
00035
00036 meta_data_message_ = map_.info;
00037
00038 publishData();
00039 }
00040
00046 MapServer::MapServer(const nav_msgs::OccupancyGrid& map)
00047 {
00048
00049 map_ = map;
00050
00051 meta_data_message_ = map_.info;
00052
00053 publishData();
00054 }
00055
00060 void MapServer::publishData(void)
00061 {
00062
00063 tfTimer = n.createTimer(ros::Duration(0.1),
00064 &MapServer::publishTransform, this);
00065
00067 metadata_pub= n.advertise<nav_msgs::MapMetaData>("map_metadata", 1, true);
00068 metadata_pub.publish( meta_data_message_ );
00069
00071 map_pub = n.advertise<nav_msgs::OccupancyGrid>("map", 1, true);
00072 map_pub.publish( map_ );
00073 }
00074
00080 void MapServer::publishTransform(const ros::TimerEvent&) {
00081
00082 tf::Vector3 translation(
00083 map_.info.origin.position.x,
00084 map_.info.origin.position.y,
00085 0);
00086
00087 tf::Quaternion rotation;
00088
00089 rotation.setRPY(0, 0, tf::getYaw(map_.info.origin.orientation));
00090
00091 tf::Transform worldTomap(rotation, translation);
00092
00093 tfBroadcaster.sendTransform(
00094 tf::StampedTransform(worldTomap, ros::Time::now(), "map", "map_static"));
00095
00096 }
00097
00098 }
00099