annotate trafficintelligence/tests/events.txt @ 1278:8e61ff3cd503 default tip

correct bug to take into account first frame num in config, and other related bugs in dltrack.py
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 27 Jun 2024 15:31:36 -0400
parents 9f1711a85c56
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1030
aafbc0bab925 moved method around to avoid cross-dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1028
diff changeset
1 >>> from trafficintelligence.events import *
aafbc0bab925 moved method around to avoid cross-dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1028
diff changeset
2 >>> from trafficintelligence.moving import MovingObject, TimeInterval, Point
aafbc0bab925 moved method around to avoid cross-dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1028
diff changeset
3 >>> from trafficintelligence.prediction import ConstantPredictionParameters
489
000bddf84ad0 corrected bugs in safety analysis
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
4
000bddf84ad0 corrected bugs in safety analysis
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
5 >>> objects = [MovingObject(num = i, timeInterval = TimeInterval(0,10)) for i in range(10)]
000bddf84ad0 corrected bugs in safety analysis
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
6 >>> interactions = createInteractions(objects)
000bddf84ad0 corrected bugs in safety analysis
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7 >>> len([i for i in interactions if len(i.roadUserNumbers) == 1])
000bddf84ad0 corrected bugs in safety analysis
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
8 0
1151
658f87232536 extended creation of interactions to non simultaneous objects for PET calculations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1150
diff changeset
9 >>> len(interactions)
658f87232536 extended creation of interactions to non simultaneous objects for PET calculations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1150
diff changeset
10 45
489
000bddf84ad0 corrected bugs in safety analysis
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
11 >>> objects2 = [MovingObject(num = i, timeInterval = TimeInterval(0,10)) for i in range(100, 110)]
000bddf84ad0 corrected bugs in safety analysis
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
12 >>> interactions = createInteractions(objects, objects2)
000bddf84ad0 corrected bugs in safety analysis
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
13 >>> len([i for i in interactions if len(i.roadUserNumbers) == 1])
000bddf84ad0 corrected bugs in safety analysis
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
14 0
1151
658f87232536 extended creation of interactions to non simultaneous objects for PET calculations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1150
diff changeset
15 >>> objects3 = [MovingObject(num = i, timeInterval = TimeInterval(12,22)) for i in range(100, 110)]
658f87232536 extended creation of interactions to non simultaneous objects for PET calculations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1150
diff changeset
16 >>> interactions = createInteractions(objects, objects3)
658f87232536 extended creation of interactions to non simultaneous objects for PET calculations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1150
diff changeset
17 >>> len(interactions)
658f87232536 extended creation of interactions to non simultaneous objects for PET calculations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1150
diff changeset
18 0
658f87232536 extended creation of interactions to non simultaneous objects for PET calculations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1150
diff changeset
19 >>> interactions = createInteractions(objects, objects3, 3)
658f87232536 extended creation of interactions to non simultaneous objects for PET calculations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1150
diff changeset
20 >>> len(interactions)
658f87232536 extended creation of interactions to non simultaneous objects for PET calculations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1150
diff changeset
21 100
658f87232536 extended creation of interactions to non simultaneous objects for PET calculations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1150
diff changeset
22 >>> interactions[0].getTimeInterval().empty()
658f87232536 extended creation of interactions to non simultaneous objects for PET calculations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1150
diff changeset
23 True
662
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
24
1150
14140b55e580 corrected issue with motion pattern for motion prediction for safety analysis (to few matches)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1148
diff changeset
25 >>> o1 = MovingObject.generate(1, Point(-5.,0.), Point(0.,0.), TimeInterval(0,10))
14140b55e580 corrected issue with motion pattern for motion prediction for safety analysis (to few matches)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1148
diff changeset
26 >>> o2 = MovingObject.generate(2, Point(0.,-5.), Point(0.,1.), TimeInterval(0,10))
14140b55e580 corrected issue with motion pattern for motion prediction for safety analysis (to few matches)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1148
diff changeset
27 >>> inter = Interaction(roadUser1 = o1, roadUser2 = o2)
14140b55e580 corrected issue with motion pattern for motion prediction for safety analysis (to few matches)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1148
diff changeset
28 >>> inter.computeIndicators() # should not crash with 0 speed
14140b55e580 corrected issue with motion pattern for motion prediction for safety analysis (to few matches)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1148
diff changeset
29 >>> va = inter.getIndicator("Velocity Angle")
14140b55e580 corrected issue with motion pattern for motion prediction for safety analysis (to few matches)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1148
diff changeset
30 >>> va.empty()
14140b55e580 corrected issue with motion pattern for motion prediction for safety analysis (to few matches)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1148
diff changeset
31 True
14140b55e580 corrected issue with motion pattern for motion prediction for safety analysis (to few matches)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1148
diff changeset
32
918
3a06007a4bb7 modularized save trajectories, added slice to Trajectory, etc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 662
diff changeset
33 >>> o1 = MovingObject.generate(1, Point(-5.,0.), Point(1.,0.), TimeInterval(0,10))
3a06007a4bb7 modularized save trajectories, added slice to Trajectory, etc
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 662
diff changeset
34 >>> o2 = MovingObject.generate(2, Point(0.,-5.), Point(0.,1.), TimeInterval(0,10))
662
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
35 >>> inter = Interaction(roadUser1 = o1, roadUser2 = o2)
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
36 >>> inter.computeIndicators()
1212
af329f3330ba work in progress on 3D safety analysis
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1151
diff changeset
37 >>> predictionParams = ConstantPredictionParameters()
662
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
38 >>> inter.computeCrossingsCollisions(predictionParams, 0.1, 10)
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
39 >>> ttc = inter.getIndicator("Time to Collision")
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
40 >>> ttc[0]
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
41 5.0
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
42 >>> ttc[1]
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
43 4.0
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
44 >>> (inter.collisionPoints[0][0] - Point(0.,0.)).norm2() < 0.0001
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
45 True
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
46 >>> (inter.collisionPoints[4][0] - Point(0.,0.)).norm2() < 0.0001
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
47 True
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
48 >>> inter.getIndicator(Interaction.indicatorNames[1])[4] < 0.000001 # collision angle
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
49 True
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
50 >>> inter.getIndicator(Interaction.indicatorNames[1])[5] is None
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
51 True
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
52 >>> inter.getIndicator(Interaction.indicatorNames[1])[6] # doctest:+ELLIPSIS
72174e66aba5 corrected bug that increased TTC by 1 frame and structure to store collision points and crossing zones
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 489
diff changeset
53 3.1415...
1148
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
54
1275
9f1711a85c56 added code to make sure TTC is replaced of recomputed and not having a value
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1269
diff changeset
55 # test if reseting object
9f1711a85c56 added code to make sure TTC is replaced of recomputed and not having a value
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1269
diff changeset
56 >>> o2 = MovingObject.generate(2, Point(0.,-5.), Point(0.,-1.), TimeInterval(0,10))
9f1711a85c56 added code to make sure TTC is replaced of recomputed and not having a value
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1269
diff changeset
57 >>> inter.setRoadUsers([o1,o2])
9f1711a85c56 added code to make sure TTC is replaced of recomputed and not having a value
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1269
diff changeset
58 >>> ttc = inter.getIndicator("Time to Collision")
9f1711a85c56 added code to make sure TTC is replaced of recomputed and not having a value
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1269
diff changeset
59 >>> ttc[0]
9f1711a85c56 added code to make sure TTC is replaced of recomputed and not having a value
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1269
diff changeset
60 5.0
9f1711a85c56 added code to make sure TTC is replaced of recomputed and not having a value
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1269
diff changeset
61 >>> inter.computeIndicators()
9f1711a85c56 added code to make sure TTC is replaced of recomputed and not having a value
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1269
diff changeset
62 >>> inter.computeCrossingsCollisions(predictionParams, 0.1, 10)
9f1711a85c56 added code to make sure TTC is replaced of recomputed and not having a value
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1269
diff changeset
63 >>> inter.getIndicator("Time to Collision") is None
9f1711a85c56 added code to make sure TTC is replaced of recomputed and not having a value
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1269
diff changeset
64 True
9f1711a85c56 added code to make sure TTC is replaced of recomputed and not having a value
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1269
diff changeset
65
1269
ca70a79688ae adding a speed threshold to avoid computing TTC at very low speeds
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1267
diff changeset
66 # test low speed
ca70a79688ae adding a speed threshold to avoid computing TTC at very low speeds
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1267
diff changeset
67 >>> inter = Interaction(roadUser1 = o1, roadUser2 = o2)
ca70a79688ae adding a speed threshold to avoid computing TTC at very low speeds
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1267
diff changeset
68 >>> inter.computeIndicators()
ca70a79688ae adding a speed threshold to avoid computing TTC at very low speeds
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1267
diff changeset
69 >>> predictionParams = ConstantPredictionParameters()
ca70a79688ae adding a speed threshold to avoid computing TTC at very low speeds
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1267
diff changeset
70 >>> inter.computeCrossingsCollisions(predictionParams, 0.1, 10, speedThreshold = 1.)
ca70a79688ae adding a speed threshold to avoid computing TTC at very low speeds
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1267
diff changeset
71 >>> inter.getIndicator("Time to Collision") is None
ca70a79688ae adding a speed threshold to avoid computing TTC at very low speeds
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1267
diff changeset
72 True
ca70a79688ae adding a speed threshold to avoid computing TTC at very low speeds
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1267
diff changeset
73
ca70a79688ae adding a speed threshold to avoid computing TTC at very low speeds
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1267
diff changeset
74 # 0 speed users
ca70a79688ae adding a speed threshold to avoid computing TTC at very low speeds
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1267
diff changeset
75 >>> inter = Interaction(roadUser1 = MovingObject.generate(1, Point(-5.,0.), Point(0.,0.), TimeInterval(0,10)), roadUser2 = MovingObject.generate(2, Point(0.,-5.), Point(0.,0.), TimeInterval(0,10)))
ca70a79688ae adding a speed threshold to avoid computing TTC at very low speeds
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1267
diff changeset
76 >>> inter.computeIndicators()
ca70a79688ae adding a speed threshold to avoid computing TTC at very low speeds
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1267
diff changeset
77 >>> predictionParams = ConstantPredictionParameters()
ca70a79688ae adding a speed threshold to avoid computing TTC at very low speeds
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1267
diff changeset
78 >>> inter.computeCrossingsCollisions(predictionParams, 0.1, 10)
ca70a79688ae adding a speed threshold to avoid computing TTC at very low speeds
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1267
diff changeset
79 >>> inter.getIndicator("Time to Collision") is None
ca70a79688ae adding a speed threshold to avoid computing TTC at very low speeds
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1267
diff changeset
80 True
ca70a79688ae adding a speed threshold to avoid computing TTC at very low speeds
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1267
diff changeset
81
1150
14140b55e580 corrected issue with motion pattern for motion prediction for safety analysis (to few matches)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1148
diff changeset
82 # test categorize
1148
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
83 >>> from collections import Counter
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
84 >>> from numpy import pi
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
85 >>> o1 = MovingObject.generate(0, Point(0,0), Point(1,0), TimeInterval(0,100))
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
86 >>> o2 = MovingObject.generate(0, Point(100,1), Point(-1,0), TimeInterval(0,100))
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
87 >>> inter12 = Interaction(roadUser1 = o1, roadUser2 = o2)
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
88 >>> inter12.computeIndicators()
1267
ad60e5adf084 cleaned interaction categorization and added stationary category
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1212
diff changeset
89 >>> inter12.categorize(pi*20/180, pi*45/180)
1148
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
90 >>> Counter(inter12.categories.values()).most_common()[0][0] # head on
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
91 0
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
92 >>> inter12.categories[max(inter12.categories.keys())] # then side
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
93 2
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
94 >>> o3 = MovingObject.generate(0, Point(0,2), Point(1,0), TimeInterval(0,100))
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
95 >>> inter13 = Interaction(roadUser1 = o1, roadUser2 = o3)
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
96 >>> inter13.computeIndicators()
1267
ad60e5adf084 cleaned interaction categorization and added stationary category
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1212
diff changeset
97 >>> inter13.categorize(pi*20/180, pi*45/180)
1148
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
98 >>> Counter(inter13.categories.values()).most_common()[0][0] # parallel
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
99 3
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
100 >>> len(Counter(inter13.categories.values()))
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
101 1
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
102 >>> o4 = MovingObject.generate(0, Point(100,20), Point(-1,0), TimeInterval(0,100))
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
103 >>> inter14 = Interaction(roadUser1 = o1, roadUser2 = o4)
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
104 >>> inter14.computeIndicators()
1267
ad60e5adf084 cleaned interaction categorization and added stationary category
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1212
diff changeset
105 >>> inter14.categorize(pi*20/180, pi*45/180)
1148
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
106 >>> Counter(inter14.categories.values()).most_common()[0][0] # side
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
107 2
1267
ad60e5adf084 cleaned interaction categorization and added stationary category
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1212
diff changeset
108 >>> inter12.categories[0] # first head on
1148
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
109 0
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
110 >>> inter12.categories[max(inter12.categories.keys())] # then side
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
111 2
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
112 >>> o5 = MovingObject.generate(0, Point(50,50), Point(0,-1), TimeInterval(0,100))
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
113 >>> inter15 = Interaction(roadUser1 = o1, roadUser2 = o5)
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
114 >>> inter15.computeIndicators()
1267
ad60e5adf084 cleaned interaction categorization and added stationary category
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1212
diff changeset
115 >>> inter15.categorize(pi*20/180, pi*45/180)
1148
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
116 >>> Counter(inter15.categories.values()).most_common()[0][0] # side
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
117 2
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
118 >>> len(Counter(inter15.categories.values()))
eb88d2984637 corrected interaction classification
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1030
diff changeset
119 1
1267
ad60e5adf084 cleaned interaction categorization and added stationary category
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1212
diff changeset
120 >>> o6 = MovingObject.generate(0, Point(50,1), Point(0,0), TimeInterval(0,100))
ad60e5adf084 cleaned interaction categorization and added stationary category
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1212
diff changeset
121 >>> inter16 = Interaction(roadUser1 = o1, roadUser2 = o6)
ad60e5adf084 cleaned interaction categorization and added stationary category
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1212
diff changeset
122 >>> inter16.computeIndicators()
ad60e5adf084 cleaned interaction categorization and added stationary category
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1212
diff changeset
123 >>> inter16.categorize(pi*20/180, pi*45/180, speedThreshold = 0.1)
ad60e5adf084 cleaned interaction categorization and added stationary category
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1212
diff changeset
124 >>> Counter(inter16.categories.values()).most_common()[0][0] # stationary
ad60e5adf084 cleaned interaction categorization and added stationary category
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1212
diff changeset
125 4
ad60e5adf084 cleaned interaction categorization and added stationary category
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1212
diff changeset
126 >>> 49 in inter16.categories
ad60e5adf084 cleaned interaction categorization and added stationary category
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1212
diff changeset
127 True
ad60e5adf084 cleaned interaction categorization and added stationary category
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1212
diff changeset
128 >>> 51 in inter16.categories # not stationary interaction past the user
ad60e5adf084 cleaned interaction categorization and added stationary category
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 1212
diff changeset
129 False