00001 #include <ros/ros.h> 00002 #include <actionlib/client/simple_action_client.h> 00003 #include <tf/transform_datatypes.h> 00004 #include <nav2d_navigator/ExploreAction.h> 00005 #include <nav2d_navigator/SendCommand.h> 00006 00007 #include <nav2d_navigator/commands.h> 00008 00009 typedef actionlib::SimpleActionClient<nav2d_navigator::ExploreAction> ExploreClient; 00010 00011 ExploreClient* gExploreClient; 00012 00013 bool receiveCommand(nav2d_navigator::SendCommand::Request &req, nav2d_navigator::SendCommand::Response &res) 00014 { 00015 if(req.command == NAV_COM_EXPLORE) 00016 { 00017 nav2d_navigator::ExploreGoal goal; 00018 gExploreClient->sendGoal(goal); 00019 return true; 00020 } 00021 return false; 00022 } 00023 00024 int main(int argc, char **argv) 00025 { 00026 ros::init(argc, argv, "Explore"); 00027 ros::NodeHandle n; 00028 00029 ros::ServiceServer cmdServer = n.advertiseService(NAV_EXPLORE_SERVICE, &receiveCommand); 00030 gExploreClient = new ExploreClient(NAV_EXPLORE_ACTION, true); 00031 gExploreClient->waitForServer(); 00032 00033 ros::spin(); 00034 00035 delete gExploreClient; 00036 return 0; 00037 }