LocalizerNode.cpp
Go to the documentation of this file.
00001 #include "ros/ros.h"
00002 #include "tf/transform_broadcaster.h"
00003 #include "nav_msgs/GetMap.h"
00004 
00005 #include "SelfLocalizer.h"
00006 
00007 int main(int argc, char **argv)
00008 {
00009         ros::init(argc, argv, "localize_node");
00010         ros::NodeHandle n;
00011 
00012         SelfLocalizer selfLocalizer(true);
00013 
00014         tf::TransformBroadcaster tfBC;
00015         
00016         // Subscribe to laser scans
00017         std::string laserTopic;
00018         n.param("laser_topic", laserTopic, std::string("scan"));
00019         ros::Subscriber laserSubscriber = n.subscribe(laserTopic, 100, &SelfLocalizer::process, &selfLocalizer);
00020 
00021         // Get the map via service call
00022         std::string mapService;
00023         n.param("map_service", mapService, std::string("get_map"));
00024         ros::ServiceClient mapClient = n.serviceClient<nav_msgs::GetMap>(mapService);
00025         
00026         nav_msgs::GetMap srv;
00027         mapClient.waitForExistence();
00028         if(mapClient.call(srv))
00029         {
00030                 selfLocalizer.convertMap(srv.response.map);
00031                 selfLocalizer.initialize();
00032         }else
00033         {
00034                 ROS_FATAL("Could not get a map.");
00035                 return 1;
00036         }
00037 
00038         ros::Rate loopRate(10);
00039         while(ros::ok())
00040         {
00041                 tfBC.sendTransform(selfLocalizer.getMapToOdometry());
00042                 
00043                 ros::spinOnce();
00044                 loopRate.sleep();
00045         }
00046 
00047         ros::spin();
00048         return 0;
00049 }


nav2d_localizer
Author(s): Sebastian Kasperski
autogenerated on Mon Oct 6 2014 02:44:14