Skip to content

Commit ca0c5ed

Browse files
committed
Added differential kinematics
1 parent 3f163ef commit ca0c5ed

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed

rtb/robot/ets.py

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,133 @@ def fkine(self, q):
185185

186186
return trans
187187

188+
def jacob0(self, q):
189+
"""
190+
The manipulator Jacobian matrix maps joint velocity to end-effector
191+
spatial velocity, expressed in the world-coordinate frame.
192+
193+
:param q: The joint coordinates of the robot
194+
:type q: float np.ndarray(n,)
195+
:return: The manipulator Jacobian in 0 frame
196+
:rtype: float np.ndarray(6,n)
197+
198+
References: Kinematic Derivatives using the Elementary Transform
199+
Sequence, J. Haviland and P. Corke
200+
"""
201+
T = self.fkine(q)
202+
U = np.eye(4)
203+
j = 0
204+
J = np.zeros((6, self.n))
205+
206+
for i in range(self.M):
207+
208+
if i != self.q_idx[j]:
209+
U = U @ self.ets[i].T()
210+
else:
211+
if self.ets[i].axis_func == et.TRz:
212+
U = U @ self.ets[i].T(q[j])
213+
Tu = np.linalg.inv(U) @ T
214+
215+
n = U[:3, 0]
216+
o = U[:3, 1]
217+
a = U[:3, 2]
218+
y = Tu[1, 3]
219+
x = Tu[0, 3]
220+
221+
J[:3, j] = (o * x) - (n * y)
222+
J[3:, j] = a
223+
224+
j += 1
225+
226+
return J
227+
228+
def hessian0(self, q, J=None):
229+
"""
230+
The manipulator Hessian tensor maps joint acceleration to end-effector
231+
spatial acceleration, expressed in the world-coordinate frame. This
232+
function calulcates this based on the ETS of the robot.
233+
234+
:param q: The joint coordinates of the robot
235+
:type q: float np.ndarray(n,)
236+
:return: The manipulator Hessian in 0 frame
237+
:rtype: float np.ndarray(6,n,n)
238+
239+
References: Kinematic Derivatives using the Elementary Transform
240+
Sequence, J. Haviland and P. Corke
241+
"""
242+
if J is None:
243+
J = self.jacob0(q)
244+
245+
H = np.zeros((6, self.n, self.n))
246+
247+
for j in range(self.n):
248+
for i in range(j, self.n):
249+
250+
H[:3, i, j] = np.cross(J[3:, j], J[:3, i])
251+
H[3:, i, j] = np.cross(J[3:, i], J[3:, i])
252+
253+
if i != j:
254+
H[:3, j, i] = H[:3, i, j]
255+
256+
return H
257+
258+
def m(self, q, J=None):
259+
"""
260+
Calculates the manipulability index (scalar) robot at the joint
261+
configuration q. It indicates dexterity, that is, how isotropic the
262+
robot's motion is with respect to the 6 degrees of Cartesian motion.
263+
The measure is high when the manipulator is capable of equal motion
264+
in all directions and low when the manipulator is close to a
265+
singularity.
266+
267+
:param q: The joint coordinates of the robot
268+
:type q: float np.ndarray(n,)
269+
:return: The manipulability index
270+
:rtype: float
271+
272+
References: Analysis and control of robot manipulators with redundancy,
273+
T. Yoshikawa,
274+
Robotics Research: The First International Symposium (M. Brady and
275+
R. Paul, eds.), pp. 735-747, The MIT press, 1984.
276+
"""
277+
278+
if J is None:
279+
J = self.jacob0(q)
280+
281+
return np.sqrt(np.linalg.det(J @ np.transpose(J)))
282+
283+
def Jm(self, q, J=None, H=None, m=None):
284+
"""
285+
Calculates the manipulability Jacobian. This measure relates the rate
286+
of change of the manipulability to the joint velocities of the robot.
287+
288+
:param q: The joint coordinates of the robot
289+
:type q: float np.ndarray(n,)
290+
:return: The manipulability Jacobian
291+
:rtype: float np.ndarray(n,1)
292+
293+
References: Maximising Manipulability in Resolved-Rate Motion Control,
294+
J. Haviland and P. Corke
295+
"""
296+
297+
if m is None:
298+
m = self.m(q)
299+
300+
if J is None:
301+
J = self.jacob0(q)
302+
303+
if H is None:
304+
H = self.hessian0(q)
305+
306+
b = np.linalg.inv(J @ np.transpose(J))
307+
Jm = np.zeros((self.n, 1))
308+
309+
for i in range(self.n):
310+
c = J @ np.transpose(H[:, :, i])
311+
Jm[i, 0] = m * np.transpose(c.flatten('F')) @ b.flatten('F')
312+
313+
return a
314+
188315
def __str__(self):
189316
"""
190317
Pretty prints the ETS Model of the robot. Will output angles in degrees

0 commit comments

Comments
 (0)