Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/common/SUMOVehicleClass.h
169678 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file SUMOVehicleClass.h
15
/// @author Daniel Krajzewicz
16
/// @author Jakob Erdmann
17
/// @author Michael Behrisch
18
/// @author Walter Bamberger
19
/// @author Laura Bieker
20
/// @date 2006-01-24
21
///
22
// Definitions of SUMO vehicle classes and helper functions
23
/****************************************************************************/
24
#pragma once
25
#include <config.h>
26
#include <string>
27
#include <set>
28
#include <limits>
29
#include <utils/common/StdDefs.h>
30
#include <utils/common/UtilExceptions.h>
31
#include <utils/common/StringBijection.h>
32
#include <utils/xml/SUMOXMLDefinitions.h>
33
34
35
// ===========================================================================
36
// class declarations
37
// ===========================================================================
38
class OutputDevice;
39
class SUMOSAXAttributes;
40
41
// ===========================================================================
42
// enum definitions
43
// ===========================================================================
44
/**
45
* @enum SUMOVehicleShape
46
* @brief Definition of vehicle classes to differ between different appearances
47
*/
48
enum class SUMOVehicleShape {
49
/// @brief not defined
50
UNKNOWN,
51
/// @brief render as a pedestrian
52
PEDESTRIAN,
53
/// @brief render as a bicycle
54
BICYCLE,
55
/// @brief render as a moped
56
MOPED,
57
/// @brief render as a motorcycle
58
MOTORCYCLE,
59
/// @brief render as a passenger vehicle
60
PASSENGER,
61
/// @brief render as a sedan passenger vehicle ("Stufenheck")
62
PASSENGER_SEDAN,
63
/// @brief render as a hatchback passenger vehicle ("Fliessheck")
64
PASSENGER_HATCHBACK,
65
/// @brief render as a wagon passenger vehicle ("Combi")
66
PASSENGER_WAGON,
67
/// @brief render as a van
68
PASSENGER_VAN,
69
/// @brief automated car (with cruise controllers)
70
//PASSENGER_AUTOMATED,
71
/// @brief render as a taxi
72
TAXI,
73
/// @brief render as a delivery vehicle
74
DELIVERY,
75
/// @brief render as a transport vehicle
76
TRUCK,
77
/// @brief render as a semi-trailer transport vehicle ("Sattelschlepper")
78
TRUCK_SEMITRAILER,
79
/// @brief render as a transport vehicle with one trailer
80
TRUCK_1TRAILER,
81
/// @brief render as a bus
82
BUS,
83
/// @brief render as a coach
84
BUS_COACH,
85
/// @brief render as a flexible city bus
86
BUS_FLEXIBLE,
87
/// @brief render as a trolley bus
88
BUS_TROLLEY,
89
/// @brief render as a rail
90
RAIL,
91
/// @brief render as a (city) rail without locomotive
92
RAIL_CAR,
93
/// @brief render as a cargo train
94
RAIL_CARGO,
95
/// @brief render as a (futuristic) e-vehicle
96
E_VEHICLE,
97
/// @brief render as a giant ant
98
ANT,
99
/// @brief render as a arbitrary ship
100
SHIP,
101
/// @brief render as an emergency vehicle
102
EMERGENCY,
103
/// @brief render as a fire brigade
104
FIREBRIGADE,
105
/// @brief render as a police car
106
POLICE,
107
/// @brief render as a rickshaw
108
RICKSHAW,
109
/// @brief render as a scooter
110
SCOOTER,
111
/// @brief render as aircraft
112
AIRCRAFT
113
};
114
115
116
117
/**
118
* @enum SUMOVehicleClass
119
* @brief Definition of vehicle classes to differ between different lane usage and authority types
120
*
121
* Bits:
122
* @arg 0-7: vehicle ownership
123
* @arg 8-23: vehicle size
124
*
125
* From NavTeq:
126
* @arg [0] All
127
* @arg [1] Passenger cars
128
* @arg [2] High Occupancy Vehicle
129
* @arg [3] Emergency Vehicle
130
* @arg [4] Taxi
131
* @arg [5] Public Bus
132
* @arg [6] Delivery Truck
133
* @arg [7] Transport Truck
134
* @arg [8] Bicycle
135
* @arg [9] Pedestrian
136
*
137
* enum type decleration to work around visual studio non-compliance
138
* see https://gist.github.com/NTimmons/a7229b1dacf8280be2292ebd6b2b8b5d#file-enum-h
139
*/
140
enum SUMOVehicleClass : int64_t {
141
/// @brief vehicles ignoring classes
142
SVC_IGNORING = 0,
143
144
/// @name vehicle ownership
145
//@{
146
147
/// @brief private vehicles
148
SVC_PRIVATE = 1,
149
/// @brief public emergency vehicles
150
SVC_EMERGENCY = 1 << 1,
151
/// @brief authorities vehicles
152
SVC_AUTHORITY = 1 << 2,
153
/// @brief army vehicles
154
SVC_ARMY = 1 << 3,
155
/// @brief vip vehicles
156
SVC_VIP = 1 << 4,
157
//@}
158
159
160
/// @name vehicle size
161
//@{
162
/// @brief pedestrian
163
SVC_PEDESTRIAN = 1 << 5,
164
165
/// @brief vehicle is a passenger car (a "normal" car)
166
SVC_PASSENGER = 1 << 6,
167
/// @brief vehicle is a HOV
168
SVC_HOV = 1 << 7,
169
/// @brief vehicle is a taxi
170
SVC_TAXI = 1 << 8,
171
/// @brief vehicle is a bus
172
SVC_BUS = 1 << 9,
173
/// @brief vehicle is a coach
174
SVC_COACH = 1 << 10,
175
/// @brief vehicle is a small delivery vehicle
176
SVC_DELIVERY = 1 << 11,
177
/// @brief vehicle is a large transport vehicle
178
SVC_TRUCK = 1 << 12,
179
/// @brief vehicle is a large transport vehicle
180
SVC_TRAILER = 1 << 13,
181
/// @brief vehicle is a motorcycle
182
SVC_MOTORCYCLE = 1 << 14,
183
/// @brief vehicle is a moped
184
SVC_MOPED = 1 << 15,
185
/// @brief vehicle is a bicycle
186
SVC_BICYCLE = 1 << 16,
187
/// @brief is an electric vehicle
188
SVC_E_VEHICLE = 1 << 17,
189
190
/// @brief vehicle is a light rail
191
SVC_TRAM = 1 << 18,
192
/// @brief vehicle is a city rail
193
SVC_RAIL_URBAN = 1 << 19,
194
/// @brief vehicle is a not electrified rail
195
SVC_RAIL = 1 << 20,
196
/// @brief rail vehicle that requires electrified tracks
197
SVC_RAIL_ELECTRIC = 1 << 21,
198
/// @brief vehicle that is allowed to drive on high-speed rail tracks
199
SVC_RAIL_FAST = 1 << 22,
200
201
/// @brief is an arbitrary ship
202
SVC_SHIP = 1 << 23,
203
204
SVC_CONTAINER = 1 << 24,
205
SVC_CABLE_CAR = 1 << 25,
206
SVC_SUBWAY = 1 << 26,
207
SVC_AIRCRAFT = 1 << 27,
208
SVC_WHEELCHAIR = 1 << 28,
209
SVC_SCOOTER = 1 << 29,
210
SVC_DRONE = 1 << 30,
211
212
/// @brief is a user-defined type
213
SVC_CUSTOM1 = (long long int)1 << 31,
214
/// @brief is a user-defined type
215
SVC_CUSTOM2 = (long long int)1 << 32,
216
//@}
217
218
/// @brief classes which drive on tracks
219
SVC_RAIL_CLASSES = SVC_RAIL_ELECTRIC | SVC_RAIL_FAST | SVC_RAIL | SVC_RAIL_URBAN | SVC_TRAM | SVC_SUBWAY | SVC_CABLE_CAR,
220
/// @brief public transport
221
SVC_PUBLIC_CLASSES = SVC_BUS | SVC_RAIL_CLASSES | SVC_CABLE_CAR | SVC_AIRCRAFT,
222
/// @brief classes which (normally) do not drive on normal roads
223
SVC_NON_ROAD_RAIL = SVC_SHIP | SVC_AIRCRAFT | SVC_DRONE | SVC_CONTAINER,
224
SVC_NON_ROAD = SVC_RAIL_CLASSES | SVC_NON_ROAD_RAIL,
225
SVC_VULNERABLE = SVC_PEDESTRIAN | SVC_WHEELCHAIR | SVC_BICYCLE | SVC_SCOOTER,
226
/// @brief classes which drive on roads
227
SVC_ROAD_MOTOR_CLASSES = (SVC_PASSENGER | SVC_HOV | SVC_TAXI | SVC_BUS | SVC_COACH | SVC_DELIVERY |
228
SVC_TRUCK | SVC_TRAILER | SVC_MOTORCYCLE | SVC_MOPED | SVC_E_VEHICLE),
229
SVC_ROAD_CLASSES = (SVC_ROAD_MOTOR_CLASSES | SVC_VULNERABLE)
230
};
231
232
extern const SUMOVehicleClass SUMOVehicleClass_MAX;
233
extern StringBijection<SUMOVehicleClass> SumoVehicleClassStrings;
234
extern std::set<std::string> deprecatedVehicleClassesSeen;
235
extern StringBijection<SUMOVehicleShape> SumoVehicleShapeStrings;
236
237
/// @brief bitset where each bit declares whether a certain SVC may use this edge/lane
238
typedef long long int SVCPermissions;
239
240
/// @brief all VClasses are allowed
241
extern const SVCPermissions SVCAll;
242
243
/// @brief permissions not specified
244
extern const SVCPermissions SVC_UNSPECIFIED;
245
246
/**
247
* @enum SUMOEmissionClass
248
* @brief Definition of vehicle emission classes
249
* @see PollutantsInterface
250
*/
251
typedef int SUMOEmissionClass;
252
253
/// @brief emission class not specified
254
extern const SUMOEmissionClass EMISSION_CLASS_UNSPECIFIED;
255
256
// ===========================================================================
257
// Stop Offsets
258
// ===========================================================================
259
260
/// @brief stop offset
261
class StopOffset {
262
263
public:
264
/// @brief constructor
265
StopOffset();
266
267
/// @brief constructor (parser)
268
StopOffset(const SUMOSAXAttributes& attrs, bool& ok);
269
270
/// @brief check if stopOffset was defined
271
bool isDefined() const;
272
273
/// @brief reset stopOffset
274
void reset();
275
276
/// @brief get permissions
277
SVCPermissions getPermissions() const;
278
279
/// @brief get exceptions (used in netedit)
280
std::string getExceptions() const;
281
282
/// @brief get offset
283
double getOffset() const;
284
285
/// @brief update permissions
286
void setPermissions(const SVCPermissions permissions);
287
288
/// @brief set exceptions (used in netedit)
289
void setExceptions(const std::string permissions);
290
291
/// @brief set offset
292
void setOffset(const double offset);
293
294
/// @brief comparator
295
bool operator==(StopOffset const& other) const;
296
297
/// @brief comparator
298
bool operator!=(StopOffset const& other) const;
299
300
private:
301
/// @brief permissions (allowed)
302
SVCPermissions myPermissions;
303
304
/// @brief offset
305
double myOffset;
306
};
307
308
// ===========================================================================
309
// method declarations
310
// ===========================================================================
311
312
// ---------------------------------------------------------------------------
313
// abstract vehicle class / purpose
314
// ---------------------------------------------------------------------------
315
316
/** @brief Returns the ids of the given classes, divided using a ' '
317
* @param[in] the permissions to encode
318
* @param[in] expand whether 'all' should be used
319
* @return The string representation of these classes
320
*/
321
extern const std::string& getVehicleClassNames(SVCPermissions permissions, bool expand = false);
322
323
/** @brief Returns the ids of the given classes, divided using a ' '
324
* @param[in] the permissions to encode
325
* @return The string representation of these classes as a vector
326
*/
327
extern const std::vector<std::string>& getVehicleClassNamesList(SVCPermissions permissions);
328
329
/** @brief Returns the class id of the abstract class given by its name
330
* @param[in] name The name of the abstract vehicle class
331
* @return The internal representation of this class. Name must not be a
332
* compound name
333
*/
334
extern SUMOVehicleClass getVehicleClassID(const std::string& name);
335
336
/** @brief Returns the OR'ed id of the compound class given by its name
337
* @param[in] name The name of the abstract vehicle class
338
* @return The OR'ed combination of base enum values
339
*/
340
extern SVCPermissions getVehicleClassCompoundID(const std::string& name);
341
342
/** @brief Parses the given definition of allowed vehicle classes into the given containers
343
* Deprecated classes go into a separate container.
344
*
345
* @param[in] classNames Space separated class names
346
* @param[out] container The set of vehicle classes to fill
347
* throws ProcessError if parsing fails
348
*/
349
extern SVCPermissions parseVehicleClasses(const std::string& allowedS);
350
351
/// @brief Checks whether the given string contains only known vehicle classes
352
extern bool canParseVehicleClasses(const std::string& classes);
353
354
/** @brief Encodes the given vector of allowed and disallowed classes into a bitset
355
* @param[in] allowedS Definition which classes are allowed
356
* @param[in] disallowedS Definition which classes are not allowed
357
*/
358
extern SVCPermissions parseVehicleClasses(const std::string& allowedS, const std::string& disallowedS, const MMVersion& networkVersion = NETWORK_VERSION);
359
360
/** @brief Encodes the given vector of allowed class into a bitset
361
* Unlike the methods which parse a string it gives immediately a warning output on deprecated vehicle classes.
362
* @param[in] classesS The names vector to parse
363
*/
364
extern SVCPermissions parseVehicleClasses(const std::vector<std::string>& allowedS);
365
366
/** @brief Interprets disallowed vehicles depending on network version
367
* @param[in] disallowed The values found in the disallow attribute
368
* @param[in] networkVersion The version of the network from which the disallow value was loaded
369
* @return The (possibly) extended set of disallowed classes
370
*/
371
extern SVCPermissions extraDisallowed(SVCPermissions disallowed, const MMVersion& networkVersion);
372
373
/// @brief negate the given permissions and ensure that only relevant bits are set
374
extern SVCPermissions invertPermissions(SVCPermissions permissions);
375
376
/// @brief writes allowed disallowed attributes if needed;
377
extern void writePermissions(OutputDevice& into, SVCPermissions permissions);
378
379
/// @brief writes allowed disallowed attributes if needed;
380
extern void writePreferences(OutputDevice& into, SVCPermissions preferred);
381
382
// ---------------------------------------------------------------------------
383
// vehicle shape class
384
// ---------------------------------------------------------------------------
385
386
/** @brief Returns the class name of the shape class given by its id
387
* @param[in] id The id of the shape class
388
* @return The string representation of this class
389
*/
390
extern std::string getVehicleShapeName(SUMOVehicleShape id);
391
392
/** @brief Returns the class id of the shape class given by its name
393
* @param[in] name The name of the shape class
394
* @return The internal representation of this class
395
*/
396
extern SUMOVehicleShape getVehicleShapeID(const std::string& name);
397
398
/// @brief Checks whether the given string contains only known vehicle shape
399
extern bool canParseVehicleShape(const std::string& shape);
400
401
/** @brief Returns whether an edge with the given permissions is a (exclusive) railway edge
402
* @param[in] permissions The permissions of the edge
403
* @return Whether the edge is a railway edge
404
*/
405
extern bool isRailway(SVCPermissions permissions);
406
407
/** @brief Returns whether an edge with the given permissions is a railway edge or a shared road/rail edge
408
* @param[in] permissions The permissions of the edge
409
* @return Whether the edge is a (non-exclusive) railway edge
410
*/
411
extern bool isRailwayOrShared(SVCPermissions permissions);
412
413
/** @brief Returns whether an edge with the given permissions is a tram edge
414
* @param[in] permissions The permissions of the edge
415
* @return Whether the edge is a tram edge
416
*/
417
extern bool isTram(SVCPermissions permissions);
418
419
/** @brief Returns whether an edge with the given permissions is a bicycle edge
420
* @param[in] permissions The permissions of the edge
421
* @return Whether the edge is a bicycle edge
422
*/
423
extern bool isBikepath(SVCPermissions permissions);
424
425
/** @brief Returns whether an edge with the given permissions is a waterway edge
426
* @param[in] permissions The permissions of the edge
427
* @return Whether the edge is a waterway edge
428
*/
429
extern bool isWaterway(SVCPermissions permissions);
430
431
/** @brief Returns whether an edge with the given permissions is an airway edge
432
* @param[in] permissions The permissions of the edge
433
* @return Whether the edge is an airway edge
434
*/
435
extern bool isAirway(SVCPermissions permissions);
436
437
/** @brief Returns whether an edge with the given permissions is a forbidden edge
438
* @param[in] permissions The permissions of the edge
439
* @return Whether the edge is forbidden
440
*/
441
extern bool isForbidden(SVCPermissions permissions);
442
443
/** @brief Returns whether an edge with the given permissions is a sidewalk
444
* @param[in] permissions The permissions of the edge
445
* @return Whether the edge is a sidewalk
446
*/
447
extern bool isSidewalk(SVCPermissions permissions);
448
449
/** @brief Returns whether an edge with the given permissions allows only vulnerable road users
450
* @param[in] permissions The permissions of the edge
451
* @return Whether the edge allows only a (non-empty) subset of SVC_PEDESTRIAN, SVC_WHEELCHAIR, SVC_BICYCLE, SVC_SCOOTER
452
*/
453
extern bool isForVulnerableModes(SVCPermissions permissions);
454
455
/** @brief Returns whether an edge with the given permissions forbids vehicles
456
* @param[in] permissions The permissions of the edge
457
* @return Whether the edge is forbidden for vehicles
458
*/
459
extern bool noVehicles(SVCPermissions permissions);
460
461
/** @brief Returns the default vehicle length
462
* This put into a function so it can be used by NBVehicle
463
* @param[in] vc the vehicle class
464
* @return the default length in m
465
*/
466
extern double getDefaultVehicleLength(const SUMOVehicleClass vc = SVC_IGNORING);
467
468
// ---------------------------------------------------------------------------
469
// default vehicle type parameter
470
// ---------------------------------------------------------------------------
471
extern const std::string DEFAULT_VTYPE_ID;
472
extern const std::string DEFAULT_PEDTYPE_ID;
473
extern const std::string DEFAULT_BIKETYPE_ID;
474
extern const std::string DEFAULT_CONTAINERTYPE_ID;
475
extern const std::string DEFAULT_TAXITYPE_ID;
476
extern const std::string DEFAULT_RAILTYPE_ID;
477
extern const std::set<std::string> DEFAULT_VTYPES;
478
479
extern const double DEFAULT_VEH_PROB; // !!! does this belong here?
480
extern const double DEFAULT_VEH_MASS;
481
extern const double DEFAULT_VEH_WIDTH;
482
extern const double DEFAULT_VEH_HEIGHT;
483
extern const double DEFAULT_VEH_SHUT_OFF_STOP;
484
485
extern const double DEFAULT_PEDESTRIAN_SPEED;
486
extern const double DEFAULT_BICYCLE_SPEED;
487
488
extern const double DEFAULT_CONTAINER_TRANSHIP_SPEED;
489
490