 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
138 std::vector<std::string>
150 std::vector<std::string>
162 std::vector<std::string>
174 std::vector<std::string>
186 std::vector<std::string>
198 std::vector<std::string>
210 std::vector<std::string>
222 std::vector<std::string>
234 std::vector<std::string>
246 std::vector<std::string>
258 std::vector<std::string>
263 std::vector<std::string>
265 std::vector<std::string> result;
267 result.push_back(pair.first);
281 std::vector<std::string>
285 std::vector<std::string> result;
286 for (std::vector<MSTransportable*>::iterator it = transportables.begin(); it != transportables.end(); it++) {
287 result.push_back((*it)->getID());
355 if (roadPos.first ==
nullptr) {
359 result.
edgeID = roadPos.first->getEdge().getID();
360 result.
laneIndex = roadPos.first->getIndex();
361 result.
pos = roadPos.second;
389 if ((roadPos1.first == roadPos2.first) && (roadPos1.second <= roadPos2.second)) {
391 return roadPos2.second - roadPos1.second;
393 double distance = 0.;
395 if (roadPos2.first->isInternal()) {
396 distance = roadPos2.second;
397 roadPos2.first = roadPos2.first->getLogicalPredecessorLane();
398 roadPos2.second = roadPos2.first->getLength();
402 MSRoute route(
"", newRoute,
false,
nullptr, std::vector<SUMOVehicleParameter::Stop>());
403 return distance + route.
getDistanceBetween(roadPos1.second, roadPos2.second, &roadPos1.first->getEdge(), &roadPos2.first->getEdge());
416 if ((roadPos1.first == roadPos2.first) && (roadPos1.second <= roadPos2.second)) {
418 return roadPos2.second - roadPos1.second;
420 double distance = 0.;
422 if (roadPos2.first->isInternal()) {
423 distance = roadPos2.second;
424 roadPos2.first = roadPos2.first->getLogicalPredecessorLane();
425 roadPos2.second = roadPos2.first->getLength();
429 MSRoute route(
"", newRoute,
false,
nullptr, std::vector<SUMOVehicleParameter::Stop>());
430 return distance + route.
getDistanceBetween(roadPos1.second, roadPos2.second, &roadPos1.first->getEdge(), &roadPos2.first->getEdge());
433 const Position pos1 = roadPos1.first->geometryPositionAtOffset(roadPos1.second);
434 const Position pos2 = roadPos2.first->geometryPositionAtOffset(roadPos2.second);
441 Simulation::findRoute(
const std::string& from,
const std::string& to,
const std::string& typeID,
const double depart,
const int routingMode) {
444 if (fromEdge ==
nullptr) {
448 if (toEdge ==
nullptr) {
455 if (type ==
nullptr) {
456 throw TraCIException(
"The vehicle type '" + typeID +
"' is not known.");
464 throw TraCIException(
"Invalid departure edge for vehicle type '" + typeID +
"' (" + e.what() +
")");
470 router.
compute(fromEdge, toEdge, vehicle, dep, edges);
471 for (
const MSEdge* e : edges) {
472 result.
edges.push_back(e->getID());
475 if (vehicle !=
nullptr) {
482 std::vector<TraCIStage>
484 const std::string& modes,
double depart,
const int routingMode,
double speed,
double walkFactor,
485 double departPos,
double arrivalPos,
const double departPosLat,
486 const std::string& pType,
const std::string& vType,
const std::string& destStop) {
488 std::vector<TraCIStage> result;
490 if (fromEdge ==
nullptr) {
494 if (toEdge ==
nullptr) {
499 std::vector<SUMOVehicleParameter*> pars;
502 pars.back()->vtypeid = vType;
503 pars.back()->id = vType;
507 const std::string mode = st.next();
511 pars.back()->id = mode;
516 pars.back()->id = mode;
519 pars.push_back(
nullptr);
528 pars.push_back(
nullptr);
539 if (walkFactor < 0) {
548 }
else if (arrivalPos < 0) {
551 if (departPos < 0 || departPos >= fromEdge->
getLength()) {
554 if (arrivalPos < 0 || arrivalPos >= toEdge->
getLength()) {
557 double minCost = std::numeric_limits<double>::max();
560 std::vector<TraCIStage> resultCand;
562 if (vehPar !=
nullptr) {
564 if (type ==
nullptr) {
565 throw TraCIException(
"Unknown vehicle type '" + vehPar->vtypeid +
"'.");
568 WRITE_WARNING(
"Ignoring vehicle type '" + type->
getID() +
"' when performing intermodal routing because it is not allowed on the start edge '" + from +
"'.");
576 std::vector<MSNet::MSIntermodalRouter::TripItem> items;
577 if (router.
compute(fromEdge, toEdge, departPos, arrivalPos, destStop,
578 speed * walkFactor, vehicle, modeSet, departStep, items, externalFactor)) {
580 for (std::vector<MSNet::MSIntermodalRouter::TripItem>::iterator it = items.begin(); it != items.end(); ++it) {
581 if (!it->edges.empty()) {
582 resultCand.push_back(
TraCIStage(it->line ==
""
585 resultCand.back().vType = it->vType;
586 resultCand.back().line = it->line;
587 resultCand.back().destStop = it->destStop;
588 for (
const MSEdge* e : it->edges) {
589 resultCand.back().edges.push_back(e->
getID());
591 resultCand.back().travelTime = it->traveltime;
592 resultCand.back().cost = it->cost;
593 resultCand.back().length = it->length;
594 resultCand.back().intended = it->intended;
595 resultCand.back().depart = it->depart;
596 resultCand.back().departPos = it->departPos;
597 resultCand.back().arrivalPos = it->arrivalPos;
598 resultCand.back().description = it->description;
602 if (cost < minCost) {
607 if (vehicle !=
nullptr) {
618 const std::string attrName = key.substr(16);
621 throw TraCIException(
"Invalid chargingStation '" + objectID +
"'");
627 }
else if (attrName ==
"lane") {
632 throw TraCIException(
"Invalid chargingStation parameter '" + attrName +
"'");
635 const std::string attrName = key.substr(12);
640 if (attrName ==
"capacity") {
642 }
else if (attrName ==
"occupancy") {
646 }
else if (attrName ==
"lane") {
651 throw TraCIException(
"Invalid parkingArea parameter '" + attrName +
"'");
654 const std::string attrName = key.substr(8);
661 }
else if (attrName ==
"lane") {
666 throw TraCIException(
"Invalid busStop parameter '" + attrName +
"'");
669 throw TraCIException(
"Parameter '" + key +
"' is not supported.");
686 std::shared_ptr<VariableWrapper>
static int getEndingTeleportNumber()
static void step(const double time=0.)
Advances by one step (or up to the given time)
The car-following model and parameter.
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...
const MSLane & getLane() const
Returns the lane this stop is located at.
static void handleSubscriptions(const SUMOTime t)
static SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const MSEdgeVector &prohibited=MSEdgeVector())
return the router instance
#define UNUSED_PARAMETER(x)
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
TRACI_CONST int VAR_EMERGENCYSTOPPING_VEHICLES_IDS
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
const std::string & getID() const
Returns the name of the vehicle type.
TRACI_CONST int VAR_PARKING_STARTING_VEHICLES_IDS
TRACI_CONST int VAR_LOADED_VEHICLES_NUMBER
A lane area vehicles can halt at.
TRACI_CONST int VAR_STOP_ENDING_VEHICLES_NUMBER
A lane area vehicles can halt at.
int getActiveCount()
return the number of active transportable objects
The vehicle has departed (was inserted into the network)
static void close()
Closes all of an applications subsystems.
#define WRITE_WARNING(msg)
bool hasContainers() const
Returns whether containers are simulated.
const Boundary & getConvBoundary() const
Returns the converted boundary.
virtual void setChosenSpeedFactor(const double factor)=0
TRACI_CONST double INVALID_DOUBLE_VALUE
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const MSEdgeVector &prohibited=MSEdgeVector()) const
const std::string DEFAULT_PEDTYPE_ID
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.
static void close()
Closes the xml-subsystem.
double zmax() const
Returns maximum z-coordinate.
void simulationStep()
Performs a single simulation step.
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation.
static int getCollidingVehiclesNumber()
double ymin() const
Returns minimum y-coordinate.
TRACI_CONST int VAR_TELEPORT_ENDING_VEHICLES_NUMBER
int getPendingFlowCount() const
Returns the number of flows that are still active.
std::map< int, std::shared_ptr< TraCIResult > > TraCIResults
{variable->value}
int getActiveVehicleCount() const
Returns the number of build vehicles that have not been removed or need to wait for a passenger or a ...
bool hasNext()
returns the information whether further substrings exist
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
TRACI_CONST int VAR_TELEPORT_STARTING_VEHICLES_NUMBER
virtual MSTransportableControl & getContainerControl()
Returns the container control.
static int getMinExpectedNumber()
The simulated network and simulation perfomer.
TRACI_CONST int VAR_BUS_STOP_WAITING
MSInsertionControl & getInsertionControl()
Returns the insertion control.
static std::vector< std::string > getStopStartingVehiclesIDList()
TRACI_CONST int VAR_EMERGENCYSTOPPING_VEHICLES_NUMBER
static TraCIPositionVector getNetBoundary()
Representation of a vehicle.
std::vector< const MSEdge * > ConstMSEdgeVector
double xmax() const
Returns maximum x-coordinate.
static OptionsCont & getOptions()
Retrieves the options.
static void load(const std::vector< std::string > &args)
load a simulation with the given arguments
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.)
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
bool hasPersons() const
Returns whether persons are simulated.
static TraCIRoadPosition convertRoad(double x, double y, bool isGeo=false, const std::string &vClass="ignoring")
TRACI_CONST int VAR_TIME_STEP
Structure representing possible vehicle parameter.
static TraCIPosition makeTraCIPosition(const Position &position, const bool includeZ=false)
static int getParkingEndingVehiclesNumber()
static int getStopEndingVehiclesNumber()
The vehicle arrived at his destination (is deleted)
double getLength() const
return the length of the edge
static void saveState(const std::string &file, SUMOTime step)
Saves the current state.
void closeSimulation(SUMOTime start)
Closes the simulation (all files, connections, etc.)
static LIBSUMO_SUBSCRIPTION_API void subscribe(const std::vector< int > &vars=std::vector< int >(), double beginTime=INVALID_DOUBLE_VALUE, double endTime=INVALID_DOUBLE_VALUE)
The vehicle had to brake harder than permitted.
static TraCIPosition convert2D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false)
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
static void clearPending(const std::string &routeID="")
static double getDistance2D(double x1, double y1, double x2, double y2, bool isGeo=false, bool isDriving=false)
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
static const MSLane * getLaneChecking(const std::string &edgeID, int laneIndex, double pos)
static const TraCIResults getSubscriptionResults()
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.
static int getArrivedNumber()
static bool isLoaded()
return whether a simulation (network) is present
virtual bool wrapDouble(const std::string &objID, const int variable, const double value)=0
TRACI_CONST int VAR_STOP_STARTING_VEHICLES_NUMBER
double travelTime
duration of the stage in seconds
std::vector< double > & getParameter()
Returns the parameters of this distribution.
The vehicles starts to park.
static std::vector< std::string > getBusStopWaitingIDList(const std::string &id)
Returns the IDs of the transportables on a given bus stop.
double xmin() const
Returns minimum x-coordinate.
static std::vector< std::string > getStartingTeleportIDList()
TRACI_CONST int CMD_SUBSCRIBE_SIM_VARIABLE
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
TRACI_CONST int VAR_DEPARTED_VEHICLES_IDS
virtual bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)=0
std::vector< MSTransportable * > getTransportables() const
Returns the tranportables waiting on this stop.
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
const std::string DEFAULT_VTYPE_ID
int getCapacity() const
Returns the area capacity.
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....
TRACI_CONST int VAR_DELTA_T
vehicle is a passenger car (a "normal" car)
static std::vector< std::string > getDepartedIDList()
A class that stores a 2D geometrical boundary.
static TraCIPosition convertGeo(double x, double y, bool fromGeo=false)
TRACI_CONST int VAR_TELEPORT_ENDING_VEHICLES_IDS
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
TRACI_CONST int VAR_TELEPORT_STARTING_VEHICLES_IDS
The vehicle is involved in a collision.
The vehicle started to teleport.
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
The vehicle was built, but has not yet departed.
A point in 2D or 3D with translation and scaling methods.
static void close()
close simulation
The vehicles starts to stop.
static std::vector< std::string > getArrivedIDList()
static void init()
Initialises the xml-subsystem.
TRACI_CONST int VAR_ARRIVED_VEHICLES_NUMBER
static double getDistanceRoad(const std::string &edgeID1, double pos1, const std::string &edgeID2, double pos2, bool isDriving=false)
A road/street connecting two junctions.
static int getCurrentTime()
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
static std::shared_ptr< VariableWrapper > makeWrapper()
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
static int getEmergencyStoppingVehiclesNumber()
static TraCIPosition convert3D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false)
static std::vector< std::string > getParkingStartingVehiclesIDList()
TRACI_CONST int VAR_STOP_ENDING_VEHICLES_IDS
static double getDeltaT()
static int getDepartedNumber()
TRACI_CONST int VAR_PARKING_STARTING_VEHICLES_NUMBER
static int getStartingTeleportNumber()
static std::vector< std::string > getBusStopIDList()
TRACI_CONST int VAR_COLLIDING_VEHICLES_IDS
const Distribution_Parameterized & getSpeedFactor() const
Returns this type's speed factor.
static std::vector< std::string > getParkingEndingVehiclesIDList()
const std::string & getMyName() const
static SubscriptionResults mySubscriptionResults
static int getStopStartingVehiclesNumber()
static int getBusStopWaiting(const std::string &id)
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
TRACI_CONST int ROUTING_MODE_AGGREGATED
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
virtual MSTransportableControl & getPersonControl()
Returns the person control.
static ContextSubscriptionResults myContextSubscriptionResults
double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
void clearPendingVehicles(const std::string &route)
clears out all pending vehicles from a route, "" for all routes
static std::vector< std::string > getLoadedIDList()
static void saveState(const std::string &fileName)
int getOccupancyIncludingBlocked() const
Returns the area occupancy.
std::vector< std::string > edges
The sequence of edges to travel.
virtual bool wrapInt(const std::string &objID, const int variable, const int value)=0
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="")
MSIntermodalRouter & getIntermodalRouter(const int routingMode=0, const MSEdgeVector &prohibited=MSEdgeVector()) const
TRACI_CONST int VAR_DEPARTED_VEHICLES_NUMBER
The vehicle ends to park.
double getTotalCharged() const
const SUMOVTypeParameter & getParameter() const
static std::vector< std::string > getStopEndingVehiclesIDList()
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
static int getLoadedNumber()
The vehicle ended being teleported.
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
static std::string getParameter(const std::string &objectID, const std::string &key)
TRACI_CONST int VAR_PARKING_ENDING_VEHICLES_IDS
int getTransportableNumber() const
Returns the number of transportables waiting on this stop.
TRACI_CONST int VAR_LOADED_VEHICLES_IDS
static bool hasInstance()
Returns whether the network was already constructed.
An edgeId, position and laneIndex.
The class responsible for building and deletion of vehicles.
static std::vector< std::string > getCollidingVehiclesIDList()
TRACI_CONST int VAR_STOP_STARTING_VEHICLES_IDS
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
TRACI_CONST int VAR_ARRIVED_VEHICLES_IDS
TRACI_CONST int VAR_COLLIDING_VEHICLES_NUMBER
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
bool hasVType(const std::string &id) const
Asks for existence of a vehicle type.
static const std::vector< std::string > & getVehicleStateChanges(const MSNet::VehicleState state)
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
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...
SVCPermissions getPermissions() const
vehicles ignoring classes
const std::string DEFAULT_BIKETYPE_ID
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true, int routePosition=0) const
Compute the distance between 2 given edges on this route, including the length of internal lanes....
void setz(double z)
set position z
const std::string & getID() const
Returns the id.
The vehicle ends to stop.
static void registerVehicleStateListener()
static std::pair< MSLane *, double > convertCartesianToRoadMap(const Position &pos, const SUMOVehicleClass vClass)
TRACI_CONST int VAR_MIN_EXPECTED_VEHICLES
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
static TraCIStage findRoute(const std::string &fromEdge, const std::string &toEdge, const std::string &vType="", const double depart=-1., const int routingMode=0)
double zmin() const
Returns minimum z-coordinate.
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int VAR_PARKING_ENDING_VEHICLES_NUMBER
static std::vector< std::string > getEndingTeleportIDList()
static void clearVehicleStates()
bool knowsParameter(const std::string &key) const
Returns whether the parameter is known.
double ymax() const
Returns maximum y-coordinate.
static std::vector< std::string > getEmergencyStoppingVehiclesIDList()
static int getParkingStartingVehiclesNumber()