move_arm_joint_goal.cpp
Go to the documentation of this file.
00001 #include <ros/ros.h>
00002 #include <actionlib/client/simple_action_client.h>
00003 #include <arm_navigation_msgs/MoveArmAction.h>
00004 
00005 static const size_t NUM_JOINTS = 5;
00006 
00007 bool move_to_joint_goal(std::vector<arm_navigation_msgs::JointConstraint> joint_constraints,
00008                         actionlib::SimpleActionClient<arm_navigation_msgs::MoveArmAction> &move_arm) {
00009 
00010   arm_navigation_msgs::MoveArmGoal goal;
00011 
00012   goal.motion_plan_request.group_name = "arm";
00013   goal.motion_plan_request.num_planning_attempts = 1;
00014   goal.motion_plan_request.allowed_planning_time = ros::Duration(5.0);
00015 
00016   goal.motion_plan_request.planner_id = std::string("");
00017   goal.planner_service_name = std::string("ompl_planning/plan_kinematic_path");
00018 
00019   goal.motion_plan_request.goal_constraints.joint_constraints = joint_constraints;
00020 
00021 
00022   bool finished_within_time = false;
00023   move_arm.sendGoal(goal);
00024   finished_within_time = move_arm.waitForResult(ros::Duration(40.0));
00025   if (!finished_within_time)
00026   {
00027     move_arm.cancelGoal();
00028     ROS_INFO("Timed out achieving goal!");
00029     return false;
00030   }
00031   else
00032   {
00033     actionlib::SimpleClientGoalState state = move_arm.getState();
00034     bool success = (state == actionlib::SimpleClientGoalState::SUCCEEDED);
00035     if (success)
00036       ROS_INFO("Action finished: %s",state.toString().c_str());
00037     else
00038       ROS_INFO("Action failed: %s",state.toString().c_str());
00039 
00040     return success;
00041   }
00042 }
00043 
00044 int main(int argc, char **argv)
00045 {
00046   ros::init(argc, argv, "move_arm_joint_goal_test");
00047   ros::NodeHandle nh;
00048   actionlib::SimpleActionClient<arm_navigation_msgs::MoveArmAction> move_arm("move_arm", true);
00049 
00050   move_arm.waitForServer();
00051   ROS_INFO("Connected to server");
00052 
00053   std::vector<std::string> names(NUM_JOINTS);
00054   names[0] = "katana_motor1_pan_joint";
00055   names[1] = "katana_motor2_lift_joint";
00056   names[2] = "katana_motor3_lift_joint";
00057   names[3] = "katana_motor4_lift_joint";
00058   names[4] = "katana_motor5_wrist_roll_joint";
00059 
00060 
00061   std::vector<arm_navigation_msgs::JointConstraint> joint_constraints(NUM_JOINTS);
00062 
00063   for (size_t i = 0; i < NUM_JOINTS; ++i)
00064   {
00065     joint_constraints[i].joint_name = names[i];
00066     joint_constraints[i].tolerance_below = 0.1;
00067     joint_constraints[i].tolerance_above = 0.1;
00068   }
00069 
00070   while (nh.ok())
00071   {
00072     bool success;
00073 
00074     //  == rechts ==
00075    /*
00076     joint_constraints[0].position = 1.19;
00077     joint_constraints[1].position = -0.13;  // was +0,13 before
00078     joint_constraints[2].position = -0.72;
00079     joint_constraints[3].position = -1.13;
00080     joint_constraints[4].position = -2.99;
00081 */
00082     /* TESTING THE CURRENT OR APPROVED POSES...
00083    [ INFO] [1307438122.669191590]: Joint: katana_motor1_pan_joint - -0.909271
00084        [ INFO] [1307438122.669238954]: Joint: katana_motor2_lift_joint - 1.914671
00085        [ INFO] [1307438122.669285121]: Joint: katana_motor3_lift_joint - -1.654437
00086        [ INFO] [1307438122.669333631]: Joint: katana_motor4_lift_joint - 0.929276
00087        [ INFO] [1307438122.669379434]: Joint: katana_motor5_wrist_roll_joint - 0.2730320
00088     */
00089 
00090     /*found solution for:
00091 -0.0241599827402
00092 0.0239433605898
00093 0.335861197319
00094 [ 0.34543854  0.13239524  0.66322618  0.65059569]
00095 
00096 positions: [-0.40978611455738623, -0.13490386708724486, 1.4753526804010932, -0.98823837545675264, -0.10254760699201027]
00097       */
00098 /*
00099         joint_constraints[0].position = -0.40978611455738623;
00100         joint_constraints[1].position =  -0.13490386708724486;  // was +0,13 before
00101         joint_constraints[2].position = 1.4753526804010932;
00102         joint_constraints[3].position = -0.98823837545675264;
00103         joint_constraints[4].position = -0.10254760699201027;
00104 */
00105             joint_constraints[0].position =  1.25364666;
00106             joint_constraints[1].position =  0.2922541;
00107             joint_constraints[2].position = -1.70401937;
00108             joint_constraints[3].position = -1.46318108;
00109             joint_constraints[4].position = -2.58356851;
00110 
00111 
00112     // rechts ganz nah an der kurtana stange
00113      /* joint_constraints[0].position = -2.556376;
00114       joint_constraints[1].position = -0.089316;
00115       joint_constraints[2].position =  0.046139;
00116       joint_constraints[3].position = -1.183483;
00117       joint_constraints[4].position = -2.931880;
00118 */
00119 
00120     ROS_INFO("Moving to goal 1");
00121     success = move_to_joint_goal(joint_constraints, move_arm);
00122     if (!success)
00123       break;
00124    /* TESTING THE CURRENT OR APPROVED POSES...
00125     [ INFO] [1307438247.950864334]: Joint: katana_motor1_pan_joint - -1.845185
00126            [ INFO] [1307438247.950905301]: Joint: katana_motor2_lift_joint - 1.539664
00127            [ INFO] [1307438247.950945234]: Joint: katana_motor3_lift_joint - 1.035806
00128            [ INFO] [1307438247.950985473]: Joint: katana_motor4_lift_joint - -0.495157
00129            [ INFO] [1307438247.951025535]: Joint: katana_motor5_wrist_roll_joint - -0.475120
00130         */
00131   /*
00132   found solution for:
00133 -0.0205625525158
00134 0.0221457064301
00135 0.416114543677
00136 [ 0.3694844   0.17774219  0.21261588  0.88695179]
00137 
00138  positions: [-0.88714380113614588, 0.41045517288472277, 0.82241279861662009, -1.1828659264763777, 0.016213812909793332]
00139 
00140 */
00141 /*
00142             joint_constraints[0].position = -0.88714380113614588;
00143             joint_constraints[1].position = 0.41045517288472277;  // was +0,13 before
00144             joint_constraints[2].position = 0.82241279861662009;
00145             joint_constraints[3].position = -1.1828659264763777;
00146             joint_constraints[4].position = 0.016213812909793332;
00147 */
00148            // links ganz nah an der kurtana stange
00149                  joint_constraints[0].position =  2.332237;
00150                  joint_constraints[1].position =  0.186090;
00151                  joint_constraints[2].position =  0.046139;
00152                  joint_constraints[3].position = -1.183483;
00153                  joint_constraints[4].position = -2.931880;
00154 
00155 
00156     //  == links ==
00157   /*
00158 
00159     joint_constraints[0].position = 2.01;
00160     joint_constraints[1].position = 0.05;  // was +0,14 before
00161     joint_constraints[2].position = -0.77;
00162     joint_constraints[3].position = -0.71;
00163     joint_constraints[4].position = -2.93;
00164 */
00165     ROS_INFO("Moving to goal 2");
00166     //success = move_to_joint_goal(joint_constraints, move_arm);
00167     if (!success)
00168       break;
00169   }
00170 
00171   ros::shutdown();
00172 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


katana_openrave_test
Author(s): Henning Deeken
autogenerated on Tue Mar 5 2013 15:25:42