pathPlannerClient.cpp
Go to the documentation of this file.
00001 #include <ros/ros.h>
00002 #include <actionlib/client/simple_action_client.h>
00003 #include <actionlib/client/terminal_state.h>
00004 #include <youbot_overhead_localization/PlanPathAction.h>
00005 #include <youbot_overhead_localization/SetGoal.h>
00006 
00007 class pathPlannerClient
00008 {
00009 public:
00010   actionlib::SimpleActionClient<youbot_overhead_localization::PlanPathAction> ac;
00011   ros::ServiceServer goalServer;
00012   ros::NodeHandle n;
00013 
00014   pathPlannerClient() :
00015       ac("path_planner", true)
00016   {
00017     ROS_INFO("Waiting for server...");
00018     ac.waitForServer();
00019     ROS_INFO("Done");
00020     ROS_INFO("Advertising service...");
00021     goalServer = n.advertiseService("update_goal", &pathPlannerClient::updateGoal, this);
00022     ROS_INFO("Done");
00023   }
00024 
00025   bool updateGoal(youbot_overhead_localization::SetGoal::Request &req,
00026                   youbot_overhead_localization::SetGoal::Response &res);
00027 };
00028 
00029 bool pathPlannerClient::updateGoal(youbot_overhead_localization::SetGoal::Request &req,
00030                                    youbot_overhead_localization::SetGoal::Response &res)
00031 {
00032   //ac.cancelAllGoals();
00033   youbot_overhead_localization::PlanPathGoal goal;
00034   goal.topic_name = req.topic_name;
00035   goal.x = req.x;
00036   goal.y = req.y;
00037   ac.sendGoal(goal);
00038 
00039   return true;
00040 }
00041 
00042 int main(int argc, char **argv)
00043 {
00044   ros::init(argc, argv, "path_planner_client");
00045 
00046   pathPlannerClient pathClient;
00047 
00048   ros::spin();
00049 }


youbot_overhead_localization
Author(s): David Kent
autogenerated on Thu Jan 2 2014 12:14:20