diff python/tests/prediction.txt @ 942:ab13aaf41432

implemented motion prediction with prototypes at constant ratio, with tests
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 18 Jul 2017 18:01:16 -0400
parents c5191acb025f
children 05d4302bf67e
line wrap: on
line diff
--- a/python/tests/prediction.txt	Tue Jul 18 16:21:39 2017 -0400
+++ b/python/tests/prediction.txt	Tue Jul 18 18:01:16 2017 -0400
@@ -1,5 +1,5 @@
 >>> from prediction import *
->>> import moving, storage
+>>> import moving, storage, utils
 >>> from numpy import absolute, array
 
 >>> et = PredictedTrajectoryConstant(moving.Point(0,0), moving.Point(1,0))
@@ -57,3 +57,15 @@
 >>> (absolute(array(traj.distances) - et.initialSpeed) < 1e-5).all()
 True
 
+>>> et = PredictedTrajectoryPrototype(proto.getPositionAt(10)+moving.Point(0.6, 0.6), proto.getVelocityAt(10)*0.7, proto, False)
+>>> absolute(et.initialSpeed - proto.getVelocityAt(10).norm2()*0.7) < 1e-5
+True
+>>> proto = moving.MovingObject.generate(1, moving.Point(-5.,0.), moving.Point(1.,0.), moving.TimeInterval(0,10))
+>>> et = PredictedTrajectoryPrototype(proto.getPositionAt(0)+moving.Point(0., 1.), proto.getVelocityAt(0)*0.5, proto, False)
+>>> for t in xrange(int(proto.length()/0.5)): x=et.predictPosition(t)
+>>> et.predictPosition(10) # doctest:+ELLIPSIS
+(0.0...,1.0...)
+>>> et.predictPosition(12) # doctest:+ELLIPSIS
+(1.0...,1.0...)
+
+