SHARE
TWEET

ur5_command

a guest Sep 20th, 2013 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <ros/ros.h>
  2. #include <actionlib/client/simple_action_client.h>
  3.  
  4. #include <arm_navigation_msgs/MoveArmAction.h>
  5. #include <arm_navigation_msgs/utils.h>
  6.  
  7. int main(int argc, char **argv){
  8.   ros::init (argc, argv, "move_arm_pose_goal_test");
  9.   ros::NodeHandle nh;
  10.   ROS_INFO("Connecting to MoveArmAction server. Waiting...");
  11.   actionlib::SimpleActionClient<arm_navigation_msgs::MoveArmAction> TCP("/move_ur5",true);
  12.  
  13.   TCP.waitForServer();
  14.   ROS_INFO("Connected to server");
  15.   arm_navigation_msgs::MoveArmGoal goalA;
  16.  
  17.   goalA.motion_plan_request.group_name = "ur5";
  18.   goalA.motion_plan_request.num_planning_attempts = 1;
  19.   goalA.motion_plan_request.planner_id = std::string("");
  20.   goalA.planner_service_name = std::string("ompl_planning/plan_kinematic_path");
  21.   goalA.motion_plan_request.allowed_planning_time = ros::Duration(5.0);
  22.  
  23.   arm_navigation_msgs::SimplePoseConstraint desired_pose;
  24.   desired_pose.header.frame_id = "base_link";
  25.   desired_pose.link_name = " ee_link";
  26.   desired_pose.pose.position.x = 0.0;
  27.   desired_pose.pose.position.y = -0.0;
  28.   desired_pose.pose.position.z = 0;
  29.  
  30.   desired_pose.pose.orientation.x = 0.0;
  31.   desired_pose.pose.orientation.y = 0.0;
  32.   desired_pose.pose.orientation.z = 0.0;
  33.   desired_pose.pose.orientation.w = 1.0;
  34.  
  35.   desired_pose.absolute_position_tolerance.x = 0.02;
  36.   desired_pose.absolute_position_tolerance.y = 0.02;
  37.   desired_pose.absolute_position_tolerance.z = 0.02;
  38.  
  39.   desired_pose.absolute_roll_tolerance = 0.04;
  40.   desired_pose.absolute_pitch_tolerance = 0.04;
  41.   desired_pose.absolute_yaw_tolerance = 0.04;
  42.  
  43.   arm_navigation_msgs::addGoalConstraintToMoveArmGoal(desired_pose,goalA);
  44.  
  45.   if (nh.ok())
  46.   {
  47.     bool finished_within_time = false;
  48.     TCP.sendGoal(goalA);
  49.     finished_within_time = TCP.waitForResult(ros::Duration(200.0));
  50.     if (!finished_within_time)
  51.     {
  52.       TCP.cancelGoal();
  53.       ROS_INFO("Timed out achieving goal A");
  54.     }
  55.     else
  56.     {
  57.       actionlib::SimpleClientGoalState state = TCP.getState();
  58.       bool success = (state == actionlib::SimpleClientGoalState::SUCCEEDED);
  59.       if(success)
  60.         ROS_INFO("Action finished: %s",state.toString().c_str());
  61.       else
  62.         ROS_INFO("Action failed: %s",state.toString().c_str());
  63.     }
  64.   }
  65.   ros::shutdown();
  66. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top