Go to the documentation of this file.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 #include <string.h>
00040 #include <pr2_controllers_msgs/JointTrajectoryGoal.h>
00041 #include <pr2_controllers_msgs/JointTrajectoryAction.h>
00042 #include <actionlib/client/simple_action_client.h>
00043
00044 namespace pr2_plugs_common{
00045
00046 static bool gotoJointPosition(double q1, double q2,double q3,double q4,double q5,double q6,double q7, bool right_arm)
00047 {
00048 ROS_INFO("Waiting for joint trajectory action");
00049 std::string arm = "r";
00050 if (!right_arm) arm = "l";
00051
00052 actionlib::SimpleActionClient<pr2_controllers_msgs::JointTrajectoryAction> trajectory_action(arm+"_arm_controller/joint_trajectory_action", true);
00053 trajectory_action.waitForServer();
00054 ROS_INFO("Moving %s arm to detection pose", arm.c_str());
00055
00056 pr2_controllers_msgs::JointTrajectoryGoal trajectory_goal ;
00057 trajectory_goal.trajectory.joint_names.resize(7);
00058 trajectory_goal.trajectory.joint_names[0] = arm+"_upper_arm_roll_joint";
00059 trajectory_goal.trajectory.joint_names[1] = arm+"_shoulder_pan_joint";
00060 trajectory_goal.trajectory.joint_names[2] = arm+"_shoulder_lift_joint";
00061 trajectory_goal.trajectory.joint_names[3] = arm+"_forearm_roll_joint";
00062 trajectory_goal.trajectory.joint_names[4] = arm+"_elbow_flex_joint";
00063 trajectory_goal.trajectory.joint_names[5] = arm+"_wrist_flex_joint";
00064 trajectory_goal.trajectory.joint_names[6] = arm+"_wrist_roll_joint";
00065
00066
00067
00068 trajectory_goal.trajectory.header.stamp = ros::Time::now()+ros::Duration(0.2);
00069 trajectory_goal.trajectory.points.resize(1);
00070 trajectory_goal.trajectory.points[0].positions.resize(7);
00071 trajectory_goal.trajectory.points[0].positions[0] = q1;
00072 trajectory_goal.trajectory.points[0].positions[1] = q2;
00073 trajectory_goal.trajectory.points[0].positions[2] = q3;
00074 trajectory_goal.trajectory.points[0].positions[3] = q4;
00075 trajectory_goal.trajectory.points[0].positions[4] = q5;
00076 trajectory_goal.trajectory.points[0].positions[5] = q6;
00077 trajectory_goal.trajectory.points[0].positions[6] = q7;
00078 trajectory_goal.trajectory.points[0].time_from_start = ros::Duration(4.0);
00079 if (trajectory_action.sendGoalAndWait(trajectory_goal,ros::Duration(20.0), ros::Duration(5.0)) != actionlib::SimpleClientGoalState::SUCCEEDED){
00080 ROS_ERROR("Failed to reach joint space detection position");
00081 return false;
00082 }
00083 return true;
00084 }
00085
00086 }