Guest User

Untitled

a guest
May 23rd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. bool akit_pick_place::rotateGripper(moveit_msgs::CollisionObject object_){ //needs adjusting (rotation in y-axis has problems)
  2.  
  3. geometry_msgs::PoseStamped object_in_world_frame, object_in_gripper_frame;
  4. object_in_world_frame.pose = object_.primitive_poses[0];
  5. object_in_world_frame.header.frame_id = object_.header.frame_id;
  6.  
  7. //transform object from world frame to gripper rotator frame
  8. transform_listener.waitForTransform("gripper_rotator", WORLD_FRAME, ros::Time::now(), ros::Duration(0.1)); //avoid time difference exceptions
  9. transform_listener.transformPose("gripper_rotator",ros::Time(0), object_in_world_frame, WORLD_FRAME, object_in_gripper_frame);
  10.  
  11. //get roll, pitch, yaw between object frame and gripper frame
  12. tf::Quaternion qq(object_in_gripper_frame.pose.orientation.x, object_in_gripper_frame.pose.orientation.y,
  13. object_in_gripper_frame.pose.orientation.z, object_in_gripper_frame.pose.orientation.w);
  14. tf::Matrix3x3 m(qq);
  15. double roll, pitch, yaw;
  16. m.getRPY(roll, pitch, yaw);
  17. ROS_INFO_STREAM("roll: " << roll << " pitch: " << pitch << "yaw: " << yaw);
  18. //account for angles in different quadrants
  19. if (yaw <= 0.0){
  20. gripperJointPositions[0] = (M_PI/2) + yaw;
  21. } else {
  22. gripperJointPositions[0] = yaw - (M_PI/2);
  23. }
  24.  
  25. gripperGroup->setJointValueTarget(gripperJointPositions);
  26.  
  27. gripperSuccess = (gripperGroup->plan(gripperMotionPlan) == moveit::planning_interface::MoveItErrorCode::SUCCESS);
  28. gripperSuccess = (gripperGroup->execute(gripperMotionPlan) == moveit::planning_interface::MoveItErrorCode::SUCCESS);
  29. ROS_INFO_STREAM("Gripper Motion Plan: " << (gripperSuccess ? "Rotated gripper" : "FAILED TO ROTATE GRIPPER"));
  30. return (gripperSuccess ? true : false);
  31. }
Add Comment
Please, Sign In to add comment