19 1- The new version supports MAGIKS (The general velocity-based IK engine) for online trajectory tracking
20 In association with version 4.0 of pr2_arm_kinematics
23 import pr2_kinematics
as pr2lib
24 import pyride_interpreter
as pint
25 import PyPR2, math, time, copy, sys, numpy
as np
26 import general_python
as genpy
28 from math_tools
import general_math
as gen
29 from math_tools.geometry import trigonometry
as trig, rotation
as rot, geometry
as geo, trajectory
as trajlib
31 from magiks.vision
import laser_scan_support
as lss
33 r_arm_joint_names =[
'r_shoulder_pan_joint',
'r_shoulder_lift_joint',
'r_upper_arm_roll_joint',
'r_elbow_flex_joint',
'r_forearm_roll_joint',
'r_wrist_flex_joint',
'r_wrist_roll_joint']
34 l_arm_joint_names =[
'l_shoulder_pan_joint',
'l_shoulder_lift_joint',
'l_upper_arm_roll_joint',
'l_elbow_flex_joint',
'l_forearm_roll_joint',
'l_wrist_flex_joint',
'l_wrist_roll_joint']
40 pint.activate_trajectory_input()
41 rt = trajlib.Trajectory_Polynomial()
43 while t - t0 < duration:
44 print "I am adding this point: ", pint.rt_position ,
" at time: ", t-t0
45 rt.add_point(phi = t - t0, pos = np.copy(pint.rt_position))
54 Trying to compute DH parameters of the right arm according to the FK measured from the robot
59 rajd = PyPR2.getArmJointPositions(
False)
61 q[i] = rajd[r_arm_joint_names[i]]
63 q[1] = q[1] + math.pi/2
65 q = trig.angles_standard_range(q)
68 t = PyPR2.getRelativeTF(
'r_shoulder_pan_link' ,
'r_shoulder_lift_link')
73 t = PyPR2.getRelativeTF(
'r_upper_arm_roll_link' ,
'r_elbow_flex_link')
78 t = PyPR2.getRelativeTF(
'r_forearm_roll_link' ,
'r_wrist_flex_link')
87 Trying to compute DH parameters of the left arm according to the FK measured from the robot
92 lajd = PyPR2.getArmJointPositions(
True)
94 q[i] = lajd[l_arm_joint_names[i]]
96 q[1] = q[1] + math.pi/2
97 q = trig.angles_standard_range(q)
99 t = PyPR2.getRelativeTF(
'l_shoulder_pan_link' ,
'l_shoulder_lift_link')
104 t = PyPR2.getRelativeTF(
'r_upper_arm_roll_link' ,
'r_elbow_flex_link')
109 t = PyPR2.getRelativeTF(
'r_forearm_roll_link' ,
'r_wrist_flex_link')
119 p = PyPR2.getRelativeTF(
'base_footprint',
'torso_lift_link')[
'position']
122 There is a 50 mm offset in x direction between footprint (Torso origin) p_BO in the paper and the base_footprint defined for PR2.
123 So I will consider this offset in parameter b0
128 p = PyPR2.getRobotPose()[
'position']
129 assert gen.equal(p[2], 0.0, epsilon = 0.01)
135 o = PyPR2.getRobotPose()['orientation']
136 assert gen.equal(np.linalg.norm(o), 1.0)
137 # h = (o[3],o[0],o[1], o[2])
138 R = rot.rotation_matrix(o)
139 uvect_i = vecmat.as_vector([1.0, 0.0, 0.0])
140 uvect_k = vecmat.as_vector([0.0, 0.0, 1.0])
141 q[3] = vecmat.vectors_angle(R[:, 0], uvect_i, positive_direction = uvect_k) # This is tau (theta[10])
143 q[3] = pint.body_angle(in_degrees =
False)
146 p = PyPR2.getRelativeTF(
'torso_lift_link' ,
'r_shoulder_pan_link')[
'position']
147 assert gen.equal(p[0], 0.0)
148 assert gen.equal(p[2], 0.0)
152 pr = PyPR2.getRelativeTF(
'r_wrist_roll_link' ,
'r_gripper_r_finger_tip_link')[
'position']
153 pl = PyPR2.getRelativeTF(
'r_wrist_roll_link' ,
'r_gripper_l_finger_tip_link')[
'position']
154 p = (vecmat.as_vector(pr) + vecmat.as_vector(pl))/2
155 assert gen.equal(p[1], 0.0)
156 assert gen.equal(p[2], 0.0)
191 self.
max_wait_time = {
'rarm':15.0,
'larm':15.0,
'body':60,
'robot':20,
'trunk':20 }
193 assert gen.equal(q_r[7], q_l[7])
194 assert gen.equal(q_r[8], q_l[8])
195 assert gen.equal(q_r[9], q_l[9])
198 super(PyRide_PR2, self).
__init__(a0 = q_r[7], d2 = q_r[8], d4 = q_r[9], d7 = q_t[5], l0 = q_t[4], b0 = q_t[6], run_magiks = run_magiks)
200 q_d = np.concatenate((q_r[0:7], q_t[0:4], q_l[0:7]))
201 super(PyRide_PR2, self).set_config(q_d)
203 self.set_target(self.end_position(), self.end_orientation())
204 self.rarm.set_target(self.rarm.wrist_position(), self.rarm.wrist_orientation())
205 self.larm.set_target(self.larm.wrist_position(), self.larm.wrist_orientation())
218 Returns True if robot and object body heights are identical
220 p = PyPR2.getRelativeTF(
'base_footprint',
'torso_lift_link')[
'position']
221 return gen.equal(p[2] , self.q[7], epsilon = 0.01)
225 Returns True if robot and object body positions are identical
227 bp = pint.body_position()
228 ba = pint.body_angle(in_degrees =
False)
230 fx = gen.equal(bp[0], self.q[8], epsilon = 0.1)
231 fy = gen.equal(bp[1], self.q[9], epsilon = 0.1)
232 ft = gen.equal(ba , self.q[10], epsilon = 0.02)
234 return(fx
and fy
and ft)
241 return vecmat.equal(trig.angles_standard_range(pint.rarm_joints(in_degrees =
False)), trig.angles_standard_range(self.rarm.config.q), epsilon = 0.01)
248 return vecmat.equal(trig.angles_standard_range(pint.larm_joints(in_degrees =
False)), trig.angles_standard_range(self.larm.config.q), epsilon = 0.01)
259 def synced(self, limb_list = ['body', 'rarm', 'larm', 'trunk']):
261 if 'body' in limb_list:
263 if 'rarm' in limb_list:
265 if 'larm' in limb_list:
278 q_d = np.concatenate((q_r[0:7], q_t[0:4], q_l[0:7]))
280 assert super(PyRide_PR2, self).set_config(q_d)
282 laggp1 = self.larm_end_position(relative =
False)
283 laggp2 = pint.pos_larm_grip()
285 assert vecmat.equal(laggp1, laggp2, epsilon = 0.1)
287 raggp1 = self.rarm_end_position(relative =
False)
288 raggp2 = pint.pos_rarm_grip()
290 assert vecmat.equal(raggp1, raggp2, epsilon = 0.1)
301 def sync_body(self, ttr = 5.0, wait = True, max_wait_time = 60.0):
303 pint.move_robot_to(x = self.q[8], y = self.q[9], tau = self.q[10], time_to_reach = ttr, in_degrees =
False)
305 max_wait_time = gen.ensured_in_range(max_wait_time, 30.0, 300.0)
308 while (t < self.max_wait_time_body)
and (
not self.
body_synced()):
309 pint.move_robot_to(x = self.q[8], y = self.q[9], tau = self.q[10], time_to_reach = ttr, in_degrees =
False)
310 pint.wait_until_finished(limb_list = [
'body'], max_time = 0.2*self.max_wait_time_body)
314 def set_config_synced(self, qd, ttr = 5.0, max_time = 120.0, limb_list = ['body', 'rarm', 'larm']):
316 sets the given configuration to the object and
317 synchronizes the robot with the object.
318 If the given joints are feasible, the robot takes the given configuration.
319 The function will return False if the robot can not reach the desired configuration within max_time
321 if self.set_config(qd):
324 while (t < max_time)
and (
not self.
synced(limb_list)):
325 if (
'body' in limb_list)
and (
not self.
body_synced()):
326 pint.move_robot_to(x = self.q[8], y = self.q[9], tau = self.q[10], time_to_reach = ttr, in_degrees =
False)
328 pint.body_reached =
True
329 if (
'rarm' in limb_list)
and (
not self.
rarm_synced()):
330 pint.take_rarm_to(self.rarm.config.q, time_to_reach = ttr)
332 pint.rarm_reached =
True
333 if (
'larm' in limb_list)
and (
not self.
larm_synced()):
334 pint.take_larm_to(self.larm.config.q, time_to_reach = ttr)
336 pint.larm_reached =
True
338 assert pint.wait_until_finished(limb_list = limb_list)
341 print "Warning from PyRide_PR2.set_config_synced(): Given joints are not feasible. Configuration was not set"
342 return self.
synced(limb_list)
355 pint.take_rarm_to(self.rarm.config.q, time_to_reach = ttr)
357 pint.wait_until_finished(limb_list = [
'rarm'], max_time = self.
max_wait_time[
'rarm'])
371 pint.take_larm_to(self.larm.config.q, time_to_reach = ttr)
373 pint.wait_until_finished(limb_list = [
'larm'], max_time = self.
max_wait_time[
'larm'])
404 pint.wait_until_finished(limb_list = ll, max_time = self.
max_wait_time[
'robot'])
406 return self.
synced(limb_list = ll)
423 func_name =
".rarm_target()"
424 self.rarm.set_target(self.rarm.xd, self.rarm.Rd)
426 if self.rarm.goto_target(optimize =
True):
427 qr = self.rarm.config.q
428 elif self.rarm.goto_target(optimize =
False):
429 qr = self.rarm.config.q
431 assert False, genpy.err_str(__name__, self.__class__.__name__, sys._getframe().f_code.co_name,
"Could not find an IK solution for given target. Make sure the target pose is in the workspace")
433 C = self.rarm.permission_set_position()
435 qr = self.rarm.IK_config(phi)
437 assert False, genpy.err_str(__name__, self.__class__.__name__, sys._getframe().f_code.co_name,
"Given phi is not in the permission set")
440 assert False, genpy.err_str(__name__, self.__class__.__name__, sys._getframe().f_code.co_name,
"No IK solution found for the given redundant parameter phi! Change the value of the redundant parameter and try again")
441 elif self.rarm.config.set_config(qr):
444 print "Error from PyRidePR2.rarm_target(): This should not happen! Check your code."
447 return self.
sync_robot(ttr = ttr, wait = wait)
or (
not wait)
465 Solves the Inverse Kinematics for the left arm with given redundant parameter "phi"
466 and takes the right arm endeffector to the target specified by self.larm.xd and self.larm.Rd
467 if phi = None, then the optimum phi will be selected.
470 self.larm.set_target(self.larm.xd, self.larm.Rd)
472 if self.larm.goto_target(optimize =
True):
473 ql = self.larm.config.q
475 assert False, genpy.err_str(__name__, self.__class__.__name__, sys._getframe().f_code.co_name,
"Could not find an IK solution for given target. Make sure the target pose is in the workspace")
478 C = self.larm.permission_set_position()
480 ql = self.larm.IK_config(phi)
482 assert False, genpy.err_str(__name__, self.__class__.__name__, sys._getframe().f_code.co_name,
"Given phi is not in the permission set")
484 assert False, genpy.err_str(__name__, self.__class__.__name__, sys._getframe().f_code.co_name,
"No IK solution found for the given redundant parameter phi! Change the value of the redundant parameter and try again")
486 if self.larm.config.set_config(ql):
489 print "Error from PyRidePR2.larm_target(): This should not happen! Check your code."
492 return self.
sync_robot(ttr = ttr, wait = wait)
or (
not wait)
498 return self.
larm_target(phi = phi, ttr = ttr, wait = wait)
500 return self.
rarm_target(phi = phi, ttr = ttr, wait = wait)
504 # should change to goto_target() calling the goto_target() function of the super class
505 Solves the IK in the current control mode and takes the robot endeffector to the desired pose specified by self.xd and self.Rd
515 if self.goto_target():
535 def arm_back(self, dx = 0.1, relative = False, wait = True):
538 pos = arm.wrist_position()
539 ori = arm.wrist_orientation()
547 arm.set_target(pos, ori)
548 return self.
arm_target(ttr = ttr, wait = wait)
560 pos = arm.wrist_position()
561 ori = arm.wrist_orientation()
567 arm.set_target(pos, ori)
568 return self.
arm_target(ttr = ttr, wait = wait)
577 def arm_down(self, dx = 0.1, relative = False, wait = True):
580 pos = arm.wrist_position()
581 ori = arm.wrist_orientation()
587 arm.set_target(pos, ori)
588 return self.
arm_target(ttr = ttr, wait = wait)
597 def arm_up(self, dx = 0.1, relative = False, wait = True):
600 pos = arm.wrist_position()
601 ori = arm.wrist_orientation()
607 arm.set_target(pos, ori)
608 return self.
arm_target(ttr = ttr, wait = wait)
617 def arm_right(self, dx = 0.1, relative = False, wait = True):
619 moves the arm to the right as much as dx (m) maintaining the orientation
623 pos = arm.wrist_position()
624 ori = arm.wrist_orientation()
630 arm.set_target(pos, ori)
631 return self.
arm_target(ttr = ttr, wait = wait)
641 def arm_left(self, dx = 0.1, relative = False, wait = True):
644 pos = arm.wrist_position()
645 ori = arm.wrist_orientation()
651 arm.set_target(pos, ori)
652 return self.
arm_target(ttr = ttr, wait = wait)
664 ttr = math.sqrt(dx*dx + dy*dy)/self.
arm_speed
666 pos = arm.wrist_position()
667 ori = arm.wrist_orientation()
674 pos = pos + dx*w - dy*h
675 arm.set_target(pos, ori)
676 return self.
arm_target(ttr = ttr, wait = wait)
687 def arm_left_up(self, dx = 0.1, dy = 0.1, relative = False, wait = True):
688 ttr = math.sqrt(dx*dx + dy*dy)/self.
arm_speed
690 pos = arm.wrist_position()
691 ori = arm.wrist_orientation()
698 pos = pos + dx*w + dy*h
699 arm.set_target(pos, ori)
700 return self.
arm_target(ttr = ttr, wait = wait)
702 def arm_right_up(self, dx = 0.1, dy = 0.1, relative = False, wait = True):
704 moves the arm to the left as much as dx (m) maintaining the orientation
706 ttr = math.sqrt(dx*dx + dy*dy)/self.
arm_speed
708 pos = arm.wrist_position()
709 ori = arm.wrist_orientation()
716 pos = pos - dx*w + dy*h
717 arm.set_target(pos, ori)
718 return self.
arm_target(ttr = ttr, wait = wait)
722 moves the arm to the left as much as dx (m) maintaining the orientation
724 ttr = math.sqrt(dx*dx + dy*dy)/self.
arm_speed
726 pos = arm.wrist_position()
727 ori = arm.wrist_orientation()
734 pos = pos - dx*w - dy*h
735 arm.set_target(pos, ori)
736 return self.
arm_target(ttr = ttr, wait = wait)
755 def arm_arc(self, center = np.array([0.0, -0.05, 0.0]), angle = math.pi, normal = np.array([1.0, 0.0, 0.0]), N = 100, wait =
True):
763 r = np.linalg.norm(center)
767 p0 = arm.wrist_position()
768 ori = arm.wrist_orientation()
770 J = [- vecmat.normalize(center)]
771 J = np.append(J, [vecmat.normalize(normal)])
772 Jdag = vecmat.right_pseudo_inverse(J)
777 g = pint.gen_larm_joint_posvel_dict(arm.config.q, np.zeros(7), 0.0)
779 g = pint.gen_rarm_joint_posvel_dict(arm.config.q, np.zeros(7), 0.0)
784 theta = (i+1)*d_theta
786 b = np.array([math.cos(theta), 0.0])
788 pos = p0 + center + r*normalize(x)
790 q0 = np.copy(arm.config.q)
791 ax = np.append(theta, vecmat.normalize(normal))
792 R = rot.rotation_matrix(ax, parametrization =
'angle_axis')
793 pos = p0 + center - np.dot(R, center)
794 arm.set_target(pos, ori)
795 arm.config.qm = np.copy(arm.config.q)
796 if arm.move_towards_target(max_speed = self.
arm_max_speed, ttr = d_theta):
800 vel = (arm.config.q - q0)/ttr
803 g = pint.gen_larm_joint_posvel_dict(arm.config.q, vel, ttr)
805 g = pint.gen_rarm_joint_posvel_dict(arm.config.q, vel, ttr)
807 print "The arc is not in the workspace!"
810 config_list.append(g)
813 pint.larm_failed =
False
814 pint.larm_reached =
False
815 moving_limbs = [
'larm']
817 pint.rarm_failed =
False
818 pint.rarm_reached =
False
819 moving_limbs = [
'rarm']
821 PyPR2.moveArmWithJointTrajectoryAndSpeed(config_list)
822 arm.config.qm = 0.5*(arm.config.ql+arm.config.qh)
824 pint.wait_until_finished(limb_list = moving_limbs, max_time = 10*N*ttr)
837 def arm_orient(self, direction = 'forward', ttr = 2.0, wait = True):
838 if direction ==
'upward':
839 ori = rot.point_upward_orientation
840 elif direction ==
'downward':
841 ori = rot.point_downward_orientation
842 elif direction ==
'forward':
843 ori = rot.point_forward_orientation
844 elif direction ==
'backward':
845 ori = rot.point_backward_orientation
846 elif direction ==
'right':
847 ori = rot.point_right_orientation
848 elif direction ==
'left':
849 ori = rot.point_left_orientation
851 assert False, genpy.err_str(__name__, self.__class__.__name__, sys._getframe().f_code.co_name, direction +
" is not a valid value for direction")
855 pos = arm.wrist_position()
856 arm.set_target(pos, ori)
857 return self.
arm_target(ttr = ttr, wait = wait)
861 Returns the front line of tilt scan
863 if not pint.tl_active:
864 self.activate_tilt_laser()
866 (a, b, r) = lss.front_line(dist = pint.tl_dist, position_range = self.
tilt_laser_scan_range, angle_min = -0.829031407833, angle_step = 0.00436332309619)
868 return (a, b, np.linalg.norm(r) )
872 Returns the front line of tilt scan
874 if not pint.bl_active:
875 self.activate_base_laser()
877 (a, b, r) = lss.front_line(dist = pint.bl_dist, position_range = self.
base_laser_scan_range, angle_min = -2.26892805099, angle_step = 0.00436332309619)
879 return (a, b, np.linalg.norm(r) )
882 def front_plane(self):
885 dist = copy.copy(pint.dist)
887 (beta, intercept, residuals) = front_line(dist)
890 outliers = rlib.which(residuals , '<' , 0.1 )
891 dist = rlib.pick(dist, - outliers)
892 (beta, intercept, residuals) = front_line(dist)
900 def arm_trajectory(self, pos_traj, ori_traj = None, resolution = 50, relative = True, wait = True):
902 First, projects the given taskspace pose trajectory into the jointspace
903 using both velocity-based and position-based inverse kinematics of the arm and
904 creates a joint trajectory.
905 Then the joint trajectory is given to function run_config_trajectory of pyride_interpreter to run on the robot.
907 L = sum(pos_traj.points_dist())
912 assert resolution > 4, genpy.err_str(__name__, self.__class__.__name__, sys._getframe().f_code.co_name, str(resolution) +
" is an invalid value for resolution. Must be greater than 4")
915 arm.dt = pos_traj.phi_end/resolution
917 jt = arm.js_project(pos_traj, ori_traj, relative = relative)
927 (pt, ot) = arm.project_to_ts(jt)
931 pint.run_config_trajectory(jt, duration = L/self.
arm_speed, dt =
None, phi_dot =
None, is_left_arm = self.
larm_reference)
934 moving_limbs = [
'larm']
936 moving_limbs = [
'rarm']
939 pint.wait_until_finished(limb_list = moving_limbs, max_time = 10*L/self.
arm_speed)
948 PyPR2.registerRawTrajectoryInput( self.
kc_service )
949 assert PyPR2.useJointVelocityControl(
True)
954 PyPR2.registerRawTrajectoryInput(
None )
955 assert PyPR2.useJointVelocityControl(
False)
960 actual_pos = pint.larm_wrist_position()
961 actual_ori = geo.Orientation_3D(pint.larm_wrist_orientation(), representation =
'quaternion')
962 actual_jnt = pint.larm_joints(in_degrees =
False)
965 actual_pos = pint.rarm_wrist_position()
966 actual_ori = geo.Orientation_3D(pint.rarm_wrist_orientation(), representation =
'quaternion')
967 actual_jnt = pint.rarm_joints(in_degrees =
False)
972 desired_pos = np.array(data[
'position'])
973 desired_ori = geo.Orientation_3D(data[
'orientation'], representation =
'quaternion')
974 desired_pos -= np.dot(desired_ori[
'matrix'], pe)
975 arm.set_target(desired_pos, desired_ori[
'matrix'])
978 self.kc_time = data['timestamp']
979 self.t0 = data['timestamp']
982 self.
t0 = time.time()
984 self.
kc_ptd = trajlib.Trajectory_Polynomial()
985 self.
kc_otd = trajlib.Orientation_Trajectory_Polynomial()
986 self.
kc_pta = trajlib.Trajectory_Polynomial()
987 self.
kc_ota = trajlib.Orientation_Trajectory_Polynomial()
988 self.
kc_jtd = trajlib.Trajectory(dimension = 7, capacity = 10)
989 self.
kc_jta = trajlib.Trajectory(dimension = 7, capacity = 10)
991 arm.goto_target(optimize = True)
993 self.kc_jtd.add_point(phi = self.
kc_time, pos = np.copy(arm.config.q), vel = np.zeros(7), acc = np.zeros(7))
996 dt = data['timestamp'] - self.kc_time
997 self.kc_time = data['timestamp']
999 dt = time.time() - self.
t0 - self.
kc_time
1001 if data[
'in_progress']:
1002 q0 = np.copy(arm.config.q)
1003 arm.config.qm = np.copy(arm.config.q)
1006 if arm.moveto_target(optimize =
True):
1007 jdir = arm.config.q - q0
1010 (jpos, vel, acc) = trajlib.feasible_position(Xd = np.copy(arm.config.q), X0 = q0, V0 = self.
prev_qdot, X_min = arm.config.ql, X_max = arm.config.qh, v_max = arm.max_js, a_max = arm.max_ja, dt = dt, smooth =
True)
1011 pint.send_arm_joint_speed(vel, is_left_arm = self.
larm_reference)
1014 self.kc_jtd.add_point(phi = self.
kc_time, pos = jpos, vel = vel, acc = acc)
1016 self.kc_jtd.add_point(phi = self.
kc_time, pos = np.copy(arm.config.q), vel = np.zeros(7), acc = np.zeros(7))
1017 pint.send_arm_joint_speed(np.zeros(7), is_left_arm = self.
larm_reference)
1018 arm.config.qm = 0.5*(arm.config.ql + arm.config.qh)
1021 self.kc_ptd.add_point(phi = self.
kc_time, pos = np.copy(desired_pos))
1022 self.kc_otd.add_point(phi = self.
kc_time, ori = copy.deepcopy(desired_ori))
1023 self.kc_pta.add_point(phi = self.
kc_time, pos = np.copy(actual_pos))
1024 self.kc_ota.add_point(phi = self.
kc_time, ori = copy.deepcopy(actual_ori))
1025 self.kc_jta.add_point(phi = self.
kc_time, pos = np.copy(actual_jnt))
1027 def arm_track(self, k = 1.0, delay = 0.1, max_speed = 1.0, relative = True):
1033 assert arm.magiks_running
1038 pint.activate_trajectory_input()
1039 if pint.rt_orientation ==
None:
1040 H = arm.ik.transfer_matrices()
1041 ra = arm.ik.task_frame[0].orientation(H)
1042 pint.rt_orientation = np.copy(ra[
'matrix'])
1045 H = arm.ik.transfer_matrices()
1046 p0 = arm.ik.task_point[0].position(H) - pint.rt_position
1047 ra = arm.ik.task_frame[0].orientation(H)
1048 R0 = np.dot(ra[
'matrix'], pint.rt_orientation.T)
1053 t = time.time() - ts
1063 p = p0 + pint.rt_position
1065 R = np.dot(R0, pint.rt_orientation)
1067 arm.ik.set_target([p], [geo.Orientation_3D(R, np.zeros((3,3)))])
1069 t = time.time() - ts
1081 err = arm.ik.pose_error()
1082 ern = arm.ik.pose_error_norm()
1083 Je = arm.ik.error_jacobian()
1085 if arm.ik.ik_settings.algorithm ==
"JPI":
1086 Je_dag = np.linalg.pinv(Je)
1092 q_dot = k*arm.ik.ik_direction()
1095 qf = arm.config.q + q_dot*dt
1096 arm.ik.set_config(qf)
1098 if arm.ik.pose_error_norm() < ern:
1099 # error is expected to reduce, send the joint speed
1101 pint.send_arm_joint_speed(q_dot, is_left_arm = self.larm_reference)
1103 # error is going to raise, send the speed with a gain
1104 landa = 0.01/(0.01 + ern)
1106 pint.send_arm_joint_speed(q_dot, is_left_arm = self.
larm_reference)
1108 # pint.send_arm_joint_speed(q_dot*k, is_left_arm = self.larm_reference)
1110 if cnt == 100*(cnt/100):
1113 print "traj pos:", pint.rt_position
1114 print "Actual: ", ik.task_point[0].position(ik.transfer_matrices())
1115 print "Desired: ", ik.task_point[0].rd
1116 print "Pose err:", ik.pose_error_norm()
1117 print "Qd Norm: ", np.linalg.norm(q_dot)
1119 t = time.time() - ts
1121 print "times: ", t, dt
1126 print "EJV: ", ik.q + dt*q_dot
1131 pint.send_arm_joint_speed(np.zeros(7), is_left_arm = self.
larm_reference)
1132 pint.deactivate_trajectory_input()
def deactivate_kc
Deactivates the Kinematic Control Service.
def sync_body
Synchronizes the position and orientation of the real robot body or robot in simulation with the obje...
def synced
Use this function to check if the robot is synchronized with the object.
def arm_left_up
Moves the reference arm wrist to both left and upward directions maintaining the gripper orientation...
def arm_back
Moves the reference arm wrist in backward direction maintaining the gripper orientation.
def arm_up
Moves the reference arm wrist in upward direction maintaining the gripper orientation.
max_wait_time
A dictionary specifying the maximum waiting time when you choose to wait for any motion to finish...
def __init__
Class Constructor.
def sync_robot
Synchronizes the real robot or robot in simulation with the object.
def sync_object
Synchronizes the object with the robot and verifies the equity of forward kinematics for both the rig...
def arm_forward
Moves the reference arm wrist in forward direction maintaining the gripper orientation.
def larm_target
Solves the Inverse Kinematics for the left arm with given redundant parameter and takes the right ar...
def sync_rarm
Synchronizes the right arm of the real robot or robot in simulation with the right arm of the object...
def larm_synced
Use this function to check if the left arm of the object is synced with the left arm of the real robo...
This class introduces a data structure for complete kinematics of a PR2 robot which can sychronize it...
def arm_down
Moves the reference arm wrist in downward direction maintaining the gripper orientation.
def say
Use this function if you want the robot to say something.
def arm_left
Moves the reference arm wrist to the left maintaining the gripper orientation.
def sync_larm
Synchronizes the left arm of the real robot or robot in simulation with the left arm of the object...
def activate_kc
Activates the Kinematic Control Service.
def arm_left_down
Moves the reference arm wrist to the left and downward direction maintaining the gripper orientation...
def rarm_synced
Use this function to check if the right arm of the object is synced with the right arm of the real ro...
def arm_orient
Changes the orientation of the reference arm gripper to a desired direction with out changing the wri...
def arm_trajectory
Runs a given arm task-space pose trajectory on the robot.
def arm_target
Solves the Inverse Kinematics for the reference arm with given redundant parameter The instructions ...
arm_speed
A float specifying the speed of arm gripper in the operational space in m/sec.
def rarm_target
Solves the Inverse Kinematics for the right arm with given redundant parameter and takes the right a...
def arm_right
Moves the reference arm wrist to the right maintaining the gripper orientation.
def arm_arc
Starting from the current wrist position , the arm wrist draws an arc around the given center with th...