72 close(
"Libsumo issued load command.");
133 std::pair<int, std::string>
157 std::vector<std::string>
169 std::vector<std::string>
181 std::vector<std::string>
193 std::vector<std::string>
205 std::vector<std::string>
217 std::vector<std::string>
229 std::vector<std::string>
241 std::vector<std::string>
253 std::vector<std::string>
265 std::vector<std::string>
277 std::vector<std::string>
282 std::vector<std::string>
284 std::vector<std::string> result;
286 result.push_back(pair.first);
300 std::vector<std::string>
304 std::vector<std::string> result;
305 for (std::vector<MSTransportable*>::iterator it = transportables.begin(); it != transportables.end(); it++) {
306 result.push_back((*it)->getID());
374 if (roadPos.first ==
nullptr) {
378 result.
edgeID = roadPos.first->getEdge().getID();
379 result.
laneIndex = roadPos.first->getIndex();
380 result.
pos = roadPos.second;
422 const Position p1 = roadPos1.first->geometryPositionAtOffset(roadPos1.second);
423 const Position p2 = roadPos2.first->geometryPositionAtOffset(roadPos2.second);
430 Simulation::findRoute(
const std::string& from,
const std::string& to,
const std::string& typeID,
const double depart,
const int routingMode) {
433 if (fromEdge ==
nullptr) {
437 if (toEdge ==
nullptr) {
442 if (type ==
nullptr) {
443 throw TraCIException(
"The vehicle type '" + typeID +
"' is not known.");
446 pars->
id =
"simulation.findRoute";
453 throw TraCIException(
"Invalid departure edge for vehicle type '" + type->
getID() +
"' (" + msg +
")");
458 throw TraCIException(
"Invalid departure edge for vehicle type '" + type->
getID() +
"' (" + e.what() +
")");
463 router.
compute(fromEdge, toEdge, vehicle, dep, edges);
464 for (
const MSEdge* e : edges) {
465 result.
edges.push_back(e->getID());
468 if (vehicle !=
nullptr) {
475 std::vector<TraCIStage>
477 const std::string& modes,
double depart,
const int routingMode,
double speed,
double walkFactor,
478 double departPos,
double arrivalPos,
const double departPosLat,
479 const std::string& pType,
const std::string& vType,
const std::string& destStop) {
481 std::vector<TraCIStage> result;
483 if (fromEdge ==
nullptr) {
487 if (toEdge ==
nullptr) {
492 std::vector<SUMOVehicleParameter*> pars;
495 pars.back()->vtypeid = vType;
496 pars.back()->id = vType;
500 const std::string mode = st.next();
504 pars.back()->id = mode;
509 pars.back()->id = mode;
512 pars.push_back(
nullptr);
521 pars.push_back(
nullptr);
532 if (walkFactor < 0) {
541 }
else if (arrivalPos < 0) {
544 if (departPos < 0 || departPos >= fromEdge->
getLength()) {
547 if (arrivalPos < 0 || arrivalPos >= toEdge->
getLength()) {
550 double minCost = std::numeric_limits<double>::max();
553 std::vector<TraCIStage> resultCand;
555 if (vehPar !=
nullptr) {
557 if (type ==
nullptr) {
558 throw TraCIException(
"Unknown vehicle type '" + vehPar->vtypeid +
"'.");
561 WRITE_WARNING(
"Ignoring vehicle type '" + type->
getID() +
"' when performing intermodal routing because it is not allowed on the start edge '" + from +
"'.");
569 std::vector<MSNet::MSIntermodalRouter::TripItem> items;
570 if (router.
compute(fromEdge, toEdge, departPos, arrivalPos, destStop,
571 speed * walkFactor, vehicle, modeSet, departStep, items, externalFactor)) {
573 for (std::vector<MSNet::MSIntermodalRouter::TripItem>::iterator it = items.begin(); it != items.end(); ++it) {
574 if (!it->edges.empty()) {
576 for (
const MSEdge* e : it->edges) {
577 resultCand.back().edges.push_back(e->
getID());
579 resultCand.back().travelTime = it->traveltime;
580 resultCand.back().cost = it->cost;
581 resultCand.back().length = it->length;
582 resultCand.back().intended = it->intended;
583 resultCand.back().depart = it->depart;
584 resultCand.back().departPos = it->departPos;
585 resultCand.back().arrivalPos = it->arrivalPos;
586 resultCand.back().description = it->description;
590 if (cost < minCost) {
595 if (vehicle !=
nullptr) {
606 const std::string attrName = key.substr(16);
609 throw TraCIException(
"Invalid chargingStation '" + objectID +
"'");
615 }
else if (attrName ==
"lane") {
620 throw TraCIException(
"Invalid chargingStation parameter '" + attrName +
"'");
623 const std::string attrName = key.substr(16);
633 throw TraCIException(
"Invalid overhead wire parameter '" + attrName +
"'");
636 const std::string attrName = key.substr(12);
641 if (attrName ==
"capacity") {
643 }
else if (attrName ==
"occupancy") {
647 }
else if (attrName ==
"lane") {
652 throw TraCIException(
"Invalid parkingArea parameter '" + attrName +
"'");
655 const std::string attrName = key.substr(8);
662 }
else if (attrName ==
"lane") {
667 throw TraCIException(
"Invalid busStop parameter '" + attrName +
"'");
670 throw TraCIException(
"Parameter '" + key +
"' is not supported.");
703 throw TraCIException(
"Loading state from '" + fileName +
"' failed.");
716 std::shared_ptr<VariableWrapper>
static std::pair< int, std::string > getVersion()
return TraCI API and SUMO version
Definition of overhead wire segment.
The vehicle has departed (was inserted into the network)
A lane area vehicles can halt at.
TRACI_CONST int VAR_MIN_EXPECTED_VEHICLES
bool compute(const E *from, const E *to, const double departPos, const double arrivalPos, const std::string stopID, const double speed, const V *const vehicle, const SVCPermissions modeSet, const SUMOTime msTime, std::vector< TripItem > &into, const double externalFactor=0.)
Builds the route between the given edges using the minimum effort at the given time The definition of...
TRACI_CONST int VAR_PARKING_ENDING_VEHICLES_NUMBER
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
double ymin() const
Returns minimum y-coordinate.
static void init()
Initialises the xml-subsystem.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
double xmax() const
Returns maximum x-coordinate.
static SubscriptionResults mySubscriptionResults
static int getStopStartingVehiclesNumber()
SUMOTime getTime() const
get time
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
virtual bool wrapInt(const std::string &objID, const int variable, const int value)=0
#define PROGRESS_BEGIN_TIME_MESSAGE(msg)
static void step(const double time=0.)
Advances by one step (or up to the given time)
bool hasPersons() const
Returns whether persons are simulated.
static void close()
Closes the xml-subsystem.
void clearPendingVehicles(const std::string &route)
clears out all pending vehicles from a route, "" for all routes
static SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, SUMOVehicleClass svc, const MSEdgeVector &prohibited=MSEdgeVector())
return the router instance
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
An edgeId, position and laneIndex.
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
TRACI_CONST int VAR_TIME_STEP
const Boundary & getConvBoundary() const
Returns the converted boundary.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
static void clearVehicleStates()
static std::vector< std::string > getParkingEndingVehiclesIDList()
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
A lane area vehicles can halt at.
TRACI_CONST int VAR_STOP_ENDING_VEHICLES_NUMBER
Parser and output filter for routes and vehicles state saving and loading.
static std::vector< TraCIStage > findIntermodalRoute(const std::string &fromEdge, const std::string &toEdge, const std::string &modes="", double depart=-1., const int routingMode=0, double speed=-1., double walkFactor=-1., double departPos=0, double arrivalPos=INVALID_DOUBLE_VALUE, const double departPosLat=0, const std::string &pType="", const std::string &vType="", const std::string &destStop="")
static double getDeltaT()
int getActiveCount()
return the number of active transportable objects
static int getDepartedNumber()
static std::vector< std::string > getEmergencyStoppingVehiclesIDList()
static TraCIPosition makeTraCIPosition(const Position &position, const bool includeZ=false)
TRACI_CONST int VAR_LOADED_VEHICLES_NUMBER
static void load(const std::vector< std::string > &args)
load a simulation with the given arguments
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, std::mt19937 *rng=nullptr)
Returns the named vehicle type or a sample from the named distribution.
std::map< int, std::shared_ptr< TraCIResult > > TraCIResults
{variable->value}
const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
std::string time2string(SUMOTime t)
convert SUMOTime to string
double zmax() const
Returns maximum z-coordinate.
static std::vector< std::string > getDepartedIDList()
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
static std::string getParameter(const std::string &objectID, const std::string &key)
std::vector< double > & getParameter()
Returns the parameters of this distribution.
static TraCIPosition convert2D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false)
void setCurrentTimeStep(const SUMOTime step)
Sets the current simulation step (used by state loading)
TRACI_CONST int VAR_EMERGENCYSTOPPING_VEHICLES_NUMBER
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary...
static const MSLane * getLaneChecking(const std::string &edgeID, int laneIndex, double pos)
int getActiveVehicleCount() const
Returns the number of build vehicles that have not been removed or need to wait for a passenger or a ...
const std::string DEFAULT_BIKETYPE_ID
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
std::vector< const MSEdge * > ConstMSEdgeVector
const std::string & getID() const
Returns the id.
int getTransportableNumber() const
Returns the number of transportables waiting on this stop.
bool hasNext()
returns the information whether further substrings exist
bool hasVType(const std::string &id) const
Asks for existence of a vehicle type.
TRACI_CONST int VAR_DEPARTED_VEHICLES_IDS
static TraCIPosition convertGeo(double x, double y, bool fromGeo=false)
double getLength() const
return the length of the edge
const std::string DEFAULT_VTYPE_ID
static void close()
Closes all of an applications subsystems.
const std::string & getMyName() const
static double getDrivingDistance(std::pair< const MSLane *, double > &roadPos1, std::pair< const MSLane *, double > &roadPos2)
double zmin() const
Returns minimum z-coordinate.
#define UNUSED_PARAMETER(x)
A class that stores a 2D geometrical boundary.
#define WRITE_WARNING(msg)
The simulated network and simulation perfomer.
TRACI_CONST int VAR_BUS_STOP_WAITING
The car-following model and parameter.
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
static OptionsCont & getOptions()
Retrieves the options.
MSIntermodalRouter & getIntermodalRouter(const int rngIndex, const int routingMode=0, const MSEdgeVector &prohibited=MSEdgeVector()) const
static double loadState(const std::string &fileName)
quick-load simulation state from file and return the state time
virtual MSTransportableControl & getContainerControl()
Returns the container control.
The vehicles starts to stop.
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
static double getDistance2D(double x1, double y1, double x2, double y2, bool isGeo=false, bool isDriving=false)
TRACI_CONST int VAR_ARRIVED_VEHICLES_NUMBER
A road/street connecting two junctions.
static TraCIStage findRoute(const std::string &fromEdge, const std::string &toEdge, const std::string &vType="", const double depart=-1., const int routingMode=0)
static int getParkingStartingVehiclesNumber()
#define PROGRESS_TIME_MESSAGE(before)
virtual bool hasValidRouteStart(std::string &msg)=0
checks wether the vehicle can depart on the first edge
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
static const std::vector< std::string > & getVehicleStateChanges(const MSNet::VehicleState state)
virtual void setChosenSpeedFactor(const double factor)=0
bool knowsParameter(const std::string &key) const
Returns whether the parameter is known.
The vehicle arrived at his destination (is deleted)
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false, const bool isRoute=false)
Runs the given handler on the given file; returns if everything's ok.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
The vehicles starts to park.
TRACI_CONST int VAR_STOP_STARTING_VEHICLES_NUMBER
The vehicle is involved in a collision.
TRACI_CONST int CMD_SUBSCRIBE_SIM_VARIABLE
static bool hasInstance()
Returns whether the network was already constructed.
TRACI_CONST int VAR_STOP_ENDING_VEHICLES_IDS
Representation of a vehicle.
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
The vehicle had to brake harder than permitted.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter ...
double recomputeCosts(const std::vector< const E *> &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
static std::vector< std::string > getLoadedIDList()
A point in 2D or 3D with translation and scaling methods.
static TraCIPositionVector getNetBoundary()
std::vector< std::string > edges
The sequence of edges to travel.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
std::vector< MSTransportable * > getTransportables() const
Returns the tranportables waiting on this stop.
bool hasContainers() const
Returns whether containers are simulated.
int getCapacity() const
Returns the area capacity.
TRACI_CONST int ROUTING_MODE_AGGREGATED
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E *> &into, bool silent=false)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
TRACI_CONST int VAR_DELTA_T
static std::vector< std::string > getStopStartingVehiclesIDList()
double xmin() const
Returns minimum x-coordinate.
The vehicle started to teleport.
TRACI_CONST int VAR_TELEPORT_STARTING_VEHICLES_IDS
static void clearSubscriptions()
static int getEndingTeleportNumber()
static std::vector< std::string > getStopEndingVehiclesIDList()
static double getDistanceRoad(const std::string &edgeID1, double pos1, const std::string &edgeID2, double pos2, bool isDriving=false)
static std::pair< MSLane *, double > convertCartesianToRoadMap(const Position &pos, const SUMOVehicleClass vClass)
static std::vector< std::string > getStartingTeleportIDList()
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
The vehicle ends to park.
static void saveState(const std::string &fileName)
static MSNet * init(const bool isLibsumo=false)
static void subscribe(const int commandId, const std::string &id, const std::vector< int > &variables, const double beginTime, const double endTime, const int contextDomain=0, const double range=0.)
static std::vector< std::string > getBusStopIDList()
TRACI_CONST int VAR_DEPARTED_VEHICLES_NUMBER
const SUMOVTypeParameter & getParameter() const
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
vehicle is a passenger car (a "normal" car)
TRACI_CONST int STAGE_WALKING
virtual bool wrapDouble(const std::string &objID, const int variable, const double value)=0
static void subscribe(const std::vector< int > &varIDs=std::vector< int >(), double begin=INVALID_DOUBLE_VALUE, double end=INVALID_DOUBLE_VALUE)
TRACI_CONST int TRACI_VERSION
TRACI_CONST int VAR_TELEPORT_ENDING_VEHICLES_IDS
The vehicle was built, but has not yet departed.
static std::vector< std::string > getParkingStartingVehiclesIDList()
void clearState(const SUMOTime step)
Resets events when quick-loading state.
TRACI_CONST int VAR_COLLIDING_VEHICLES_IDS
static int getCollidingVehiclesNumber()
static int getBusStopWaiting(const std::string &id)
static int getStartingTeleportNumber()
int getOccupancyIncludingBlocked() const
Returns the area occupancy.
static void close(const std::string &reason="Libsumo requested termination.")
close simulation
Structure representing possible vehicle parameter.
static const TraCIResults getSubscriptionResults()
static std::vector< std::string > getEndingTeleportIDList()
MSInsertionControl & getInsertionControl()
Returns the insertion control.
const std::string DEFAULT_PEDTYPE_ID
static std::vector< std::string > getBusStopWaitingIDList(const std::string &id)
Returns the IDs of the transportables on a given bus stop.
int getPendingFlowCount() const
Returns the number of flows that are still active.
TRACI_CONST int VAR_LOADED_VEHICLES_IDS
static int getParkingEndingVehiclesNumber()
static bool isLoaded()
return whether a simulation (network) is present
TRACI_CONST int VAR_STOP_STARTING_VEHICLES_IDS
TRACI_CONST int VAR_COLLIDING_VEHICLES_NUMBER
TRACI_CONST int STAGE_DRIVING
const std::string & getID() const
Returns the name of the vehicle type.
double travelTime
duration of the stage in seconds
TRACI_CONST int VAR_PARKING_STARTING_VEHICLES_NUMBER
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
static int getEmergencyStoppingVehiclesNumber()
The vehicle ends to stop.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
static ContextSubscriptionResults myContextSubscriptionResults
static int getArrivedNumber()
static int getMinExpectedNumber()
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation. ...
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
static std::vector< std::string > getCollidingVehiclesIDList()
static void writeMessage(const std::string &msg)
static TraCIRoadPosition convertRoad(double x, double y, bool isGeo=false, const std::string &vClass="ignoring")
static LIBSUMO_GET_PARAMETER_WITH_KEY_API void clearPending(const std::string &routeID="")
The class responsible for building and deletion of vehicles.
SVCPermissions getPermissions() const
Returns the combined permissions of all lanes of this edge.
double getTotalCharged() const
TRACI_CONST int VAR_ARRIVED_VEHICLES_IDS
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true)
Builds a vehicle, increases the number of built vehicles.
void simulationStep()
Performs a single simulation step.
static void handleSubscriptions(const SUMOTime t)
const MSLane & getLane() const
Returns the lane this stop is located at.
TRACI_CONST int VAR_PARKING_STARTING_VEHICLES_IDS
virtual bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)=0
double ymax() const
Returns maximum y-coordinate.
#define WRITE_MESSAGE(msg)
static std::shared_ptr< VariableWrapper > makeWrapper()
TRACI_CONST double INVALID_DOUBLE_VALUE
An overhead wire segment.
static std::vector< std::string > getArrivedIDList()
static int getLoadedNumber()
static int getCurrentTime()
const Distribution_Parameterized & getSpeedFactor() const
Returns this type's speed factor.
The vehicle ended being teleported.
TRACI_CONST int VAR_PARKING_ENDING_VEHICLES_IDS
vehicles ignoring classes
static TraCIPosition convert3D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false)
TRACI_CONST int VAR_EMERGENCYSTOPPING_VEHICLES_IDS
TRACI_CONST int VAR_TELEPORT_ENDING_VEHICLES_NUMBER
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
double getTotalCharged() const
static void saveState(const std::string &file, SUMOTime step)
Saves the current state.
std::string id
The vehicle's id.
TRACI_CONST int VAR_TELEPORT_STARTING_VEHICLES_NUMBER
static int getStopEndingVehiclesNumber()
void setz(double z)
set position z
void closeSimulation(SUMOTime start, const std::string &reason="")
Closes the simulation (all files, connections, etc.)