34 from moveit_msgs.srv
import GetPositionIK, GetPositionIKRequest
39 ROBOT_PROGRAM_DIR =
'/opt/ros/scripts' 43 self.
ns =
'/' + robot_name +
'/' 58 rospy.wait_for_service(self.
ns +
'solve_ik')
60 req = GetPositionIKRequest()
61 req.ik_request.pose_stamped.pose.position.x = position[0]
62 req.ik_request.pose_stamped.pose.position.y = position[1]
63 req.ik_request.pose_stamped.pose.position.z = position[2]
64 req.ik_request.pose_stamped.pose.orientation.x = orientation[0]
65 req.ik_request.pose_stamped.pose.orientation.y = orientation[1]
66 req.ik_request.pose_stamped.pose.orientation.z = orientation[2]
67 req.ik_request.pose_stamped.pose.orientation.w = orientation[3]
70 if result.error_code.val == result.error_code.SUCCESS:
71 return list(result.solution.joint_state.position)
76 rospy.wait_for_service(self.
ns +
'set_posture')
80 rospy.wait_for_service(self.
ns +
'get_posture')
88 print(self._tool.get_offset())
89 self.
_set_tool(1, *self._tool.get_offset())
94 def _set_tool(self, tool_id, offx=0, offy=0, offz=0, offrz=0, offry=0, offrx=0):
95 rospy.wait_for_service(self.
ns +
'set_tool_offset')
97 req = SetToolOffsetRequest()
101 req.rotation.z = offrz
102 req.rotation.y = offry
103 req.rotation.x = offrx
133 tool_id = 1
if self.
_tool else 0
155 tool_id = 1
if self.
_tool else 0
176 if __name__ ==
'__main__':
178 print rb.get_position_ik([0.4, 0.066, 0.663], [0, 0, 0, 1])
180 print rb.get_posture()
182 print rb.get_posture()
def _set_tool(self, tool_id, offx=0, offy=0, offz=0, offrz=0, offry=0, offrx=0)
def set_line_speed(self, speed)
def set_joint_speed(self, speed)
def line_move(self, x, y, z, rz, ry, rx, posture=7)
def get_position_ik(self, position, orientation)
def __init__(self, robot_name=None)
def set_posture(self, posture)
def tool_move(self, x=0, y=0, z=0, rz=0, ry=0, rx=0)