Mercurial Hosting > traffic-intelligence
comparison scripts/safety-analysis.py @ 857:6d89520e269f
minor modifications to safety-analysis
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 06 Oct 2016 17:16:31 -0400 |
parents | 806df5f61c03 |
children | 8ba82b371eea |
comparison
equal
deleted
inserted
replaced
856:e310577cc0b8 | 857:6d89520e269f |
---|---|
10 # todo: very slow if too many predicted trajectories | 10 # todo: very slow if too many predicted trajectories |
11 # add computation of probality of unsucessful evasive action | 11 # add computation of probality of unsucessful evasive action |
12 | 12 |
13 parser = argparse.ArgumentParser(description='The program processes indicators for all pairs of road users in the scene') | 13 parser = argparse.ArgumentParser(description='The program processes indicators for all pairs of road users in the scene') |
14 parser.add_argument('--cfg', dest = 'configFilename', help = 'name of the configuration file', required = True) | 14 parser.add_argument('--cfg', dest = 'configFilename', help = 'name of the configuration file', required = True) |
15 parser.add_argument('-n', dest = 'nObjects', help = 'number of objects to analyse', type = int) | |
16 # TODO analyze only | |
15 parser.add_argument('--prediction-method', dest = 'predictionMethod', help = 'prediction method (constant velocity (vector computation), constant velocity, normal adaptation, point set prediction)', choices = ['cvd', 'cv', 'na', 'ps']) | 17 parser.add_argument('--prediction-method', dest = 'predictionMethod', help = 'prediction method (constant velocity (vector computation), constant velocity, normal adaptation, point set prediction)', choices = ['cvd', 'cv', 'na', 'ps']) |
16 parser.add_argument('--display-cp', dest = 'displayCollisionPoints', help = 'display collision points', action = 'store_true') | 18 parser.add_argument('--display-cp', dest = 'displayCollisionPoints', help = 'display collision points', action = 'store_true') |
17 parser.add_argument('-n', dest = 'nProcesses', help = 'number of processes to run in parallel', type = int, default = 1) | 19 parser.add_argument('--nthreads', dest = 'nProcesses', help = 'number of processes to run in parallel', type = int, default = 1) |
18 args = parser.parse_args() | 20 args = parser.parse_args() |
19 | 21 |
20 params = storage.ProcessParameters(args.configFilename) | 22 params = storage.ProcessParameters(args.configFilename) |
21 | 23 |
22 # parameters for prediction methods | 24 # parameters for prediction methods |
23 if args.predictionMethod: | 25 if args.predictionMethod is not None: |
24 predictionMethod = args.predictionMethod | 26 predictionMethod = args.predictionMethod |
25 else: | 27 else: |
26 predictionMethod = params.predictionMethod | 28 predictionMethod = params.predictionMethod |
27 | 29 |
28 def accelerationDistribution(): | 30 def accelerationDistribution(): |
49 # params.minExtremeAcceleration, | 51 # params.minExtremeAcceleration, |
50 # params.maxExtremeAcceleration, | 52 # params.maxExtremeAcceleration, |
51 # params.maxExtremeSteering, | 53 # params.maxExtremeSteering, |
52 # params.useFeaturesForPrediction) | 54 # params.useFeaturesForPrediction) |
53 | 55 |
54 objects = storage.loadTrajectoriesFromSqlite(params.databaseFilename,'object') | 56 objects = storage.loadTrajectoriesFromSqlite(params.databaseFilename, 'object', args.nObjects, withFeatures = params.useFeaturesForPrediction) |
55 if params.useFeaturesForPrediction: | 57 # if params.useFeaturesForPrediction: |
56 features = storage.loadTrajectoriesFromSqlite(params.databaseFilename,'feature') # needed if normal adaptation | 58 # features = storage.loadTrajectoriesFromSqlite(params.databaseFilename,'feature') # needed if normal adaptation |
57 for obj in objects: | 59 # for obj in objects: |
58 obj.setFeatures(features) | 60 # obj.setFeatures(features) |
59 | 61 |
60 interactions = events.createInteractions(objects) | 62 interactions = events.createInteractions(objects) |
61 for inter in interactions: | 63 for inter in interactions: |
62 inter.computeIndicators() | 64 inter.computeIndicators() |
63 inter.computeCrossingsCollisions(predictionParameters, params.collisionDistance, params.predictionTimeHorizon, params.crossingZones, nProcesses = args.nProcesses) | 65 inter.computeCrossingsCollisions(predictionParameters, params.collisionDistance, params.predictionTimeHorizon, params.crossingZones, nProcesses = args.nProcesses) |