Mercurial > hg > nsaunier > traffic-intelligence
comparison trafficintelligence/events.py @ 1252:fe35473acee3
adding method to compute PET using polygon for the outline of a vehicle (bird eye view of the vehicle)
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 22 Mar 2024 14:33:25 -0400 |
| parents | 0e5d37b0b9ff |
| children | 56d0195d043e |
comparison
equal
deleted
inserted
replaced
| 1251:2b1c8fe8f7e4 | 1252:fe35473acee3 |
|---|---|
| 275 for i, cz in self.crossingZones.items(): | 275 for i, cz in self.crossingZones.items(): |
| 276 pPETs[i] = prediction.SafetyPoint.computeExpectedIndicator(cz) | 276 pPETs[i] = prediction.SafetyPoint.computeExpectedIndicator(cz) |
| 277 self.addIndicator(indicators.SeverityIndicator(Interaction.indicatorNames[9], pPETs, mostSevereIsMax=False)) | 277 self.addIndicator(indicators.SeverityIndicator(Interaction.indicatorNames[9], pPETs, mostSevereIsMax=False)) |
| 278 # TODO add probability of collision, and probability of successful evasive action | 278 # TODO add probability of collision, and probability of successful evasive action |
| 279 | 279 |
| 280 def computePET(self, collisionDistanceThreshold): | 280 def computePET(self, collisionDistanceThreshold, computePetWithBoundingPoly): |
| 281 pet, t1, t2= moving.MovingObject.computePET(self.roadUser1, self.roadUser2, collisionDistanceThreshold) | 281 'Warning: when computing PET from interactions, there could be PETs between objects that do not coexist and therefore are not considered interactions' |
| 282 pet, t1, t2= moving.MovingObject.computePET(self.roadUser1, self.roadUser2, collisionDistanceThreshold, computePetWithBoundingPoly) | |
| 282 if pet is not None: | 283 if pet is not None: |
| 283 self.addIndicator(indicators.SeverityIndicator(Interaction.indicatorNames[10], {min(t1, t2): pet}, mostSevereIsMax = False)) | 284 self.addIndicator(indicators.SeverityIndicator(Interaction.indicatorNames[10], {min(t1, t2): pet}, mostSevereIsMax = False)) |
| 284 | 285 |
| 285 def setCollision(self, collision): | 286 def setCollision(self, collision): |
| 286 '''indicates if it is a collision: argument should be boolean''' | 287 '''indicates if it is a collision: argument should be boolean''' |
| 323 if i<len(interactions): | 324 if i<len(interactions): |
| 324 return interactions[i] | 325 return interactions[i] |
| 325 else: | 326 else: |
| 326 return None | 327 return None |
| 327 | 328 |
| 328 def computeIndicators(interactions, computeMotionPrediction, computePET, predictionParameters, collisionDistanceThreshold, timeHorizon, computeCZ = False, debug = False, timeInterval = None): | 329 def computeIndicators(interactions, computeMotionPrediction, computePET, predictionParameters, collisionDistanceThreshold, computePetWithBoundingPoly, timeHorizon, computeCZ = False, debug = False, timeInterval = None): |
| 329 for inter in interactions: | 330 for inter in interactions: |
| 330 print('processing interaction {}'.format(inter.getNum())) # logging.debug('processing interaction {}'.format(inter.getNum())) | 331 print('processing interaction {}'.format(inter.getNum())) # logging.debug('processing interaction {}'.format(inter.getNum())) |
| 331 inter.computeIndicators() | 332 inter.computeIndicators() |
| 332 if computeMotionPrediction: | 333 if computeMotionPrediction: |
| 333 inter.computeCrossingsCollisions(predictionParameters, collisionDistanceThreshold, timeHorizon, computeCZ, debug, timeInterval) | 334 inter.computeCrossingsCollisions(predictionParameters, collisionDistanceThreshold, timeHorizon, computeCZ, debug, timeInterval) |
| 334 if computePET: | 335 if computePET: |
| 335 inter.computePET(collisionDistanceThreshold) | 336 inter.computePET(collisionDistanceThreshold, computePetWithBoundingPoly) |
| 336 return interactions | 337 return interactions |
| 337 | 338 |
| 338 def aggregateSafetyPoints(interactions, pointType = 'collision'): | 339 def aggregateSafetyPoints(interactions, pointType = 'collision'): |
| 339 '''Put all collision points or crossing zones in a list for display''' | 340 '''Put all collision points or crossing zones in a list for display''' |
| 340 allPoints = [] | 341 allPoints = [] |
