Mercurial Hosting > traffic-intelligence
comparison python/prediction.py @ 701:4cc56ff82c3c dev
corrected bug for prediction at constant velocity, exact computation
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 17 Jul 2015 18:00:00 -0400 |
parents | 8d99a9e16644 |
children | 8b74a5176549 |
comparison
equal
deleted
inserted
replaced
700:0f1b6907643a | 701:4cc56ff82c3c |
---|---|
553 Warning: the computed time to collision may be higher than timeHorizon (not used)''' | 553 Warning: the computed time to collision may be higher than timeHorizon (not used)''' |
554 | 554 |
555 def __init__(self): | 555 def __init__(self): |
556 PredictionParameters.__init__(self, 'constant velocity (direct exact computation)', None) | 556 PredictionParameters.__init__(self, 'constant velocity (direct exact computation)', None) |
557 | 557 |
558 def computeCrossingsCollisionsAtInstant(self, currentInstant, obj1, obj2, collisionDistanceThreshold, timeHorizon, computeCZ = False, debug = False): | 558 def computeCrossingsCollisionsAtInstant(self, currentInstant, obj1, obj2, collisionDistanceThreshold, timeHorizon, computeCZ = False, debug = False, *kwargs): |
559 'TODO add collision point coordinates, compute pPET' | 559 'TODO add collision point coordinates, compute pPET' |
560 #collisionPoints = [] | 560 #collisionPoints = [] |
561 #crossingZones = [] | 561 #crossingZones = [] |
562 | 562 |
563 p1 = obj1.getPositionAtInstant(currentInstant) | 563 p1 = obj1.getPositionAtInstant(currentInstant) |
567 intersection = moving.intersection(p1, p1+v1, p2, p2+v2) | 567 intersection = moving.intersection(p1, p1+v1, p2, p2+v2) |
568 | 568 |
569 if intersection is not None: | 569 if intersection is not None: |
570 ttc = moving.Point.timeToCollision(p1, p2, v1, v2, collisionDistanceThreshold) | 570 ttc = moving.Point.timeToCollision(p1, p2, v1, v2, collisionDistanceThreshold) |
571 if ttc: | 571 if ttc: |
572 return [SafetyPoint(intersection, 1., ttc)], [] # (p1+v1.multiply(ttc)+p2+v2.multiply(ttc)).multiply(0.5) | 572 return currentInstant, [SafetyPoint(intersection, 1., ttc)], [] # (p1+v1.multiply(ttc)+p2+v2.multiply(ttc)).multiply(0.5) |
573 else: | 573 else: |
574 return [],[] | 574 return currentInstant, [],[] |
575 | 575 |
576 #### | 576 #### |
577 # Other Methods | 577 # Other Methods |
578 #### | 578 #### |
579 class PrototypePredictionParameters(PredictionParameters): | 579 class PrototypePredictionParameters(PredictionParameters): |