Mercurial Hosting > traffic-intelligence
comparison scripts/safety-analysis.py @ 348:c64a4f889b97
added safety analysis options to feature tracking (with default values for backward compatibility)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 26 Jun 2013 18:40:31 -0400 |
parents | 14a2405f54f8 |
children | 7e9ad2d9d79c |
comparison
equal
deleted
inserted
replaced
347:7b865f4174aa | 348:c64a4f889b97 |
---|---|
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('configFilename', help = 'name of the configuration file') |
12 # parser.add_argument('-c', 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) |
13 #parser.add_argument('--time-horizon', dest = 'maxSpeed', help = 'maximum speed when predicting future motion (km/h)', default = 50, type = int) | |
13 args = parser.parse_args() | 14 args = parser.parse_args() |
14 print(args) | 15 |
15 # TODO work on the way to indicate an interaction definition | 16 # TODO work on the way to indicate an interaction definition |
16 | 17 |
17 # if False: # test if there is a configuration file? | 18 # if False: # test if there is a configuration file? |
18 params = utils.TrackingParameters() | 19 params = utils.TrackingParameters() |
19 params.loadConfigFile(args.configFilename) | 20 params.loadConfigFile(args.configFilename) |
20 | 21 |
21 # configuration parameters # TODO from command line | 22 # configuration parameters # TODO from command line |
22 frameRate = 15 # frame per second | 23 maxSpeed = args.maxSpeed/3.6/params.videoFrameRate # speed limit 50 km/h for urban envt, 90km/hr = 25 m/sec for highways |
23 maxSpeed = 90/3.6/frameRate # speed limit 50 km/h for urban envt, 90km/hr = 25 m/sec for highways | 24 timeHorizon= params.videoFrameRate*5 # prediction time Horizon = 1.5 s (reaction time) (5 second) |
24 timeHorizon= frameRate*5 # prediction time Horizon = 1.5 s (reaction time) (5 second) | |
25 collisionDistanceThreshold= 1.8 # m | 25 collisionDistanceThreshold= 1.8 # m |
26 computeCZ = True | 26 computeCZ = False |
27 | 27 |
28 display = False | 28 # display = False |
29 | 29 |
30 # parameters for prediction methods | 30 # parameters for prediction methods |
31 constantVelocityPredictionParameters = prediction.ConstantPredictionParameters(maxSpeed) | 31 constantVelocityPredictionParameters = prediction.ConstantPredictionParameters(maxSpeed) |
32 | 32 |
33 normalAdaptationPredictionParameters = prediction.NormalAdaptationPredictionParameters(maxSpeed, 100, 2./frameRate**2, # m/s2 | 33 normalAdaptationPredictionParameters = prediction.NormalAdaptationPredictionParameters(maxSpeed, 100, 2./frameRate**2, # m/s2 |
51 # features = storage.loadTrajectoriesFromSqlite('amherst-10.sqlite','feature') # needed if normal adaptation | 51 # features = storage.loadTrajectoriesFromSqlite('amherst-10.sqlite','feature') # needed if normal adaptation |
52 | 52 |
53 interactions = events.createInteractions(objects) | 53 interactions = events.createInteractions(objects) |
54 for inter in interactions: | 54 for inter in interactions: |
55 inter.computeIndicators() | 55 inter.computeIndicators() |
56 # inter.computeCrossingsCollisions(constantVelocityPredictionParameters, collisionDistanceThreshold, timeHorizon, computeCZ) | 56 inter.computeCrossingsCollisions(constantVelocityPredictionParameters, collisionDistanceThreshold, timeHorizon, computeCZ) |
57 | 57 |
58 storage.saveIndicators(params.databaseFilename, interactions) | 58 storage.saveIndicators(params.databaseFilename, interactions) |
59 | 59 |
60 if display: | 60 # if display: |
61 plt.figure() | 61 # plt.figure() |
62 plt.axis('equal') | 62 # plt.axis('equal') |
63 for inter in interactions[:2]: | 63 # for inter in interactions[:2]: |
64 for collisionPoints in inter.collisionPoints.values(): | 64 # for collisionPoints in inter.collisionPoints.values(): |
65 for cp in collisionPoints: | 65 # for cp in collisionPoints: |
66 plot([cp.x], [cp.y], 'x') | 66 # plot([cp.x], [cp.y], 'x') |
67 | 67 |
68 # for the demo, output automatically a map | 68 # for the demo, output automatically a map |
69 # possibility to process longitudinal coords only | 69 # possibility to process longitudinal coords only |
70 | 70 |