comparison 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
comparison
equal deleted inserted replaced
941:c5191acb025f 942:ab13aaf41432
1 >>> from prediction import * 1 >>> from prediction import *
2 >>> import moving, storage 2 >>> import moving, storage, utils
3 >>> from numpy import absolute, array 3 >>> from numpy import absolute, array
4 4
5 >>> et = PredictedTrajectoryConstant(moving.Point(0,0), moving.Point(1,0)) 5 >>> et = PredictedTrajectoryConstant(moving.Point(0,0), moving.Point(1,0))
6 >>> et.predictPosition(4) # doctest:+ELLIPSIS 6 >>> et.predictPosition(4) # doctest:+ELLIPSIS
7 (4.0...,0.0...) 7 (4.0...,0.0...)
55 >>> traj = et.getPredictedTrajectory() 55 >>> traj = et.getPredictedTrajectory()
56 >>> traj.computeCumulativeDistances() 56 >>> traj.computeCumulativeDistances()
57 >>> (absolute(array(traj.distances) - et.initialSpeed) < 1e-5).all() 57 >>> (absolute(array(traj.distances) - et.initialSpeed) < 1e-5).all()
58 True 58 True
59 59
60 >>> et = PredictedTrajectoryPrototype(proto.getPositionAt(10)+moving.Point(0.6, 0.6), proto.getVelocityAt(10)*0.7, proto, False)
61 >>> absolute(et.initialSpeed - proto.getVelocityAt(10).norm2()*0.7) < 1e-5
62 True
63 >>> proto = moving.MovingObject.generate(1, moving.Point(-5.,0.), moving.Point(1.,0.), moving.TimeInterval(0,10))
64 >>> et = PredictedTrajectoryPrototype(proto.getPositionAt(0)+moving.Point(0., 1.), proto.getVelocityAt(0)*0.5, proto, False)
65 >>> for t in xrange(int(proto.length()/0.5)): x=et.predictPosition(t)
66 >>> et.predictPosition(10) # doctest:+ELLIPSIS
67 (0.0...,1.0...)
68 >>> et.predictPosition(12) # doctest:+ELLIPSIS
69 (1.0...,1.0...)
70
71