8000 handle time argument · ctc-eng/robotics-toolbox-python@0b07739 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0b07739

Browse files
committed
handle time argument
1 parent 1c62b3e commit 0b07739

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

roboticstoolbox/tools/trajectory.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -670,14 +670,18 @@ def qplot(x, y=None, arm=False, block=False, labels=None):
670670

671671
# -------------------------------------------------------------------------- #
672672

673-
def ctraj(T0, T1, s):
673+
def ctraj(T0, T1, t=None, s=None):
674674
"""
675675
Cartesian trajectory between two poses
676676
677677
:param T0: initial pose
678678
:type T0: SE3
679679
:param T1: final pose
680680
:type T1: SE3
681+
:param t: number of samples or time vector
682+
:type t: int or ndarray(n)
683+
:param s: array of distance along the path, in the interval [0, 1]
684+
:type s: ndarray(s)
681685
:return T0: smooth path from ``T0`` to ``T1``
682686
:rtype: SE3
683687
@@ -686,7 +690,10 @@ def ctraj(T0, T1, s):
686690
the path. The Cartesian trajectory is an SE3 instance containing ``n``
687691
values.
688692
689-
``ctraj(T0, T1, s)`` as above but the elements of ``s`` specify the
693+
``ctraj(T0, T1, t)`` as above but the trajectory is sampled at
694+
the points in the array ``t``.
695+
696+
``ctraj(T0, T1, s=s)`` as above but the elements of ``s`` specify the
690697
fractional distance along the path, and these values are in the
691698
range [0 1]. The i'th point corresponds to a distance ``s[i]`` along
692699
the path.
@@ -713,8 +720,11 @@ def ctraj(T0, T1, s):
713720
:func:`~spatialmath.unitquaternion.interp`
714721
"""
715722

716-
if isinstance(s, int):
717-
s = lspb(0, 1, s).s
723+
if isinstance(t, int):
724+
s = lspb(0, 1, t).s
725+
elif isvector(t):
726+
t = getvector(t)
727+
s = lspb(0, 1, t / np.max(t)).s
718728
elif isvector(s):
719729
s = getvector(s)
720730
else:

0 commit comments

Comments
 (0)
0