SUMO - Simulation of Urban MObility

MSVehicleType Class Reference

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

#include <MSVehicleType.h>

Public Member Functions

bool amVehicleSpecific () const throw ()
 Returns whether this type belongs to a single vehicle only (was modified)
 MSVehicleType (const std::string &id, SUMOReal lengthWithGap, SUMOReal minGap, SUMOReal maxSpeed, SUMOReal prob, SUMOReal speedFactor, SUMOReal speedDev, SUMOVehicleClass vclass, SUMOEmissionClass emissionClass, SUMOReal guiWidth, SUMOVehicleShape shape, const std::string &lcModel, const RGBColor &c) throw ()
 Constructor.
void saveState (std::ostream &os)
 Saves the states of a vehicle.
virtual ~MSVehicleType () throw ()
 Destructor.
Atomar getter for simulation
const std::string & getID () const throw ()
 Returns the name of the vehicle type.
SUMOReal getLength () const throw ()
 Get vehicle's length [m].
SUMOReal getLengthWithGap () const throw ()
 Get vehicle's length including the minimum gap [m].
SUMOReal getMinGap () const throw ()
 Get the free space in front of vehicles of this class.
const MSCFModel & getCarFollowModel () const throw ()
 Returns the vehicle type's car following model definition (const version)
MSCFModel & getCarFollowModel () throw ()
 Returns the vehicle type's car following model definition (non-const version)
SUMOReal getMaxSpeed () const throw ()
 Get vehicle's maximum speed [m/s].
SUMOReal hasSpeedDeviation () const throw ()
 Get vehicle's maximum speed [m/s].
SUMOReal getMaxSpeedWithDeviation (SUMOReal referenceSpeed) const throw ()
 Get vehicle's maximum speed [m/s] drawn from a normal distribution.
SUMOReal getDefaultProbability () const throw ()
 Get the default probability of this vehicle type.
SUMOVehicleClass getVehicleClass () const throw ()
 Get this vehicle type's vehicle class.
SUMOEmissionClass getEmissionClass () const throw ()
 Get this vehicle type's emission class.
const RGBColor & getColor () const throw ()
 Returns this type's color.
SUMOReal getSpeedFactor () const throw ()
 Returns this type's speed factor.
SUMOReal getSpeedDeviation () const throw ()
 Returns this type's speed deviation.
Atomar getter for visualization
SUMOReal getGuiWidth () const throw ()
 Get the width which vehicles of this class shall have when being drawn.
SUMOVehicleShape getGuiShape () const throw ()
 Get this vehicle type's shape.
Setter methods
void setLength (const SUMOReal &length) throw ()
 Set a new value for this type's length.
void setMinGap (const SUMOReal &minGap) throw ()
 Set a new value for this type's minimum gap.
void setMaxSpeed (const SUMOReal &maxSpeed) throw ()
 Set a new value for this type's maximum speed.
void setVClass (SUMOVehicleClass vclass) throw ()
 Set a new value for this type's vehicle class.
void setDefaultProbability (const SUMOReal &prob) throw ()
 Set a new value for this type's default probability.
void setSpeedFactor (const SUMOReal &factor) throw ()
 Set a new value for this type's speed factor.
void setSpeedDeviation (const SUMOReal &dev) throw ()
 Set a new value for this type's speed deviation.
void setEmissionClass (SUMOEmissionClass eclass) throw ()
 Set a new value for this type's emission class.
void setColor (const RGBColor &color) throw ()
 Set a new value for this type's color.
void setWidth (const SUMOReal &width) throw ()
 Set a new value for this type's width.
void setShape (SUMOVehicleShape shape) throw ()
 Set a new value for this type's shape.

Static Public Member Functions

Static methods for building vehicle types
static MSVehicleType * build (SUMOVTypeParameter &from) throw (ProcessError)
 Builds the microsim vehicle type described by the given parameter.
static MSVehicleType * build (const std::string &id, const MSVehicleType *from) throw ()
 Duplicates the microsim vehicle type giving it a the given id.
static SUMOReal get (const SUMOVTypeParameter::CFParams &from, SumoXMLAttr attr, SUMOReal defaultValue)
 Returns the named value from the map, or the default if it is ot contained there.

Private Member Functions

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

Private Attributes

MSCFModel * myCarFollowModel
 ID of the car following model.
RGBColor myColor
 The color.
SUMOReal myDefaultProbability
 The probability when being added to a distribution without an explicit probability.
SUMOEmissionClass myEmissionClass
 The emission class of such vehicles.
std::string myID
 Unique ID.
std::string myLaneChangeModel
 ID of the lane change model.
SUMOReal myLength
 Vehicles' length [m].
SUMOReal myMaxSpeed
 Vehicles' maximum speed [m/s].
SUMOReal myMinGap
 This class' free space in front of the vehicle itself.
const MSVehicleType * myOriginalType
 The original type.
SUMOReal mySpeedDev
 The standard deviation for speed variations.
SUMOReal mySpeedFactor
 The factor by which the maximum speed may deviate from the allowed max speed on the street.
SUMOVehicleClass myVehicleClass
 The vehicles' class.
Values for drawing this class' vehicles
SUMOReal myWidth
 This class' width.
SUMOVehicleShape myShape
 This class' shape.

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 69 of file MSVehicleType.h.


Constructor & Destructor Documentation

MSVehicleType::MSVehicleType ( const std::string &  id,
SUMOReal  lengthWithGap,
SUMOReal  minGap,
SUMOReal  maxSpeed,
SUMOReal  prob,
SUMOReal  speedFactor,
SUMOReal  speedDev,
SUMOVehicleClass  vclass,
SUMOEmissionClass  emissionClass,
SUMOReal  guiWidth,
SUMOVehicleShape  shape,
const std::string &  lcModel,
const RGBColor &  c 
) throw ()

Constructor.

Parameters:
[in]idThe vehicle type's id
[in]lengthThe length of vehicles that of this type
[in]minGapThe free space in front of the vehicles of this class
[in]maxSpeedThe maximum velocity vehicles of this type may drive with
[in]probThe probability of this vehicle type
[in]speedFactorThe speed factor to scale maximum speed with
[in]speedDevThe speed deviation
[in]vclassThe class vehicles of this type belong to
[in]emissionClassThe emission class vehicles of this type belong to
[in]guiWidthThe width of the vehicles when being drawn
[in]shapeHow vehicles of this class shall be drawn
[in]lcModelName of the lane-change model to use
[in]cColor of this vehicle type

Definition at line 52 of file MSVehicleType.cpp.

MSVehicleType::~MSVehicleType ( ) throw () [virtual]

Destructor.

Definition at line 72 of file MSVehicleType.cpp.

References myCarFollowModel.

MSVehicleType::MSVehicleType ( const MSVehicleType &  ) [private]

Invalidated copy constructor.


Member Function Documentation

bool MSVehicleType::amVehicleSpecific ( ) const throw () [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 394 of file MSVehicleType.h.

References myOriginalType.

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

MSVehicleType * MSVehicleType::build ( const std::string &  id,
const MSVehicleType *  from 
) throw () [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 284 of file MSVehicleType.cpp.

References MSCFModel::duplicate(), myCarFollowModel, and myOriginalType.

SUMOReal MSVehicleType::get ( const SUMOVTypeParameter::CFParams &  from,
SumoXMLAttr  attr,
SUMOReal  defaultValue 
) [static]

Returns the named value from the map, or the default if it is ot contained there.

Parameters:
[in]fromThe map to retrieve values from
[in]attrThe corresponding xml attribute
[in]defaultValueThe value to return if the given map does not contain the named variable
Returns:
The named value from the map or the default if it does not exist there

Definition at line 204 of file MSVehicleType.cpp.

Referenced by MSVehicleControl::getVType().

const MSCFModel& MSVehicleType::getCarFollowModel ( ) const throw () [inline]

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

Returns:
The vehicle type's car following model definition

Definition at line 140 of file MSVehicleType.h.

References myCarFollowModel.

Referenced by MSVehicle::getCarFollowModel(), TraCIServerAPI_VehicleType::getVariable(), MSVehicle::moveChecked(), TraCIServerAPI_VehicleType::setVariable(), and MSVehicle::vsafeCriticalCont().

MSCFModel& MSVehicleType::getCarFollowModel ( ) throw () [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 148 of file MSVehicleType.h.

References myCarFollowModel.

const RGBColor& MSVehicleType::getColor ( ) const throw () [inline]

Returns this type's color.

Returns:
The color of this type

Definition at line 211 of file MSVehicleType.h.

References myColor.

Referenced by TraCIServerAPI_VehicleType::getVariable().

SUMOReal MSVehicleType::getDefaultProbability ( ) const throw () [inline]

Get the default probability of this vehicle type.

Returns:
The probability to use this type

Definition at line 185 of file MSVehicleType.h.

References myDefaultProbability.

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

SUMOVehicleShape MSVehicleType::getGuiShape ( ) const throw () [inline]

Get this vehicle type's shape.

Returns:
The shape of this vehicle type
See also:
SUMOVehicleShape

Definition at line 248 of file MSVehicleType.h.

References myShape.

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

SUMOReal MSVehicleType::getGuiWidth ( ) const throw () [inline]

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

Returns:
The width of this type's vehicles

Definition at line 240 of file MSVehicleType.h.

References myWidth.

Referenced by drawAction_drawVehicleAsBoxPlus(), drawAction_drawVehicleAsPoly(), drawAction_drawVehicleBlinker(), drawAction_drawVehicleBrakeLight(), and TraCIServerAPI_VehicleType::getVariable().

SUMOReal MSVehicleType::getLength ( ) const throw () [inline]

Get vehicle's length [m].

Returns:
The length vehicles of this type have in m

Definition at line 116 of file MSVehicleType.h.

References myLength.

Referenced by MSCFModel_Wiedemann::_v(), TraCIServerAPI_VehicleType::getVariable(), and MSInstantInductLoop::write().

SUMOReal MSVehicleType::getMaxSpeed ( ) const throw () [inline]

Get vehicle's maximum speed [m/s].

Returns:
The maximum speed (in m/s) of vehicles of this class

Definition at line 156 of file MSVehicleType.h.

References myMaxSpeed.

Referenced by MSBaseVehicle::adaptMaxSpeed(), MSCFModel_IDM::desiredSpeed(), MSBaseVehicle::getMaxSpeed(), TraCIServerAPI_VehicleType::getVariable(), MSCFModel::maxNextSpeed(), saveState(), MSLCM_DK2004::wantsChangeToLeft(), and MSLCM_DK2004::wantsChangeToRight().

SUMOReal MSVehicleType::getMaxSpeedWithDeviation ( SUMOReal  referenceSpeed) const throw () [inline]

Get vehicle's maximum speed [m/s] drawn from a normal distribution.

The speed is calculated relative to the reference speed (which is usually the maximum allowed speed on a lane or edge).

Returns:
The maximum speed (in m/s) of vehicles of this class

Definition at line 174 of file MSVehicleType.h.

References MAX3(), MIN3(), myMaxSpeed, mySpeedDev, mySpeedFactor, RandHelper::randNorm(), and SUMOReal.

Referenced by MSBaseVehicle::adaptMaxSpeed().

SUMOReal MSVehicleType::getMinGap ( ) const throw () [inline]

Get the free space in front of vehicles of this class.

Returns:
The place before the vehicle

Definition at line 132 of file MSVehicleType.h.

References myMinGap.

Referenced by MSCFModel_IDM::_v(), drawAction_drawBlinker(), drawAction_drawVehicleAsBoxPlus(), drawAction_drawVehicleAsPoly(), and TraCIServerAPI_VehicleType::getVariable().

SUMOReal MSVehicleType::getSpeedDeviation ( ) const throw () [inline]

Returns this type's speed deviation.

Returns:
The speed deviation of this type

Definition at line 227 of file MSVehicleType.h.

References mySpeedDev.

Referenced by TraCIServerAPI_VehicleType::getVariable().

SUMOReal MSVehicleType::getSpeedFactor ( ) const throw () [inline]

Returns this type's speed factor.

Returns:
The speed factor of this type

Definition at line 219 of file MSVehicleType.h.

References mySpeedFactor.

Referenced by TraCIServerAPI_VehicleType::getVariable().

SUMOVehicleClass MSVehicleType::getVehicleClass ( ) const throw () [inline]

Get this vehicle type's vehicle class.

Returns:
The class of this vehicle type
See also:
SUMOVehicleClass

Definition at line 194 of file MSVehicleType.h.

References myVehicleClass.

Referenced by MSVehicleTransfer::checkInsertions(), MSVehicle::getBestLanes(), TraCIServerAPI_VehicleType::getVariable(), and MSLane::succLinkSec().

SUMOReal MSVehicleType::hasSpeedDeviation ( ) const throw () [inline]

Get vehicle's maximum speed [m/s].

Returns:
The maximum speed (in m/s) of vehicles of this class

Definition at line 163 of file MSVehicleType.h.

References mySpeedDev, and mySpeedFactor.

Referenced by MSBaseVehicle::adaptMaxSpeed().

MSVehicleType& MSVehicleType::operator= ( const MSVehicleType &  ) [private]

Invalidated assignment operator.

void MSVehicleType::setColor ( const RGBColor &  color) throw ()

Set a new value for this type's color.

Parameters:
[in]colorThe new color of this type

Definition at line 179 of file MSVehicleType.cpp.

Referenced by TraCIServerAPI_VehicleType::setVariable().

void MSVehicleType::setDefaultProbability ( const SUMOReal &  prob) throw ()

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 140 of file MSVehicleType.cpp.

void MSVehicleType::setEmissionClass ( SUMOEmissionClass  eclass) throw ()

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

Parameters:
[in]eclassThe new emission class of this type

Definition at line 173 of file MSVehicleType.cpp.

Referenced by TraCIServerAPI_VehicleType::setVariable().

void MSVehicleType::setLength ( const SUMOReal &  length) throw ()

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 101 of file MSVehicleType.cpp.

Referenced by TraCIServerAPI_VehicleType::setVariable().

void MSVehicleType::setMaxSpeed ( const SUMOReal &  maxSpeed) throw ()

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 123 of file MSVehicleType.cpp.

Referenced by TraCIServerAPI_VehicleType::setVariable().

void MSVehicleType::setMinGap ( const SUMOReal &  minGap) throw ()

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]offsetThe new minimum gap of this type

Definition at line 112 of file MSVehicleType.cpp.

Referenced by TraCIServerAPI_VehicleType::setVariable().

void MSVehicleType::setShape ( SUMOVehicleShape  shape) throw ()

Set a new value for this type's shape.

Parameters:
[in]shapeThe new shape of this type

Definition at line 196 of file MSVehicleType.cpp.

Referenced by TraCIServerAPI_VehicleType::setVariable().

void MSVehicleType::setSpeedDeviation ( const SUMOReal &  dev) throw ()

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 162 of file MSVehicleType.cpp.

Referenced by TraCIServerAPI_VehicleType::setVariable().

void MSVehicleType::setSpeedFactor ( const SUMOReal &  factor) throw ()

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 151 of file MSVehicleType.cpp.

Referenced by TraCIServerAPI_VehicleType::setVariable().

void MSVehicleType::setVClass ( SUMOVehicleClass  vclass) throw ()

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

Parameters:
[in]vclassThe new vehicle class of this type

Definition at line 134 of file MSVehicleType.cpp.

Referenced by TraCIServerAPI_VehicleType::setVariable().

void MSVehicleType::setWidth ( const SUMOReal &  width) throw ()

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 185 of file MSVehicleType.cpp.

Referenced by TraCIServerAPI_VehicleType::setVariable().


Field Documentation

ID of the car following model.

Definition at line 422 of file MSVehicleType.h.

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

The color.

Definition at line 431 of file MSVehicleType.h.

Referenced by getColor(), and saveState().

The probability when being added to a distribution without an explicit probability.

Definition at line 413 of file MSVehicleType.h.

Referenced by getDefaultProbability(), and saveState().

The emission class of such vehicles.

Definition at line 428 of file MSVehicleType.h.

Referenced by getEmissionClass(), and saveState().

std::string MSVehicleType::myID [private]

Unique ID.

Definition at line 401 of file MSVehicleType.h.

Referenced by getID(), and saveState().

std::string MSVehicleType::myLaneChangeModel [private]

ID of the lane change model.

Definition at line 425 of file MSVehicleType.h.

Referenced by saveState().

SUMOReal MSVehicleType::myLength [private]

Vehicles' length [m].

Definition at line 404 of file MSVehicleType.h.

Referenced by getLength(), getLengthWithGap(), and saveState().

SUMOReal MSVehicleType::myMaxSpeed [private]

Vehicles' maximum speed [m/s].

Definition at line 410 of file MSVehicleType.h.

Referenced by getMaxSpeed(), and getMaxSpeedWithDeviation().

SUMOReal MSVehicleType::myMinGap [private]

This class' free space in front of the vehicle itself.

Definition at line 407 of file MSVehicleType.h.

Referenced by getLengthWithGap(), getMinGap(), and saveState().

The original type.

Definition at line 449 of file MSVehicleType.h.

Referenced by amVehicleSpecific(), and build().

This class' shape.

Definition at line 444 of file MSVehicleType.h.

Referenced by getGuiShape(), and saveState().

SUMOReal MSVehicleType::mySpeedDev [private]

The standard deviation for speed variations.

Definition at line 419 of file MSVehicleType.h.

Referenced by getMaxSpeedWithDeviation(), getSpeedDeviation(), hasSpeedDeviation(), and saveState().

SUMOReal MSVehicleType::mySpeedFactor [private]

The factor by which the maximum speed may deviate from the allowed max speed on the street.

Definition at line 416 of file MSVehicleType.h.

Referenced by getMaxSpeedWithDeviation(), getSpeedFactor(), hasSpeedDeviation(), and saveState().

The vehicles' class.

Definition at line 434 of file MSVehicleType.h.

Referenced by getVehicleClass(), and saveState().

SUMOReal MSVehicleType::myWidth [private]

This class' width.

Definition at line 441 of file MSVehicleType.h.

Referenced by getGuiWidth(), and saveState().


The documentation for this class was generated from the following files:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines