changeset 941:c5191acb025f

added test for motion prediction at constant speed with prototype
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 18 Jul 2017 16:21:39 -0400
parents d8ab183a7351
children ab13aaf41432
files python/tests/prediction.txt
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/python/tests/prediction.txt	Tue Jul 18 13:46:17 2017 -0400
+++ b/python/tests/prediction.txt	Tue Jul 18 16:21:39 2017 -0400
@@ -1,5 +1,6 @@
 >>> from prediction import *
->>> import moving
+>>> import moving, storage
+>>> from numpy import absolute, array
 
 >>> et = PredictedTrajectoryConstant(moving.Point(0,0), moving.Point(1,0))
 >>> et.predictPosition(4) # doctest:+ELLIPSIS
@@ -44,3 +45,15 @@
 >>> collision, t, cp1, cp2 = computeCollisionTime(et1, et2, 0.1, 4)
 >>> collision
 False
+
+>>> proto = storage.loadTrajectoriesFromSqlite('../samples/laurier.sqlite', 'feature', [1204])[0]
+>>> proto.getPositions().computeCumulativeDistances()
+>>> et = PredictedTrajectoryPrototype(proto.getPositionAt(10)+moving.Point(0.5, 0.5), proto.getVelocityAt(10)*0.9, proto, True)
+>>> absolute(et.initialSpeed - proto.getVelocityAt(10).norm2()*0.9) < 1e-5
+True
+>>> for t in xrange(int(proto.length())): x=et.predictPosition(t)
+>>> traj = et.getPredictedTrajectory()
+>>> traj.computeCumulativeDistances()
+>>> (absolute(array(traj.distances) - et.initialSpeed) < 1e-5).all()
+True
+