Mercurial > hg > nsaunier > traffic-intelligence
comparison python/prediction.py @ 466:e891a41c6c75
name change in prediction.py
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Wed, 05 Mar 2014 17:47:26 -0500 |
| parents | dcc821b98efc |
| children | 08b67c9baca2 |
comparison
equal
deleted
inserted
replaced
| 465:16fe64136506 | 466:e891a41c6c75 |
|---|---|
| 45 self.predictedSpeedOrientations = {0: moving.NormAngle.fromPoint(initialVelocity)} | 45 self.predictedSpeedOrientations = {0: moving.NormAngle.fromPoint(initialVelocity)} |
| 46 | 46 |
| 47 def getControl(self): | 47 def getControl(self): |
| 48 return self.control | 48 return self.control |
| 49 | 49 |
| 50 class PredictedTrajectoryNormalAdaptation(PredictedTrajectory): | 50 class PredictedTrajectoryPrototype(PredictedTrajectory): |
| 51 '''Random small adaptation of vehicle control ''' | 51 '''Predicted trajectory that follows a prototype trajectory |
| 52 The prototype is in the format of a moving.Trajectory: it could be | |
| 53 1. an observed trajectory (extracted from video) | |
| 54 2. a generic polyline (eg the road centerline) that a vehicle is supposed to follow | |
| 55 | |
| 56 Prediction can be done | |
| 57 1. at constant speed (the instant speed of the user''' | |
| 58 | |
| 59 def __init__(self) | |
| 60 | |
| 61 class PredictedTrajectoryRandomControl(PredictedTrajectory): | |
| 62 '''Random vehicle control: suitable for normal adaptation''' | |
| 52 def __init__(self, initialPosition, initialVelocity, accelerationDistribution, steeringDistribution, probability = 1., maxSpeed = None): | 63 def __init__(self, initialPosition, initialVelocity, accelerationDistribution, steeringDistribution, probability = 1., maxSpeed = None): |
| 53 '''Constructor | 64 '''Constructor |
| 54 accelerationDistribution and steeringDistribution are distributions | 65 accelerationDistribution and steeringDistribution are distributions |
| 55 that return random numbers drawn from them''' | 66 that return random numbers drawn from them''' |
| 56 self.accelerationDistribution = accelerationDistribution | 67 self.accelerationDistribution = accelerationDistribution |
| 243 else: | 254 else: |
| 244 positions = [obj.getPositionAtInstant(instant)] | 255 positions = [obj.getPositionAtInstant(instant)] |
| 245 velocities = [obj.getVelocityAtInstant(instant)] | 256 velocities = [obj.getVelocityAtInstant(instant)] |
| 246 for i in xrange(self.nPredictedTrajectories): | 257 for i in xrange(self.nPredictedTrajectories): |
| 247 for initialPosition,initialVelocity in zip(positions, velocities): | 258 for initialPosition,initialVelocity in zip(positions, velocities): |
| 248 predictedTrajectories.append(PredictedTrajectoryNormalAdaptation(initialPosition, | 259 predictedTrajectories.append(PredictedTrajectoryRandomControl(initialPosition, |
| 249 initialVelocity, | 260 initialVelocity, |
| 250 self.accelerationDistribution, | 261 self.accelerationDistribution, |
| 251 self.steeringDistribution, | 262 self.steeringDistribution, |
| 252 maxSpeed = self.maxSpeed)) | 263 maxSpeed = self.maxSpeed)) |
| 253 return predictedTrajectories | 264 return predictedTrajectories |
| 254 | 265 |
| 255 class PointSetPredictionParameters(PredictionParameters): | 266 class PointSetPredictionParameters(PredictionParameters): |
| 256 # todo generate several trajectories with normal adaptatoins from each position (feature) | 267 # todo generate several trajectories with normal adaptatoins from each position (feature) |
| 257 def __init__(self, nPredictedTrajectories, maxSpeed): | 268 def __init__(self, nPredictedTrajectories, maxSpeed): |
