Skip to content

Commit 52c2945

Browse files
committed
Add a jtraj method to Robot class, compute jspace trajectory given two poses
1 parent 6d1d02a commit 52c2945

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

roboticstoolbox/robot/Robot.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,43 @@ def linkcolormap(self, linkcolors="viridis"):
622622
# assume it is a colormap name
623623
return cm.get_cmap(linkcolors, 6)
624624

625+
def jtraj(self, T1, T2, t, **kwargs):
626+
"""
627+
Joint-space trajectory between SE(3) poses
628+
629+
:param T1: initial end-effector pose
630+
:type T1: SE3 instance
631+
:param T2: final end-effector pose
632+
:type T2: SE3 instance
633+
:param t: time vector or number of steps
634+
:type t: ndarray(m) or int
635+
:param kwargs: arguments passed to the IK solver
636+
:return: trajectory
637+
:rtype: Trajectory instance
638+
639+
``traj = obot.jtraj(T1, T2, t)`` is a trajectory object whose
640+
attribute ``traj.q`` is a row-wise joint-space trajectory.
641+
642+
The initial and final poses are mapped to joint space using inverse
643+
kinematics:
644+
645+
- if the object has an analytic solution ``ikine_a`` that will be used,
646+
- otherwise the general numerical algorithm ``ikine_min`` will be used.
647+
648+
649+
"""
650+
651+
if hasattr(self, 'ikine_a'):
652+
ik = self.ikine_a
653+
else:
654+
ik = self.ikine_min
655+
656+
q1 = ik(T1, **kwargs)
657+
q2 = ik(T2, **kwargs)
658+
659+
return rtb.jtraj(q1.q, q2.q, t)
660+
661+
625662
def manipulability(
626663
self, q=None, J=None, method='yoshikawa',
627664
axes='all', **kwargs):

0 commit comments

Comments
 (0)