Mercurial Hosting > traffic-intelligence
comparison python/tests/prediction.txt @ 662:72174e66aba5
corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 18 May 2015 17:17:06 +0200 |
parents | e891a41c6c75 |
children | c5191acb025f |
comparison
equal
deleted
inserted
replaced
661:dc70d9e711f5 | 662:72174e66aba5 |
---|---|
1 >>> import prediction | 1 >>> from prediction import * |
2 >>> import moving | 2 >>> import moving |
3 | 3 |
4 >>> et = prediction.PredictedTrajectoryConstant(moving.Point(0,0), moving.Point(1,0)) | 4 >>> et = PredictedTrajectoryConstant(moving.Point(0,0), moving.Point(1,0)) |
5 >>> et.predictPosition(4) # doctest:+ELLIPSIS | 5 >>> et.predictPosition(4) # doctest:+ELLIPSIS |
6 (4.0...,0.0...) | 6 (4.0...,0.0...) |
7 >>> et.predictPosition(1) # doctest:+ELLIPSIS | 7 >>> et.predictPosition(1) # doctest:+ELLIPSIS |
8 (1.0...,0.0...) | 8 (1.0...,0.0...) |
9 | 9 |
10 >>> et = prediction.PredictedTrajectoryConstant(moving.Point(0,0), moving.Point(1,0), moving.NormAngle(0.1,0), maxSpeed = 2) | 10 >>> et = PredictedTrajectoryConstant(moving.Point(0,0), moving.Point(1,0), moving.NormAngle(0.1,0), maxSpeed = 2) |
11 >>> et.predictPosition(10) # doctest:+ELLIPSIS | 11 >>> et.predictPosition(10) # doctest:+ELLIPSIS |
12 (15.5...,0.0...) | 12 (15.5...,0.0...) |
13 >>> et.predictPosition(11) # doctest:+ELLIPSIS | 13 >>> et.predictPosition(11) # doctest:+ELLIPSIS |
14 (17.5...,0.0...) | 14 (17.5...,0.0...) |
15 >>> et.predictPosition(12) # doctest:+ELLIPSIS | 15 >>> et.predictPosition(12) # doctest:+ELLIPSIS |
16 (19.5...,0.0...) | 16 (19.5...,0.0...) |
17 | 17 |
18 >>> import random | 18 >>> import random |
19 >>> acceleration = lambda: random.uniform(-0.5,0.5) | 19 >>> acceleration = lambda: random.uniform(-0.5,0.5) |
20 >>> steering = lambda: random.uniform(-0.1,0.1) | 20 >>> steering = lambda: random.uniform(-0.1,0.1) |
21 >>> et = prediction.PredictedTrajectoryRandomControl(moving.Point(0,0),moving.Point(1,1), acceleration, steering, maxSpeed = 2) | 21 >>> et = PredictedTrajectoryRandomControl(moving.Point(0,0),moving.Point(1,1), acceleration, steering, maxSpeed = 2) |
22 >>> p = et.predictPosition(500) | 22 >>> p = et.predictPosition(500) |
23 >>> from numpy import max | 23 >>> from numpy import max |
24 >>> max(et.getPredictedSpeeds()) <= 2. | 24 >>> max(et.getPredictedSpeeds()) <= 2. |
25 True | 25 True |
26 | 26 |
27 >>> p = moving.Point(3,4) | 27 >>> p = moving.Point(3,4) |
28 >>> sp = prediction.SafetyPoint(p, 0.1, 0) | 28 >>> sp = SafetyPoint(p, 0.1, 0) |
29 >>> print(sp) | 29 >>> print(sp) |
30 3 4 0.1 0 | 30 3 4 0.1 0 |
31 | |
32 >>> et1 = PredictedTrajectoryConstant(moving.Point(-5.,0.), moving.Point(1.,0.)) | |
33 >>> et2 = PredictedTrajectoryConstant(moving.Point(0.,-5.), moving.Point(0.,1.)) | |
34 >>> collision, t, cp1, cp2 = computeCollisionTime(et1, et2, 0.1, 10) | |
35 >>> collision | |
36 True | |
37 >>> t | |
38 5 | |
39 >>> collision, t, cp1, cp2 = computeCollisionTime(et1, et2, 0.1, 5) | |
40 >>> collision | |
41 True | |
42 >>> t | |
43 5 | |
44 >>> collision, t, cp1, cp2 = computeCollisionTime(et1, et2, 0.1, 4) | |
45 >>> collision | |
46 False |