42 self.U = [
None for i
in range(0, self.config_settings.njoint) ]
48 def __getitem__(self, link_number):
49 if self.U[link_number] ==
None:
50 self.U[link_number] = [numpy.eye(4)
for j
in range(0, link_number + 1)]
52 for jj
in range(0, link_number + 1):
53 if self.config_settings.free[jj]:
54 if self.config_settings.prismatic[jj]:
55 self.U[link_number][j][0,0] = 0.00
56 self.U[link_number][j][1,1] = 0.00
57 self.U[link_number][j][2,2] = 0.00
59 U[link_number][j][2,3] = 1.00
61 self.U[link_number][j][0,3] = self.H[jj-1][0,2]
62 self.U[link_number][j][1,3] = self.H[jj-1][1,2]
63 self.U[link_number][j][2,3] = self.H[jj-1][2,2]
69 szj_1 = numpy.array( [[0 , -1, 0 ],
73 pj_1 = self.H[jj-1][0:3,3]
74 szj_1 = rotation.skew(self.H[jj-1][0:3,2])
77 RRQJ = vecmatlib.extended_matrix(szj_1, - numpy.dot(szj_1,pj_1) )
78 self.U[link_number][j] = numpy.dot(RRQJ, self.H[link_number])
81 return self.U[link_number]
93 "Definition of the geometric jacobian matrix"
94 self.
value = numpy.zeros((3 , config_settings.DOF))
101 def update_for_position(self, task_point, analytic_jacobian):
103 Create and calculate the geometric jacobian for the given position references (reference_positions)
108 self.
value = numpy.zeros((3, self.config_settings.DOF))
109 gj = [numpy.zeros((3))
for i
in range(0, self.config_settings.DOF)]
110 for j
in range(0, len(task_point.lp)):
112 for kk
in range(0,task_point.lp[j].ln + 1):
113 if self.config_settings.free[kk]:
114 x = numpy.dot(analytic_jacobian[task_point.lp[j].ln][k],vecmatlib.extend_vector(task_point.lp[j].pv))
115 gj[k] = gj[k] + task_point.lp[j].w * x[0:3]
118 for j
in range(0, self.config_settings.DOF):
119 self.
value[i,j] = gj[j][i]
121 def update_for_orientation(self, tskfrm, transfer_matrices):
123 Create and calculate the geometric jacobian for the given orientation references (reference_orientations)
125 self.
value = numpy.zeros((3, self.config_settings.DOF))
131 for ii
in range(0,tskfrm.ln + 1):
133 if self.config_settings.free[ii]:
134 if self.config_settings.prismatic[i]:
138 v = numpy.array([0,0,1])
140 v = vecmatlib.uvect(transfer_matrices[ii-1],2)
142 self.
value[0,i] = v[0]
143 self.
value[1,i] = v[1]
144 self.
value[2,i] = v[2]
152 def __init__(self, config_settings):
153 self.config_settings = config_settings
160 def basis_error_jacobian_for_position(self, tskpnt, ajac):
162 Calculate and return the error jacobian (Jf) according to the basis error function for position represented by: tskpnt.error.basis_error_function
163 In this version only one representation of position error is supported: "differential_cartesian_coordinates"
165 if tskpnt.error.settings.representation ==
'Cartesian Coordinates':
168 for jj in range(0,self.config_settings.DOF):
169 if self.config_settings.free[jj]:
170 e = tskpnt.error.value
171 de = tskpnt.geometric_jacobian.value[:,j]
172 b = self.settings.power*de*(e**(self.settings.power - numpy.ones(4)))
176 J = np.append(J, [b], axis = 0)
180 assert len(tskpnt.error.settings.power) == p
181 Jf = numpy.copy(tskpnt.geometric_jacobian(ajac))
183 for k
in range (0,p):
184 if (tskpnt.error.settings.power[k] != 0)
and (tskpnt.error.settings.power[k] != 1):
185 err = tskpnt.error.power[k]*((tskpnt.r[k] - tskpnt.rd[k])**(tskpnt.error.settings.power[k] - 1))
187 for jj
in range(0,self.config_settings.DOF):
188 if self.config_settings.free[jj]:
189 Jf[k,j] = tskpnt.geometric_jacobian.value[k,j]*err
192 elif tskpnt.error.settings.representation ==
'Cylindrical Coordinates':
194 elif tskpnt.error.settings.representation ==
'Spherical Coordinates':
201 def basis_error_jacobian_for_orientation(self, tskfrm, ajac):
203 Calculate and return the error jacobian (Jf) according to the basis error function for orientation represented by: tskfrm.error.basis_error_function
204 In this version six representations of orientation error are supported:
205 "Axis Inner Product" , "relative_rotation_matrix_trace_minus_three" , "differential_quaternions" , "relative_rotation_angle",
206 "relative_rotation_vector_Cayley_Gibbs_Rodrigues" and "differential_rotation_matrix"
208 rpn = tskfrm.error.settings.representation
209 pwr = tskfrm.error.settings.power
211 tskfrm.ra.set_parametrization( tskfrm.error.settings.parametrization )
212 tskfrm.rd.set_parametrization( tskfrm.error.settings.parametrization )
213 if tskfrm.error.settings.metric_type ==
'relative':
216 for jj
in range(0, tskfrm.ln + 1):
217 if self.config_settings.free[jj]:
218 ra = tskfrm.orientation(ajac.H)
219 ra.set_velocity(ajac[tskfrm.ln][j][0:3,0:3])
222 de = Oe[rpn +
'_velocity']
226 b = pwr*de*(e**(pwr - numpy.ones(p)))
230 J = numpy.append(J, [b], axis = 0)
233 elif tskfrm.error.settings.metric_type ==
'differential':
237 e = tskfrm.ra[rpn] - tskfrm.rd[rpn]
241 for jj
in range(0,tskfrm.ln + 1):
242 if self.config_settings.free[jj]:
243 tskfrm.ra.set_velocity(ajac[tskfrm.ln][j][0:3,0:3])
244 de = tskfrm.ra[rpn +
'_velocity']
247 b = pwr*de*(e**(pwr - numpy.ones(p)))
251 J = numpy.append(J, [b], axis = 0)
254 elif tskfrm.error.settings.metric_type ==
'special':
258 rd = tskfrm.rd[
'matrix']
259 Jf = numpy.zeros((p,self.config_settings.DOF))
260 for k
in range (0,p):
268 err = 2*(numpy.dot(tskfrm.rd.frame_axis(k),tskfrm.ra.frame_axis(k)) - 1)
271 err = tskfrm.error.power[k]*((numpy.dot(tskfrm.rd.frame_axis(k),tskfrm.ra.frame_axis(k)) - 1)**(tskfrm.error.power[k] - 1))
273 for jj
in range(0,tskfrm.ln + 1):
274 if self.config_settings.free[jj]:
275 jz1_k_j = numpy.dot(ajac[tskfrm.ln][j][0:3,k],rd[0:3,k])
276 Jf[k,j] = jz1_k_j*err
279 elif rpn ==
'DiNoQu':
281 Jf = numpy.zeros((p,self.config_settings.DOF))
283 qnd = tskfrm.rd[
'quaternion']
284 for jj
in range(0,tskfrm.ln + 1):
285 if self.config_settings.free[jj]:
286 uqns = quaternions.unit_quaternion_velocity(tskfrm.ra[
'matrix'], ajac[tskfrm.ln][j])
287 for k
in range (0,3):
289 jz_k_j = qnd[k+1]*uqns[0] - qnd[0]*uqns[k+1]
293 qn = tskfrm.ra[
'quaternion']
294 err = pwr[k]*((qnd[0]*qn[k+1] - qn[0]*qnd[k+1])**(pwr[k] - 1))
298 elif rpn ==
'AxInPr + DiNoQu':
300 Jf = numpy.zeros((p,self.config_settings.DOF))
301 for k
in range (0,3):
309 err = 2*(numpy.dot(tskfrm.rd.frame_axis(k),tskfrm.ra.frame_axis(k)) - 1)
312 err = tskfrm.error.power[k]*((numpy.dot(tskfrm.rd.frame_axis(k),tskfrm.ra.frame_axis(k)) - 1)**(tskfrm.error.power[k] - 1))
314 for jj
in range(0,tskfrm.ln + 1):
315 if self.config_settings.free[jj]:
316 jz1_k_j = numpy.dot(analytic.U[tskfrm.ln][j][0:3,k],tskfrm.rd.frame_axis(k))
317 Jf[k,j] = jz1_k_j*err
320 qnd = tskfrm.rd[
'quaternion']
321 for jj
in range(0,tskfrm.ln + 1):
322 if self.config_settings.free[jj]:
323 uqns = quaternions.unit_quaternion_velocity(tskfrm.ra[
'matrix'], analytic.U[tskfrm.ln][j])
324 for k
in range (3,6):
326 jz_k_j = qnd[k-2]*uqns[0] - qnd[0]*uqns[k-2]
330 qn = tskfrm.ra[
'quaternion']
331 err = pwr[k]*((qnd[0]*qn[k-2] - qn[0]*qnd[k-2])**(pwr[k] - 1))
335 elif rpn ==
'ReRoAn + ReOrVe':
341 for jj
in range(0, tskfrm.ln + 1):
342 if self.config_settings.free[jj]:
343 tskfrm.ra.set_velocity(analytic.U[tskfrm.ln][j][0:3,0:3])
344 Oe = tskfrm.ra / tskfrm.rd
347 e[1:4] = Oe[
'vector']
348 de[0] = Oe[
'angle_velocity']
349 de[1:4] = Oe[
'vector_velocity']
350 b = pwr*de*(e**(pwr - numpy.ones(p)))
354 J = numpy.append(J, [b], axis = 0)
363 assert False, gen.err_msg(__name__,
"basis_error_jacobian_for_orientation", tskfrm.error.settings.metric_type +
"is an invalid metric type")
367 def update_for_position(self, tskpnt, ajac):
369 Calculate and Update the error jacobian for position
370 First calculate the basis error jacobian and then multiplied by the weighting matrix
372 bej = self.basis_error_jacobian_for_position(tskpnt, ajac)
373 self.value = numpy.dot(tskpnt.error.settings.weight, bej)
375 def update_for_orientation(self, tskfrm, ajac):
377 Calculate and Update the error jacobian for orientation
378 First calculate the basis error jacobian and then multiplied by the weighting matrix
380 bej = self.basis_error_jacobian_for_orientation(tskfrm, ajac)
381 self.value = numpy.dot(tskfrm.error.settings.weight, bej)
Contains the Error Jacobian of an end-effector established from one or more reference positions (Task...
def __init__
The Class Constructor:
def __init__
The Class Constructor:
This class contains the standard analytic jacobian of a manipulator with required methods for calcula...
Contains the Geometric jacobian of an end-effector that can be established of a number of reference p...