00001
00060 #include <ros/ros.h>
00061 #include <actionlib/client/simple_action_client.h>
00062 #include <move_arm_msgs/MoveArmAction.h>
00063
00064 int main(int argc, char **argv){
00065 ros::init (argc, argv, "move_arm_joint_goal_test");
00066 ros::NodeHandle nh;
00067 actionlib::SimpleActionClient<move_arm_msgs::MoveArmAction> move_arm("move_arm",true);
00068
00069 ROS_INFO("waiting for action server...");
00070 move_arm.waitForServer();
00071 ROS_INFO("Connected to server");
00072
00073 move_arm_msgs::MoveArmGoal goalB;
00074 std::vector<std::string> names(7);
00075 names[0] = "arm_1_joint";
00076 names[1] = "arm_2_joint";
00077 names[2] = "arm_3_joint";
00078 names[3] = "arm_4_joint";
00079 names[4] = "arm_5_joint";
00080 names[5] = "arm_6_joint";
00081 names[6] = "arm_7_joint";
00082
00083 goalB.motion_plan_request.group_name = "arm";
00084 goalB.motion_plan_request.num_planning_attempts = 1;
00085 goalB.motion_plan_request.allowed_planning_time = ros::Duration(5.0);
00086
00087 goalB.motion_plan_request.planner_id= std::string("");
00088 goalB.planner_service_name = std::string("ompl_planning/plan_kinematic_path");
00089 goalB.motion_plan_request.goal_constraints.joint_constraints.resize(names.size());
00090
00091 for (unsigned int i = 0 ; i < goalB.motion_plan_request.goal_constraints.joint_constraints.size(); ++i)
00092 {
00093 goalB.motion_plan_request.goal_constraints.joint_constraints[i].joint_name = names[i];
00094 goalB.motion_plan_request.goal_constraints.joint_constraints[i].position = 0.0;
00095 goalB.motion_plan_request.goal_constraints.joint_constraints[i].tolerance_below = 0.1;
00096 goalB.motion_plan_request.goal_constraints.joint_constraints[i].tolerance_above = 0.1;
00097 }
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 if (nh.ok())
00125 {
00126 bool finished_within_time = false;
00127 move_arm.sendGoal(goalB);
00128 finished_within_time = move_arm.waitForResult(ros::Duration(200.0));
00129 if (!finished_within_time)
00130 {
00131 move_arm.cancelGoal();
00132 ROS_INFO("Timed out achieving goal A");
00133 }
00134 else
00135 {
00136 actionlib::SimpleClientGoalState state = move_arm.getState();
00137 bool success = (state == actionlib::SimpleClientGoalState::SUCCEEDED);
00138 if(success)
00139 ROS_INFO("Action finished: %s",state.toString().c_str());
00140 else
00141 ROS_INFO("Action failed: %s",state.toString().c_str());
00142 }
00143 }
00144 ros::shutdown();
00145 }
00146