Mercurial > hg > nsaunier > traffic-intelligence
comparison scripts/safety-analysis.py @ 343:74e437ab5f11
first version of indicator loading code
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 21 Jun 2013 15:28:59 -0400 |
| parents | f3aceea2afbb |
| children | 14a2405f54f8 |
comparison
equal
deleted
inserted
replaced
| 342:4d69486869a5 | 343:74e437ab5f11 |
|---|---|
| 25 maxSpeed = 90/3.6/frameRate # speed limit 50 km/h for urban envt, 90km/hr = 25 m/sec for highways | 25 maxSpeed = 90/3.6/frameRate # speed limit 50 km/h for urban envt, 90km/hr = 25 m/sec for highways |
| 26 timeHorizon= frameRate*5 # prediction time Horizon = 1.5 s (reaction time) (5 second) | 26 timeHorizon= frameRate*5 # prediction time Horizon = 1.5 s (reaction time) (5 second) |
| 27 collisionDistanceThreshold= 1.8 # m | 27 collisionDistanceThreshold= 1.8 # m |
| 28 computeCZ = True | 28 computeCZ = True |
| 29 | 29 |
| 30 display = False | |
| 31 | |
| 30 # parameters for prediction methods | 32 # parameters for prediction methods |
| 31 constantVelocityPredictionParameters = prediction.ConstantPredictionParameters(maxSpeed) | 33 constantVelocityPredictionParameters = prediction.ConstantPredictionParameters(maxSpeed) |
| 32 | 34 |
| 33 normalAdaptationPredictionParameters = prediction.NormalAdaptationPredictionParameters(maxSpeed, 100, 2./frameRate**2, # m/s2 | 35 normalAdaptationPredictionParameters = prediction.NormalAdaptationPredictionParameters(maxSpeed, 100, 2./frameRate**2, # m/s2 |
| 34 0.2/frameRate) # rad/s | 36 0.2/frameRate) # rad/s |
| 50 objects = storage.loadTrajectoriesFromSqlite(params.databaseFilename,'object') | 52 objects = storage.loadTrajectoriesFromSqlite(params.databaseFilename,'object') |
| 51 # features = storage.loadTrajectoriesFromSqlite('amherst-10.sqlite','feature') # needed if normal adaptation | 53 # features = storage.loadTrajectoriesFromSqlite('amherst-10.sqlite','feature') # needed if normal adaptation |
| 52 | 54 |
| 53 interactions = events.createInteractions(objects) | 55 interactions = events.createInteractions(objects) |
| 54 for inter in interactions[:2]: | 56 for inter in interactions[:2]: |
| 55 inter.computeCrossingsCollisions(constantVelocityPredictionParameters, collisionDistanceThreshold, timeHorizon, computeCZ) | 57 inter.computeIndicators() |
| 58 # inter.computeCrossingsCollisions(constantVelocityPredictionParameters, collisionDistanceThreshold, timeHorizon, computeCZ) | |
| 56 | 59 |
| 57 plt.figure() | 60 storage.saveIndicators(params.databaseFilename, interactions) |
| 58 plt.axis('equal') | 61 |
| 59 for inter in interactions[:2]: | 62 if display: |
| 60 for collisionPoints in inter.collisionPoints.values(): | 63 plt.figure() |
| 61 for cp in collisionPoints: | 64 plt.axis('equal') |
| 62 plot([cp.x], [cp.y], 'x') | 65 for inter in interactions[:2]: |
| 66 for collisionPoints in inter.collisionPoints.values(): | |
| 67 for cp in collisionPoints: | |
| 68 plot([cp.x], [cp.y], 'x') | |
| 63 | 69 |
| 64 # for the demo, output automatically a map | 70 # for the demo, output automatically a map |
| 65 # possibility to process longitudinal coords only | 71 # possibility to process longitudinal coords only |
| 66 | 72 |
