Mercurial Hosting > traffic-intelligence
changeset 1104:1c59091853e0
generalization of motion prediction methods to curvilinear trajectories
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 11 Mar 2019 15:41:05 -0400 |
parents | 7594802f281a |
children | e62c2f5e25e6 |
files | trafficintelligence/prediction.py |
diffstat | 1 files changed, 18 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/trafficintelligence/prediction.py Fri Mar 01 13:17:44 2019 -0500 +++ b/trafficintelligence/prediction.py Mon Mar 11 15:41:05 2019 -0400 @@ -265,9 +265,10 @@ class PredictionParameters(object): - def __init__(self, name, maxSpeed): + def __init__(self, name, maxSpeed, useCurvilinear = False): self.name = name self.maxSpeed = maxSpeed + self.useCurvilinear = useCurvilinear def __str__(self): return '{0} {1}'.format(self.name, self.maxSpeed) @@ -523,26 +524,29 @@ using direct computation of the intersecting point (solving the equation) Warning: the computed time to collision may be higher than timeHorizon (not used)''' - def __init__(self): - PredictionParameters.__init__(self, 'constant velocity (direct exact computation)', None) + def __init__(self, useCurvilinear = False): + PredictionParameters.__init__(self, 'constant velocity (direct exact computation)', None, useCurvilinear) def computeCrossingsCollisionsAtInstant(self, currentInstant, obj1, obj2, collisionDistanceThreshold, timeHorizon, computeCZ = False, debug = False, *kwargs): 'TODO compute pPET' collisionPoints = [] crossingZones = [] - p1 = obj1.getPositionAtInstant(currentInstant) - p2 = obj2.getPositionAtInstant(currentInstant) - v1 = obj1.getVelocityAtInstant(currentInstant) - v2 = obj2.getVelocityAtInstant(currentInstant) - #intersection = moving.intersection(p1, p1+v1, p2, p2+v2) + if self.useCurvilinear: + pass # Lionel + else: + p1 = obj1.getPositionAtInstant(currentInstant) + p2 = obj2.getPositionAtInstant(currentInstant) + v1 = obj1.getVelocityAtInstant(currentInstant) + v2 = obj2.getVelocityAtInstant(currentInstant) + #intersection = moving.intersection(p1, p1+v1, p2, p2+v2) - if not moving.Point.parallel(v1, v2): - ttc = moving.Point.timeToCollision(p1, p2, v1, v2, collisionDistanceThreshold) - if ttc is not None: - collisionPoints = [SafetyPoint((p1+(v1*ttc)+p2+(v2*ttc))*0.5, 1., ttc)] - else: - pass # compute pPET + if not moving.Point.parallel(v1, v2): + ttc = moving.Point.timeToCollision(p1, p2, v1, v2, collisionDistanceThreshold) + if ttc is not None: + collisionPoints = [SafetyPoint((p1+(v1*ttc)+p2+(v2*ttc))*0.5, 1., ttc)] + else: + pass # compute pPET return collisionPoints, crossingZones