comparison trafficintelligence/events.py @ 1269:ca70a79688ae

adding a speed threshold to avoid computing TTC at very low speeds
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 05 Jun 2024 10:12:43 -0400
parents ad60e5adf084
children 655a1646f0d5
comparison
equal deleted inserted replaced
1268:27b206d118b7 1269:ca70a79688ae
276 # leaving is not a good interaction category (issue in Etienne's 2022 paper): 276 # leaving is not a good interaction category (issue in Etienne's 2022 paper):
277 # means we are past the situation in which users are approaching 277 # means we are past the situation in which users are approaching
278 # could try to predict what happened before, but it's not observed 278 # could try to predict what happened before, but it's not observed
279 279
280 280
281 def computeCrossingsCollisions(self, predictionParameters, collisionDistanceThreshold, timeHorizon, computeCZ = False, debug = False, timeInterval = None): 281 def computeCrossingsCollisions(self, predictionParameters, collisionDistanceThreshold, timeHorizon, computeCZ = False, debug = False, timeInterval = None, speedThreshold = 0.):
282 '''Computes all crossing and collision points at each common instant for two road users. ''' 282 '''Computes all crossing and collision points at each common instant for two road users.
283
284 speedThreshold defines when users are stationary: TTC is not computed when both users are stationary'''
283 TTCs = {} 285 TTCs = {}
284 collisionProbabilities = {} 286 collisionProbabilities = {}
285 if timeInterval is not None: 287 if timeInterval is not None:
286 commonTimeInterval = timeInterval 288 commonTimeInterval = timeInterval
287 else: 289 else:
288 commonTimeInterval = self.timeInterval 290 commonTimeInterval = self.timeInterval
289 self.collisionPoints, crossingZones = predictionParameters.computeCrossingsCollisions(self.roadUser1, self.roadUser2, collisionDistanceThreshold, timeHorizon, computeCZ, debug, commonTimeInterval) 291 self.collisionPoints, crossingZones = predictionParameters.computeCrossingsCollisions(self.roadUser1, self.roadUser2, collisionDistanceThreshold, timeHorizon, computeCZ, debug, commonTimeInterval, speedThreshold)
290 for i, cps in self.collisionPoints.items(): 292 for i, cps in self.collisionPoints.items():
291 TTCs[i] = prediction.SafetyPoint.computeExpectedIndicator(cps) 293 TTCs[i] = prediction.SafetyPoint.computeExpectedIndicator(cps)
292 collisionProbabilities[i] = sum([p.probability for p in cps]) 294 collisionProbabilities[i] = sum([p.probability for p in cps])
293 if len(TTCs) > 0: 295 if len(TTCs) > 0:
294 self.addIndicator(indicators.SeverityIndicator(Interaction.indicatorNames[7], TTCs, mostSevereIsMax=False)) 296 self.addIndicator(indicators.SeverityIndicator(Interaction.indicatorNames[7], TTCs, mostSevereIsMax=False))