SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSVehicleType Class Reference

The car-following model and parameter. More...

#include <MSVehicleType.h>

Public Member Functions

bool amVehicleSpecific () const
 Returns whether this type belongs to a single vehicle only (was modified)
const SUMOVTypeParametergetParameter () const
 MSVehicleType (const SUMOVTypeParameter &parameter)
 Constructor.
bool wasSet (int what) const
 Returns whether the given parameter was set.
virtual ~MSVehicleType ()
 Destructor.
Atomar getter for simulation
const std::string & getID () const
 Returns the name of the vehicle type.
int getNumericalID () const
 Returns the running index of the vehicle type.
SUMOReal getLength () const
 Get vehicle's length [m].
SUMOReal getLengthWithGap () const
 Get vehicle's length including the minimum gap [m].
SUMOReal getMinGap () const
 Get the free space in front of vehicles of this class.
const MSCFModelgetCarFollowModel () const
 Returns the vehicle type's car following model definition (const version)
MSCFModelgetCarFollowModel ()
 Returns the vehicle type's car following model definition (non-const version)
LaneChangeModel getLaneChangeModel () const
SUMOReal getMaxSpeed () const
 Get vehicle's maximum speed [m/s].
SUMOReal computeChosenSpeedDeviation (MTRand &rng, const SUMOReal minDevFactor=0.2) const
 Computes and returns the speed deviation.
SUMOReal getDefaultProbability () const
 Get the default probability of this vehicle type.
SUMOVehicleClass getVehicleClass () const
 Get this vehicle type's vehicle class.
SUMOEmissionClass getEmissionClass () const
 Get this vehicle type's emission class.
const RGBColorgetColor () const
 Returns this type's color.
SUMOReal getSpeedFactor () const
 Returns this type's speed factor.
SUMOReal getSpeedDeviation () const
 Returns this type's speed deviation.
SUMOReal getImpatience () const
 Returns this type's impatience.
Atomar getter for visualization
SUMOReal getWidth () const
 Get the width which vehicles of this class shall have when being drawn.
SUMOReal getHeight () const
 Get the height which vehicles of this class shall have when being drawn.
SUMOVehicleShape getGuiShape () const
 Get this vehicle type's shape.
std::string getOSGFile () const
 Get this vehicle type's 3D model file name.
std::string getImgFile () const
 Get this vehicle type's raster model file name.
Setter methods
void setLength (const SUMOReal &length)
 Set a new value for this type's length.
void setMinGap (const SUMOReal &minGap)
 Set a new value for this type's minimum gap.
void setMaxSpeed (const SUMOReal &maxSpeed)
 Set a new value for this type's maximum speed.
void setVClass (SUMOVehicleClass vclass)
 Set a new value for this type's vehicle class.
void setDefaultProbability (const SUMOReal &prob)
 Set a new value for this type's default probability.
void setSpeedFactor (const SUMOReal &factor)
 Set a new value for this type's speed factor.
void setSpeedDeviation (const SUMOReal &dev)
 Set a new value for this type's speed deviation.
void setEmissionClass (SUMOEmissionClass eclass)
 Set a new value for this type's emission class.
void setColor (const RGBColor &color)
 Set a new value for this type's color.
void setWidth (const SUMOReal &width)
 Set a new value for this type's width.
void setShape (SUMOVehicleShape shape)
 Set a new value for this type's shape.
void setImpatience (const SUMOReal impatience)
 Set a new value for this type's impatience.

Static Public Member Functions

Static methods for building vehicle types
static MSVehicleTypebuild (SUMOVTypeParameter &from)
 Builds the microsim vehicle type described by the given parameter.
static MSVehicleTypebuild (const std::string &id, const MSVehicleType *from)
 Duplicates the microsim vehicle type giving it a the given id.

Private Member Functions

 MSVehicleType (const MSVehicleType &)
 Invalidated copy constructor.
MSVehicleTypeoperator= (const MSVehicleType &)
 Invalidated assignment operator.

Private Attributes

MSCFModelmyCarFollowModel
 ID of the car following model.
const int myIndex
 the running index
const MSVehicleTypemyOriginalType
 The original type.
SUMOVTypeParameter myParameter
 the parameter container

Static Private Attributes

static int myNextIndex = 0
 next value for the running index

Detailed Description

The car-following model and parameter.

MSVehicleType stores the parameter of a single vehicle type and methods that use these for computing the vehicle's car-following behavior

It is assumed that within the simulation many vehicles are using the same vehicle type, quite common is using only one vehicle type for all vehicles.

You can think of it like of having a vehicle type for each VW Golf or Ford Mustang in your simulation while the car instances just refer to it.

Definition at line 74 of file MSVehicleType.h.

Constructor & Destructor Documentation

MSVehicleType::MSVehicleType ( const SUMOVTypeParameter parameter)

Constructor.

Parameters
[in]parameterThe vehicle type's parameter

Definition at line 66 of file MSVehicleType.cpp.

References getLength(), and getMaxSpeed().

Referenced by build().

MSVehicleType::~MSVehicleType ( )
virtual

Destructor.

Definition at line 73 of file MSVehicleType.cpp.

References myCarFollowModel.

MSVehicleType::MSVehicleType ( const MSVehicleType )
private

Invalidated copy constructor.

Member Function Documentation

bool MSVehicleType::amVehicleSpecific ( ) const
inline

Returns whether this type belongs to a single vehicle only (was modified)

Returns
Whether this vehicle type is based on a differen one, and belongs to one vehicle only

Definition at line 405 of file MSVehicleType.h.

References myOriginalType.

Referenced by MSVehicle::replaceVehicleType(), and MSVehicle::~MSVehicle().

MSVehicleType * MSVehicleType::build ( const std::string &  id,
const MSVehicleType from 
)
static

Duplicates the microsim vehicle type giving it a the given id.

Parameters
[in]idThe new id of the type
[in]fromThe vehicle type
Returns
The built vehicle type

Definition at line 260 of file MSVehicleType.cpp.

References MSCFModel::duplicate(), SUMOVTypeParameter::id, MSVehicleType(), myCarFollowModel, myOriginalType, and myParameter.

SUMOReal MSVehicleType::computeChosenSpeedDeviation ( MTRand rng,
const SUMOReal  minDevFactor = 0.2 
) const

Computes and returns the speed deviation.

Returns
A new, random speed deviation

Definition at line 79 of file MSVehicleType.cpp.

References MAX2(), MIN2(), myParameter, RandHelper::randNorm(), SUMOVTypeParameter::speedDev, SUMOVTypeParameter::speedFactor, and SUMOReal.

Referenced by GUIVehicleControl::buildVehicle(), MSVehicleControl::buildVehicle(), and MSVehicle::MSVehicle().

const MSCFModel& MSVehicleType::getCarFollowModel ( ) const
inline
MSCFModel& MSVehicleType::getCarFollowModel ( )
inline

Returns the vehicle type's car following model definition (non-const version)

Returns
The vehicle type's car following model definition

Definition at line 150 of file MSVehicleType.h.

References myCarFollowModel.

const RGBColor& MSVehicleType::getColor ( ) const
inline

Returns this type's color.

Returns
The color of this type

Definition at line 203 of file MSVehicleType.h.

References SUMOVTypeParameter::color, and myParameter.

Referenced by TraCIServerAPI_VehicleType::getVariable().

SUMOReal MSVehicleType::getDefaultProbability ( ) const
inline

Get the default probability of this vehicle type.

Returns
The probability to use this type

Definition at line 177 of file MSVehicleType.h.

References SUMOVTypeParameter::defaultProbability, and myParameter.

Referenced by MSRouteHandler::myEndElement(), MSRouteHandler::openVehicleTypeDistribution(), and setDefaultProbability().

SUMOVehicleShape MSVehicleType::getGuiShape ( ) const
inline

Get this vehicle type's shape.

Returns
The shape of this vehicle type
See Also
SUMOVehicleShape

Definition at line 255 of file MSVehicleType.h.

References myParameter, and SUMOVTypeParameter::shape.

Referenced by GUIVehicle::drawAction_drawVehicleAsPoly(), and TraCIServerAPI_VehicleType::getVariable().

SUMOReal MSVehicleType::getHeight ( ) const
inline

Get the height which vehicles of this class shall have when being drawn.

Returns
The height of this type's vehicles

Definition at line 247 of file MSVehicleType.h.

References SUMOVTypeParameter::height, and myParameter.

std::string MSVehicleType::getImgFile ( ) const
inline

Get this vehicle type's raster model file name.

Returns
The raster file name of this vehicle type

Definition at line 270 of file MSVehicleType.h.

References SUMOVTypeParameter::imgFile, and myParameter.

Referenced by GUIPerson::drawAction_drawAsImage(), and GUIVehicle::drawAction_drawVehicleAsImage().

SUMOReal MSVehicleType::getImpatience ( ) const
inline

Returns this type's impatience.

Returns
The impatience of this type

Definition at line 227 of file MSVehicleType.h.

References SUMOVTypeParameter::impatience, and myParameter.

Referenced by setImpatience().

LaneChangeModel MSVehicleType::getLaneChangeModel ( ) const
inline

Definition at line 155 of file MSVehicleType.h.

References SUMOVTypeParameter::lcModel, and myParameter.

Referenced by MSVehicle::MSVehicle().

SUMOReal MSVehicleType::getLength ( ) const
inline

Get vehicle's length [m].

Returns
The length vehicles of this type have in m

Definition at line 118 of file MSVehicleType.h.

References SUMOVTypeParameter::length, and myParameter.

Referenced by MSCFModel_Wiedemann::_v(), MSVehicle::checkRewindLinkLanes(), MSInductLoop::collectVehiclesOnDet(), MSLane::detectCollisions(), MSE2Collector::detectorUpdate(), GUIPerson::drawAction_drawAsImage(), GUIVehicle::drawAction_drawRailCarriages(), GUIVehicle::drawAction_drawVehicleAsImage(), GUIVehicle::drawAction_drawVehicleAsPoly(), GUIVehicle::drawAction_drawVehicleAsTrianglePlus(), GUIVehicle::drawGL(), MSLane::enteredByLaneChange(), MSVehicle::enterLaneAtInsertion(), MSVehicle::enterLaneAtLaneChange(), MSVehicle::executeMove(), MSLane::executeMovements(), MSLane::freeInsertion(), MSVehicle::getAngle(), MSLane::getBruttoOccupancy(), MSLane::getLastVehicleInformation(), MSVehicle::getLeader(), MSLane::getLeaderOnConsecutive(), MSLane::getNettoOccupancy(), GUIVehicle::getParameterWindow(), MSLaneChanger::getRealFollower(), MSLaneChanger::getRealThisLeader(), TraCIServerAPI_VehicleType::getVariable(), MSLane::incorporateVehicle(), MSLCM_JE2013::informFollower(), MSLCM_LC2013::informFollower(), MSLCM_JE2013::informLeader(), MSLCM_LC2013::informLeader(), MSLane::insertVehicle(), MSLane::integrateNewVehicle(), MSLane::isInsertionSuccess(), MSInductLoop::leaveDetectorByMove(), MSLane::leftByLaneChange(), MSLane::maxSpeedGapInsertion(), MSLink::maybeOccupied(), MSVehicleType(), MSE2Collector::notifyEnter(), MSE2Collector::notifyLeave(), MSInstantInductLoop::notifyMove(), MSMeanData::MeanDataValues::notifyMove(), MSInductLoop::notifyMove(), MSE2Collector::notifyMove(), MSMeanData_Net::MSLaneMeanDataValues::notifyMoveInternal(), MSVehicle::planMoveInternal(), MSAbstractLaneChangeModel::predInteraction(), MSVehicle::processNextStop(), MSLane::pWagGenericInsertion(), MSLane::pWagSimpleInsertion(), MSLane::removeVehicle(), GUIVehicle::selectBlockingFoes(), MSLink::setApproaching(), setLength(), MSInstantInductLoop::write(), and MSQueueExport::writeLane().

int MSVehicleType::getNumericalID ( ) const
inline

Returns the running index of the vehicle type.

Returns
This type's numerical id

Definition at line 110 of file MSVehicleType.h.

References myIndex.

Referenced by MSAmitranTrajectories::writeVehicle().

std::string MSVehicleType::getOSGFile ( ) const
inline

Get this vehicle type's 3D model file name.

Returns
The model file name of this vehicle type

Definition at line 262 of file MSVehicleType.h.

References myParameter, and SUMOVTypeParameter::osgFile.

const SUMOVTypeParameter& MSVehicleType::getParameter ( ) const
inline
SUMOReal MSVehicleType::getSpeedDeviation ( ) const
inline

Returns this type's speed deviation.

Returns
The speed deviation of this type

Definition at line 219 of file MSVehicleType.h.

References myParameter, and SUMOVTypeParameter::speedDev.

Referenced by TraCIServerAPI_VehicleType::getVariable(), MSVehicle::MSVehicle(), and setSpeedDeviation().

SUMOReal MSVehicleType::getSpeedFactor ( ) const
inline

Returns this type's speed factor.

Returns
The speed factor of this type

Definition at line 211 of file MSVehicleType.h.

References myParameter, and SUMOVTypeParameter::speedFactor.

Referenced by TraCIServerAPI_VehicleType::getVariable(), MSVehicle::MSVehicle(), and setSpeedFactor().

SUMOVehicleClass MSVehicleType::getVehicleClass ( ) const
inline
MSVehicleType& MSVehicleType::operator= ( const MSVehicleType )
private

Invalidated assignment operator.

void MSVehicleType::setColor ( const RGBColor color)

Set a new value for this type's color.

Parameters
[in]colorThe new color of this type

Definition at line 161 of file MSVehicleType.cpp.

References SUMOVTypeParameter::color, and myParameter.

Referenced by TraCIServerAPI_VehicleType::setVariable().

void MSVehicleType::setDefaultProbability ( const SUMOReal prob)

Set a new value for this type's default probability.

If the given value<0 then the one from the original type will be used.

Parameters
[in]probThe new default probability of this type

Definition at line 125 of file MSVehicleType.cpp.

References SUMOVTypeParameter::defaultProbability, getDefaultProbability(), myOriginalType, and myParameter.

void MSVehicleType::setEmissionClass ( SUMOEmissionClass  eclass)

Set a new value for this type's emission class.

Parameters
[in]eclassThe new emission class of this type

Definition at line 155 of file MSVehicleType.cpp.

References SUMOVTypeParameter::emissionClass, and myParameter.

Referenced by TraCIServerAPI_VehicleType::setVariable().

void MSVehicleType::setImpatience ( const SUMOReal  impatience)

Set a new value for this type's impatience.

Parameters
[in]impatienceThe new impatience of this type

Definition at line 177 of file MSVehicleType.cpp.

References getImpatience(), SUMOVTypeParameter::impatience, myOriginalType, and myParameter.

void MSVehicleType::setLength ( const SUMOReal length)

Set a new value for this type's length.

If the given value<0 then the one from the original type will be used.

Parameters
[in]lengthThe new length of this type

Definition at line 89 of file MSVehicleType.cpp.

References getLength(), SUMOVTypeParameter::length, myOriginalType, and myParameter.

Referenced by TraCIServerAPI_VehicleType::setVariable().

void MSVehicleType::setMaxSpeed ( const SUMOReal maxSpeed)

Set a new value for this type's maximum speed.

If the given value<0 then the one from the original type will be used.

Parameters
[in]maxSpeedThe new maximum speed of this type

Definition at line 109 of file MSVehicleType.cpp.

References getMaxSpeed(), SUMOVTypeParameter::maxSpeed, myOriginalType, and myParameter.

Referenced by TraCIServerAPI_VehicleType::setVariable().

void MSVehicleType::setMinGap ( const SUMOReal minGap)

Set a new value for this type's minimum gap.

If the given value<0 then the one from the original type will be used.

Parameters
[in]minGapThe new minimum gap of this type

Definition at line 99 of file MSVehicleType.cpp.

References getMinGap(), SUMOVTypeParameter::minGap, myOriginalType, and myParameter.

Referenced by TraCIServerAPI_VehicleType::setVariable().

void MSVehicleType::setShape ( SUMOVehicleShape  shape)

Set a new value for this type's shape.

Parameters
[in]shapeThe new shape of this type

Definition at line 187 of file MSVehicleType.cpp.

References myParameter, and SUMOVTypeParameter::shape.

Referenced by TraCIServerAPI_VehicleType::setVariable().

void MSVehicleType::setSpeedDeviation ( const SUMOReal dev)

Set a new value for this type's speed deviation.

If the given value<0 then the one from the original type will be used.

Parameters
[in]devThe new speed deviation of this type

Definition at line 145 of file MSVehicleType.cpp.

References getSpeedDeviation(), myOriginalType, myParameter, and SUMOVTypeParameter::speedDev.

Referenced by TraCIServerAPI_VehicleType::setVariable().

void MSVehicleType::setSpeedFactor ( const SUMOReal factor)

Set a new value for this type's speed factor.

If the given value<0 then the one from the original type will be used.

Parameters
[in]factorThe new speed factor of this type

Definition at line 135 of file MSVehicleType.cpp.

References getSpeedFactor(), myOriginalType, myParameter, and SUMOVTypeParameter::speedFactor.

Referenced by TraCIServerAPI_VehicleType::setVariable().

void MSVehicleType::setVClass ( SUMOVehicleClass  vclass)

Set a new value for this type's vehicle class.

Parameters
[in]vclassThe new vehicle class of this type

Definition at line 119 of file MSVehicleType.cpp.

References myParameter, and SUMOVTypeParameter::vehicleClass.

Referenced by TraCIServerAPI_VehicleType::setVariable().

void MSVehicleType::setWidth ( const SUMOReal width)

Set a new value for this type's width.

If the given value<0 then the one from the original type will be used.

Parameters
[in]widthThe new width of this type

Definition at line 167 of file MSVehicleType.cpp.

References getWidth(), myOriginalType, myParameter, and SUMOVTypeParameter::width.

Referenced by TraCIServerAPI_VehicleType::setVariable().

bool MSVehicleType::wasSet ( int  what) const
inline

Returns whether the given parameter was set.

Parameters
[in]whatThe parameter which one asks for
Returns
Whether the given parameter was set

Definition at line 91 of file MSVehicleType.h.

References myParameter, and SUMOVTypeParameter::setParameter.

Referenced by MSRouteHandler::myStartElement().

Field Documentation

MSCFModel* MSVehicleType::myCarFollowModel
private

ID of the car following model.

Definition at line 423 of file MSVehicleType.h.

Referenced by build(), getCarFollowModel(), and ~MSVehicleType().

const int MSVehicleType::myIndex
private

the running index

Definition at line 420 of file MSVehicleType.h.

Referenced by getNumericalID().

int MSVehicleType::myNextIndex = 0
staticprivate

next value for the running index

Definition at line 429 of file MSVehicleType.h.

const MSVehicleType* MSVehicleType::myOriginalType
private

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