Skip to content

Commit 0a327fc

Browse files
committed
Refactored trajectory timing check into utility function.
1 parent 035d6f3 commit 0a327fc

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/prpy/base/robot.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,7 @@ def ExecuteTrajectory(self, traj, defer=False, timeout=None, period=0.01, **kwar
459459

460460
# Verify that the trajectory is timed by checking whether the first
461461
# waypoint has a valid deltatime value.
462-
cspec = traj.GetConfigurationSpecification()
463-
if cspec.ExtractDeltaTime(traj.GetWaypoint(0)) is None:
462+
if not util.IsTimedTrajectory(traj):
464463
raise ValueError('Trajectory cannot be executed, it is not timed.')
465464

466465
# Verify that the trajectory has non-zero duration.

src/prpy/util.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,3 +735,17 @@ def IsAtTrajectoryStart(robot, trajectory):
735735

736736
# If all joints match, return True.
737737
return True
738+
739+
740+
def IsTimedTrajectory(trajectory):
741+
"""
742+
Returns True if the trajectory is timed.
743+
744+
This function checks whether a trajectory has a valid `deltatime` group,
745+
indicating that it is a timed trajectory.
746+
747+
@param trajectory: an OpenRAVE trajectory
748+
@returns: True if the trajectory is timed, False otherwise
749+
"""
750+
cspec = trajectory.GetConfigurationSpecification()
751+
return cspec.ExtractDeltaTime(trajectory.GetWaypoint(0)) is not None

0 commit comments

Comments
 (0)