 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
59 double departPos,
double arrivalPos,
double departPosLat) :
62 "person '" + personID +
"' walking to " + route.back()->getID()),
63 MOVING_WITHOUT_VEHICLE),
64 myWalkingTime(walkingTime),
66 myCurrentInternalEdge(nullptr),
67 myDepartPos(departPos),
68 myDepartPosLat(departPosLat),
70 myPedestrianState(&myDummyState) {
72 "person '" + personID +
"' walking from " + route.front()->getID());
73 if (walkingTime > 0) {
81 delete myPedestrianState;
87 return new MSPersonStage_Walking(
"dummyID", myRoute, myDestinationStop, myWalkingTime, mySpeed, myDepartPos, myArrivalPos, myDepartPosLat);
92 if (myCurrentInternalEdge !=
nullptr) {
93 return myCurrentInternalEdge;
102 return myRoute.front();
108 return myPedestrianState ==
nullptr ? -1 : myPedestrianState->getEdgePos(*
this, now);
114 return myPedestrianState->getPosition(*
this, now);
120 return myPedestrianState->getAngle(*
this, now);
126 return myPedestrianState->getWaitingTime(*
this, now);
132 return myPedestrianState->getSpeed(*
this);
145 myRouteStep = myRoute.begin();
146 myLastEdgeEntryTime = now;
147 if (myWalkingTime == 0) {
148 if (!person->
proceed(net, now)) {
155 if (myWalkingTime > 0) {
156 mySpeed = computeAverageSpeed();
160 if (myPedestrianState ==
nullptr) {
164 const MSEdge* edge = *myRouteStep;
166 if (lane !=
nullptr) {
189 return walkDistance() /
STEPS2TIME(myWalkingTime + 1);
196 for (
const MSEdge* edge : myRoute) {
197 length += edge->getLength();
201 for (ConstMSEdgeVector::const_iterator i = myRoute.begin(); i != myRoute.end() - 1; ++i) {
202 const MSEdge* fromEdge = *i;
203 const MSEdge* toEdge = *(i + 1);
204 const MSLane* from = getSidewalk<MSEdge, MSLane>(fromEdge);
205 const MSLane* to = getSidewalk<MSEdge, MSLane>(toEdge);
208 if (from !=
nullptr && to !=
nullptr) {
231 const double lengthFwd = (length - myDepartPos - (
234 : myRoute.back()->getLength() - myArrivalPos));
235 const double lengthBwd = (length - (myRoute.front()->getLength() - myDepartPos) - (
238 : myRoute.back()->getLength() - myArrivalPos));
240 if (myRoute.size() == 1) {
241 if (myDepartPos > myArrivalPos) {
247 if (mayStartForward && mayStartBackward) {
248 length = lengthFwd < lengthBwd ? lengthFwd : lengthBwd;
249 }
else if (mayStartForward) {
251 }
else if (mayStartBackward) {
271 const double distance = walkDistance();
273 const SUMOTime duration = myArrived - myDeparted;
274 const SUMOTime timeLoss = myArrived == -1 ? 0 : duration -
TIME2STEPS(distance / maxSpeed);
280 os.
writeAttr(
"arrivalPos", myArrivalPos);
281 os.
writeAttr(
"duration", myDeparted < 0 ?
"-1" :
293 std::string comment =
"";
294 if (myDestinationStop !=
nullptr) {
296 if (myDestinationStop->getMyName() !=
"") {
300 if (myWalkingTime > 0) {
302 }
else if (mySpeed > 0) {
305 if (withRouteLength) {
306 os.
writeAttr(
"routeLength", walkDistance());
330 const bool arrived = myRouteStep == myRoute.end() - 1;
331 if (lane !=
nullptr) {
333 rem->updateDetector(*person, 0.0, lane->
getLength(), myLastEdgeEntryTime, currentTime, currentTime,
true);
334 rem->notifyLeave(*person,
339 myLastEdgeEntryTime = currentTime;
342 if (myDestinationStop !=
nullptr) {
343 myDestinationStop->addTransportable(person);
351 if (nextInternal ==
nullptr) {
353 myCurrentInternalEdge =
nullptr;
355 myCurrentInternalEdge = nextInternal;
357 const MSLane* nextLane = getSidewalk<MSEdge, MSLane>(
getEdge());
358 if (nextLane !=
nullptr) {
370 assert(routeOffset >= 0);
371 assert(routeOffset < (
int)myRoute.size());
373 myRouteStep = myRoute.begin() + routeOffset;
384 const std::string dest = (getDestinationStop() ==
nullptr ?
386 " stop '" + getDestinationStop()->getID() +
"'" + (
387 getDestinationStop()->getMyName() !=
"" ?
" (" + getDestinationStop()->getMyName() +
")" :
""));
388 return "walking to " + dest;
396 MSStoppingPlace* toStop,
const double arrivalPos,
const std::vector<std::string>& lines,
397 const std::string& intendedVeh,
SUMOTime intendedDepart) :
402 intendedVeh, intendedDepart) {
410 return new MSPersonStage_Driving(myDestination, myDestinationStop, myArrivalPos, std::vector<std::string>(myLines.begin(), myLines.end()),
411 myIntendedVehicleID, myIntendedDepart);
419 myWaitingSince = now;
423 const std::string vehID = *myLines.begin();
425 if (startVeh ==
nullptr) {
426 throw ProcessError(
"Vehicle '" + vehID +
"' not found for triggered departure of person '" + person->
getID() +
"'.");
428 setVehicle(startVeh);
429 myVehicle->addPerson(person);
432 if (start !=
nullptr) {
438 myWaitingEdge = previous->
getEdge();
442 SUMOVehicle* availableVehicle = myWaitingEdge->getWaitingVehicle(person, myWaitingPos);
444 setVehicle(availableVehicle);
445 myVehicle->addPerson(person);
447 myWaitingEdge->removeWaiting(myVehicle);
451 myWaitingEdge->addPerson(person);
464 const std::string dest = (getDestinationStop() ==
nullptr ?
466 " stop '" + getDestinationStop()->getID() +
"'" + (
467 getDestinationStop()->getMyName() !=
"" ?
" (" + getDestinationStop()->getMyName() +
")" :
""));
468 const std::string intended = myIntendedVehicleID !=
"" ?
469 " (vehicle " + myIntendedVehicleID +
" at time " +
time2string(myIntendedDepart) +
")" :
472 "waiting for " +
joinToString(myLines,
",") + intended +
" then drive to " + dest :
473 "driving to " + dest;
480 const SUMOTime departed = myDeparted >= 0 ? myDeparted : now;
481 const SUMOTime waitingTime = myWaitingSince >= 0 && myDeparted >= 0 ? departed - myWaitingSince : -1;
482 const SUMOTime duration = myArrived - myDeparted;
491 (myDeparted >= 0 ?
time2string(now - myDeparted) :
"-1"));
492 os.
writeAttr(
"routeLength", myVehicleDistance);
504 std::string comment =
"";
505 if (myDestinationStop !=
nullptr) {
507 if (myDestinationStop->getMyName() !=
"") {
512 if (myIntendedVehicleID !=
"") {
515 if (myIntendedDepart >= 0) {
518 if (withRouteLength) {
519 os.
writeAttr(
"routeLength", myVehicleDistance);
529 const double arrivalPos,
const double dist,
const bool isExit) :
531 myDist(dist), myAmExit(isExit) {
544 return new MSPersonStage_Access(myDestination, myDestinationStop, myArrivalPos, myDist, myAmExit);
552 myDestinationStop->getLane().getEdge().addPerson(person);
564 return (myAmExit ?
"access from stop '" :
"access to stop '") + getDestinationStop()->getID() +
"'";
570 return myPath.positionAtOffset(myPath.length() * (now - myDeparted) / (myEstimatedArrival - myDeparted));
576 return myPath.angleAt2D(0);
592 myStopEdge->removePerson(myPerson);
632 if (accessDist > 0.) {
643 if (accessDist > 0.) {
648 (*myStep)->proceed(net,
this, time, prior);
677 if (nextEdge !=
nullptr) {
678 return nextEdge->
getID();
688 assert(walkingStage != 0);
703 for (MSTransportablePlan::const_iterator i =
myPlan->begin(); i !=
myPlan->end(); ++i) {
704 (*i)->tripInfoOutput(os,
this);
717 for (MSTransportablePlan::const_iterator i =
myPlan->begin(); i !=
myPlan->end(); ++i) {
718 (*i)->routeOutput(os, withRouteLength);
727 assert(nextIndex > firstIndex);
743 for (
int i = nextIndex - 1; i >= firstIndex; i--) {
777 myRemoteXYPos = xyPos;
780 myRemotePosLat = posLat;
781 myRemoteAngle = angle;
782 myRemoteEdgeOffset = edgeOffset;
783 myRemoteRoute = route;
784 myLastRemoteAccess = t;
796 return myLastRemoteAccess >= t -
TIME2STEPS(10);
818 s->
getPedestrianState()->
moveToXY(p, myRemoteXYPos, myRemoteLane, myRemotePos, myRemotePosLat, myRemoteAngle, myRemoteEdgeOffset, myRemoteRoute,
The car-following model and parameter.
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
const MSLane & getLane() const
Returns the lane this stop is located at.
const std::string & getID() const
Returns the name of the vehicle type.
A lane area vehicles can halt at.
double computeAverageSpeed() const
const MSEdge * getDestination() const
Returns the current destination.
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
static int canTraverse(int dir, const ConstMSEdgeVector &route)
static const int BACKWARD
Representation of a lane in the micro simulation.
const std::string DEFAULT_PEDTYPE_ID
const std::string & getNextEdge() const
return the list of internal edges if this person is walking and the pedestrian model allows it
~MSPersonStage_Access()
destructor
void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
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.
MSStoppingPlace * myDestinationStop
the stop to reach by getting transported (if any)
static const Position INVALID
used to indicate that a position is valid
MSPersonStage_Driving(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const std::vector< std::string > &lines, const std::string &intendedVeh="", SUMOTime intendedDepart=-1)
constructor
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
const SUMOVehicleParameter * myParameter
the plan of the transportable
void postProcessRemoteControl(MSPerson *p)
virtual void erase(MSTransportable *transportable)
removes a single transportable
The simulated network and simulation perfomer.
double getBeginLanePosition() const
Returns the begin position of this stop.
~MSPersonStage_Walking()
destructor
MSInsertionControl & getInsertionControl()
Returns the insertion control.
std::string getStageDescription() const
returns the stage description as a string
MSPersonStage_Walking(const std::string &personID, const ConstMSEdgeVector &route, MSStoppingPlace *toStop, SUMOTime walkingTime, double speed, double departPos, double arrivalPos, double departPosLat)
constructor
Representation of a vehicle.
std::vector< const MSEdge * > ConstMSEdgeVector
std::string getStageSummary() const
return string summary of the current stage
static OptionsCont & getOptions()
Retrieves the options.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
void removeTransportable(MSTransportable *p)
Removes a transportable from this stop.
virtual void addPerson(MSTransportable *p) const
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
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.
virtual bool proceed(MSNet *net, SUMOTime time)=0
SUMOTime execute(SUMOTime currentTime)
Executes the command.
const MSEdge * getFromEdge() const
StageType getStageType(int next) const
the stage type for the nth next stage
StageType getCurrentStageType() const
the current stage type of the transportable
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
const MSEdge * getDestination() const
returns the destination edge
Something on a lane to be noticed about vehicle movement.
static void addPedestrianData(double walkLength, SUMOTime walkDuration, SUMOTime walkTimeLoss)
record tripinfo data for pedestrians
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Changes the wished person speed and position.
virtual const MSEdge * getEdge() const
Returns the current edge.
virtual double getSpeedFactor() const
the current speed factor of the transportable (where applicable)
double walkDistance() const
compute total walking distance
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
const MSJunction * getFromJunction() const
const MSEdge * getEdge() const
Returns the current edge.
Influencer & getInfluencer()
Returns the velocity/lane influencer.
double getSpeed() const
the speed of the transportable
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, Stage *previous)
proceeds to the next step
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
virtual void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
MSTransportable::Stage * getCurrentStage() const
Return the current stage.
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
void abort(MSTransportable *)
abort this stage (TraCI)
bool isRemoteAffected(SUMOTime t) const
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
int getNumStages() const
Return the total number stages in this persons plan.
double getMaxSpeed() const
Returns the vehicle's maximum speed.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
virtual PedestrianState * add(MSPerson *person, MSPerson::MSPersonStage_Walking *stage, SUMOTime now)=0
register the given person as a pedestrian
std::string getStageSummary() const
return string summary of the current stage
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
@ SUMO_ATTR_EDGES
the edges of a route
double getLength() const
Returns the lane's length.
~MSPersonStage_Driving()
destructor
double getMaxSpeed(const MSTransportable *const person) const
accessors to be used by MSPModel
A point in 2D or 3D with translation and scaling methods.
Position getPosition(SUMOTime now) const
returns the position of the transportable
Position getPosition(SUMOTime now) const
returns the position of the transportable
std::string getStageSummary() const
return string summary of the current stage
std::string time2string(SUMOTime t)
bool isWaiting4Vehicle() const
Whether the transportable waits for a vehicle.
virtual void routeOutput(OutputDevice &os, const bool withRouteLength) const
Called on writing vehroute output.
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
A road/street connecting two junctions.
@ DEPART_TRIGGERED
The departure is person triggered.
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
const MSJunction * getToJunction() const
virtual const MSStoppingPlace * getOriginStop() const
returns the origin stop (if any). only needed for Stage_Trip
double getAccessDistance(const MSEdge *edge) const
the distance from the access on the given edge to the stop, -1 on failure
MSPersonStage_Access(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const double dist, const bool isExit)
constructor
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
const double myChosenSpeedFactor
double getAngle(SUMOTime now) const
returns the angle of the transportable
StageType getStageType() const
virtual void routeOutput(OutputDevice &os, const bool withRouteLength) const
Called on writing vehroute output.
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag tag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
virtual void removePerson(MSTransportable *p) const
virtual void remove(PedestrianState *state)=0
remove the specified person from the pedestrian simulation
MSEdge & getEdge() const
Returns the lane's edge.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
static DummyState myDummyState
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
const PositionVector & getShape() const
Returns this lane's shape.
MSPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, const double speedFactor)
constructor
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 bool hasDeparted() const =0
Returns whether this vehicle has departed.
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, Stage *previous)
proceeds to the next step
double getArrivalPos() const
returns the final arrival pos
bool moveToNextEdge(MSPerson *person, SUMOTime currentTime, MSEdge *nextInternal=nullptr)
move forward and return whether the person arrived
PositionVector reverse() const
reverse position vector
const MSVehicleType & getVehicleType() const
Returns the vehicle's type.
MSTransportable::Stage * getNextStage(int next) const
Return the current stage.
bool hasArrived() const
return whether the person has reached the end of its plan
void addWaiting(const MSEdge *edge, MSTransportable *person)
adds a transportable to the list of transportables waiting for a vehicle on the specified edge
static const int UNDEFINED_DIRECTION
SUMOTime getDesiredDepart() const
Returns the desired departure time.
void lf()
writes a line feed if applicable
const MSEdge * getNextEdgePtr() const
returns the next edge ptr if this person is walking and the pedestrian model allows it
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
static std::string emptyString
An empty string.
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
double getWaitingPositionOnLane(MSTransportable *t) const
Returns the lane position corresponding to getWaitPosition()
static MSPModel * getModel()
MSTransportablePlan::iterator myStep
the iterator over the route
virtual void moveToXY(MSPerson *p, Position pos, MSLane *lane, double lanePos, double lanePosLat, double angle, int routeOffset, const ConstMSEdgeVector &edges, SUMOTime t)
try to move person to the given position
virtual Position getWaitPosition(MSTransportable *person) const
Returns the next free waiting place for pedestrians / containers.
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
void removeStage(int next)
removes the nth next stage
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
MSTransportablePlan * myPlan
the plan of the transportable
const MSEdge * getFromEdge() const
Returns the departure edge.
const MSEdge * getEdge() const
Returns the current edge.
void reroute(ConstMSEdgeVector &newEdges, double departPos, int firstIndex, int nextIndex)
set new walk and replace the stages with relative indices in the interval [firstIndex,...
virtual ~MSPerson()
destructor
ConstMSEdgeVector getEdges() const
the edges of the current stage
double getAngle(SUMOTime now) const
returns the angle of the transportable
double getEdgePos(SUMOTime now) const
const SUMOVehicleParameter & getParameter() const
const std::string & getID() const
Returns the id.
static void addRideData(double rideLength, SUMOTime rideDuration, SUMOVehicleClass vClass, const std::string &line, SUMOTime waitingTime)
record tripinfo data for rides
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
virtual bool usingInternalLanes()=0
whether movements on intersections are modelled
void setRouteIndex(MSPerson *person, int routeOffset)
place person on a previously passed edge
bool isRemoteControlled() const
virtual const MSEdge * getNextEdge(const MSPerson::MSPersonStage_Walking &stage) const =0
return the list of internal edges if the pedestrian is on an intersection
static double interpretEdgePos(double pos, double maximumValue, SumoXMLAttr attr, const std::string &id)
Interprets negative edge positions and fits them onto a given edge.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
std::string getStageDescription() const
returns the stage description as a string
bool proceed(MSNet *net, SUMOTime time)
Influencer * myInfluencer
An instance of a speed/position influencing instance; built in "getInfluencer".
void unregisterOneWaiting(const bool isPerson)
decreases the count of vehicles waiting for a transport to allow recognition of person / container re...
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
virtual void routeOutput(OutputDevice &os, const bool withRouteLength) const
Called on writing vehroute output.
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, Stage *previous)
proceeds to the next step
PedestrianState * getPedestrianState() const