 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
52 : myDestination(destination), myDestinationStop(toStop), myArrivalPos(arrivalPos), myDeparted(-1), myArrived(-1), myType(type) {}
102 if (myDeparted < 0) {
124 return getLanePosition(e->
getLanes()[0], at, offset);
134 return e->
getLanes()[0]->getShape().rotationAtOffset(at);
140 myDestination = newDestination;
141 myDestinationStop = newDestStop;
142 if (newDestStop !=
nullptr) {
155 const std::string& vTypes,
const double speed,
const double walkFactor,
156 const double departPosLat,
const bool hasArrivalPos,
const double arrivalPos):
159 myOriginStop(fromStop),
160 myDuration(duration),
164 myWalkFactor(walkFactor),
165 myDepartPosLat(departPosLat),
166 myHaveArrivalPos(hasArrivalPos) {
175 myDestination, myDestinationStop, myDuration,
176 myModeSet, myVTypes, mySpeed, myWalkFactor, myDepartPosLat, myHaveArrivalPos, myArrivalPos);
210 std::vector<SUMOVehicleParameter*> pars;
213 pars.back()->vtypeid = st.next();
216 pars.back()->id = transportable->
getID() +
"_" +
toString(pars.size() - 1);
221 pars.back()->id = transportable->
getID() +
"_0";
226 pars.back()->id = transportable->
getID() +
"_b0";
230 pars.push_back(
nullptr);
249 if (vehPar !=
nullptr) {
250 if (myDepartPos != 0) {
252 vehPar->departPos = myDepartPos;
257 WRITE_WARNING(
"Ignoring vehicle type '" + type->
getID() +
"' when routing person '" + transportable->
getID() +
"' because it is not allowed on the start edge.");
263 bool carUsed =
false;
264 std::vector<MSNet::MSIntermodalRouter::TripItem> result;
267 transportable->
getMaxSpeed() * myWalkFactor, vehicle, myModeSet, time, result)) {
268 for (std::vector<MSNet::MSIntermodalRouter::TripItem>::iterator it = result.begin(); it != result.end(); ++it) {
269 if (!it->edges.empty()) {
271 double localArrivalPos = bs !=
nullptr ? bs->
getAccessPos(it->edges.back()) : it->edges.back()->getLength() / 2.;
272 if (it + 1 == result.end() && myHaveArrivalPos) {
273 localArrivalPos = myArrivalPos;
275 if (it->line ==
"") {
279 }
else if (previous->
getEdge() != it->edges.front()) {
287 transportable->
appendStage(previous, stageIndex++);
288 }
else if (vehicle !=
nullptr && it->line == vehicle->
getID()) {
289 if (bs ==
nullptr && it + 1 != result.end()) {
291 localArrivalPos = it->edges.back()->getLength();
294 transportable->
appendStage(previous, stageIndex++);
301 transportable->
appendStage(previous, stageIndex++);
309 const std::string error =
"No connection found between edge '" + myOrigin->getID() +
"' and edge '" + (myDestinationStop !=
nullptr ? myDestinationStop->getID() : myDestination->getID()) +
"' for person '" + transportable->
getID() +
"'.";
316 if (vehicle !=
nullptr && !carUsed) {
326 transportable->
proceed(net, now);
362 const bool initial) :
366 myWaitingDuration(duration),
367 myWaitingUntil(until),
381 return myWaitingUntil;
387 return getEdgePosition(myDestination, myArrivalPos,
401 const SUMOTime until =
MAX3(now, now + myWaitingDuration, myWaitingUntil);
402 if (myDestinationStop !=
nullptr) {
403 myDestinationStop->addTransportable(transportable);
405 if (
dynamic_cast<MSPerson*
>(transportable) !=
nullptr) {
433 if (myWaitingDuration >= 0) {
436 if (myWaitingUntil >= 0) {
460 return now - myDeparted;
475 std::string timeInfo;
476 if (myWaitingUntil >= 0) {
477 timeInfo +=
" until " +
time2string(myWaitingUntil);
479 if (myWaitingDuration >= 0) {
480 timeInfo +=
" duration " +
time2string(myWaitingDuration);
482 return "stopping at edge '" +
getDestination()->
getID() +
"' " + timeInfo +
" (" + myActType +
")";
490 MSStoppingPlace* toStop,
const double arrivalPos,
const std::vector<std::string>& lines,
491 const std::string& intendedVeh,
SUMOTime intendedDepart) :
493 myLines(lines.begin(), lines.end()),
497 myVehicleDistance(-1.),
499 myWaitingEdge(nullptr),
501 myIntendedVehicleID(intendedVeh),
502 myIntendedDepart(intendedDepart) {
510 if (myVehicle !=
nullptr) {
511 if (myVehicle->getLane() !=
nullptr) {
512 return &myVehicle->getLane()->getEdge();
514 return myVehicle->getEdge();
516 return myWaitingEdge;
522 return myWaitingEdge;
532 return MIN2(myVehicle->getPositionOnLane(),
getEdge()->getLength());
540 return myStopWaitPos;
542 return getEdgePosition(myWaitingEdge, myWaitingPos,
545 return myVehicle->getPosition();
553 if (veh !=
nullptr) {
565 return (myLines.count(vehicle->
getID()) > 0
567 || (myLines.count(
"ANY") > 0 && (
568 myDestinationStop ==
nullptr
570 : vehicle->
stopsAt(myDestinationStop))));
576 return myVehicle ==
nullptr;
603 if (myVehicle !=
nullptr) {
605 myVehicleDistance = myVehicle->getRoute().getDistanceBetween(
606 myVehicle->getDepartPos(), myVehicle->getPositionOnLane(),
607 myVehicle->getRoute().begin(), myVehicle->getCurrentRouteEdge()) - myVehicleDistance;
608 if (myVehicle->isStopped()) {
609 myArrivalPos = myVehicle->getPositionOnLane();
612 myVehicleDistance = -1.;
619 myVehicleID = v->
getID();
622 myVehicleDistance = myVehicle->getRoute().getDistanceBetween(
623 myVehicle->getDepartPos(), myVehicle->getPositionOnLane(),
624 myVehicle->getRoute().begin(), myVehicle->getCurrentRouteEdge());
629 if (myVehicle !=
nullptr) {
631 dynamic_cast<MSVehicle*
>(myVehicle)->removeTransportable(t);
644 +
" at " + (myDestinationStop ==
nullptr
645 ? (
"edge '" + myWaitingEdge->getID() +
"'")
646 : (
"busStop '" + myDestinationStop->getID() +
"'"))
683 for (MSTransportablePlan::const_iterator i =
myPlan->begin(); i !=
myPlan->end(); ++i) {
710 (*myStep)->setDeparted(now);
735 return (*myStep)->getSpeed();
746 return (
int)
myPlan->size();
756 if (stepIndex + next > (
int)
myPlan->size()) {
759 myPlan->insert(
myPlan->begin() + stepIndex + next, stage);
767 assert(
myStep + next < myPlan->end());
780 (*myStep)->abort(
this);
788 for (MSTransportablePlan::const_iterator i =
myPlan->begin(); i !=
myPlan->end(); ++i) {
789 (*i)->setSpeed(speed);
820 const Position back = p +
Position(-cos(angle) * length, -sin(angle) * length);
821 centerLine.push_back(p);
822 centerLine.push_back(back);
834 assert(stageIndex < (
int)
myPlan->size());
835 assert(stageIndex >= 0);
836 return (*
myPlan)[stageIndex]->getStageSummary();
847 return myPlan->size() > 0 &&
myPlan->front()->getDeparted() >= 0;
857 if (
dynamic_cast<MSPerson*
>(
this) ==
nullptr) {
858 WRITE_WARNING(
"parkingAreaReroute not support for containers");
884 const Stage*
const futureStage = *it;
885 Stage*
const prevStage = *(it - 1);
894 replacement, -1, 0,
"", -1, 1, 0,
true, stage->
getArrivalPos());
895 int prevStageRelIndex = (int)(it - 1 -
myStep);
909 if (
typeid(*dev) == type) {
920 const double gp = edge->
getLanes()[0]->interpolateLanePosToGeometryPos(ep);
921 return edge->
getLanes()[0]->getShape().slopeDegreeAtOffset(gp);
void setDeparted(SUMOTime now)
logs end of the step
The car-following model and parameter.
void abortWaitingForVehicle(MSTransportable *t)
let the given transportable abort waiting for a vehicle (when removing stage via TraCI)
const MSLane & getLane() const
Returns the lane this stop is located at.
virtual const MSEdge * getFromEdge() const
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the person waits for the given vehicle.
MSVehicleType * buildSingularType(const std::string &id) const
Duplicates the microsim vehicle type giving the newly created type the given id, marking it as vehicl...
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
ConstMSEdgeVector getEdges() const
the edges of the current stage
const std::string & getID() const
Returns the name of the vehicle type.
A lane area vehicles can halt at.
bool hasDeparted() const
return whether the transportable has started it's plan
static void buildTransportableDevices(MSTransportable &p, std::vector< MSTransportableDevice * > &into)
Build devices for the given person, if needed.
const MSEdge * getDestination() const
Returns the current destination.
Position getPosition(SUMOTime now) const
returns the position of the transportable
virtual void routeOutput(OutputDevice &os, const bool withRouteLength) const
Called on writing vehroute output.
const MSEdge * getEdge() const
Returns the current edge.
#define WRITE_WARNING(msg)
bool isWaiting4Vehicle() const
Whether the person waits for a vehicle.
std::string getStageSummary(int stageIndex) const
return textual summary for the given stage
Representation of a lane in the micro simulation.
virtual bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true)=0
Replaces the current route by the given edges.
bool isVehicleSpecific() const
Returns whether this type belongs to a single vehicle only (was modified)
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.
Stage(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, StageType type)
constructor
virtual void routeOutput(OutputDevice &os, const bool withRouteLength) const
Called on writing vehroute output.
void removeVType(const MSVehicleType *vehType)
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
void appendStage(Stage *stage, int next=-1)
Appends the given stage to the current plan.
double getEndLanePosition() const
Returns the end position of this stop.
Static storage of an output device and its base (abstract) implementation.
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
Position getLanePosition(const MSLane *lane, double at, double offset) const
get position on lane at length at with orthogonal offset
static const Position INVALID
used to indicate that a position is valid
bool hasNext()
returns the information whether further substrings exist
virtual MSTransportableControl & getContainerControl()
Returns the container control.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
virtual const std::string & getID() const =0
Get the vehicle's ID.
const SUMOVehicleParameter * myParameter
the plan of the transportable
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
void setDestination(const MSEdge *newDestination, MSStoppingPlace *newDestStop)
virtual ~MSTransportable()
destructor
The simulated network and simulation perfomer.
double getBeginLanePosition() const
Returns the begin position of this stop.
virtual void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, Stage *previous)
proceeds to the next step
Representation of a vehicle.
std::vector< const MSEdge * > ConstMSEdgeVector
virtual SUMOVehicleClass getVClass() const =0
Returns the vehicle's access class.
@ SVC_BICYCLE
vehicle is a bicycle
virtual bool stopsAt(MSStoppingPlace *stop) const =0
Returns whether the vehicle stops at the given stopping place.
virtual void addPerson(MSTransportable *p) const
virtual ConstMSEdgeVector getEdges() const
the edges of the current stage
virtual void setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now)
logs end of the step
virtual double getEdgePos(SUMOTime now) const
Structure representing possible vehicle parameter.
const MSEdge * getEdge() const
Returns the current edge.
virtual bool proceed(MSNet *net, SUMOTime time)=0
void setWaitEnd(SUMOTime time, MSTransportable *transportable)
sets the arrival time for a waiting transportable
StageType getCurrentStageType() const
the current stage type of the transportable
const MSEdge * getDestination() const
returns the destination edge
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
virtual const MSEdge * getEdge() const
Returns the current edge.
MSTransportableDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
virtual double getSpeedFactor() const
the current speed factor of the transportable (where applicable)
virtual ~Stage_Trip()
destructor
void abort(MSTransportable *)
abort this stage (TraCI)
virtual SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
void setDeparted(SUMOTime now)
logs depart time of the current stage
std::string line
The vehicle's line (mainly for public transport)
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.
SUMOTime getUntil() const
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
virtual bool stopsAtEdge(const MSEdge *edge) const =0
Returns whether the vehicle stops at the given edge.
double getAngle(SUMOTime now) const
returns the angle of the transportable
const MSEdge * getEdge() const
Returns the current edge.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
const std::set< std::string > & getLines() const
double getAngle(SUMOTime now) const
returns the angle of the transportable
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Stage_Trip(const MSEdge *origin, MSStoppingPlace *fromStop, const MSEdge *destination, MSStoppingPlace *toStop, const SUMOTime duration, const SVCPermissions modeSet, const std::string &vTypes, const double speed, const double walkFactor, const double departPosLat, const bool hasArrivalPos, const double arrivalPos)
constructor
MSIntermodalRouter & getIntermodalRouter(const int rngIndex, const int routingMode=0, const MSEdgeVector &prohibited=MSEdgeVector()) const
void setVehicle(SUMOVehicle *v)
MSTransportable(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportablePlan *plan)
constructor
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
double getSpeed() const
the speed of the transportable
bool lefthand() const
return whether the network was built for lefthand traffic
SUMOVehicle * getVehicle() const
Whether the transportable waits for a vehicle.
int getNumStages() const
Return the total number stages in this persons plan.
virtual double getWaitingSeconds() const
the time this transportable spent waiting in seconds
double getMaxSpeed() const
Returns the vehicle's maximum speed.
virtual void setArrivalPos(double arrivalPos)=0
Sets this vehicle's desired arrivalPos for its current route.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
std::string id
The vehicle's id.
Stage_Waiting(const MSEdge *destination, MSStoppingPlace *toStop, SUMOTime duration, SUMOTime until, double pos, const std::string &actType, const bool initial)
constructor
double getEdgePos(SUMOTime now) const
double interpolateLanePosToGeometryPos(double lanePos) const
const MSEdge * getFromEdge() const
virtual ~Stage_Driving()
destructor
double getAngle(SUMOTime now) const
returns the angle of the transportable
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
Stage_Driving(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const std::vector< std::string > &lines, const std::string &intendedVeh="", SUMOTime intendedDepart=-1)
constructor
double getAngle() const
Returns the vehicle's direction in radians.
A point in 2D or 3D with translation and scaling methods.
void rerouteParkingArea(MSStoppingPlace *orig, MSStoppingPlace *replacement)
adapt plan when the vehicle reroutes and now stops at replacement instead of orig
std::string time2string(SUMOTime t)
bool isWaiting4Vehicle() const
Whether the transportable waits for a vehicle.
void append(const PositionVector &v, double sameThreshold=2.0)
void setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now)
marks arrival time and records driven distance
A road/street connecting two junctions.
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
@ DEPART_TRIGGERED
The departure is person triggered.
double getSlope() const
Returns the slope of the road at vehicle's position.
@ DEPART_POS_RANDOM
The position is chosen randomly.
virtual void removeTransportable(MSTransportable *t)=0
removes a person or container
SUMOTime getDeparted() const
get departure time of stage
virtual double getSpeed() const
the speed of the transportable
StageType getStageType() const
virtual void setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now)
logs end of the step
Abstract in-person device.
SUMOTime getWaitingTime(SUMOTime now) const
time spent waiting for a ride
double getArrivalPos() const
double getEdgePos(SUMOTime now) const
virtual double getEdgePos() const
Return the position on the edge.
std::string getStageSummary() const
return string summary of the current stage
MSEdge & getEdge() const
Returns the lane's edge.
virtual bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the transportable waits for the given vehicle.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
const int VEHPARS_VTYPE_SET
@ SUMO_TAG_BUS_STOP
A bus stop.
const PositionVector & getShape() const
Returns this lane's shape.
PositionVector getBoundingBox() const
return the bounding box of the person
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
int getNumRemainingStages() const
Return the number of remaining stages (including the current)
virtual MSTransportableControl & getPersonControl()
Returns the person control.
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
Position getEdgePosition(const MSEdge *e, double at, double offset) const
get position on edge e at length at with orthogonal offset
virtual double getSpeed() const
the current speed of the transportable
Position getPosition(SUMOTime now) const
returns the position of the transportable
PositionVector reverse() const
reverse position vector
const MSVehicleType & getVehicleType() const
Returns the vehicle's type.
double getLength() const
Get vehicle's length [m].
const int VEHPARS_DEPARTPOS_SET
MSTransportable::Stage * getNextStage(int next) const
Return the current stage.
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
bool hasArrived() const
return whether the person has reached the end of its plan
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
virtual void addContainer(MSTransportable *container) const
Add a container to myContainers.
double getEdgeAngle(const MSEdge *e, double at) const
get angle of the edge at a certain position
SUMOTime getDesiredDepart() const
Returns the desired departure time.
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
const std::string & getID() const
returns the id of the transportable
double getAccessPos(const MSEdge *edge) const
the position on the given edge which is connected to this stop, -1 on failure
std::vector< MSTransportableDevice * > myDevices
The devices this transportable has.
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
virtual Position getPosition() const
Return the Network coordinate of the transportable.
virtual ~Stage_Waiting()
destructor
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
virtual void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, Stage *previous)
proceeds to the next step
virtual ~Stage()
destructor
void abort(MSTransportable *)
abort this stage (TraCI)
MSTransportablePlan::iterator myStep
the iterator over the route
The class responsible for building and deletion of vehicles.
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
std::string getWaitingDescription() const
Return where the person waits and for what.
void removeStage(int next)
removes the nth next stage
MSTransportablePlan * myPlan
the plan of the transportable
SUMOTime getWaitingTime() const
std::string getStageSummary() const
return string summary of the current stage
void abortWaiting(MSTransportable *t)
aborts waiting stage of transportable
@ DEPART_POS_GIVEN
The position is given.
const MSEdge * getFromEdge() const
Returns the departure edge.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
MSVehicleType * myVType
This transportable's type. (mainly used for drawing related information Note sure if it is really nec...
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...
@ SVC_IGNORING
vehicles ignoring classes
const std::string DEFAULT_BIKETYPE_ID
Position getPosition(SUMOTime now) const
returns the position of the transportable
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
const SUMOVehicleParameter & getParameter() const
const std::string & getID() const
Returns the id.
virtual double getAngle() const
return the current angle of the transportable
static const double ROADSIDE_OFFSET
the offset for computing positions when standing at an edge
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
double departPos
(optional) The position the vehicle shall depart from
void move2side(double amount, double maxExtension=100)
move position vector to side using certain ammount
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
Representation of a vehicle in the micro simulation.