Mercurial Hosting > traffic-intelligence
changeset 466:e891a41c6c75
name change in prediction.py
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 05 Mar 2014 17:47:26 -0500 |
parents | 16fe64136506 |
children | 08b67c9baca2 5304299e53a5 |
files | python/prediction.py python/tests/prediction.txt |
diffstat | 2 files changed, 19 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/python/prediction.py Thu Feb 27 03:30:28 2014 -0500 +++ b/python/prediction.py Wed Mar 05 17:47:26 2014 -0500 @@ -47,8 +47,19 @@ def getControl(self): return self.control -class PredictedTrajectoryNormalAdaptation(PredictedTrajectory): - '''Random small adaptation of vehicle control ''' +class PredictedTrajectoryPrototype(PredictedTrajectory): + '''Predicted trajectory that follows a prototype trajectory + The prototype is in the format of a moving.Trajectory: it could be + 1. an observed trajectory (extracted from video) + 2. a generic polyline (eg the road centerline) that a vehicle is supposed to follow + + Prediction can be done + 1. at constant speed (the instant speed of the user''' + + def __init__(self) + +class PredictedTrajectoryRandomControl(PredictedTrajectory): + '''Random vehicle control: suitable for normal adaptation''' def __init__(self, initialPosition, initialVelocity, accelerationDistribution, steeringDistribution, probability = 1., maxSpeed = None): '''Constructor accelerationDistribution and steeringDistribution are distributions @@ -245,11 +256,11 @@ velocities = [obj.getVelocityAtInstant(instant)] for i in xrange(self.nPredictedTrajectories): for initialPosition,initialVelocity in zip(positions, velocities): - predictedTrajectories.append(PredictedTrajectoryNormalAdaptation(initialPosition, - initialVelocity, - self.accelerationDistribution, - self.steeringDistribution, - maxSpeed = self.maxSpeed)) + predictedTrajectories.append(PredictedTrajectoryRandomControl(initialPosition, + initialVelocity, + self.accelerationDistribution, + self.steeringDistribution, + maxSpeed = self.maxSpeed)) return predictedTrajectories class PointSetPredictionParameters(PredictionParameters):
--- a/python/tests/prediction.txt Thu Feb 27 03:30:28 2014 -0500 +++ b/python/tests/prediction.txt Wed Mar 05 17:47:26 2014 -0500 @@ -18,7 +18,7 @@ >>> import random >>> acceleration = lambda: random.uniform(-0.5,0.5) >>> steering = lambda: random.uniform(-0.1,0.1) ->>> et = prediction.PredictedTrajectoryNormalAdaptation(moving.Point(0,0),moving.Point(1,1), acceleration, steering, maxSpeed = 2) +>>> et = prediction.PredictedTrajectoryRandomControl(moving.Point(0,0),moving.Point(1,1), acceleration, steering, maxSpeed = 2) >>> p = et.predictPosition(500) >>> from numpy import max >>> max(et.getPredictedSpeeds()) <= 2.