Skip to content

Commit e1bc8da

Browse files
author
Michael Koval
committed
Fixed IsTimedTrajectory on empty trajectories.
1 parent ce7b6e2 commit e1bc8da

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/prpy/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,8 @@ def IsTimedTrajectory(trajectory):
762762
@returns: True if the trajectory is timed, False otherwise
763763
"""
764764
cspec = trajectory.GetConfigurationSpecification()
765-
return cspec.ExtractDeltaTime(trajectory.GetWaypoint(0)) is not None
765+
empty_waypoint = numpy.zeros(cspec.GetDOF())
766+
return cspec.ExtractDeltaTime(empty_waypoint) is not None
766767

767768
def ComputeEnabledAABB(kinbody):
768769
"""

tests/test_util.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import openravepy
2+
import prpy.util
3+
import unittest
4+
5+
class IsTimedTrajectoryTests(unittest.TestCase):
6+
def setUp(self):
7+
self.env = openravepy.Environment()
8+
self.traj = openravepy.RaveCreateTrajectory(self.env, '')
9+
10+
def test_IsTimed_ReturnsTrue(self):
11+
cspec = openravepy.ConfigurationSpecification()
12+
cspec.AddDeltaTimeGroup()
13+
14+
self.traj.Init(cspec)
15+
self.assertTrue(prpy.util.IsTimedTrajectory(self.traj))
16+
17+
self.traj.Insert(0, [0.])
18+
self.assertTrue(prpy.util.IsTimedTrajectory(self.traj))
19+
20+
def test_IsNotTimed_ReturnsFalse(self):
21+
cspec = openravepy.ConfigurationSpecification()
22+
cspec.AddGroup('joint_values test_robot 0', 1, 'linear')
23+
24+
self.traj.Init(cspec)
25+
self.assertFalse(prpy.util.IsTimedTrajectory(self.traj))
26+
27+
self.traj.Insert(0, [0.])
28+
self.assertFalse(prpy.util.IsTimedTrajectory(self.traj))

0 commit comments

Comments
 (0)