Mercurial Hosting > traffic-intelligence
diff python/traffic_engineering.py @ 300:f65b828e5521
working on trajectory simulation
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 13 Feb 2013 18:26:49 -0500 |
parents | 82b4101d9a2f |
children | 9d88a4d97473 |
line wrap: on
line diff
--- a/python/traffic_engineering.py Tue Feb 12 18:08:00 2013 -0500 +++ b/python/traffic_engineering.py Wed Feb 13 18:26:49 2013 -0500 @@ -11,21 +11,34 @@ ######################### class Vehicle: - 'Generic vehicle class' - def __init__(self, position = 0, speed = 0, acceleration = 0, prt = 2.5, leader = None, log=True): - self.position = position - self.speed = speed - self.acceleration = acceleration + 'Generic vehicle class + 1D coordinates for now' + class PredictedTrajectory1D(prediction.PredictedTrajectory): + def __init__(self, initialPosition, initialSpeed, control, maxSpeed = None): + self.control = control + self.maxSpeed = maxSpeed + self.probability = None + self.predictedPositions = {0: moving.Point(initialPosition)} + self.predictedSpeedOrientations = {0: moving.NormAngle(initialSpeed, 0)} + + def setAcceleration(self, acceleration): + self.control = moving.NormAngle(acceleration, 0) + + def getControl(self): + return self.control + + + def __init__(self, initialPosition = 0, initialSpeed = 0, acceleration = 0, prt = 2.5, leader = None): + self.positions = PredictedTrajectory1D(initialPosition, initialSpeed) + self.prt = prt self.leader = leader - self.log = log - if log: - self.positions = [position] - self.speeds = [speed] - self.accelerations = [acceleration] - # todo add microModel + # todo add microModel (Treiber) - def updatePosition(self, dt): + def setAcceleration(self, acceleration): + self.positions.setAcceleration(acceleration) + + def updatePosition(self, dt): # knowledge of time outside of vehicle ?? speed = self.speed self.speed += self.acceleration*dt self.position += speed*dt