tvaLib
Classes | Functions | Variables
lib.int Namespace Reference

Classes

class  Behaviour
 
class  Interaction
 
class  InteractionInstantDescriptor
 
class  SafetyPoint
 
class  UserPairs
 
class  VehicleSDRs
 

Functions

def computeCrossingsCollisionsWorker (userPairs, objOffset, predictionMethod, triage=False, collisionDistanceThreshold=1.8, timeHorizon=100, verbose=0)
 

Variables

 oldstdout
 
 stdout
 

Function Documentation

◆ computeCrossingsCollisionsWorker()

def lib.int.computeCrossingsCollisionsWorker (   userPairs,
  objOffset,
  predictionMethod,
  triage = False,
  collisionDistanceThreshold = 1.8,
  timeHorizon = 100,
  verbose = 0 
)
This is a worker function outside of the UserPairs object used to
    parallelize the computeCrossingsCollisions operations. 
    
    Notes:
    ======
    CPList from a computeCrossingsCollisions should have the format:
        [x,y,prob,TTC]

Definition at line 242 of file int.py.

242 def computeCrossingsCollisionsWorker(userPairs, objOffset, predictionMethod, triage=False, collisionDistanceThreshold=1.8, timeHorizon=100, verbose=0):
243  ''' This is a worker function outside of the UserPairs object used to
244  parallelize the computeCrossingsCollisions operations.
245 
246  Notes:
247  ======
248  CPList from a computeCrossingsCollisions should have the format:
249  [x,y,prob,TTC]
250  '''
251 
252  result = []
253  skipped_rates = []
254 
255 
256  if(type(timeHorizon) == int or type(timeHorizon) == float): timeHorizon_ = timeHorizon
257  else: timeHorizon_ = timeHorizon.value
258  if(type(verbose) == int): verbose_ = verbose
259  else: verbose_ = verbose.value
260  if(type(collisionDistanceThreshold) == float): collisionDistanceThreshold_ = collisionDistanceThreshold
261  else: collisionDistanceThreshold_ = collisionDistanceThreshold.value
262 
263 
264  if(predictionMethod.protocol == 'ccc'):
265  behaviour = Behaviour(predictionMethod.params.getMaxSteering(), predictionMethod.params.getMaxAcceleration(), predictionMethod.params.getMinAcceleration())
266  predictionMethod.setAccelerationDistribution(behaviour.accelerationDistribution)
267  predictionMethod.setSteeringDistribution(behaviour.steeringDistribution)
268 
269  prediction = predictionMethod.getPredictionClass()
270  for userPair in range(len(userPairs)):
271  CPList, CZList = prediction.computeCrossingsCollisions(userPairs[userPair].roadUser1, userPairs[userPair].roadUser2, collisionDistanceThreshold=collisionDistanceThreshold_, timeHorizon=timeHorizon_, computeCZ = False)
272  # Fix bug with probability reporting of Traffic-Intelligence
273  # TODO: submit bug report for this in TI
274  if(CPList):
275  for cpt in CPList:
276  for y in range(len(CPList[cpt])):
277  CPList[cpt][y].probability = CPList[cpt][y].probability/float(len(CPList[cpt]))
278  result.append({})
279  result[-1]['ix'] = objOffset+userPair
280  result[-1]['CP'] = CPList
281  result[-1]['CZ'] = CZList
282 
283 
284 
285  else:
286  prediction = predictionMethod.getPredictionClass()
287  for userPair in range(len(userPairs)):
288  result.append({})
289  result[-1]['ix'] = objOffset+userPair
290  result[-1]['CP'] = prediction.computeCrossingsCollisions(obj1=userPairs[userPair].roadUser1, obj2=userPairs[userPair].roadUser2, interval=userPairs[userPair].getTimeInterval(), triage=triage, timeHorizon=timeHorizon_, verbose=verbose_)
291  skipped_rates.append(1-len(result[-1]['CP'])/userPairs[userPair].getTimeInterval().length())
292  if(verbose >= 5): print(' Interaction instance skip rate: {0:.1f}%'.format(skipped_rates[-1]*100))
293 
294  return [result, skipped_rates]
295 
def computeCrossingsCollisionsWorker(userPairs, objOffset, predictionMethod, triage=False, collisionDistanceThreshold=1.8, timeHorizon=100, verbose=0)
Definition: int.py:242

Variable Documentation

◆ oldstdout

lib.int.oldstdout

Definition at line 22 of file int.py.

◆ stdout

lib.int.stdout

Definition at line 22 of file int.py.