map_loader_node.cpp
Go to the documentation of this file.
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 "stdr_server/map_loader.h"
00023 #include <stdr_msgs/LoadExternalMap.h>
00024 
00025 #define USAGE "USAGE: load_map <map_file.yaml>"
00026 
00033 int main(int argc, char** argv) {
00034 
00035   ros::init(argc, argv, "map_loader", ros::init_options::AnonymousName);
00036 
00037   ros::NodeHandle nh;
00038 
00039   if (argc == 2) {
00040 
00041     nav_msgs::OccupancyGrid map;
00042 
00043     map = stdr_server::map_loader::loadMap(std::string(argv[1]));
00044 
00045     ros::ServiceClient client;
00046 
00047     while (!ros::service::waitForService(
00048       "/stdr_server/load_static_map_external", ros::Duration(.1)) && ros::ok())
00049     {
00050       ROS_WARN(
00051         "Trying to register to /stdr_server/load_static_map_external...");
00052     }
00053     client = nh.serviceClient<stdr_msgs::LoadExternalMap>
00054       ("/stdr_server/load_static_map_external", true);
00055 
00056     stdr_msgs::LoadExternalMap srv;
00057 
00058     srv.request.map = map;
00059 
00060     if (client.call(srv)) {
00061       ROS_INFO("Map successfully loaded");
00062       return 0;
00063     }
00064     else {
00065       ROS_ERROR("Could not load map, maybe already loaded...");
00066       return -1;
00067     }
00068 
00069   }
00070   else {
00071     ROS_ERROR("%s", USAGE);
00072     return -1;
00073   }
00074 
00075 }


stdr_server
Author(s): Chris Zalidis
autogenerated on Tue Feb 7 2017 03:46:33