SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00010 // The car-following model and parameter 00011 /****************************************************************************/ 00012 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00013 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00014 /****************************************************************************/ 00015 // 00016 // This file is part of SUMO. 00017 // SUMO is free software: you can redistribute it and/or modify 00018 // it under the terms of the GNU General Public License as published by 00019 // the Free Software Foundation, either version 3 of the License, or 00020 // (at your option) any later version. 00021 // 00022 /****************************************************************************/ 00023 #ifndef MSVehicleType_h 00024 #define MSVehicleType_h 00025 00026 00027 // =========================================================================== 00028 // included modules 00029 // =========================================================================== 00030 #ifdef _MSC_VER 00031 #include <windows_config.h> 00032 #else 00033 #include <config.h> 00034 #endif 00035 00036 #include <cassert> 00037 #include <map> 00038 #include <string> 00039 #include "MSCFModel.h" 00040 #include <utils/common/SUMOTime.h> 00041 #include <utils/common/StdDefs.h> 00042 #include <utils/common/SUMOVehicleClass.h> 00043 #include <utils/common/RandHelper.h> 00044 #include <utils/common/SUMOVTypeParameter.h> 00045 #include <utils/common/RGBColor.h> 00046 00047 00048 // =========================================================================== 00049 // class declarations 00050 // =========================================================================== 00051 class MSLane; 00052 class BinaryInputDevice; 00053 class MSCFModel; 00054 class SUMOVTypeParameter; 00055 00056 00057 // =========================================================================== 00058 // class definitions 00059 // =========================================================================== 00073 class MSVehicleType { 00074 public: 00093 MSVehicleType(const std::string& id, const SUMOReal lengthWithGap, 00094 const SUMOReal minGap, const SUMOReal maxSpeed, 00095 const SUMOReal prob, const SUMOReal speedFactor, 00096 const SUMOReal speedDev, const SUMOVehicleClass vclass, 00097 const SUMOEmissionClass emissionClass, 00098 const SUMOReal width, const SUMOReal height, 00099 const SUMOVehicleShape shape, const std::string osgFile, 00100 const std::string& lcModel, 00101 const RGBColor& c) ; 00102 00103 00105 virtual ~MSVehicleType() ; 00106 00107 00108 00111 00115 const std::string& getID() const { 00116 return myID; 00117 } 00118 00119 00123 SUMOReal getLength() const { 00124 return myLength; 00125 } 00126 00127 00131 SUMOReal getLengthWithGap() const { 00132 return myLength + myMinGap; 00133 } 00134 00135 00139 SUMOReal getMinGap() const { 00140 return myMinGap; 00141 } 00142 00143 00147 inline const MSCFModel& getCarFollowModel() const { 00148 return *myCarFollowModel; 00149 } 00150 00151 00155 inline MSCFModel& getCarFollowModel() { 00156 return *myCarFollowModel; 00157 } 00158 00159 00163 SUMOReal getMaxSpeed() const { 00164 return myMaxSpeed; 00165 } 00166 00170 SUMOReal hasSpeedDeviation() const { 00171 return mySpeedDev != 0.0 || mySpeedFactor != 1.0; 00172 } 00173 00174 00181 SUMOReal getMaxSpeedWithDeviation(SUMOReal referenceSpeed) const { 00182 SUMOReal meanSpeed = mySpeedFactor * referenceSpeed; 00183 SUMOReal speedDev = mySpeedDev * meanSpeed; 00184 SUMOReal speed = MIN3(RandHelper::randNorm(meanSpeed, speedDev), meanSpeed + 2 * speedDev, myMaxSpeed); 00185 return MAX3((SUMOReal)0.0, speed, meanSpeed - 2 * speedDev); 00186 } 00187 00188 00192 SUMOReal getDefaultProbability() const { 00193 return myDefaultProbability; 00194 } 00195 00196 00201 SUMOVehicleClass getVehicleClass() const { 00202 return myVehicleClass; 00203 } 00204 00205 00210 SUMOEmissionClass getEmissionClass() const { 00211 return myEmissionClass; 00212 } 00213 00214 00218 const RGBColor& getColor() const { 00219 return myColor; 00220 } 00221 00222 00226 SUMOReal getSpeedFactor() const { 00227 return mySpeedFactor; 00228 } 00229 00230 00234 SUMOReal getSpeedDeviation() const { 00235 return mySpeedDev; 00236 } 00238 00239 00240 00243 00247 SUMOReal getWidth() const { 00248 return myWidth; 00249 } 00250 00254 SUMOReal getHeight() const { 00255 return myHeight; 00256 } 00257 00262 SUMOVehicleShape getGuiShape() const { 00263 return myShape; 00264 } 00265 00269 std::string getOSGFile() const { 00270 return myOSGFile; 00271 } 00272 00274 00275 00276 00277 00278 00280 void saveState(std::ostream& os); 00281 00282 00283 00286 00294 void setLength(const SUMOReal& length) ; 00295 00296 00304 void setMinGap(const SUMOReal& minGap) ; 00305 00306 00314 void setMaxSpeed(const SUMOReal& maxSpeed) ; 00315 00316 00320 void setVClass(SUMOVehicleClass vclass) ; 00321 00322 00330 void setDefaultProbability(const SUMOReal& prob) ; 00331 00332 00340 void setSpeedFactor(const SUMOReal& factor) ; 00341 00342 00350 void setSpeedDeviation(const SUMOReal& dev) ; 00351 00352 00356 void setEmissionClass(SUMOEmissionClass eclass) ; 00357 00358 00362 void setColor(const RGBColor& color) ; 00363 00364 00372 void setWidth(const SUMOReal& width) ; 00373 00374 00378 void setShape(SUMOVehicleShape shape) ; 00380 00381 00382 00385 00391 static MSVehicleType* build(SUMOVTypeParameter& from) ; 00392 00393 00399 static MSVehicleType* build(const std::string& id, const MSVehicleType* from) ; 00401 00402 00406 bool amVehicleSpecific() const { 00407 return myOriginalType != 0; 00408 } 00409 00410 00411 private: 00413 std::string myID; 00414 00416 SUMOReal myLength; 00417 00419 SUMOReal myMinGap; 00420 00422 SUMOReal myMaxSpeed; 00423 00425 SUMOReal myDefaultProbability; 00426 00428 SUMOReal mySpeedFactor; 00429 00431 SUMOReal mySpeedDev; 00432 00434 MSCFModel* myCarFollowModel; 00435 00437 std::string myLaneChangeModel; 00438 00440 SUMOEmissionClass myEmissionClass; 00441 00443 RGBColor myColor; 00444 00446 SUMOVehicleClass myVehicleClass; 00447 00448 00451 00453 SUMOReal myWidth; 00454 00456 SUMOReal myHeight; 00457 00459 SUMOVehicleShape myShape; 00460 00462 std::string myOSGFile; 00464 00465 00467 const MSVehicleType* myOriginalType; 00468 00469 00470 private: 00472 MSVehicleType(const MSVehicleType&); 00473 00475 MSVehicleType& operator=(const MSVehicleType&); 00476 00477 }; 00478 00479 00480 #endif 00481 00482 /****************************************************************************/ 00483