Mercurial Hosting > traffic-intelligence
comparison python/prediction.py @ 881:8ba82b371eea
work on storing PET
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 14 Mar 2017 17:48:40 -0400 |
parents | 07c5eab11eba |
children | 40994bb43148 |
comparison
equal
deleted
inserted
replaced
880:000555430b28 | 881:8ba82b371eea |
---|---|
556 | 556 |
557 def __init__(self): | 557 def __init__(self): |
558 PredictionParameters.__init__(self, 'constant velocity (direct exact computation)', None) | 558 PredictionParameters.__init__(self, 'constant velocity (direct exact computation)', None) |
559 | 559 |
560 def computeCrossingsCollisionsAtInstant(self, currentInstant, obj1, obj2, collisionDistanceThreshold, timeHorizon, computeCZ = False, debug = False, *kwargs): | 560 def computeCrossingsCollisionsAtInstant(self, currentInstant, obj1, obj2, collisionDistanceThreshold, timeHorizon, computeCZ = False, debug = False, *kwargs): |
561 'TODO add collision point coordinates, compute pPET' | 561 'TODO compute pPET' |
562 #collisionPoints = [] | 562 collisionPoints = [] |
563 #crossingZones = [] | 563 crossingZones = [] |
564 | 564 |
565 p1 = obj1.getPositionAtInstant(currentInstant) | 565 p1 = obj1.getPositionAtInstant(currentInstant) |
566 p2 = obj2.getPositionAtInstant(currentInstant) | 566 p2 = obj2.getPositionAtInstant(currentInstant) |
567 v1 = obj1.getVelocityAtInstant(currentInstant) | 567 v1 = obj1.getVelocityAtInstant(currentInstant) |
568 v2 = obj2.getVelocityAtInstant(currentInstant) | 568 v2 = obj2.getVelocityAtInstant(currentInstant) |
569 intersection = moving.intersection(p1, p1+v1, p2, p2+v2) | 569 intersection = moving.intersection(p1, p1+v1, p2, p2+v2) |
570 | 570 |
571 if intersection is not None: | 571 if intersection is not None: |
572 ttc = moving.Point.timeToCollision(p1, p2, v1, v2, collisionDistanceThreshold) | 572 ttc = moving.Point.timeToCollision(p1, p2, v1, v2, collisionDistanceThreshold) |
573 if ttc: | 573 if ttc is not None: |
574 return currentInstant, [SafetyPoint(intersection, 1., ttc)], [] # (p1+v1.multiply(ttc)+p2+v2.multiply(ttc)).multiply(0.5) | 574 collisionPoints = SafetyPoint(intersection, 1., ttc) |
575 else: | 575 else: |
576 return currentInstant, [],[] | 576 pass # compute pPET |
577 | |
578 return currentInstant, collisionPoints, crossingZones | |
577 | 579 |
578 #### | 580 #### |
579 # Other Methods | 581 # Other Methods |
580 #### | 582 #### |
581 class PrototypePredictionParameters(PredictionParameters): | 583 class PrototypePredictionParameters(PredictionParameters): |