Vehicle Class Reference

A Base class from which specific Vehicle types are derived. More...

#include <Vehicle.h>

Inheritance diagram for Vehicle:

Inheritance graph
[legend]
Collaboration diagram for Vehicle:

Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual void doSAFTData (char *pTruck)
 Default implementation for printing SAFT data.
virtual void doCASTORData (char *pTruck)
 Default implementation for printing CASTOR data.
int DecideNextLane (double LeftAdv, double RightAdv)
double DecideLaneChange (Vehicle *frontVeh, Vehicle *backVeh, bool overtake)
 Vehicle ()
 Default Constructor.
virtual ~Vehicle ()
 Default Destructor.
void setChangeStatus (bool stat)
 Sets whether or not the Vehicle wishes to change lanes.
void setRoadPos (double r)
 Sets the position of the Vehicle on the road.
void setPos (double p)
 Sets the position of the Vehicle to a given value.
void setAccel (double acceler)
 Sets the acceleration of the Vehicle to a given value.
void setLength (double length)
 Sets the length of the Vehicle to a given value.
void setVelocity (double velocity)
 Sets the velocity of the Vehicle to a given value.
void setLane (int l)
 Sets the lane that the Vehicle is in.
void setDirection (bool DirPointsRight)
 Sets the direction of the Vehicle.
bool getChangeStatus ()
 Gets whether or not the Vehicle wishes to change lane.
double getRoadPos ()
 Gets the position of the Vehicle on the road.
double getPos ()
 Gets the Vehicle's position.
double getDesiredVel ()
 Gets the desired velocity of the Vehicle's driver model.
double getAccel ()
 Gets the acceleration of the Vehicle.
double getLength ()
 Gets the length of the Vehicle.
double getVelocity ()
 Gets the velocity of the Vehicle.
double getLane ()
 Gets the lane that the Vehicle is in.
bool getDirection ()
 Gets the direction that the Vehicle is travelling in.
DriverModelgetDriver ()
 Gets the Vehicle's DriverModel.
void setDriver (IDM driver)
 Sets the Vehicle's DriverModel.
void updateProperties (double step, double accel)
 Updates the velocity, acceleration and position of the Vehicle based its acceleration and the timestep.
void update (double step, Vehicle *pV)
 Updates the position of the Vehicle based on the timestep and preceding Vehicle.
void update (double step)
 Updates the position of the Vehicle based on the timestep.
int getID ()
 Gets the class of the Vehicle.
double calcAccel ()
 Calculates a Vehicle's acceleration when unimpeded by other Vehicles.
bool changeTime (double step)
 Handles the timer for checking Lane changes.
double calcAccel (Vehicle *pV)
 Calculates a Vehicle's acceleration based on properties of the preceding Vehicle.
int DecideLaneChange (Vehicle *LeftFrontVehicle, Vehicle *LeftBackVehicle, Vehicle *RightFrontVehicle, Vehicle *RightBackVehicle, bool LeftLaneExists, bool RightLaneExists)
 Handles whether or not the Vehicle will change Lane.

Protected Member Functions

double LaneChangeAdvantage (Vehicle *FrontVehicle, Vehicle *BackVehicle, bool overtake)
 Gets the advantage a Vehicle would gain from switching Lanes.

Protected Attributes

DriverModelm_pDriver
IDM m_IDMDriver
double len
double vel
double acc
double lane
double m_x
bool m_DirPointsToRight
double roadPos
int ID
bool laneChange
double tdelay


Detailed Description

A Base class from which specific Vehicle types are derived.

Constructor & Destructor Documentation

Vehicle::Vehicle (  ) 

Default Constructor.

Vehicle::~Vehicle (  )  [virtual]

Default Destructor.


Member Function Documentation

void Vehicle::doSAFTData ( char *  pTruck  )  [virtual]

Default implementation for printing SAFT data.

Parameters:
pTruck The string to print the information to

Reimplemented in Truck.

void Vehicle::doCASTORData ( char *  pTruck  )  [virtual]

Default implementation for printing CASTOR data.

Parameters:
pTruck The string to print the information to

Reimplemented in Truck.

int Vehicle::DecideNextLane ( double  LeftAdv,
double  RightAdv 
)

double Vehicle::DecideLaneChange ( Vehicle frontVeh,
Vehicle backVeh,
bool  overtake 
)

void Vehicle::setChangeStatus ( bool  stat  ) 

Sets whether or not the Vehicle wishes to change lanes.

Parameters:
stat whether or not the Vehicle wants to change lanes

void Vehicle::setRoadPos ( double  r  ) 

Sets the position of the Vehicle on the road.

For graphical use

Parameters:
r the Vehicle's position on the road

void Vehicle::setPos ( double  p  ) 

Sets the position of the Vehicle to a given value.

Parameters:
p the Vehicle's position

void Vehicle::setAccel ( double  acceler  ) 

Sets the acceleration of the Vehicle to a given value.

Parameters:
acceler the Vehicle's new acceleration

void Vehicle::setLength ( double  length  ) 

Sets the length of the Vehicle to a given value.

Parameters:
length The Vehicle's new length

void Vehicle::setVelocity ( double  velocity  ) 

Sets the velocity of the Vehicle to a given value.

Parameters:
velocity the Vehicle's new velocity

void Vehicle::setLane ( int  l  ) 

Sets the lane that the Vehicle is in.

Parameters:
l the Vehicle's lane

void Vehicle::setDirection ( bool  DirPointsRight  ) 

Sets the direction of the Vehicle.

Parameters:
DirPointsRight Whether the vehicle is in a positive or negative direction

bool Vehicle::getChangeStatus (  ) 

Gets whether or not the Vehicle wishes to change lane.

Returns:
laneChange whether or not the Vehicle wishes to change lane

double Vehicle::getRoadPos (  ) 

Gets the position of the Vehicle on the road.

Graphical use

Returns:
roadPos the position of the Vehicle on the road

double Vehicle::getPos (  ) 

Gets the Vehicle's position.

Returns:
m_x the Vehicle's position

double Vehicle::getDesiredVel (  ) 

Gets the desired velocity of the Vehicle's driver model.

Returns:
the driver model's desired velocity

double Vehicle::getAccel (  ) 

Gets the acceleration of the Vehicle.

Returns:
acc the acceleration of the Vehicle

double Vehicle::getLength (  ) 

Gets the length of the Vehicle.

Returns:
len the length of the Vehicle

double Vehicle::getVelocity (  ) 

Gets the velocity of the Vehicle.

Returns:
vel the velocity of the Vehicle

double Vehicle::getLane (  ) 

Gets the lane that the Vehicle is in.

Returns:
lane the Vehicle's lane

bool Vehicle::getDirection (  ) 

Gets the direction that the Vehicle is travelling in.

Returns:
dir the Vehicle's direction

DriverModel * Vehicle::getDriver (  ) 

Gets the Vehicle's DriverModel.

Returns:
the Vehicle's driver

void Vehicle::setDriver ( IDM  driver  ) 

Sets the Vehicle's DriverModel.

Parameters:
driver The Vehicle's driver

void Vehicle::updateProperties ( double  step,
double  accel 
)

Updates the velocity, acceleration and position of the Vehicle based its acceleration and the timestep.

Parameters:
step The timestep
accel The Vehicle's acceleration
This function updates the properties of the Vehicle based on how much it has accelerated in the previous timestep, assuming average velocity over the timestep. The velocity, and acceleration of the Vehicle are updated, as well as the Vehicle's position.

void Vehicle::update ( double  step,
Vehicle pV 
)

Updates the position of the Vehicle based on the timestep and preceding Vehicle.

Parameters:
step the timestep
pV a pointer to the Vehicle in front of this one
Every Vehicle in the Lane will call this function except the head of the Lane. The velocity and acceleration of the Vehicle will be altered based on the velocity of, and distance to, the Vehicle in front. This function also handles the timer for when the Vehicle will check to see if changing Lane would be advantageous.

void Vehicle::update ( double  step  ) 

Updates the position of the Vehicle based on the timestep.

Parameters:
step the timestep
The Vehicle calling this function will always be the head of traffic in its particular Lane, as it has no Vehicle in front to reference and instead drives towards the end of the Road This function also handles the timer for when the Vehicle will check to see if changing Lane would be advantageous.

int Vehicle::getID (  ) 

Gets the class of the Vehicle.

Returns:
ID the Vehicle's class

double Vehicle::calcAccel (  ) 

Calculates a Vehicle's acceleration when unimpeded by other Vehicles.

This function serves the purpose of determining the acceleration of a Vehicle when there are no other Vehicles in front of it in the same Lane. Based on the distance to the end of the Road, the DriverModel alters acceleration accordingly

bool Vehicle::changeTime ( double  step  ) 

Handles the timer for checking Lane changes.

Parameters:
step The timestep
Returns:
Whether or not it is time to check for a Lane change

double Vehicle::calcAccel ( Vehicle pV  ) 

Calculates a Vehicle's acceleration based on properties of the preceding Vehicle.

Parameters:
pV A pointer to the preceding Vehicle
This function serves the purpose of determining the acceleration of a Vehicle when there is another Vehicle in front of it in the same Lane. Based on the distance between the two vehicles, and the difference in their velocity, the DriverModel alters acceleration accordingly.

int Vehicle::DecideLaneChange ( Vehicle LeftFrontVehicle,
Vehicle LeftBackVehicle,
Vehicle RightFrontVehicle,
Vehicle RightBackVehicle,
bool  LeftLaneExists,
bool  RightLaneExists 
)

Handles whether or not the Vehicle will change Lane.

Parameters:
LeftFrontVehicle The Vehicle in front in the Left Lane
LeftBackVehicle The Vehicle behind in the Left Lane
RightFrontVehicle The Vehicle in front in the Right Lane
RightBackVehicle The Vehicle behind in the Right Lane
LeftLaneExists Whether or not there is a Lane to the left
RightLaneExists Whether or not there is a Lane to the Right
Returns:
The Lane to change to
See also:
LaneChangeAdvantage()
This function determines which Lane the Vehicle should change to if it changes Lane at all. Pointers to Vehicles that would be in front of, and behind, the current Vehicle if it were in either the right or left Lane are passed to the function, along with identifiers which specify whether or not there exists a Lane to the left or right of the current Lane.

double Vehicle::LaneChangeAdvantage ( Vehicle FrontVehicle,
Vehicle BackVehicle,
bool  overtake 
) [protected]

Gets the advantage a Vehicle would gain from switching Lanes.

Parameters:
FrontVehicle The Vehicle in front in the new Lane
BackVehicle The Vehicle behind in the new Lane
overtake Whether the Vehicle is overtaking or undertaking
Returns:
The net advantage of the Lane change
This function takes pointers to the Vehicles both in front, and behind, the position that the current Vehicle would have in the new Lane. If the Vehicle that would be in front is null, then the change in acceleration is decided with relation to acceleration on an open Road. Otherwise, the acceleration is decided with relation to the Vehicle in front.


Member Data Documentation

double Vehicle::len [protected]

double Vehicle::vel [protected]

double Vehicle::acc [protected]

double Vehicle::lane [protected]

double Vehicle::m_x [protected]

bool Vehicle::m_DirPointsToRight [protected]

double Vehicle::roadPos [protected]

int Vehicle::ID [protected]

bool Vehicle::laneChange [protected]

double Vehicle::tdelay [protected]


The documentation for this class was generated from the following files:

Generated on Fri Jul 25 16:11:23 2008 for EvolveTraffic by  doxygen 1.5.6