Mercurial > hg > nsaunier > traffic-intelligence
comparison scripts/safety-analysis.py @ 350:7e9ad2d9d79c
added new parameters in safety analysis script
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Thu, 27 Jun 2013 00:18:39 -0400 |
| parents | c64a4f889b97 |
| children | 891858351bcb |
comparison
equal
deleted
inserted
replaced
| 349:e3f910c26fae | 350:7e9ad2d9d79c |
|---|---|
| 6 | 6 |
| 7 import matplotlib.pyplot as plt | 7 import matplotlib.pyplot as plt |
| 8 import numpy as np | 8 import numpy as np |
| 9 | 9 |
| 10 parser = argparse.ArgumentParser(description='The program processes indicators for all pairs of road users in the scene') | 10 parser = argparse.ArgumentParser(description='The program processes indicators for all pairs of road users in the scene') |
| 11 parser.add_argument('configFilename', help = 'name of the configuration file') | 11 parser.add_argument('--cfg', dest = 'configFilename', help = 'name of the configuration file') |
| 12 #parser.add_argument('--maxspeed', dest = 'maxSpeed', help = 'maximum speed when predicting future motion (km/h)', default = 50, type = int) | 12 #parser.add_argument('--maxspeed', dest = 'maxSpeed', help = 'maximum speed when predicting future motion (km/h)', default = 50, type = int) |
| 13 #parser.add_argument('--time-horizon', dest = 'maxSpeed', help = 'maximum speed when predicting future motion (km/h)', default = 50, type = int) | 13 #parser.add_argument('--time-horizon', dest = 'maxSpeed', help = 'maximum speed when predicting future motion (km/h)', default = 50, type = int) |
| 14 args = parser.parse_args() | 14 args = parser.parse_args() |
| 15 | 15 |
| 16 # TODO work on the way to indicate an interaction definition | 16 # TODO work on the way to indicate an interaction definition |
| 17 | 17 |
| 18 # if False: # test if there is a configuration file? | 18 # if False: # test if there is a configuration file? |
| 19 params = utils.TrackingParameters() | 19 params = utils.TrackingParameters() |
| 20 params.loadConfigFile(args.configFilename) | 20 params.loadConfigFile(args.configFilename) |
| 21 | 21 |
| 22 # configuration parameters # TODO from command line | 22 # parameters for prediction methods |
| 23 maxSpeed = args.maxSpeed/3.6/params.videoFrameRate # speed limit 50 km/h for urban envt, 90km/hr = 25 m/sec for highways | 23 constantVelocityPredictionParameters = prediction.ConstantPredictionParameters(params.maxPredictedSpeed) |
| 24 timeHorizon= params.videoFrameRate*5 # prediction time Horizon = 1.5 s (reaction time) (5 second) | |
| 25 collisionDistanceThreshold= 1.8 # m | |
| 26 computeCZ = False | |
| 27 | 24 |
| 28 # display = False | 25 normalAdaptationPredictionParameters = prediction.NormalAdaptationPredictionParameters(params.maxPredictedSpeed, |
| 26 params.nPredictedTrajectories, | |
| 27 params.maxAcceleration, | |
| 28 params.maxSteering) | |
| 29 | 29 |
| 30 # parameters for prediction methods | 30 featurePredictionParameters = prediction.PointSetPredictionParameters(params.maxPredictedSpeed, params.nPredictedTrajectories) |
| 31 constantVelocityPredictionParameters = prediction.ConstantPredictionParameters(maxSpeed) | |
| 32 | 31 |
| 33 normalAdaptationPredictionParameters = prediction.NormalAdaptationPredictionParameters(maxSpeed, 100, 2./frameRate**2, # m/s2 | 32 evasiveActionPredictionParameters = prediction.EvasiveActionPredictionParameters(params.maxPredictedSpeed, |
| 34 0.2/frameRate) # rad/s | 33 params.nPredictedTrajectories, |
| 35 | 34 params.minAcceleration, |
| 36 featurePredictionParameters = prediction.PointSetPredictionParameters(maxSpeed) | 35 params.maxAcceleration, |
| 37 | 36 params.maxSteering, |
| 38 evasiveActionPredictionParameters = prediction.EvasiveActionPredictionParameters(maxSpeed, 100, -9.1/frameRate**2, # m/s2 | |
| 39 4.3/frameRate**2, # m/s2 | |
| 40 0.5/frameRate, # rad/s | |
| 41 False) | 37 False) |
| 42 | 38 |
| 43 featureEvasiveActionPredictionParameters = prediction.EvasiveActionPredictionParameters(maxSpeed, 10, -9.1/frameRate**2, # m/s2 | 39 featureEvasiveActionPredictionParameters = prediction.EvasiveActionPredictionParameters(params.maxPredictedSpeed, |
| 44 4.3/frameRate**2, # m/s2 | 40 params.nPredictedTrajectories, |
| 45 0.5/frameRate, # rad/s | 41 params.minAcceleration, |
| 42 params.maxAcceleration, | |
| 43 params.maxSteering, | |
| 46 True) | 44 True) |
| 47 | 45 |
| 48 | 46 |
| 49 | 47 |
| 50 objects = storage.loadTrajectoriesFromSqlite(params.databaseFilename,'object') | 48 objects = storage.loadTrajectoriesFromSqlite(params.databaseFilename,'object') |
| 51 # features = storage.loadTrajectoriesFromSqlite('amherst-10.sqlite','feature') # needed if normal adaptation | 49 # features = storage.loadTrajectoriesFromSqlite('amherst-10.sqlite','feature') # needed if normal adaptation |
| 52 | 50 |
| 53 interactions = events.createInteractions(objects) | 51 interactions = events.createInteractions(objects) |
| 54 for inter in interactions: | 52 for inter in interactions: |
| 55 inter.computeIndicators() | 53 inter.computeIndicators() |
| 56 inter.computeCrossingsCollisions(constantVelocityPredictionParameters, collisionDistanceThreshold, timeHorizon, computeCZ) | 54 inter.computeCrossingsCollisions(constantVelocityPredictionParameters, params.collisionDistance, params.predictionTimeHorizon, params.crossingZones) |
| 57 | 55 |
| 58 storage.saveIndicators(params.databaseFilename, interactions) | 56 storage.saveIndicators(params.databaseFilename, interactions) |
| 59 | 57 |
| 60 # if display: | 58 # if display: |
| 61 # plt.figure() | 59 # plt.figure() |
