Mercurial > hg > nsaunier > traffic-intelligence
comparison python/tests/prediction.txt @ 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 | 72174e66aba5 |
| children | ab13aaf41432 |
comparison
equal
deleted
inserted
replaced
| 940:d8ab183a7351 | 941:c5191acb025f |
|---|---|
| 1 >>> from prediction import * | 1 >>> from prediction import * |
| 2 >>> import moving | 2 >>> import moving, storage |
| 3 >>> from numpy import absolute, array | |
| 3 | 4 |
| 4 >>> et = PredictedTrajectoryConstant(moving.Point(0,0), moving.Point(1,0)) | 5 >>> et = PredictedTrajectoryConstant(moving.Point(0,0), moving.Point(1,0)) |
| 5 >>> et.predictPosition(4) # doctest:+ELLIPSIS | 6 >>> et.predictPosition(4) # doctest:+ELLIPSIS |
| 6 (4.0...,0.0...) | 7 (4.0...,0.0...) |
| 7 >>> et.predictPosition(1) # doctest:+ELLIPSIS | 8 >>> et.predictPosition(1) # doctest:+ELLIPSIS |
| 42 >>> t | 43 >>> t |
| 43 5 | 44 5 |
| 44 >>> collision, t, cp1, cp2 = computeCollisionTime(et1, et2, 0.1, 4) | 45 >>> collision, t, cp1, cp2 = computeCollisionTime(et1, et2, 0.1, 4) |
| 45 >>> collision | 46 >>> collision |
| 46 False | 47 False |
| 48 | |
| 49 >>> proto = storage.loadTrajectoriesFromSqlite('../samples/laurier.sqlite', 'feature', [1204])[0] | |
| 50 >>> proto.getPositions().computeCumulativeDistances() | |
| 51 >>> et = PredictedTrajectoryPrototype(proto.getPositionAt(10)+moving.Point(0.5, 0.5), proto.getVelocityAt(10)*0.9, proto, True) | |
| 52 >>> absolute(et.initialSpeed - proto.getVelocityAt(10).norm2()*0.9) < 1e-5 | |
| 53 True | |
| 54 >>> for t in xrange(int(proto.length())): x=et.predictPosition(t) | |
| 55 >>> traj = et.getPredictedTrajectory() | |
| 56 >>> traj.computeCumulativeDistances() | |
| 57 >>> (absolute(array(traj.distances) - et.initialSpeed) < 1e-5).all() | |
| 58 True | |
| 59 |
