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 SUMOVehicleClass.h 11 /// @author Daniel Krajzewicz 12 /// @author Jakob Erdmann 13 /// @author Michael Behrisch 14 /// @author Walter Bamberger 15 /// @author Laura Bieker 16 /// @date 2006-01-24 17 /// @version $Id$ 18 /// 19 // Definitions of SUMO vehicle classes and helper functions 20 /****************************************************************************/ 21 #ifndef SUMOVehicleClass_h 22 #define SUMOVehicleClass_h 23 24 25 // =========================================================================== 26 // included modules 27 // =========================================================================== 28 29 #include <string> 30 #include <set> 31 #include <limits> 32 #include <utils/common/UtilExceptions.h> 33 #include <utils/common/StringBijection.h> 34 #include <utils/xml/SUMOXMLDefinitions.h> 35 36 37 // =========================================================================== 38 // class declarations 39 // =========================================================================== 40 class OutputDevice; 41 class SUMOSAXAttributes; 42 43 // =========================================================================== 44 // enum definitions 45 // =========================================================================== 46 /** 47 * @enum SUMOVehicleShape 48 * @brief Definition of vehicle classes to differ between different appearences 49 */ 50 enum SUMOVehicleShape { 51 /// @brief not defined 52 SVS_UNKNOWN, 53 /// @brief render as a pedestrian 54 SVS_PEDESTRIAN, 55 /// @brief render as a bicycle 56 SVS_BICYCLE, 57 /// @brief render as a moped 58 SVS_MOPED, 59 /// @brief render as a motorcycle 60 SVS_MOTORCYCLE, 61 /// @brief render as a passenger vehicle 62 SVS_PASSENGER, 63 /// @brief render as a sedan passenger vehicle ("Stufenheck") 64 SVS_PASSENGER_SEDAN, 65 /// @brief render as a hatchback passenger vehicle ("Fliessheck") 66 SVS_PASSENGER_HATCHBACK, 67 /// @brief render as a wagon passenger vehicle ("Combi") 68 SVS_PASSENGER_WAGON, 69 /// @brief render as a van 70 SVS_PASSENGER_VAN, 71 /// @brief automated car (with cruise controllers) 72 //SVS_PASSENGER_AUTOMATED, 73 /// @brief render as a delivery vehicle 74 SVS_DELIVERY, 75 /// @brief render as a transport vehicle 76 SVS_TRUCK, 77 /// @brief render as a semi-trailer transport vehicle ("Sattelschlepper") 78 SVS_TRUCK_SEMITRAILER, 79 /// @brief render as a transport vehicle with one trailer 80 SVS_TRUCK_1TRAILER, 81 /// @brief render as a bus 82 SVS_BUS, 83 /// @brief render as a coach 84 SVS_BUS_COACH, 85 /// @brief render as a flexible city bus 86 SVS_BUS_FLEXIBLE, 87 /// @brief render as a trolley bus 88 SVS_BUS_TROLLEY, 89 /// @brief render as a rail 90 SVS_RAIL, 91 /// @brief render as a (city) rail without locomotive 92 SVS_RAIL_CAR, 93 /// @brief render as a cargo train 94 SVS_RAIL_CARGO, 95 /// @brief render as a (futuristic) e-vehicle 96 SVS_E_VEHICLE, 97 /// @brief render as a giant ant 98 SVS_ANT, 99 /// @brief render as a arbitrary ship 100 SVS_SHIP, 101 /// @brief render as an emergency vehicle 102 SVS_EMERGENCY, 103 /// @brief render as a fire brigade 104 SVS_FIREBRIGADE, 105 /// @brief render as a police car 106 SVS_POLICE, 107 /// @brief render as a rickshaw 108 SVS_RICKSHAW 109 }; 110 111 112 113 /** 114 * @enum SUMOVehicleClass 115 * @brief Definition of vehicle classes to differ between different lane usage and authority types 116 * 117 * Bits: 118 * @arg 0-7: vehicle ownership 119 * @arg 8-23: vehicle size 120 * 121 * From NavTeq: 122 * @arg [0] All 123 * @arg [1] Passenger cars 124 * @arg [2] High Occupancy Vehicle 125 * @arg [3] Emergency Vehicle 126 * @arg [4] Taxi 127 * @arg [5] Public Bus 128 * @arg [6] Delivery Truck 129 * @arg [7] Transport Truck 130 * @arg [8] Bicycle 131 * @arg [9] Pedestrian 132 */ 133 enum SUMOVehicleClass { 134 /// @brief vehicles ignoring classes 135 SVC_IGNORING = 0, 136 137 /// @name vehicle ownership 138 //@{ 139 140 /// @brief private vehicles 141 SVC_PRIVATE = 1, 142 /// @brief public emergency vehicles 143 SVC_EMERGENCY = 1 << 1, 144 /// @brief authorities vehicles 145 SVC_AUTHORITY = 1 << 2, 146 /// @brief army vehicles 147 SVC_ARMY = 1 << 3, 148 /// @brief vip vehicles 149 SVC_VIP = 1 << 4, 150 //@} 151 152 153 /// @name vehicle size 154 //@{ 155 156 /// @brief vehicle is a passenger car (a "normal" car) 157 SVC_PASSENGER = 1 << 5, 158 /// @brief vehicle is a HOV 159 SVC_HOV = 1 << 6, 160 /// @brief vehicle is a taxi 161 SVC_TAXI = 1 << 7, 162 /// @brief vehicle is a bus 163 SVC_BUS = 1 << 8, 164 /// @brief vehicle is a coach 165 SVC_COACH = 1 << 9, 166 /// @brief vehicle is a small delivery vehicle 167 SVC_DELIVERY = 1 << 10, 168 /// @brief vehicle is a large transport vehicle 169 SVC_TRUCK = 1 << 11, 170 /// @brief vehicle is a large transport vehicle 171 SVC_TRAILER = 1 << 12, 172 /// @brief vehicle is a light rail 173 SVC_TRAM = 1 << 13, 174 /// @brief vehicle is a city rail 175 SVC_RAIL_URBAN = 1 << 14, 176 /// @brief vehicle is a not electrified rail 177 SVC_RAIL = 1 << 15, 178 /// @brief vehicle is a (possibly fast moving) electric rail 179 SVC_RAIL_ELECTRIC = 1 << 16, 180 181 /// @brief vehicle is a motorcycle 182 SVC_MOTORCYCLE = 1 << 17, 183 /// @brief vehicle is a moped 184 SVC_MOPED = 1 << 18, 185 /// @brief vehicle is a bicycle 186 SVC_BICYCLE = 1 << 19, 187 /// @brief is a pedestrian 188 SVC_PEDESTRIAN = 1 << 20, 189 /// @brief is an electric vehicle 190 SVC_E_VEHICLE = 1 << 21, 191 /// @brief is an arbitrary ship 192 SVC_SHIP = 1 << 22, 193 /// @brief is a user-defined type 194 SVC_CUSTOM1 = 1 << 23, 195 /// @brief is a user-defined type 196 SVC_CUSTOM2 = 1 << 24, 197 /// @brief is an automated car (ACC/CACC capable) 198 SVC_AUTOMATED = 1 << 25, 199 //@} 200 201 /// @brief classes which drive on tracks 202 SVC_RAIL_CLASSES = SVC_RAIL_ELECTRIC | SVC_RAIL | SVC_RAIL_URBAN | SVC_TRAM, 203 /// @brief classes which (normally) do not drive on normal roads 204 SVC_NON_ROAD = SVC_RAIL_CLASSES | SVC_SHIP 205 }; 206 207 extern const int SUMOVehicleClass_MAX; 208 extern StringBijection<SUMOVehicleClass> SumoVehicleClassStrings; 209 extern std::set<std::string> deprecatedVehicleClassesSeen; 210 extern StringBijection<SUMOVehicleShape> SumoVehicleShapeStrings; 211 212 /// @brief bitset where each bit declares whether a certain SVC may use this edge/lane 213 typedef int SVCPermissions; 214 215 /// @brief all VClasses are allowed 216 extern const SVCPermissions SVCAll; 217 218 /// @brief permissions not specified 219 extern const SVCPermissions SVC_UNSPECIFIED; 220 221 /** 222 * @enum SUMOEmissionClass 223 * @brief Definition of vehicle emission classes 224 * @see PollutantsInterface 225 */ 226 typedef int SUMOEmissionClass; 227 228 229 // =========================================================================== 230 // method declarations 231 // =========================================================================== 232 233 // --------------------------------------------------------------------------- 234 // abstract vehicle class / purpose 235 // --------------------------------------------------------------------------- 236 /** @brief Returns the ids of the given classes, divided using a ' ' 237 * @param[in] the permissions to encode 238 * @param[in] expand whether 'all' should be used 239 * @return The string representation of these classes 240 */ 241 extern const std::string& getVehicleClassNames(SVCPermissions permissions, bool expand = false); 242 243 /** @brief Returns the ids of the given classes, divided using a ' ' 244 * @param[in] the permissions to encode 245 * @return The string representation of these classes as a vector 246 */ 247 extern const std::vector<std::string>& getVehicleClassNamesList(SVCPermissions permissions); 248 249 /** @brief Returns the class id of the abstract class given by its name 250 * @param[in] name The name of the abstract vehicle class 251 * @return The internal representation of this class. Name must not be a 252 * compound name 253 */ 254 extern SUMOVehicleClass getVehicleClassID(const std::string& name); 255 256 /** @brief Returns the OR'ed id of the compound class given by its name 257 * @param[in] name The name of the abstract vehicle class 258 * @return The OR'ed combination of base enum values 259 */ 260 extern int getVehicleClassCompoundID(const std::string& name); 261 262 /** @brief Parses the given definition of allowed vehicle classes into the given containers 263 * Deprecated classes go into a separate container. 264 * 265 * @param[in] classNames Space separated class names 266 * @param[out] container The set of vehicle classes to fill 267 * throws ProcessError if parsing fails 268 */ 269 extern SVCPermissions parseVehicleClasses(const std::string& allowedS); 270 271 /// @brief Checks whether the given string contains only known vehicle classes 272 extern bool canParseVehicleClasses(const std::string& classes); 273 274 /** @brief Encodes the given vector of allowed and disallowed classes into a bitset 275 * @param[in] allowedS Definition which classes are allowed 276 * @param[in] disallowedS Definition which classes are not allowed 277 */ 278 extern SVCPermissions parseVehicleClasses(const std::string& allowedS, const std::string& disallowedS); 279 280 /** @brief Encodes the given vector of allowed classs into a bitset 281 * Unlike the methods which parse a string it gives immediately a warning output on deprecated vehicle classes. 282 * @param[in] classesS The names vector to parse 283 */ 284 extern SVCPermissions parseVehicleClasses(const std::vector<std::string>& allowedS); 285 286 /// @brief negate the given permissions and ensure that only relevant bits are set 287 extern SVCPermissions invertPermissions(SVCPermissions permissions); 288 289 /// @brief writes allowed disallowed attributes if needed; 290 extern void writePermissions(OutputDevice& into, SVCPermissions permissions); 291 292 /// @brief writes allowed disallowed attributes if needed; 293 extern void writePreferences(OutputDevice& into, SVCPermissions preferred); 294 295 /// @brief Extract stopOffsets from attributes of stopOffset element 296 extern std::map<SVCPermissions, double> parseStopOffsets(const SUMOSAXAttributes& attrs, bool& ok); 297 298 // --------------------------------------------------------------------------- 299 // vehicle shape class 300 // --------------------------------------------------------------------------- 301 /** @brief Returns the class name of the shape class given by its id 302 * @param[in] id The id of the shape class 303 * @return The string representation of this class 304 */ 305 extern std::string getVehicleShapeName(SUMOVehicleShape id); 306 307 /** @brief Returns the class id of the shape class given by its name 308 * @param[in] name The name of the shape class 309 * @return The internal representation of this class 310 */ 311 extern SUMOVehicleShape getVehicleShapeID(const std::string& name); 312 313 /// @brief Checks whether the given string contains only known vehicle shape 314 extern bool canParseVehicleShape(const std::string& shape); 315 316 /** @brief Returns whether an edge with the given permission is a railway edge 317 * @param[in] permissions The permissions of the edge 318 * @return Whether the edge is a railway edge 319 */ 320 extern bool isRailway(SVCPermissions permissions); 321 322 /** @brief Returns whether an edge with the given permission is a waterway edge 323 * @param[in] permissions The permissions of the edge 324 * @return Whether the edge is a waterway edge 325 */ 326 extern bool isWaterway(SVCPermissions permissions); 327 328 /** @brief Returns whether an edge with the given permission is a forbidden edge 329 * @param[in] permissions The permissions of the edge 330 * @return Whether the edge is forbidden 331 */ 332 extern bool isForbidden(SVCPermissions permissions); 333 334 /** @brief Returns whether an edge with the given permission is a sidewalk 335 * @param[in] permissions The permissions of the edge 336 * @return Whether the edge is a sidewalk 337 */ 338 extern bool isSidewalk(SVCPermissions permissions); 339 340 /** @brief Returns whether an edge with the given permission forbids vehicles 341 * @param[in] permissions The permissions of the edge 342 * @return Whether the edge is forbidden for vehicles 343 */ 344 extern bool noVehicles(SVCPermissions permissions); 345 346 // --------------------------------------------------------------------------- 347 // default vehicle type parameter 348 // --------------------------------------------------------------------------- 349 extern const std::string DEFAULT_VTYPE_ID; 350 extern const std::string DEFAULT_PEDTYPE_ID; 351 extern const std::string DEFAULT_BIKETYPE_ID; 352 353 extern const double DEFAULT_VEH_PROB; // !!! does this belong here? 354 355 extern const double DEFAULT_PEDESTRIAN_SPEED; 356 357 extern const double DEFAULT_CONTAINER_TRANSHIP_SPEED; 358 359 #endif 360 361 /****************************************************************************/ 362 363