Skip to content

Commit 035d6f3

Browse files
committed
Merge pull request #148 from personalrobotics/bugfix/traj_length_check
Changed GetDuration=0.0 error to warning.
2 parents e0a2067 + c616fa1 commit 035d6f3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/prpy/base/robot.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,18 @@ def ExecuteTrajectory(self, traj, defer=False, timeout=None, period=0.01, **kwar
457457
else:
458458
return traj
459459

460-
# Verify that the trajectory is timed.
460+
# Verify that the trajectory is timed by checking whether the first
461+
# waypoint has a valid deltatime value.
462+
cspec = traj.GetConfigurationSpecification()
463+
if cspec.ExtractDeltaTime(traj.GetWaypoint(0)) is None:
464+
raise ValueError('Trajectory cannot be executed, it is not timed.')
465+
466+
# Verify that the trajectory has non-zero duration.
461467
if traj.GetDuration() <= 0.0:
462-
raise ValueError('Attempted to execute untimed trajectory.')
468+
import warnings
469+
warnings.warn('Executing zero-length trajectory. Please update the'
470+
' function that produced this trajectory to return a'
471+
' single-waypoint trajectory.', FutureWarning)
463472

464473
# TODO: Check if this trajectory contains the base.
465474
needs_base = util.HasAffineDOFs(traj.GetConfigurationSpecification())

0 commit comments

Comments
 (0)