Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/roboticstoolbox/tools/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ def __init__(self, q0: float, qf: float, T: float, V: float | None = None) -> No
self._a = 0.0
else:
self.tb = (q0 - qf + vel * T) / vel
self._a = vel / self.tb
self._a = 0.0 if self.tb == 0 else vel / self.tb

self.V = vel
self._q0 = q0
Expand Down Expand Up @@ -753,6 +753,10 @@ def __call__(self, t: Any) -> Any:
for k, tk in enumerate(times.flat):
if tk < 0:
pk, pdk, pddk = q0, 0.0, 0.0
elif tb == 0 and tk <= T:
pk = q0 + V * tk
pdk = V
pddk = 0.0
elif tk <= tb:
# initial blend
pk = q0 + a / 2 * tk**2
Expand Down
10 changes: 10 additions & 0 deletions tests/test_trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ def test_trapezoidal_time_origin(self) -> None:
getattr(actual, field), getattr(expected, field), atol=1e-12
)

def test_trapezoidal_zero_blend_velocity_boundary(self) -> None:
for q0, qf in ((0.0, 1.0), (1.0, 0.0)):
with self.subTest(q0=q0, qf=qf):
trajectory = tr.trapezoidal(q0, qf, np.array([0.0, 0.5, 1.0]), V=1.0)

self.assertEqual(trajectory.tblend, 0.0)
nt.assert_allclose(trajectory.q, [q0, 0.5, qf])
nt.assert_allclose(trajectory.qd, np.full(3, qf - q0))
nt.assert_allclose(trajectory.qdd, np.zeros(3))

def test_mtraj_time_origin(self) -> None:
elapsed = np.linspace(0, 2, 9)
for generator in (tr.quintic, tr.trapezoidal):
Expand Down
Loading