Mercurial Hosting > traffic-intelligence
comparison trafficintelligence/events.py @ 1275:9f1711a85c56
added code to make sure TTC is replaced of recomputed and not having a value
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 19 Jun 2024 16:11:35 -0400 |
parents | 655a1646f0d5 |
children |
comparison
equal
deleted
inserted
replaced
1274:0bfcbc58352f | 1275:9f1711a85c56 |
---|---|
124 if j in tmpobjects: | 124 if j in tmpobjects: |
125 self.roadUser2 = tmpobjects[j] | 125 self.roadUser2 = tmpobjects[j] |
126 | 126 |
127 def getIndicator(self, indicatorName): | 127 def getIndicator(self, indicatorName): |
128 return self.indicators.get(indicatorName, None) | 128 return self.indicators.get(indicatorName, None) |
129 | |
130 def resetIndicator(self, indicatorName): | |
131 if indicatorName in self.indicators: | |
132 del self.indicators[indicatorName] | |
129 | 133 |
130 def addIndicator(self, indicator): | 134 def addIndicator(self, indicator): |
131 if indicator is not None: | 135 if indicator is not None: |
132 self.indicators[indicator.name] = indicator | 136 self.indicators[indicator.name] = indicator |
133 | 137 |
282 TTCs[i] = prediction.SafetyPoint.computeExpectedIndicator(cps) | 286 TTCs[i] = prediction.SafetyPoint.computeExpectedIndicator(cps) |
283 collisionProbabilities[i] = sum([p.probability for p in cps]) | 287 collisionProbabilities[i] = sum([p.probability for p in cps]) |
284 if len(TTCs) > 0: | 288 if len(TTCs) > 0: |
285 self.addIndicator(indicators.SeverityIndicator(Interaction.indicatorNames[7], TTCs, mostSevereIsMax=False)) | 289 self.addIndicator(indicators.SeverityIndicator(Interaction.indicatorNames[7], TTCs, mostSevereIsMax=False)) |
286 self.addIndicator(indicators.SeverityIndicator(Interaction.indicatorNames[6], collisionProbabilities)) | 290 self.addIndicator(indicators.SeverityIndicator(Interaction.indicatorNames[6], collisionProbabilities)) |
291 else: | |
292 for i in [6,7]: | |
293 self.resetIndicator(Interaction.indicatorNames[i]) | |
287 | 294 |
288 # crossing zones and pPET | 295 # crossing zones and pPET |
289 if computeCZ: | 296 if computeCZ: |
290 self.crossingZones = crossingZones | 297 self.crossingZones = crossingZones |
291 pPETs = {} | 298 pPETs = {} |
297 def computePET(self, collisionDistanceThreshold, computePetWithBoundingPoly): | 304 def computePET(self, collisionDistanceThreshold, computePetWithBoundingPoly): |
298 'Warning: when computing PET from interactions, there could be PETs between objects that do not coexist and therefore are not considered interactions' | 305 'Warning: when computing PET from interactions, there could be PETs between objects that do not coexist and therefore are not considered interactions' |
299 pet, t1, t2= moving.MovingObject.computePET(self.roadUser1, self.roadUser2, collisionDistanceThreshold, computePetWithBoundingPoly) | 306 pet, t1, t2= moving.MovingObject.computePET(self.roadUser1, self.roadUser2, collisionDistanceThreshold, computePetWithBoundingPoly) |
300 if pet is not None: | 307 if pet is not None: |
301 self.addIndicator(indicators.SeverityIndicator(Interaction.indicatorNames[10], {min(t1, t2): pet, max(t1, t2): pet}, mostSevereIsMax = False)) | 308 self.addIndicator(indicators.SeverityIndicator(Interaction.indicatorNames[10], {min(t1, t2): pet, max(t1, t2): pet}, mostSevereIsMax = False)) |
309 else: | |
310 self.resetIndicator(Interaction.indicatorNames[10]) | |
302 | 311 |
303 def setCollision(self, collision): | 312 def setCollision(self, collision): |
304 '''indicates if it is a collision: argument should be boolean''' | 313 '''indicates if it is a collision: argument should be boolean''' |
305 self.collision = collision | 314 self.collision = collision |
306 | 315 |