2 from math
import cos, sin
10 ERROR_NO_CONVERGE = -2
16 self.
T = numpy.zeros(shape=(6,6))
19 Solves the analytical jacobian given the joint position array q_ar 20 Returns a numerical jacobian matrix 23 if not isinstance(q_ar, numpy.ndarray)
or len(q_ar) != self.
NUM_JOINTS:
24 return SvenzvaKinematics.ERROR_BAD_FORMAT
34 self.
T[0][0] = sin(q1)*(-6.025E-3)-cos(q1)*cos(q2)*7.378496964862803E-19+cos(q1)*sin(q2)*2.662502E-1-cos(q4)*sin(q1)*2.31625E-2+sin(q1)*sin(q3)*2.743843197132029E-17-sin(q1)*sin(q4)*sin(q5)*1.4014E-1-cos(q1)*cos(q2)*cos(q4)*2.836588148525057E-18-cos(q1)*cos(q2)*sin(q3)*2.240518E-1+cos(q1)*cos(q3)*sin(q2)*2.240518E-1+cos(q3)*sin(q1)*sin(q4)*2.836588148525057E-18+cos(q5)*sin(q1)*sin(q3)*1.716220024325101E-17-cos(q1)*cos(q2)*cos(q3)*sin(q4)*2.31625E-2-cos(q1)*cos(q2)*cos(q5)*sin(q3)*1.4014E-1+cos(q1)*cos(q3)*cos(q5)*sin(q2)*1.4014E-1-cos(q1)*cos(q2)*sin(q4)*sin(q5)*1.716220024325101E-17-cos(q3)*cos(q4)*sin(q1)*sin(q5)*1.716220024325101E-17-cos(q1)*sin(q2)*sin(q3)*sin(q4)*2.31625E-2+cos(q1)*cos(q2)*cos(q3)*cos(q4)*sin(q5)*1.4014E-1+cos(q1)*cos(q4)*sin(q2)*sin(q3)*sin(q5)*1.4014E-1;
35 self.
T[0][1] = sin(q1)*(cos(q2)*4.320156490763342E36+sin(q2)*1.197229581605184E19+cos(q2)*cos(q3)*3.635448304028355E36+cos(q4)*sin(q2)*4.60262741641993E19+sin(q2)*sin(q3)*3.635448304028355E36+sin(q2)*sin(q4)*sin(q5)*2.784726200268058E20+cos(q2)*cos(q3)*cos(q5)*2.273901505484596E36-cos(q2)*sin(q3)*sin(q4)*3.758330499556655E35+cos(q3)*sin(q2)*sin(q4)*3.758330499556655E35+cos(q5)*sin(q2)*sin(q3)*2.273901505484596E36+cos(q2)*cos(q4)*sin(q3)*sin(q5)*2.273901505484596E36-cos(q3)*cos(q4)*sin(q2)*sin(q5)*2.273901505484596E36)*6.162975822039155E-38;
36 self.
T[0][2] = cos(q1)*cos(q3)*(-2.743843197132029E-17)-sin(q1)*sin(q2)*sin(q3)*2.240518E-1-cos(q1)*cos(q3)*cos(q5)*1.716220024325101E-17-cos(q2)*cos(q3)*sin(q1)*2.240518E-1+cos(q1)*sin(q3)*sin(q4)*2.836588148525057E-18-cos(q2)*cos(q3)*cos(q5)*sin(q1)*1.4014E-1-cos(q1)*cos(q4)*sin(q3)*sin(q5)*1.716220024325101E-17+cos(q2)*sin(q1)*sin(q3)*sin(q4)*2.31625E-2-cos(q3)*sin(q1)*sin(q2)*sin(q4)*2.31625E-2-cos(q5)*sin(q1)*sin(q2)*sin(q3)*1.4014E-1-cos(q2)*cos(q4)*sin(q1)*sin(q3)*sin(q5)*1.4014E-1+cos(q3)*cos(q4)*sin(q1)*sin(q2)*sin(q5)*1.4014E-1;
37 self.
T[0][3] = cos(q1)*sin(q4)*(-2.31625E-2)-cos(q1)*cos(q3)*cos(q4)*2.836588148525057E-18+cos(q1)*cos(q4)*sin(q5)*1.4014E-1+cos(q2)*sin(q1)*sin(q4)*2.836588148525057E-18-cos(q2)*cos(q3)*cos(q4)*sin(q1)*2.31625E-2-cos(q2)*cos(q4)*sin(q1)*sin(q5)*1.716220024325101E-17-cos(q1)*cos(q3)*sin(q4)*sin(q5)*1.716220024325101E-17-cos(q4)*sin(q1)*sin(q2)*sin(q3)*2.31625E-2-cos(q2)*cos(q3)*sin(q1)*sin(q4)*sin(q5)*1.4014E-1-sin(q1)*sin(q2)*sin(q3)*sin(q4)*sin(q5)*1.4014E-1;
38 self.
T[0][4] = cos(q1)*cos(q5)*sin(q4)*1.4014E-1+cos(q1)*sin(q3)*sin(q5)*1.716220024325101E-17+cos(q1)*cos(q3)*cos(q4)*cos(q5)*1.716220024325101E-17-cos(q2)*cos(q5)*sin(q1)*sin(q4)*1.716220024325101E-17+cos(q2)*sin(q1)*sin(q3)*sin(q5)*1.4014E-1-cos(q3)*sin(q1)*sin(q2)*sin(q5)*1.4014E-1+cos(q2)*cos(q3)*cos(q4)*cos(q5)*sin(q1)*1.4014E-1+cos(q4)*cos(q5)*sin(q1)*sin(q2)*sin(q3)*1.4014E-1;
39 self.
T[1][0] = cos(q1)*6.025E-3+cos(q1)*cos(q4)*2.31625E-2-cos(q2)*sin(q1)*7.378496964862803E-19-cos(q1)*sin(q3)*2.743843197132029E-17+sin(q1)*sin(q2)*2.662502E-1-cos(q2)*cos(q4)*sin(q1)*2.836588148525057E-18-cos(q1)*cos(q3)*sin(q4)*2.836588148525057E-18-cos(q1)*cos(q5)*sin(q3)*1.716220024325101E-17-cos(q2)*sin(q1)*sin(q3)*2.240518E-1+cos(q3)*sin(q1)*sin(q2)*2.240518E-1+cos(q1)*sin(q4)*sin(q5)*1.4014E-1+cos(q1)*cos(q3)*cos(q4)*sin(q5)*1.716220024325101E-17-cos(q2)*cos(q3)*sin(q1)*sin(q4)*2.31625E-2-cos(q2)*cos(q5)*sin(q1)*sin(q3)*1.4014E-1+cos(q3)*cos(q5)*sin(q1)*sin(q2)*1.4014E-1-cos(q2)*sin(q1)*sin(q4)*sin(q5)*1.716220024325101E-17-sin(q1)*sin(q2)*sin(q3)*sin(q4)*2.31625E-2+cos(q2)*cos(q3)*cos(q4)*sin(q1)*sin(q5)*1.4014E-1+cos(q4)*sin(q1)*sin(q2)*sin(q3)*sin(q5)*1.4014E-1;
40 self.
T[1][1] = cos(q1)*(cos(q2)*4.320156490763342E36+sin(q2)*1.197229581605184E19+cos(q2)*cos(q3)*3.635448304028355E36+cos(q4)*sin(q2)*4.60262741641993E19+sin(q2)*sin(q3)*3.635448304028355E36+sin(q2)*sin(q4)*sin(q5)*2.784726200268058E20+cos(q2)*cos(q3)*cos(q5)*2.273901505484596E36-cos(q2)*sin(q3)*sin(q4)*3.758330499556655E35+cos(q3)*sin(q2)*sin(q4)*3.758330499556655E35+cos(q5)*sin(q2)*sin(q3)*2.273901505484596E36+cos(q2)*cos(q4)*sin(q3)*sin(q5)*2.273901505484596E36-cos(q3)*cos(q4)*sin(q2)*sin(q5)*2.273901505484596E36)*(-6.162975822039155E-38);
41 self.
T[1][2] = cos(q3)*sin(q1)*(-2.743843197132029E-17)+sin(q1)*sin(q3)*sin(q4)*2.836588148525057E-18+cos(q1)*cos(q2)*cos(q3)*2.240518E-1-cos(q3)*cos(q5)*sin(q1)*1.716220024325101E-17+cos(q1)*sin(q2)*sin(q3)*2.240518E-1+cos(q1)*cos(q2)*cos(q3)*cos(q5)*1.4014E-1-cos(q1)*cos(q2)*sin(q3)*sin(q4)*2.31625E-2+cos(q1)*cos(q3)*sin(q2)*sin(q4)*2.31625E-2+cos(q1)*cos(q5)*sin(q2)*sin(q3)*1.4014E-1-cos(q4)*sin(q1)*sin(q3)*sin(q5)*1.716220024325101E-17+cos(q1)*cos(q2)*cos(q4)*sin(q3)*sin(q5)*1.4014E-1-cos(q1)*cos(q3)*cos(q4)*sin(q2)*sin(q5)*1.4014E-1;
42 self.
T[1][3] = sin(q1)*sin(q4)*(-2.31625E-2)-cos(q1)*cos(q2)*sin(q4)*2.836588148525057E-18-cos(q3)*cos(q4)*sin(q1)*2.836588148525057E-18+cos(q4)*sin(q1)*sin(q5)*1.4014E-1+cos(q1)*cos(q2)*cos(q3)*cos(q4)*2.31625E-2+cos(q1)*cos(q2)*cos(q4)*sin(q5)*1.716220024325101E-17+cos(q1)*cos(q4)*sin(q2)*sin(q3)*2.31625E-2-cos(q3)*sin(q1)*sin(q4)*sin(q5)*1.716220024325101E-17+cos(q1)*cos(q2)*cos(q3)*sin(q4)*sin(q5)*1.4014E-1+cos(q1)*sin(q2)*sin(q3)*sin(q4)*sin(q5)*1.4014E-1;
43 self.
T[1][4] = sin(q1)*sin(q3)*sin(q5)*1.716220024325101E-17+cos(q5)*sin(q1)*sin(q4)*1.4014E-1+cos(q1)*cos(q2)*cos(q5)*sin(q4)*1.716220024325101E-17+cos(q3)*cos(q4)*cos(q5)*sin(q1)*1.716220024325101E-17-cos(q1)*cos(q2)*sin(q3)*sin(q5)*1.4014E-1+cos(q1)*cos(q3)*sin(q2)*sin(q5)*1.4014E-1-cos(q1)*cos(q2)*cos(q3)*cos(q4)*cos(q5)*1.4014E-1-cos(q1)*cos(q4)*cos(q5)*sin(q2)*sin(q3)*1.4014E-1;
44 self.
T[2][1] = cos(q2)*(-7.378496964862803E-19)+sin(q2)*2.662502E-1-cos(q2)*cos(q4)*2.836588148525057E-18-cos(q2)*sin(q3)*2.240518E-1+cos(q3)*sin(q2)*2.240518E-1-sin(q2)*sin(q3)*sin(q4)*2.31625E-2-cos(q2)*cos(q3)*sin(q4)*2.31625E-2-cos(q2)*cos(q5)*sin(q3)*1.4014E-1+cos(q3)*cos(q5)*sin(q2)*1.4014E-1-cos(q2)*sin(q4)*sin(q5)*1.716220024325101E-17+cos(q2)*cos(q3)*cos(q4)*sin(q5)*1.4014E-1+cos(q4)*sin(q2)*sin(q3)*sin(q5)*1.4014E-1;
45 self.
T[2][2] = cos(q2)*sin(q3)*2.240518E-1-cos(q3)*sin(q2)*2.240518E-1+sin(q2)*sin(q3)*sin(q4)*2.31625E-2+cos(q2)*cos(q3)*sin(q4)*2.31625E-2+cos(q2)*cos(q5)*sin(q3)*1.4014E-1-cos(q3)*cos(q5)*sin(q2)*1.4014E-1-cos(q2)*cos(q3)*cos(q4)*sin(q5)*1.4014E-1-cos(q4)*sin(q2)*sin(q3)*sin(q5)*1.4014E-1;
46 self.
T[2][3] = sin(q2)*sin(q4)*2.836588148525057E-18+cos(q2)*cos(q4)*sin(q3)*2.31625E-2-cos(q3)*cos(q4)*sin(q2)*2.31625E-2-cos(q4)*sin(q2)*sin(q5)*1.716220024325101E-17+cos(q2)*sin(q3)*sin(q4)*sin(q5)*1.4014E-1-cos(q3)*sin(q2)*sin(q4)*sin(q5)*1.4014E-1;
47 self.
T[2][4] = sin(q2)*sin(q3)*sin(q5)*1.4014E-1+cos(q2)*cos(q3)*sin(q5)*1.4014E-1-cos(q5)*sin(q2)*sin(q4)*1.716220024325101E-17-cos(q2)*cos(q4)*cos(q5)*sin(q3)*1.4014E-1+cos(q3)*cos(q4)*cos(q5)*sin(q2)*1.4014E-1;
48 self.
T[3][1] = -cos(q1);
49 self.
T[3][2] = cos(q1)-cos(q2)*sin(q1)*1.224646799147353E-16;
50 self.
T[3][3] = cos(q1)*sin(q3)*1.224646799147353E-16+cos(q2)*sin(q1)*sin(q3)-cos(q3)*sin(q1)*sin(q2);
51 self.
T[3][4] = -cos(q1)*cos(q4)+cos(q2)*cos(q4)*sin(q1)*1.224646799147353E-16+cos(q1)*cos(q3)*sin(q4)*1.224646799147353E-16+cos(q2)*cos(q3)*sin(q1)*sin(q4)+sin(q1)*sin(q2)*sin(q3)*sin(q4);
52 self.
T[3][5] = sin(q5)*(cos(q1)*sin(q4)*4.056481920730334E31+cos(q1)*cos(q3)*cos(q4)*4.967757600021511E15-cos(q2)*sin(q1)*sin(q4)*4.967757600021511E15+cos(q2)*cos(q3)*cos(q4)*sin(q1)*4.056481920730334E31+cos(q4)*sin(q1)*sin(q2)*sin(q3)*4.056481920730334E31)*2.465190328815662E-32-cos(q5)*(cos(q1)*sin(q3)*4.967757600021511E15+cos(q2)*sin(q1)*sin(q3)*4.056481920730334E31-cos(q3)*sin(q1)*sin(q2)*4.056481920730334E31)*2.465190328815662E-32;
53 self.
T[4][1] = -sin(q1);
54 self.
T[4][2] = sin(q1)+cos(q1)*cos(q2)*1.224646799147353E-16;
55 self.
T[4][3] = sin(q1)*sin(q3)*1.224646799147353E-16-cos(q1)*cos(q2)*sin(q3)+cos(q1)*cos(q3)*sin(q2);
56 self.
T[4][4] = -cos(q4)*sin(q1)-cos(q1)*cos(q2)*cos(q4)*1.224646799147353E-16+cos(q3)*sin(q1)*sin(q4)*1.224646799147353E-16-cos(q1)*cos(q2)*cos(q3)*sin(q4)-cos(q1)*sin(q2)*sin(q3)*sin(q4);
57 self.
T[4][5] = sin(q5)*(sin(q1)*sin(q4)*4.056481920730334E31+cos(q1)*cos(q2)*sin(q4)*4.967757600021511E15+cos(q3)*cos(q4)*sin(q1)*4.967757600021511E15-cos(q1)*cos(q2)*cos(q3)*cos(q4)*4.056481920730334E31-cos(q1)*cos(q4)*sin(q2)*sin(q3)*4.056481920730334E31)*2.465190328815662E-32-cos(q5)*(sin(q1)*sin(q3)*4.967757600021511E15-cos(q1)*cos(q2)*sin(q3)*4.056481920730334E31+cos(q1)*cos(q3)*sin(q2)*4.056481920730334E31)*2.465190328815662E-32;
59 self.
T[5][2] = sin(q2)*(-1.224646799147353E-16);
60 self.
T[5][3] = cos(q2-q3);
61 self.
T[5][4] = cos(q4)*sin(q2)*1.224646799147353E-16-cos(q2)*sin(q3)*sin(q4)+cos(q3)*sin(q2)*sin(q4);
62 self.
T[5][5] = sin(q2)*sin(q4)*sin(q5)*(-1.224646799147353E-16)-cos(q2)*cos(q3)*cos(q5)-cos(q5)*sin(q2)*sin(q3)-cos(q2)*cos(q4)*sin(q3)*sin(q5)+cos(q3)*cos(q4)*sin(q2)*sin(q5);
70 q_ar - numpyarray - [q0, ... qN] joint values for N joints 71 ee_vel - numpyarray - desired end effector velocity in Twist format, ie [X,Y,Z,R,P,Y] 79 return SvenzvaKinematics.ERROR_BAD_FORMAT
80 if not isinstance(ee_vel, numpy.ndarray):
81 return SvenzvaKinematics.ERROR_BAD_FORMAT
83 self.
det = numpy.linalg.det(self.
T)
86 R = numpy.linalg.inv(self.
T).dot(ee_vel)
89 return SvenzvaKinematics.ERROR_SINGULAR
91 return SvenzvaKinematics.ERROR_SINGULAR
95 q_ar - numpyarray - [q0, ... , qN] joint values for N joints 96 ee_vel - numpyarray - desired end effector velocity in Twist format 97 time_step - double - time step to determine future joint value 98 returns determinant of jacobian at the future joint position of the arm 103 return SvenzvaKinematics.ERROR_BAD_FORMAT
104 if not isinstance(ee_vel, numpy.ndarray):
105 return SvenzvaKinematics.ERROR_BAD_FORMAT
107 q_dot = numpy.linalg.inv(self.
T).dot(ee_vel)
108 for i, index
in enumerate(q_ar):
109 q_ar[i] += q_dot[i]*time_step
115 return SvenzvaKinematics.ERROR_BAD_FORMAT
116 res = numpy.linalg.det(self.
T)
128 return numpy.linalg.det(self.
T[2:5, 2:5])
132 q = numpy.array([0,0.2,0.2,0.2,0.2,0])
133 twist = numpy.array([0,0,0,1,0,0])
135 print kine.get_joint_vel(q,twist)
136 print kine.get_jacobian_det()
138 print "Took " + str(end - start) +
"s" 140 if __name__==
"__main__":
def get_joint_vel(self, q_ar, ee_vel)
def solve_jacobian(self, q_ar)
def get_next_det(self, q_ar, ee_vel, time_step)
def get_jacobian_det(self)
def get_jacobian_wrist_det(self)