1 /****************************************************************************/ 2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others. 4 // This program and the accompanying materials 5 // are made available under the terms of the Eclipse Public License v2.0 6 // which accompanies this distribution, and is available at 7 // http://www.eclipse.org/legal/epl-v20.html 8 // SPDX-License-Identifier: EPL-2.0 9 /****************************************************************************/ 10 /// @file SUMOVTypeParameter.h 11 /// @author Daniel Krajzewicz 12 /// @author Jakob Erdmann 13 /// @author Michael Behrisch 14 /// @date 10.09.2009 15 /// @version $Id$ 16 /// 17 // Structure representing possible vehicle parameter 18 /****************************************************************************/ 19 #ifndef SUMOVTypeParameter_h 20 #define SUMOVTypeParameter_h 21 22 23 // =========================================================================== 24 // included modules 25 // =========================================================================== 26 #include <config.h> 27 28 #include <string> 29 #include <map> 30 #include <utils/common/Parameterised.h> 31 #include <utils/common/RGBColor.h> 32 #include <utils/common/SUMOTime.h> 33 #include <utils/common/SUMOVehicleClass.h> 34 #include <utils/distribution/Distribution_Parameterized.h> 35 36 // =========================================================================== 37 // class declarations 38 // =========================================================================== 39 class OutputDevice; 40 class OptionsCont; 41 42 43 // =========================================================================== 44 // value definitions 45 // =========================================================================== 46 const int VTYPEPARS_LENGTH_SET = 1; 47 const int VTYPEPARS_MINGAP_SET = 1 << 1; 48 const int VTYPEPARS_MAXSPEED_SET = 1 << 2; 49 const int VTYPEPARS_PROBABILITY_SET = 1 << 3; 50 const int VTYPEPARS_SPEEDFACTOR_SET = 1 << 4; 51 const int VTYPEPARS_EMISSIONCLASS_SET = 1 << 5; 52 const int VTYPEPARS_COLOR_SET = 1 << 6; 53 const int VTYPEPARS_VEHICLECLASS_SET = 1 << 7; 54 const int VTYPEPARS_WIDTH_SET = 1 << 8; 55 const int VTYPEPARS_HEIGHT_SET = 1 << 9; 56 const int VTYPEPARS_SHAPE_SET = 1 << 10; 57 const int VTYPEPARS_OSGFILE_SET = 1 << 11; 58 const int VTYPEPARS_IMGFILE_SET = 1 << 12; 59 const int VTYPEPARS_IMPATIENCE_SET = 1 << 13; 60 const int VTYPEPARS_LANE_CHANGE_MODEL_SET = 1 << 14; 61 const int VTYPEPARS_PERSON_CAPACITY = 1 << 15; 62 const int VTYPEPARS_BOARDING_DURATION = 1 << 16; 63 const int VTYPEPARS_CONTAINER_CAPACITY = 1 << 17; 64 const int VTYPEPARS_LOADING_DURATION = 1 << 18; 65 const int VTYPEPARS_CAR_FOLLOW_MODEL = 1 << 19; 66 const int VTYPEPARS_MAXSPEED_LAT_SET = 1 << 20; 67 const int VTYPEPARS_LATALIGNMENT_SET = 1 << 21; 68 const int VTYPEPARS_MINGAP_LAT_SET = 1 << 22; 69 const int VTYPEPARS_ACTIONSTEPLENGTH_SET = 1 << 23; 70 const int VTYPEPARS_HASDRIVERSTATE_SET = 1 << 24; 71 72 73 const int VTYPEPARS_DEFAULT_EMERGENCYDECEL_DEFAULT = -1; 74 const int VTYPEPARS_DEFAULT_EMERGENCYDECEL_DECEL = -2; 75 76 // =========================================================================== 77 // struct definitions 78 // =========================================================================== 79 /** 80 * @class SUMOVTypeParameter 81 * @brief Structure representing possible vehicle parameter 82 */ 83 class SUMOVTypeParameter : public Parameterised { 84 public: 85 /** @brief Constructor 86 * 87 * Initialises the structure with default values 88 */ 89 SUMOVTypeParameter(const std::string& vtid, const SUMOVehicleClass vc = SVC_IGNORING); 90 ~SUMOVTypeParameter()91 virtual ~SUMOVTypeParameter() {}; 92 93 /** @brief Returns whether the given parameter was set 94 * @param[in] what The parameter which one asks for 95 * @return Whether the given parameter was set 96 */ wasSet(int what)97 bool wasSet(int what) const { 98 return (parametersSet & what) != 0; 99 } 100 101 102 /** @brief Writes the vtype 103 * 104 * @param[in, out] dev The device to write into 105 * @exception IOError not yet implemented 106 */ 107 void write(OutputDevice& dev) const; 108 109 /// @brief Validates stored car-following parameter 110 void validateCFParameter() const; 111 112 /** @brief Returns the named value from the map, or the default if it is not contained there 113 * @param[in] attr The corresponding xml attribute 114 * @param[in] defaultValue The value to return if the given map does not contain the named variable 115 * @return The named value from the map or the default if it does not exist there 116 */ 117 double getCFParam(const SumoXMLAttr attr, const double defaultValue) const; 118 119 /** @brief Returns the named value from the map, or the default if it is not contained there 120 * @param[in] attr The corresponding xml attribute 121 * @param[in] defaultValue The value to return if the given map does not contain the named variable 122 * @return The named value from the map or the default if it does not exist there 123 */ 124 std::string getCFParamString(const SumoXMLAttr attr, const std::string defaultValue) const; 125 126 /** @brief Returns the named value from the map, or the default if it is not contained there 127 * @param[in] attr The corresponding xml attribute 128 * @param[in] defaultValue The value to return if the given map does not contain the named variable 129 * @return The named value from the map or the default if it does not exist there 130 */ 131 double getLCParam(const SumoXMLAttr attr, const double defaultValue) const; 132 133 /// @brief sub-model parameters 134 typedef std::map<SumoXMLAttr, std::string> SubParams; 135 136 /// @brief Returns the LC parameter 137 const SubParams& getLCParams() const; 138 139 /** @brief Returns the named value from the map, or the default if it is not contained there 140 * @param[in] attr The corresponding xml attribute 141 * @param[in] defaultValue The value to return if the given map does not contain the named variable 142 * @return The named value from the map or the default if it does not exist there 143 */ 144 double getJMParam(const SumoXMLAttr attr, const double defaultValue) const; 145 146 /** @brief Returns the named value from the map, or the default if it is not contained there 147 * @param[in] attr The corresponding xml attribute 148 * @param[in] defaultValue The value to return if the given map does not contain the named variable 149 * @return The named value from the map or the default if it does not exist there 150 */ 151 std::string getJMParamString(const SumoXMLAttr attr, const std::string defaultValue) const; 152 153 /// @brief The vehicle type's id 154 std::string id; 155 156 /// @brief The physical vehicle length 157 double length; 158 /// @brief This class' free space in front of the vehicle itself 159 double minGap; 160 /// @brief The vehicle type's maximum speed [m/s] 161 double maxSpeed; 162 /// @brief The vehicle type's default actionStepLength [ms], i.e. the interval between two control actions. 163 /// The default value of 0ms. induces the value to be traced from MSGlobals::gActionStepLength 164 SUMOTime actionStepLength; 165 /// @brief The probability when being added to a distribution without an explicit probability 166 double defaultProbability; 167 /// @brief The factor by which the maximum speed may deviate from the allowed max speed on the street 168 Distribution_Parameterized speedFactor; 169 /// @brief The emission class of this vehicle 170 SUMOEmissionClass emissionClass; 171 /// @brief The color 172 RGBColor color; 173 /// @brief The vehicle's class 174 SUMOVehicleClass vehicleClass; 175 /// @brief The vehicle's impatience (willingness to obstruct others) 176 double impatience; 177 /// @brief The person capacity of the vehicle 178 int personCapacity; 179 /// @brief The container capacity of the vehicle 180 int containerCapacity; 181 /// @brief The time a person needs to board the vehicle 182 SUMOTime boardingDuration; 183 /// @brief The time a container needs to get loaded on the vehicle 184 SUMOTime loadingDuration; 185 186 /// @name Values for drawing this class' vehicles 187 /// @{ 188 189 /// @brief This class' width 190 double width; 191 192 /// @brief This class' height 193 double height; 194 195 /// @brief This class' shape 196 SUMOVehicleShape shape; 197 198 /// @brief 3D model file for this class 199 std::string osgFile; 200 201 /// @brief Image file for this class 202 std::string imgFile; 203 /// @} 204 205 206 /// @brief The enum-representation of the car-following model to use 207 SumoXMLTag cfModel; 208 209 /// @brief Whether vehicles of this type are equipped with a driver (i.e. MSDriverState)) 210 bool hasDriverState; 211 212 /// @brief Car-following parameter 213 SubParams cfParameter; 214 /// @brief Lane-changing parameter 215 SubParams lcParameter; 216 /// @brief Junction-model parameter 217 SubParams jmParameter; 218 219 /// @brief The lane-change model to use 220 LaneChangeModel lcModel; 221 222 /// @brief The vehicle type's maximum lateral speed [m/s] 223 double maxSpeedLat; 224 /// @brief The vehicles desired lateral alignment 225 LateralAlignment latAlignment; 226 /// @brief The vehicle type's minimum lateral gap [m] 227 double minGapLat; 228 229 /// @brief the length of train carriages and locomotive 230 double carriageLength; 231 double locomotiveLength; 232 double carriageGap; 233 234 /// @brief Information for the router which parameter were set 235 int parametersSet; 236 237 238 /// @brief Information whether this type was already saved (needed by routers) 239 mutable bool saved; 240 241 /// @brief Information whether this is a type-stub, being only referenced but not defined (needed by routers) 242 bool onlyReferenced; 243 244 /** @brief Returns the default acceleration for the given vehicle class 245 * This needs to be a function because the actual value is stored in the car following model 246 * @param[in] vc the vehicle class 247 * @return the acceleration in m/s^2 248 */ 249 static double getDefaultAccel(const SUMOVehicleClass vc = SVC_IGNORING); 250 251 /** @brief Returns the default deceleration for the given vehicle class 252 * This needs to be a function because the actual value is stored in the car following model 253 * @param[in] vc the vehicle class 254 * @return the deceleration in m/s^2 255 */ 256 static double getDefaultDecel(const SUMOVehicleClass vc = SVC_IGNORING); 257 258 /** @brief Returns the default emergency deceleration for the given vehicle class 259 * This needs to be a function because the actual value is stored in the car following model 260 * @param[in] vc the vehicle class 261 * @param[in] decel the deceleration of the vehicle type 262 * @return the emergency deceleration in m/s^2 263 */ 264 static double getDefaultEmergencyDecel(const SUMOVehicleClass vc, double decel, double defaultOption); 265 266 /** @brief Returns the default driver's imperfection (sigma or epsilon in Krauss' model) for the given vehicle class 267 * This needs to be a function because the actual value is stored in the car following model 268 * @param[in] vc the vehicle class 269 * @return the imperfection as a value between 0 and 1 270 */ 271 static double getDefaultImperfection(const SUMOVehicleClass vc = SVC_IGNORING); 272 273 /// @brief return the default parameters, this is a function due to the http://www.parashift.com/c++-faq/static-init-order.html 274 static const SUMOVTypeParameter& getDefault(); 275 276 }; 277 278 #endif 279 280 /****************************************************************************/ 281 282