00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include "pr2_doors_actions/action_detect_door.h"
00041 #include <pr2_doors_common/door_functions.h>
00042 #include <actionlib/client/simple_action_client.h>
00043 #include <door_msgs/DoorAction.h>
00044 #include <ros/ros.h>
00045
00046 using namespace ros;
00047 using namespace std;
00048 using namespace door_handle_detector;
00049 using namespace pr2_doors_common;
00050
00051
00052
00053
00054
00055 int
00056 main (int argc, char **argv)
00057 {
00058 ros::init(argc, argv, "trigger_door_action");
00059
00060 if (argc < 2){
00061 ROS_ERROR("Name of action to trigger required");
00062 return 0;
00063 }
00064
00065
00066 door_msgs::DoorGoal door_goal;
00067 door_goal.door.frame_p1.x = 1.0;
00068 door_goal.door.frame_p1.y = -0.5;
00069 door_goal.door.frame_p2.x = 1.0;
00070 door_goal.door.frame_p2.y = 0.5;
00071 door_goal.door.rot_dir = door_msgs::Door::ROT_DIR_COUNTERCLOCKWISE;
00072 door_goal.door.hinge = door_msgs::Door::HINGE_P2;
00073 door_goal.door.header.frame_id = "base_footprint";
00074
00075
00076 actionlib::SimpleActionClient<door_msgs::DoorAction> action_client(argv[1], true);
00077 cout << "waiting for action server to start..." << endl;
00078 boost::thread(boost::bind(&ros::spin));
00079 action_client.waitForServer();
00080 cout << "... started" << endl;
00081
00082
00083 action_client.sendGoalAndWait(door_goal);
00084 bool finished_before_timeout = action_client.waitForResult(ros::Duration(30.0));
00085
00086 if (finished_before_timeout){
00087 actionlib::SimpleClientGoalState state = action_client.getState();
00088 cout << "Door detection finished with state " << state.toString() << endl;
00089 cout << " resulting door: " << action_client.getResult()->door << endl;
00090 }
00091 else{
00092 cout << "Door detection timed out" << endl;
00093 }
00094
00095 return (0);
00096 }