comparison python/prediction.py @ 295:ba29bd82bd04

added option to disable computation of crossing zones
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 11 Feb 2013 15:59:15 -0500
parents 9f81218e497a
children 586ead03fc00
comparison
equal deleted inserted replaced
294:1f253f218b9f 295:ba29bd82bd04
188 p1 = predictedTrajectory1.predictPosition(t) 188 p1 = predictedTrajectory1.predictPosition(t)
189 p2 = predictedTrajectory2.predictPosition(t) 189 p2 = predictedTrajectory2.predictPosition(t)
190 t += 1 190 t += 1
191 return t, p1, p2 191 return t, p1, p2
192 192
193 def computeCrossingsCollisionsAtInstant(currentInstant, obj1, obj2, predictionParameters, collisionDistanceThreshold, timeHorizon, debug = False): 193 def computeCrossingsCollisionsAtInstant(currentInstant, obj1, obj2, predictionParameters, collisionDistanceThreshold, timeHorizon, computeCZ = False, debug = False):
194 '''returns the lists of collision points and crossing zones 194 '''returns the lists of collision points and crossing zones
195 195
196 Check: Predicting all the points together, as if they represent the whole vehicle''' 196 Check: Predicting all the points together, as if they represent the whole vehicle'''
197 predictedTrajectories1 = predictionParameters.generatePredictedTrajectories(obj1, currentInstant) 197 predictedTrajectories1 = predictionParameters.generatePredictedTrajectories(obj1, currentInstant)
198 predictedTrajectories2 = predictionParameters.generatePredictedTrajectories(obj2, currentInstant) 198 predictedTrajectories2 = predictionParameters.generatePredictedTrajectories(obj2, currentInstant)
203 for et2 in predictedTrajectories2: 203 for et2 in predictedTrajectories2:
204 t, p1, p2 = computeCollisionTime(et1, et2, collisionDistanceThreshold, timeHorizon) 204 t, p1, p2 = computeCollisionTime(et1, et2, collisionDistanceThreshold, timeHorizon)
205 205
206 if t <= timeHorizon: 206 if t <= timeHorizon:
207 collisionPoints.append(SafetyPoint((p1+p2).multiply(0.5), et1.probability*et2.probability, t)) 207 collisionPoints.append(SafetyPoint((p1+p2).multiply(0.5), et1.probability*et2.probability, t))
208 else: # check if there is a crossing zone 208 elif computeCZ: # check if there is a crossing zone
209 # TODO? zone should be around the points at which the traj are the closest 209 # TODO? zone should be around the points at which the traj are the closest
210 # look for CZ at different times, otherwise it would be a collision 210 # look for CZ at different times, otherwise it would be a collision
211 # an approximation would be to look for close points at different times, ie the complementary of collision points 211 # an approximation would be to look for close points at different times, ie the complementary of collision points
212 cz = None 212 cz = None
213 t1 = 0 213 t1 = 0