00001 00059 /* 00060 * plane_extraction_action_client.cpp 00061 * 00062 * Created on: 26.08.2011 00063 * Author: goa 00064 */ 00065 00066 00067 #include <ros/ros.h> 00068 #include <actionlib/client/simple_action_client.h> 00069 #include <actionlib/client/terminal_state.h> 00070 #include <cob_3d_mapping_msgs/PlaneExtractionAction.h> 00071 00072 int main (int argc, char **argv) 00073 { 00074 ros::init(argc, argv, "test_plane_extraction"); 00075 00076 // create the action client 00077 // true causes the client to spin its own thread 00078 actionlib::SimpleActionClient<cob_3d_mapping_msgs::PlaneExtractionAction> ac("plane_extraction", true); 00079 00080 ROS_INFO("Waiting for action server to start."); 00081 // wait for the action server to start 00082 ac.waitForServer(); //will wait for infinite time 00083 00084 ROS_INFO("Action server started, sending goal."); 00085 // send a goal to the action 00086 cob_3d_mapping_msgs::PlaneExtractionGoal goal; 00087 ac.sendGoal(goal); 00088 00089 //wait for the action to return 00090 bool finished_before_timeout = ac.waitForResult(ros::Duration(30.0)); 00091 00092 if (finished_before_timeout) 00093 { 00094 actionlib::SimpleClientGoalState state = ac.getState(); 00095 ROS_INFO("Action finished: %s",state.toString().c_str()); 00096 } 00097 else 00098 ROS_INFO("Action did not finish before the time out."); 00099 00100 //exit 00101 return 0; 00102 } 00103