/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file SUMOVehicleClass.h14/// @author Daniel Krajzewicz15/// @author Jakob Erdmann16/// @author Michael Behrisch17/// @author Walter Bamberger18/// @author Laura Bieker19/// @date 2006-01-2420///21// Definitions of SUMO vehicle classes and helper functions22/****************************************************************************/23#pragma once24#include <config.h>25#include <string>26#include <set>27#include <limits>28#include <utils/common/StdDefs.h>29#include <utils/common/UtilExceptions.h>30#include <utils/common/StringBijection.h>31#include <utils/xml/SUMOXMLDefinitions.h>323334// ===========================================================================35// class declarations36// ===========================================================================37class OutputDevice;38class SUMOSAXAttributes;3940// ===========================================================================41// enum definitions42// ===========================================================================43/**44* @enum SUMOVehicleShape45* @brief Definition of vehicle classes to differ between different appearances46*/47enum class SUMOVehicleShape {48/// @brief not defined49UNKNOWN,50/// @brief render as a pedestrian51PEDESTRIAN,52/// @brief render as a bicycle53BICYCLE,54/// @brief render as a moped55MOPED,56/// @brief render as a motorcycle57MOTORCYCLE,58/// @brief render as a passenger vehicle59PASSENGER,60/// @brief render as a sedan passenger vehicle ("Stufenheck")61PASSENGER_SEDAN,62/// @brief render as a hatchback passenger vehicle ("Fliessheck")63PASSENGER_HATCHBACK,64/// @brief render as a wagon passenger vehicle ("Combi")65PASSENGER_WAGON,66/// @brief render as a van67PASSENGER_VAN,68/// @brief automated car (with cruise controllers)69//PASSENGER_AUTOMATED,70/// @brief render as a taxi71TAXI,72/// @brief render as a delivery vehicle73DELIVERY,74/// @brief render as a transport vehicle75TRUCK,76/// @brief render as a semi-trailer transport vehicle ("Sattelschlepper")77TRUCK_SEMITRAILER,78/// @brief render as a transport vehicle with one trailer79TRUCK_1TRAILER,80/// @brief render as a bus81BUS,82/// @brief render as a coach83BUS_COACH,84/// @brief render as a flexible city bus85BUS_FLEXIBLE,86/// @brief render as a trolley bus87BUS_TROLLEY,88/// @brief render as a rail89RAIL,90/// @brief render as a (city) rail without locomotive91RAIL_CAR,92/// @brief render as a cargo train93RAIL_CARGO,94/// @brief render as a (futuristic) e-vehicle95E_VEHICLE,96/// @brief render as a giant ant97ANT,98/// @brief render as a arbitrary ship99SHIP,100/// @brief render as an emergency vehicle101EMERGENCY,102/// @brief render as a fire brigade103FIREBRIGADE,104/// @brief render as a police car105POLICE,106/// @brief render as a rickshaw107RICKSHAW,108/// @brief render as a scooter109SCOOTER,110/// @brief render as aircraft111AIRCRAFT112};113114115116/**117* @enum SUMOVehicleClass118* @brief Definition of vehicle classes to differ between different lane usage and authority types119*120* Bits:121* @arg 0-7: vehicle ownership122* @arg 8-23: vehicle size123*124* From NavTeq:125* @arg [0] All126* @arg [1] Passenger cars127* @arg [2] High Occupancy Vehicle128* @arg [3] Emergency Vehicle129* @arg [4] Taxi130* @arg [5] Public Bus131* @arg [6] Delivery Truck132* @arg [7] Transport Truck133* @arg [8] Bicycle134* @arg [9] Pedestrian135*136* enum type decleration to work around visual studio non-compliance137* see https://gist.github.com/NTimmons/a7229b1dacf8280be2292ebd6b2b8b5d#file-enum-h138*/139enum SUMOVehicleClass : int64_t {140/// @brief vehicles ignoring classes141SVC_IGNORING = 0,142143/// @name vehicle ownership144//@{145146/// @brief private vehicles147SVC_PRIVATE = 1,148/// @brief public emergency vehicles149SVC_EMERGENCY = 1 << 1,150/// @brief authorities vehicles151SVC_AUTHORITY = 1 << 2,152/// @brief army vehicles153SVC_ARMY = 1 << 3,154/// @brief vip vehicles155SVC_VIP = 1 << 4,156//@}157158159/// @name vehicle size160//@{161/// @brief pedestrian162SVC_PEDESTRIAN = 1 << 5,163164/// @brief vehicle is a passenger car (a "normal" car)165SVC_PASSENGER = 1 << 6,166/// @brief vehicle is a HOV167SVC_HOV = 1 << 7,168/// @brief vehicle is a taxi169SVC_TAXI = 1 << 8,170/// @brief vehicle is a bus171SVC_BUS = 1 << 9,172/// @brief vehicle is a coach173SVC_COACH = 1 << 10,174/// @brief vehicle is a small delivery vehicle175SVC_DELIVERY = 1 << 11,176/// @brief vehicle is a large transport vehicle177SVC_TRUCK = 1 << 12,178/// @brief vehicle is a large transport vehicle179SVC_TRAILER = 1 << 13,180/// @brief vehicle is a motorcycle181SVC_MOTORCYCLE = 1 << 14,182/// @brief vehicle is a moped183SVC_MOPED = 1 << 15,184/// @brief vehicle is a bicycle185SVC_BICYCLE = 1 << 16,186/// @brief is an electric vehicle187SVC_E_VEHICLE = 1 << 17,188189/// @brief vehicle is a light rail190SVC_TRAM = 1 << 18,191/// @brief vehicle is a city rail192SVC_RAIL_URBAN = 1 << 19,193/// @brief vehicle is a not electrified rail194SVC_RAIL = 1 << 20,195/// @brief rail vehicle that requires electrified tracks196SVC_RAIL_ELECTRIC = 1 << 21,197/// @brief vehicle that is allowed to drive on high-speed rail tracks198SVC_RAIL_FAST = 1 << 22,199200/// @brief is an arbitrary ship201SVC_SHIP = 1 << 23,202203SVC_CONTAINER = 1 << 24,204SVC_CABLE_CAR = 1 << 25,205SVC_SUBWAY = 1 << 26,206SVC_AIRCRAFT = 1 << 27,207SVC_WHEELCHAIR = 1 << 28,208SVC_SCOOTER = 1 << 29,209SVC_DRONE = 1 << 30,210211/// @brief is a user-defined type212SVC_CUSTOM1 = (long long int)1 << 31,213/// @brief is a user-defined type214SVC_CUSTOM2 = (long long int)1 << 32,215//@}216217/// @brief classes which drive on tracks218SVC_RAIL_CLASSES = SVC_RAIL_ELECTRIC | SVC_RAIL_FAST | SVC_RAIL | SVC_RAIL_URBAN | SVC_TRAM | SVC_SUBWAY | SVC_CABLE_CAR,219/// @brief public transport220SVC_PUBLIC_CLASSES = SVC_BUS | SVC_RAIL_CLASSES | SVC_CABLE_CAR | SVC_AIRCRAFT,221/// @brief classes which (normally) do not drive on normal roads222SVC_NON_ROAD_RAIL = SVC_SHIP | SVC_AIRCRAFT | SVC_DRONE | SVC_CONTAINER,223SVC_NON_ROAD = SVC_RAIL_CLASSES | SVC_NON_ROAD_RAIL,224SVC_VULNERABLE = SVC_PEDESTRIAN | SVC_WHEELCHAIR | SVC_BICYCLE | SVC_SCOOTER,225/// @brief classes which drive on roads226SVC_ROAD_MOTOR_CLASSES = (SVC_PASSENGER | SVC_HOV | SVC_TAXI | SVC_BUS | SVC_COACH | SVC_DELIVERY |227SVC_TRUCK | SVC_TRAILER | SVC_MOTORCYCLE | SVC_MOPED | SVC_E_VEHICLE),228SVC_ROAD_CLASSES = (SVC_ROAD_MOTOR_CLASSES | SVC_VULNERABLE)229};230231extern const SUMOVehicleClass SUMOVehicleClass_MAX;232extern StringBijection<SUMOVehicleClass> SumoVehicleClassStrings;233extern std::set<std::string> deprecatedVehicleClassesSeen;234extern StringBijection<SUMOVehicleShape> SumoVehicleShapeStrings;235236/// @brief bitset where each bit declares whether a certain SVC may use this edge/lane237typedef long long int SVCPermissions;238239/// @brief all VClasses are allowed240extern const SVCPermissions SVCAll;241242/// @brief permissions not specified243extern const SVCPermissions SVC_UNSPECIFIED;244245/**246* @enum SUMOEmissionClass247* @brief Definition of vehicle emission classes248* @see PollutantsInterface249*/250typedef int SUMOEmissionClass;251252/// @brief emission class not specified253extern const SUMOEmissionClass EMISSION_CLASS_UNSPECIFIED;254255// ===========================================================================256// Stop Offsets257// ===========================================================================258259/// @brief stop offset260class StopOffset {261262public:263/// @brief constructor264StopOffset();265266/// @brief constructor (parser)267StopOffset(const SUMOSAXAttributes& attrs, bool& ok);268269/// @brief check if stopOffset was defined270bool isDefined() const;271272/// @brief reset stopOffset273void reset();274275/// @brief get permissions276SVCPermissions getPermissions() const;277278/// @brief get exceptions (used in netedit)279std::string getExceptions() const;280281/// @brief get offset282double getOffset() const;283284/// @brief update permissions285void setPermissions(const SVCPermissions permissions);286287/// @brief set exceptions (used in netedit)288void setExceptions(const std::string permissions);289290/// @brief set offset291void setOffset(const double offset);292293/// @brief comparator294bool operator==(StopOffset const& other) const;295296/// @brief comparator297bool operator!=(StopOffset const& other) const;298299private:300/// @brief permissions (allowed)301SVCPermissions myPermissions;302303/// @brief offset304double myOffset;305};306307// ===========================================================================308// method declarations309// ===========================================================================310311// ---------------------------------------------------------------------------312// abstract vehicle class / purpose313// ---------------------------------------------------------------------------314315/** @brief Returns the ids of the given classes, divided using a ' '316* @param[in] the permissions to encode317* @param[in] expand whether 'all' should be used318* @return The string representation of these classes319*/320extern const std::string& getVehicleClassNames(SVCPermissions permissions, bool expand = false);321322/** @brief Returns the ids of the given classes, divided using a ' '323* @param[in] the permissions to encode324* @return The string representation of these classes as a vector325*/326extern const std::vector<std::string>& getVehicleClassNamesList(SVCPermissions permissions);327328/** @brief Returns the class id of the abstract class given by its name329* @param[in] name The name of the abstract vehicle class330* @return The internal representation of this class. Name must not be a331* compound name332*/333extern SUMOVehicleClass getVehicleClassID(const std::string& name);334335/** @brief Returns the OR'ed id of the compound class given by its name336* @param[in] name The name of the abstract vehicle class337* @return The OR'ed combination of base enum values338*/339extern SVCPermissions getVehicleClassCompoundID(const std::string& name);340341/** @brief Parses the given definition of allowed vehicle classes into the given containers342* Deprecated classes go into a separate container.343*344* @param[in] classNames Space separated class names345* @param[out] container The set of vehicle classes to fill346* throws ProcessError if parsing fails347*/348extern SVCPermissions parseVehicleClasses(const std::string& allowedS);349350/// @brief Checks whether the given string contains only known vehicle classes351extern bool canParseVehicleClasses(const std::string& classes);352353/** @brief Encodes the given vector of allowed and disallowed classes into a bitset354* @param[in] allowedS Definition which classes are allowed355* @param[in] disallowedS Definition which classes are not allowed356*/357extern SVCPermissions parseVehicleClasses(const std::string& allowedS, const std::string& disallowedS, const MMVersion& networkVersion = NETWORK_VERSION);358359/** @brief Encodes the given vector of allowed class into a bitset360* Unlike the methods which parse a string it gives immediately a warning output on deprecated vehicle classes.361* @param[in] classesS The names vector to parse362*/363extern SVCPermissions parseVehicleClasses(const std::vector<std::string>& allowedS);364365/** @brief Interprets disallowed vehicles depending on network version366* @param[in] disallowed The values found in the disallow attribute367* @param[in] networkVersion The version of the network from which the disallow value was loaded368* @return The (possibly) extended set of disallowed classes369*/370extern SVCPermissions extraDisallowed(SVCPermissions disallowed, const MMVersion& networkVersion);371372/// @brief negate the given permissions and ensure that only relevant bits are set373extern SVCPermissions invertPermissions(SVCPermissions permissions);374375/// @brief writes allowed disallowed attributes if needed;376extern void writePermissions(OutputDevice& into, SVCPermissions permissions);377378/// @brief writes allowed disallowed attributes if needed;379extern void writePreferences(OutputDevice& into, SVCPermissions preferred);380381// ---------------------------------------------------------------------------382// vehicle shape class383// ---------------------------------------------------------------------------384385/** @brief Returns the class name of the shape class given by its id386* @param[in] id The id of the shape class387* @return The string representation of this class388*/389extern std::string getVehicleShapeName(SUMOVehicleShape id);390391/** @brief Returns the class id of the shape class given by its name392* @param[in] name The name of the shape class393* @return The internal representation of this class394*/395extern SUMOVehicleShape getVehicleShapeID(const std::string& name);396397/// @brief Checks whether the given string contains only known vehicle shape398extern bool canParseVehicleShape(const std::string& shape);399400/** @brief Returns whether an edge with the given permissions is a (exclusive) railway edge401* @param[in] permissions The permissions of the edge402* @return Whether the edge is a railway edge403*/404extern bool isRailway(SVCPermissions permissions);405406/** @brief Returns whether an edge with the given permissions is a railway edge or a shared road/rail edge407* @param[in] permissions The permissions of the edge408* @return Whether the edge is a (non-exclusive) railway edge409*/410extern bool isRailwayOrShared(SVCPermissions permissions);411412/** @brief Returns whether an edge with the given permissions is a tram edge413* @param[in] permissions The permissions of the edge414* @return Whether the edge is a tram edge415*/416extern bool isTram(SVCPermissions permissions);417418/** @brief Returns whether an edge with the given permissions is a bicycle edge419* @param[in] permissions The permissions of the edge420* @return Whether the edge is a bicycle edge421*/422extern bool isBikepath(SVCPermissions permissions);423424/** @brief Returns whether an edge with the given permissions is a waterway edge425* @param[in] permissions The permissions of the edge426* @return Whether the edge is a waterway edge427*/428extern bool isWaterway(SVCPermissions permissions);429430/** @brief Returns whether an edge with the given permissions is an airway edge431* @param[in] permissions The permissions of the edge432* @return Whether the edge is an airway edge433*/434extern bool isAirway(SVCPermissions permissions);435436/** @brief Returns whether an edge with the given permissions is a forbidden edge437* @param[in] permissions The permissions of the edge438* @return Whether the edge is forbidden439*/440extern bool isForbidden(SVCPermissions permissions);441442/** @brief Returns whether an edge with the given permissions is a sidewalk443* @param[in] permissions The permissions of the edge444* @return Whether the edge is a sidewalk445*/446extern bool isSidewalk(SVCPermissions permissions);447448/** @brief Returns whether an edge with the given permissions allows only vulnerable road users449* @param[in] permissions The permissions of the edge450* @return Whether the edge allows only a (non-empty) subset of SVC_PEDESTRIAN, SVC_WHEELCHAIR, SVC_BICYCLE, SVC_SCOOTER451*/452extern bool isForVulnerableModes(SVCPermissions permissions);453454/** @brief Returns whether an edge with the given permissions forbids vehicles455* @param[in] permissions The permissions of the edge456* @return Whether the edge is forbidden for vehicles457*/458extern bool noVehicles(SVCPermissions permissions);459460/** @brief Returns the default vehicle length461* This put into a function so it can be used by NBVehicle462* @param[in] vc the vehicle class463* @return the default length in m464*/465extern double getDefaultVehicleLength(const SUMOVehicleClass vc = SVC_IGNORING);466467// ---------------------------------------------------------------------------468// default vehicle type parameter469// ---------------------------------------------------------------------------470extern const std::string DEFAULT_VTYPE_ID;471extern const std::string DEFAULT_PEDTYPE_ID;472extern const std::string DEFAULT_BIKETYPE_ID;473extern const std::string DEFAULT_CONTAINERTYPE_ID;474extern const std::string DEFAULT_TAXITYPE_ID;475extern const std::string DEFAULT_RAILTYPE_ID;476extern const std::set<std::string> DEFAULT_VTYPES;477478extern const double DEFAULT_VEH_PROB; // !!! does this belong here?479extern const double DEFAULT_VEH_MASS;480extern const double DEFAULT_VEH_WIDTH;481extern const double DEFAULT_VEH_HEIGHT;482extern const double DEFAULT_VEH_SHUT_OFF_STOP;483484extern const double DEFAULT_PEDESTRIAN_SPEED;485extern const double DEFAULT_BICYCLE_SPEED;486487extern const double DEFAULT_CONTAINER_TRANSHIP_SPEED;488489490