#include <MSVehicleType.h>
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 68 of file MSVehicleType.h.
Public Member Functions | |
| MSVehicleType (const std::string &id, SUMOReal length, SUMOReal maxSpeed, SUMOReal prob, SUMOReal speedFactor, SUMOReal speedDev, SUMOVehicleClass vclass, SUMOEmissionClass emissionClass, SUMOVehicleShape shape, SUMOReal guiWidth, SUMOReal guiOffset, int cfModel, 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 MSCFModel & | getCarFollowModel () const throw () |
| Returns the vehicle type's car following model definition. | |
| const RGBColor & | getColor () const throw () |
| Returns this type's color. | |
| SUMOReal | getDefaultProbability () const throw () |
| Get the default probability of this vehicle type. | |
| SUMOEmissionClass | getEmissionClass () const throw () |
| Get this vehicle type's emission class. | |
| const std::string & | getID () const throw () |
| Returns the name of the vehicle type. | |
| SUMOReal | getLength () const throw () |
| Get vehicle's length [m]. | |
| SUMOReal | getMaxSpeed () 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. | |
| SUMOVehicleClass | getVehicleClass () const throw () |
| Get this vehicle type's vehicle class. | |
| SUMOReal | hasSpeedDeviation () const throw () |
| Get vehicle's maximum speed [m/s]. | |
Atomar getter for visualization | |
| SUMOReal | getGuiOffset () const throw () |
| Get the free space (not drawn) in front of vehicles of this class. | |
| SUMOVehicleShape | getGuiShape () const throw () |
| Get this vehicle type's shape. | |
| SUMOReal | getGuiWidth () const throw () |
| Get the width which vehicles of this class shall have when being drawn. | |
Static Public Member Functions | |
Static methods for building vehicle types from descriptions | |
| static MSVehicleType * | build (SUMOVTypeParameter &from) throw (ProcessError) |
| Builds the microsim vehicle type described by the given parameter. | |
| static SUMOReal | get (const std::map< std::string, SUMOReal > &from, const std::string &name, SUMOReal defaultValue) throw () |
| 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 | 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 | myOffset |
| This class' free space in front of the vehicle itself. | |
| SUMOVehicleShape | myShape |
| This class' shape. | |
| SUMOReal | myWidth |
| This class' width. | |
| MSVehicleType::MSVehicleType | ( | const std::string & | id, | |
| SUMOReal | length, | |||
| SUMOReal | maxSpeed, | |||
| SUMOReal | prob, | |||
| SUMOReal | speedFactor, | |||
| SUMOReal | speedDev, | |||
| SUMOVehicleClass | vclass, | |||
| SUMOEmissionClass | emissionClass, | |||
| SUMOVehicleShape | shape, | |||
| SUMOReal | guiWidth, | |||
| SUMOReal | guiOffset, | |||
| int | cfModel, | |||
| const std::string & | lcModel, | |||
| const RGBColor & | c | |||
| ) | throw () |
Constructor.
| [in] | id | The vehicle type's id |
| [in] | length | The length of vehicles that are of this type |
| [in] | maxSpeed | The maximum velocity vehicles of this type may drive with |
| [in] | prob | The probability of this vehicle type |
| [in] | speedFactor | The speed factor to scale maximum speed with |
| [in] | speedDev | The speed deviation |
| [in] | vclass | The class vehicles of this type belong to |
| [in] | emissionClass | The emission class vehicles of this type belong to |
| [in] | shape | How vehicles of this class shall be drawn |
| [in] | guiWidth | The width of the vehicles when being drawn |
| [in] | guiOffset | The free space in front of the vehicles of this class |
| [in] | cfModel | Enumeration of the car-following model to use |
| [in] | lcModel | Name of the lane-change model to use |
| [in] | c | Color of this vehicle type |
Definition at line 51 of file MSVehicleType.cpp.
Referenced by build().
00060 : myID(id), myLength(length), myMaxSpeed(maxSpeed), 00061 myDefaultProbability(prob), mySpeedFactor(speedFactor), 00062 mySpeedDev(speedDev), myVehicleClass(vclass), 00063 myLaneChangeModel(lcModel), 00064 myEmissionClass(emissionClass), myColor(c), 00065 myWidth(guiWidth), myOffset(guiOffset), myShape(shape) { 00066 assert(myLength > 0); 00067 assert(getMaxSpeed() > 0); 00068 }
| MSVehicleType::~MSVehicleType | ( | ) | throw () [virtual] |
| MSVehicleType::MSVehicleType | ( | const MSVehicleType & | ) | [private] |
Invalidated copy constructor.
| MSVehicleType * MSVehicleType::build | ( | SUMOVTypeParameter & | from | ) | throw (ProcessError) [static] |
Builds the microsim vehicle type described by the given parameter.
| [in] | from | The vehicle type description |
| ProcessError | on false values (not et used) |
Definition at line 107 of file MSVehicleType.cpp.
References DEFAULT_VEH_ACCEL, DEFAULT_VEH_DECEL, DEFAULT_VEH_SIGMA, DEFAULT_VEH_TAU, MSVehicleType(), myCarFollowModel, SUMO_TAG_CF_BKERNER, SUMO_TAG_CF_IDM, SUMO_TAG_CF_KRAUSS, SUMO_TAG_CF_KRAUSS_ORIG1, and SUMO_TAG_CF_PWAGNER2009.
Referenced by MSVehicleControl::MSVehicleControl(), and MSRouteHandler::myEndElement().
00107 { 00108 MSVehicleType *vtype = new MSVehicleType( 00109 from.id, from.length, from.maxSpeed, 00110 from.defaultProbability, from.speedFactor, from.speedDev, from.vehicleClass, from.emissionClass, 00111 from.shape, from.width, from.offset, from.cfModel, from.lcModel, from.color); 00112 MSCFModel *model = 0; 00113 switch (from.cfModel) { 00114 case SUMO_TAG_CF_IDM: 00115 model = new MSCFModel_IDM(vtype, 00116 get(from.cfParameter, "accel", DEFAULT_VEH_ACCEL), 00117 get(from.cfParameter, "decel", DEFAULT_VEH_DECEL), 00118 get(from.cfParameter, "timeHeadWay", 1.5), 00119 get(from.cfParameter, "minGap", 5.), 00120 get(from.cfParameter, "tau", DEFAULT_VEH_TAU)); 00121 break; 00122 case SUMO_TAG_CF_BKERNER: 00123 model = new MSCFModel_Kerner(vtype, 00124 get(from.cfParameter, "accel", DEFAULT_VEH_ACCEL), 00125 get(from.cfParameter, "decel", DEFAULT_VEH_DECEL), 00126 get(from.cfParameter, "tau", DEFAULT_VEH_TAU), 00127 get(from.cfParameter, "k", .5), 00128 get(from.cfParameter, "phi", 5.)); 00129 break; 00130 case SUMO_TAG_CF_KRAUSS_ORIG1: 00131 model = new MSCFModel_KraussOrig1(vtype, 00132 get(from.cfParameter, "accel", DEFAULT_VEH_ACCEL), 00133 get(from.cfParameter, "decel", DEFAULT_VEH_DECEL), 00134 get(from.cfParameter, "sigma", DEFAULT_VEH_SIGMA), 00135 get(from.cfParameter, "tau", DEFAULT_VEH_TAU)); 00136 break; 00137 case SUMO_TAG_CF_PWAGNER2009: 00138 model = new MSCFModel_PWag2009(vtype, 00139 get(from.cfParameter, "accel", DEFAULT_VEH_ACCEL), 00140 get(from.cfParameter, "decel", DEFAULT_VEH_DECEL), 00141 get(from.cfParameter, "sigma", DEFAULT_VEH_SIGMA), 00142 get(from.cfParameter, "tau", DEFAULT_VEH_TAU)); 00143 break; 00144 case SUMO_TAG_CF_KRAUSS: 00145 default: 00146 model = new MSCFModel_Krauss(vtype, 00147 get(from.cfParameter, "accel", DEFAULT_VEH_ACCEL), 00148 get(from.cfParameter, "decel", DEFAULT_VEH_DECEL), 00149 get(from.cfParameter, "sigma", DEFAULT_VEH_SIGMA), 00150 get(from.cfParameter, "tau", DEFAULT_VEH_TAU)); 00151 break; 00152 } 00153 vtype->myCarFollowModel = model; 00154 return vtype; 00155 }
| SUMOReal MSVehicleType::get | ( | const std::map< std::string, SUMOReal > & | from, | |
| const std::string & | name, | |||
| SUMOReal | defaultValue | |||
| ) | throw () [static] |
Returns the named value from the map, or the default if it is ot contained there.
| [in] | from | The map to retrieve values from |
| [in] | name | The name of variable |
| [in] | defaultValue | The value to return if the given map does not contain the named variable |
Definition at line 97 of file MSVehicleType.cpp.
00097 { 00098 std::map<std::string, SUMOReal>::const_iterator i = from.find(name); 00099 if (i==from.end()) { 00100 return defaultValue; 00101 } 00102 return (*i).second; 00103 }
| const MSCFModel& MSVehicleType::getCarFollowModel | ( | ) | const throw () [inline] |
Returns the vehicle type's car following model definition.
Definition at line 123 of file MSVehicleType.h.
References myCarFollowModel.
Referenced by MSVehicle::checkRewindLinkLanes(), MSVehicle::getCarFollowModel(), and TraCIServerAPI_VehicleType::processGet().
00123 { 00124 return *myCarFollowModel; 00125 }
| const RGBColor& MSVehicleType::getColor | ( | ) | const throw () [inline] |
Returns this type's color.
Definition at line 186 of file MSVehicleType.h.
References myColor.
Referenced by TraCIServerAPI_VehicleType::processGet(), and GUIVehicle::setOwnTypeColor().
00186 { 00187 return myColor; 00188 }
| SUMOReal MSVehicleType::getDefaultProbability | ( | ) | const throw () [inline] |
Get the default probability of this vehicle type.
Definition at line 160 of file MSVehicleType.h.
References myDefaultProbability.
Referenced by MSRouteHandler::myEndElement(), and MSRouteHandler::openVehicleTypeDistribution().
00160 { 00161 return myDefaultProbability; 00162 }
| SUMOEmissionClass MSVehicleType::getEmissionClass | ( | ) | const throw () [inline] |
Get this vehicle type's emission class.
Definition at line 178 of file MSVehicleType.h.
References myEmissionClass.
Referenced by MSVehicle::getHarmonoise_NoiseEmissions(), MSVehicle::getHBEFA_CO2Emissions(), MSVehicle::getHBEFA_COEmissions(), MSVehicle::getHBEFA_FuelConsumption(), MSVehicle::getHBEFA_HCEmissions(), MSVehicle::getHBEFA_NOxEmissions(), MSVehicle::getHBEFA_PMxEmissions(), traci::TraCIServer::handleVehicleDomain(), TraCIServerAPI_VehicleType::processGet(), TraCIServerAPI_Vehicle::processGet(), and MSDevice_HBEFA::wrappedComputeCommandExecute().
00178 { 00179 return myEmissionClass; 00180 }
| SUMOReal MSVehicleType::getGuiOffset | ( | ) | const throw () [inline] |
Get the free space (not drawn) in front of vehicles of this class.
Definition at line 216 of file MSVehicleType.h.
References myOffset.
Referenced by drawAction_drawVehicleAsBoxPlus(), drawAction_drawVehicleAsPoly(), drawAction_drawVehicleBlinker(), and TraCIServerAPI_VehicleType::processGet().
00216 { 00217 return myOffset; 00218 }
| SUMOVehicleShape MSVehicleType::getGuiShape | ( | ) | const throw () [inline] |
Get this vehicle type's shape.
Definition at line 200 of file MSVehicleType.h.
References myShape.
Referenced by drawAction_drawVehicleAsPoly(), and TraCIServerAPI_VehicleType::processGet().
00200 { 00201 return myShape; 00202 }
| SUMOReal MSVehicleType::getGuiWidth | ( | ) | const throw () [inline] |
Get the width which vehicles of this class shall have when being drawn.
Definition at line 208 of file MSVehicleType.h.
References myWidth.
Referenced by drawAction_drawVehicleAsBoxPlus(), drawAction_drawVehicleAsPoly(), drawAction_drawVehicleBlinker(), and TraCIServerAPI_VehicleType::processGet().
00208 { 00209 return myWidth; 00210 }
| const std::string& MSVehicleType::getID | ( | ) | const throw () [inline] |
Returns the name of the vehicle type.
Definition at line 107 of file MSVehicleType.h.
References myID.
Referenced by MSVTypeProbe::execute(), MSCalibrator::execute(), GUIVehicle::getParameterWindow(), MSRouteHandler::myEndElement(), TraCIServerAPI_Vehicle::processGet(), and MSVehicle::saveState().
00107 { 00108 return myID; 00109 }
| SUMOReal MSVehicleType::getLength | ( | ) | const throw () [inline] |
Get vehicle's length [m].
Definition at line 115 of file MSVehicleType.h.
References myLength.
Referenced by MSLaneChanger::change(), MSVehicle::checkRewindLinkLanes(), MSInductLoop::collectVehiclesOnDet(), drawAction_drawVehicleAsBoxPlus(), drawAction_drawVehicleAsPoly(), drawAction_drawVehicleAsTrianglePlus(), drawAction_drawVehicleBlinker(), drawAction_drawVehicleName(), GUIVehicle::drawGL(), MSLane::enteredByLaneChange(), MSVehicle::enterLaneAtEmit(), MSVehicle::enterLaneAtLaneChange(), MSLane::freeEmit(), MSLane::getLastVehicleInformation(), MSLaneChanger::getRealFollower(), MSLaneChanger::getRealThisLeader(), MSLane::integrateNewVehicle(), MSLane::isEmissionSuccess(), MSE2Collector::isStillActive(), MSLane::leftByLaneChange(), MSVehicle::moveFirstChecked(), MSInductLoop::notifyEnter(), MSE3Collector::MSE3LeaveReminder::notifyEnter(), MSE2Collector::notifyEnter(), MSAbstractLaneChangeModel::predInteraction(), TraCIServerAPI_VehicleType::processGet(), MSVehicle::processNextStop(), MSLane::removeFirstVehicle(), MSLane::removeVehicle(), MSLane::setCritical(), MSE2Collector::update(), MSLCM_DK2004::wantsChangeToLeft(), and MSLCM_DK2004::wantsChangeToRight().
00115 { 00116 return myLength; 00117 }
| SUMOReal MSVehicleType::getMaxSpeed | ( | ) | const throw () [inline] |
Get vehicle's maximum speed [m/s].
Definition at line 131 of file MSVehicleType.h.
References myMaxSpeed.
Referenced by MSVehicle::adaptMaxSpeed(), MSCFModel_IDM::desiredSpeed(), MSCFModel_Krauss::getMaxAccel(), MSVehicle::getMaxSpeed(), MSCFModel::maxNextSpeed(), MSVehicle::moveFirstChecked(), TraCIServerAPI_VehicleType::processGet(), saveState(), MSLCM_DK2004::wantsChangeToLeft(), and MSLCM_DK2004::wantsChangeToRight().
00131 { 00132 return myMaxSpeed; 00133 }
| 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).
Definition at line 149 of file MSVehicleType.h.
References MAX3(), MIN3(), myMaxSpeed, mySpeedDev, mySpeedFactor, RandHelper::randNorm(), and SUMOReal.
Referenced by MSVehicle::adaptMaxSpeed().
00149 { 00150 SUMOReal meanSpeed = mySpeedFactor * referenceSpeed; 00151 SUMOReal speedDev = mySpeedDev * meanSpeed; 00152 SUMOReal speed = MIN3(RandHelper::randNorm(meanSpeed, speedDev), meanSpeed + 2*speedDev, myMaxSpeed); 00153 return MAX3((SUMOReal)0.0, speed, meanSpeed - 2*speedDev); 00154 }
| SUMOVehicleClass MSVehicleType::getVehicleClass | ( | ) | const throw () [inline] |
Get this vehicle type's vehicle class.
Definition at line 169 of file MSVehicleType.h.
References myVehicleClass.
Referenced by MSVehicleTransfer::checkEmissions(), MSVehicle::getBestLanes(), MSVehicle::hasValidRoute(), TraCIServerAPI_VehicleType::processGet(), MSVehicle::rebuildContinuationsFor(), and MSLane::succLinkSec().
00169 { 00170 return myVehicleClass; 00171 }
| SUMOReal MSVehicleType::hasSpeedDeviation | ( | ) | const throw () [inline] |
Get vehicle's maximum speed [m/s].
Definition at line 138 of file MSVehicleType.h.
References mySpeedDev, and mySpeedFactor.
Referenced by MSVehicle::adaptMaxSpeed().
00138 { 00139 return mySpeedDev != 0.0 || mySpeedFactor != 1.0; 00140 }
| MSVehicleType& MSVehicleType::operator= | ( | const MSVehicleType & | ) | [private] |
Invalidated assignment operator.
| void MSVehicleType::saveState | ( | std::ostream & | os | ) |
Saves the states of a vehicle.
Definition at line 75 of file MSVehicleType.cpp.
References RGBColor::blue(), getMaxSpeed(), MSCFModel::getModelID(), RGBColor::green(), myCarFollowModel, myColor, myDefaultProbability, myEmissionClass, myID, myLaneChangeModel, myLength, myOffset, myShape, mySpeedDev, mySpeedFactor, myVehicleClass, myWidth, RGBColor::red(), FileHelpers::writeFloat(), FileHelpers::writeInt(), and FileHelpers::writeString().
00075 { 00076 FileHelpers::writeString(os, myID); 00077 FileHelpers::writeFloat(os, myLength); 00078 FileHelpers::writeFloat(os, getMaxSpeed()); 00079 FileHelpers::writeInt(os, (int) myVehicleClass); 00080 FileHelpers::writeInt(os, (int) myEmissionClass); 00081 FileHelpers::writeInt(os, (int) myShape); 00082 FileHelpers::writeFloat(os, myWidth); 00083 FileHelpers::writeFloat(os, myOffset); 00084 FileHelpers::writeFloat(os, myDefaultProbability); 00085 FileHelpers::writeFloat(os, mySpeedFactor); 00086 FileHelpers::writeFloat(os, mySpeedDev); 00087 FileHelpers::writeFloat(os, myColor.red()); 00088 FileHelpers::writeFloat(os, myColor.green()); 00089 FileHelpers::writeFloat(os, myColor.blue()); 00090 FileHelpers::writeInt(os, myCarFollowModel->getModelID()); 00091 FileHelpers::writeString(os, myLaneChangeModel); 00092 //myCarFollowModel->saveState(os); 00093 }
MSCFModel* MSVehicleType::myCarFollowModel [private] |
ID of the car following model.
Definition at line 275 of file MSVehicleType.h.
Referenced by build(), getCarFollowModel(), and saveState().
RGBColor MSVehicleType::myColor [private] |
The color.
Definition at line 284 of file MSVehicleType.h.
Referenced by getColor(), and saveState().
SUMOReal MSVehicleType::myDefaultProbability [private] |
The probability when being added to a distribution without an explicit probability.
Definition at line 266 of file MSVehicleType.h.
Referenced by getDefaultProbability(), and saveState().
The emission class of such vehicles.
Definition at line 281 of file MSVehicleType.h.
Referenced by getEmissionClass(), and saveState().
std::string MSVehicleType::myID [private] |
std::string MSVehicleType::myLaneChangeModel [private] |
ID of the lane change model.
Definition at line 278 of file MSVehicleType.h.
Referenced by saveState().
SUMOReal MSVehicleType::myLength [private] |
Vehicles' length [m].
Definition at line 257 of file MSVehicleType.h.
Referenced by getLength(), and saveState().
SUMOReal MSVehicleType::myMaxSpeed [private] |
Vehicles' maximum speed [m/s].
Definition at line 260 of file MSVehicleType.h.
Referenced by getMaxSpeed(), and getMaxSpeedWithDeviation().
SUMOReal MSVehicleType::myOffset [private] |
This class' free space in front of the vehicle itself.
Definition at line 294 of file MSVehicleType.h.
Referenced by getGuiOffset(), and saveState().
SUMOVehicleShape MSVehicleType::myShape [private] |
This class' shape.
Definition at line 297 of file MSVehicleType.h.
Referenced by getGuiShape(), and saveState().
SUMOReal MSVehicleType::mySpeedDev [private] |
The standard deviation for speed variations.
Definition at line 272 of file MSVehicleType.h.
Referenced by getMaxSpeedWithDeviation(), 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 269 of file MSVehicleType.h.
Referenced by getMaxSpeedWithDeviation(), hasSpeedDeviation(), and saveState().
The vehicles' class.
Definition at line 263 of file MSVehicleType.h.
Referenced by getVehicleClass(), and saveState().
SUMOReal MSVehicleType::myWidth [private] |
This class' width.
Definition at line 291 of file MSVehicleType.h.
Referenced by getGuiWidth(), and saveState().
1.5.6