comparison python/tests/events.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 000bddf84ad0
children 3a06007a4bb7
comparison
equal deleted inserted replaced
661:dc70d9e711f5 662:72174e66aba5
1 >>> from events import * 1 >>> from events import *
2 >>> from moving import MovingObject, TimeInterval 2 >>> from moving import MovingObject, TimeInterval, Point
3 >>> from prediction import ConstantPredictionParameters
3 4
4 >>> objects = [MovingObject(num = i, timeInterval = TimeInterval(0,10)) for i in range(10)] 5 >>> objects = [MovingObject(num = i, timeInterval = TimeInterval(0,10)) for i in range(10)]
5 >>> interactions = createInteractions(objects) 6 >>> interactions = createInteractions(objects)
6 >>> len([i for i in interactions if len(i.roadUserNumbers) == 1]) 7 >>> len([i for i in interactions if len(i.roadUserNumbers) == 1])
7 0 8 0
8 >>> objects2 = [MovingObject(num = i, timeInterval = TimeInterval(0,10)) for i in range(100, 110)] 9 >>> objects2 = [MovingObject(num = i, timeInterval = TimeInterval(0,10)) for i in range(100, 110)]
9 >>> interactions = createInteractions(objects, objects2) 10 >>> interactions = createInteractions(objects, objects2)
10 >>> len([i for i in interactions if len(i.roadUserNumbers) == 1]) 11 >>> len([i for i in interactions if len(i.roadUserNumbers) == 1])
11 0 12 0
13
14 >>> o1 = MovingObject.generate(Point(-5.,0.), Point(1.,0.), TimeInterval(0,10))
15 >>> o2 = MovingObject.generate(Point(0.,-5.), Point(0.,1.), TimeInterval(0,10))
16 >>> inter = Interaction(roadUser1 = o1, roadUser2 = o2)
17 >>> inter.computeIndicators()
18 >>> predictionParams = ConstantPredictionParameters(10.)
19 >>> inter.computeCrossingsCollisions(predictionParams, 0.1, 10)
20 >>> ttc = inter.getIndicator("Time to Collision")
21 >>> ttc[0]
22 5.0
23 >>> ttc[1]
24 4.0
25 >>> (inter.collisionPoints[0][0] - Point(0.,0.)).norm2() < 0.0001
26 True
27 >>> (inter.collisionPoints[4][0] - Point(0.,0.)).norm2() < 0.0001
28 True
29 >>> inter.getIndicator(Interaction.indicatorNames[1])[4] < 0.000001 # collision angle
30 True
31 >>> inter.getIndicator(Interaction.indicatorNames[1])[5] is None
32 True
33 >>> inter.getIndicator(Interaction.indicatorNames[1])[6] # doctest:+ELLIPSIS
34 3.1415...