Go to the documentation of this file.00001
00002 #include "bwi_kr_execution/ExecutePlanAction.h"
00003
00004 #include <actionlib/client/simple_action_client.h>
00005 #include <bwi_msgs/LogicalNavigationAction.h>
00006
00007 #include <std_srvs/Empty.h>
00008 #include <ros/ros.h>
00009
00010 typedef actionlib::SimpleActionClient<bwi_kr_execution::ExecutePlanAction> Client;
00011
00012 using namespace std;
00013
00014
00015
00016 int main(int argc, char**argv) {
00017 ros::init(argc, argv, "look_for_person");
00018 ros::NodeHandle n;
00019
00020 ros::NodeHandle privateNode("~");
00021 string person;
00022 privateNode.param<string>("person",person,"peter");
00023
00024 Client client("action_executor/execute_plan", true);
00025 client.waitForServer();
00026
00027
00028 ROS_INFO_STREAM("Looking for " << person);
00029
00030 bwi_kr_execution::ExecutePlanGoal goal;
00031
00032 bwi_kr_execution::AspRule rule;
00033 bwi_kr_execution::AspFluent fluent;
00034 fluent.name = "not ingdc";
00035 fluent.variables.push_back(person);
00036
00037 rule.body.push_back(fluent);
00038
00039
00040 bwi_kr_execution::AspFluent fluent_not;
00041 fluent_not.name = "not -ingdc";
00042 fluent_not.variables.push_back(person);
00043 rule.body.push_back(fluent_not);
00044
00045 bwi_kr_execution::AspRule flag_rule;
00046 bwi_kr_execution::AspFluent find_person_flag;
00047 find_person_flag.name = "findPersonTask";
00048 flag_rule.head.push_back(find_person_flag);
00049
00050
00051 goal.aspGoal.push_back(rule);
00052 goal.aspGoal.push_back(flag_rule);
00053
00054
00055 ROS_INFO("sending goal");
00056 client.sendGoalAndWait(goal);
00057
00058 if (client.getState() == actionlib::SimpleClientGoalState::ABORTED) {
00059 ROS_INFO("Aborted");
00060 } else if (client.getState() == actionlib::SimpleClientGoalState::PREEMPTED) {
00061 ROS_INFO("Preempted");
00062 }
00063
00064 else if (client.getState() == actionlib::SimpleClientGoalState::SUCCEEDED) {
00065 ROS_INFO("Succeeded!");
00066 } else
00067 ROS_INFO("Terminated");
00068
00069 client.cancelAllGoals();
00070
00071 return 0;
00072 }