 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
135 std::vector<std::string>
147 std::vector<std::string>
159 std::vector<std::string>
171 std::vector<std::string>
183 std::vector<std::string>
195 std::vector<std::string>
207 std::vector<std::string>
219 std::vector<std::string>
231 std::vector<std::string>
243 std::vector<std::string>
255 std::vector<std::string>
260 std::vector<std::string>
262 std::vector<std::string> result;
264 result.push_back(pair.first);
278 std::vector<std::string>
282 std::vector<std::string> result;
283 for (std::vector<MSTransportable*>::iterator it = transportables.begin(); it != transportables.end(); it++) {
284 result.push_back((*it)->getID());
352 if (roadPos.first ==
nullptr) {
356 result.
edgeID = roadPos.first->getEdge().getID();
357 result.
laneIndex = roadPos.first->getIndex();
358 result.
pos = roadPos.second;
386 if ((roadPos1.first == roadPos2.first) && (roadPos1.second <= roadPos2.second)) {
388 return roadPos2.second - roadPos1.second;
390 double distance = 0.;
392 if (roadPos2.first->isInternal()) {
393 distance = roadPos2.second;
394 roadPos2.first = roadPos2.first->getLogicalPredecessorLane();
395 roadPos2.second = roadPos2.first->getLength();
399 MSRoute route(
"", newRoute,
false,
nullptr, std::vector<SUMOVehicleParameter::Stop>());
400 return distance + route.
getDistanceBetween(roadPos1.second, roadPos2.second, &roadPos1.first->getEdge(), &roadPos2.first->getEdge());
413 if ((roadPos1.first == roadPos2.first) && (roadPos1.second <= roadPos2.second)) {
415 return roadPos2.second - roadPos1.second;
417 double distance = 0.;
419 if (roadPos2.first->isInternal()) {
420 distance = roadPos2.second;
421 roadPos2.first = roadPos2.first->getLogicalPredecessorLane();
422 roadPos2.second = roadPos2.first->getLength();
426 MSRoute route(
"", newRoute,
false,
nullptr, std::vector<SUMOVehicleParameter::Stop>());
427 return distance + route.
getDistanceBetween(roadPos1.second, roadPos2.second, &roadPos1.first->getEdge(), &roadPos2.first->getEdge());
430 const Position p1 = roadPos1.first->geometryPositionAtOffset(roadPos1.second);
431 const Position p2 = roadPos2.first->geometryPositionAtOffset(roadPos2.second);
438 Simulation::findRoute(
const std::string& from,
const std::string& to,
const std::string& typeID,
const double depart,
const int routingMode) {
441 if (fromEdge ==
nullptr) {
445 if (toEdge ==
nullptr) {
452 if (type ==
nullptr) {
453 throw TraCIException(
"The vehicle type '" + typeID +
"' is not known.");
461 throw TraCIException(
"Invalid departure edge for vehicle type '" + typeID +
"' (" + e.what() +
")");
467 router.
compute(fromEdge, toEdge, vehicle, dep, edges);
468 for (
const MSEdge* e : edges) {
469 result.
edges.push_back(e->getID());
472 if (vehicle !=
nullptr) {
479 std::vector<TraCIStage>
481 const std::string& modes,
double depart,
const int routingMode,
double speed,
double walkFactor,
482 double departPos,
double arrivalPos,
const double departPosLat,
483 const std::string& pType,
const std::string& vType,
const std::string& destStop) {
485 std::vector<TraCIStage> result;
487 if (fromEdge ==
nullptr) {
491 if (toEdge ==
nullptr) {
496 std::vector<SUMOVehicleParameter*> pars;
499 pars.back()->vtypeid = vType;
500 pars.back()->id = vType;
504 const std::string mode = st.next();
508 pars.back()->id = mode;
513 pars.back()->id = mode;
516 pars.push_back(
nullptr);
525 pars.push_back(
nullptr);
536 if (walkFactor < 0) {
545 }
else if (arrivalPos < 0) {
548 if (departPos < 0 || departPos >= fromEdge->
getLength()) {
551 if (arrivalPos < 0 || arrivalPos >= toEdge->
getLength()) {
554 double minCost = std::numeric_limits<double>::max();
557 std::vector<TraCIStage> resultCand;
559 if (vehPar !=
nullptr) {
561 if (type ==
nullptr) {
562 throw TraCIException(
"Unknown vehicle type '" + vehPar->vtypeid +
"'.");
565 WRITE_WARNING(
"Ignoring vehicle type '" + type->
getID() +
"' when performing intermodal routing because it is not allowed on the start edge '" + from +
"'.");
573 std::vector<MSNet::MSIntermodalRouter::TripItem> items;
574 if (router.
compute(fromEdge, toEdge, departPos, arrivalPos, destStop,
575 speed * walkFactor, vehicle, modeSet, departStep, items, externalFactor)) {
577 for (std::vector<MSNet::MSIntermodalRouter::TripItem>::iterator it = items.begin(); it != items.end(); ++it) {
578 if (!it->edges.empty()) {
579 resultCand.push_back(
TraCIStage(it->line ==
""
582 resultCand.back().vType = it->vType;
583 resultCand.back().line = it->line;
584 resultCand.back().destStop = it->destStop;
585 for (
const MSEdge* e : it->edges) {
586 resultCand.back().edges.push_back(e->
getID());
588 resultCand.back().travelTime = it->traveltime;
589 resultCand.back().cost = it->cost;
590 resultCand.back().length = it->length;
591 resultCand.back().intended = it->intended;
592 resultCand.back().depart = it->depart;
593 resultCand.back().departPos = it->departPos;
594 resultCand.back().arrivalPos = it->arrivalPos;
595 resultCand.back().description = it->description;
599 if (cost < minCost) {
604 if (vehicle !=
nullptr) {
615 const std::string attrName = key.substr(16);
618 throw TraCIException(
"Invalid chargingStation '" + objectID +
"'");
624 }
else if (attrName ==
"lane") {
629 throw TraCIException(
"Invalid chargingStation parameter '" + attrName +
"'");
632 const std::string attrName = key.substr(12);
637 if (attrName ==
"capacity") {
639 }
else if (attrName ==
"occupancy") {
643 }
else if (attrName ==
"lane") {
648 throw TraCIException(
"Invalid parkingArea parameter '" + attrName +
"'");
651 const std::string attrName = key.substr(8);
658 }
else if (attrName ==
"lane") {
663 throw TraCIException(
"Invalid busStop parameter '" + attrName +
"'");
666 throw TraCIException(
"Parameter '" + key +
"' is not supported.");
688 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)
#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
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
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
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)
static SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector())
return the router instance
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.)
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
static void writeMessage(const std::string &msg)
std::vector< double > & getParameter()
Returns the parameters of this distribution.
The vehicles starts to park.
MSIntermodalRouter & getIntermodalRouter(const int rngIndex, const int routingMode=0, const MSEdgeVector &prohibited=MSEdgeVector()) const
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()
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 void clearSubscriptions()
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 subscribe(const std::vector< int > &varIDs=std::vector< int >(), double begin=INVALID_DOUBLE_VALUE, double end=INVALID_DOUBLE_VALUE)
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="")
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.
#define WRITE_MESSAGE(msg)
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()