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_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 }