types are derived.
|
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.
|
DriverModel * | getDriver () |
| 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 |
DriverModel * | m_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 |
types are derived.
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:
-
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.
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.