59 double departPos,
double arrivalPos,
double departPosLat,
int departLane,
60 const std::string& routeID) :
62 myWalkingTime(walkingTime),
63 myExitTimes(nullptr) {
65 "person '" + personID +
"' walking from edge '" + route.front()->getID() +
"'");
67 "person '" + personID +
"' walking to edge '" + route.back()->getID() +
"'");
68 if (walkingTime > 0) {
81 std::vector<const MSEdge*> route = myRoute;
82 double departPos = myDepartPos;
83 double arrivalPos = myArrivalPos;
84 int departLane = myDepartLane;
87 if (departPos > route[0]->getLength()) {
88 WRITE_WARNINGF(
TL(
"Adjusting departPos for cloned walk with routeDistribution '%'"), myRouteID);
89 departPos = route[0]->getLength();
91 if (arrivalPos > route.back()->getLength()) {
92 WRITE_WARNINGF(
TL(
"Adjusting arrivalPos for cloned walk with routeDistribution '%'"), myRouteID);
93 arrivalPos = route.back()->getLength();
95 if (departLane >= route[0]->getNumLanes()) {
96 WRITE_WARNINGF(
TL(
"Adjusting departLane for cloned walk with routeDistribution '%'"), myRouteID);
97 departLane = route[0]->getNumLanes() - 1;
100 return new MSPersonStage_Walking(
"dummyID", route, myDestinationStop, myWalkingTime, mySpeed, departPos, arrivalPos, myDepartPosLat, departLane, myRouteID);
107 myRouteStep = myRoute.begin();
108 myLastEdgeEntryTime = now;
109 if (myWalkingTime == 0) {
110 if (!person->
proceed(net, now)) {
117 if (myWalkingTime > 0) {
118 mySpeed = computeAverageSpeed();
123 if (myState ==
nullptr) {
124 pControl.
erase(person);
127 const MSLane*
const lane = getSidewalk<MSEdge, MSLane>(
getEdge());
128 if (lane !=
nullptr) {
131 myMoveReminders.push_back(rem);
136 myExitTimes =
new std::vector<SUMOTime>();
138 (*myRouteStep)->addTransportable(person);
156 return walkDistance() /
STEPS2TIME(myWalkingTime + 1);
163 if (stage !=
nullptr) {
172 auto endIt = partial && myArrived < 0 ? myRouteStep + 1 : myRoute.end();
173 for (ConstMSEdgeVector::const_iterator i = myRoute.begin(); i != endIt; ++i) {
174 length += (*i)->getLength();
178 for (ConstMSEdgeVector::const_iterator i = myRoute.begin(); i != endIt - 1; ++i) {
179 const MSEdge* fromEdge = *i;
180 const MSEdge* toEdge = *(i + 1);
181 const MSLane* from = getSidewalk<MSEdge, MSLane>(fromEdge);
182 const MSLane* to = getSidewalk<MSEdge, MSLane>(toEdge);
185 if (from !=
nullptr && to !=
nullptr) {
209 const double arrivalPos = partial && myArrived < 0 ?
getEdgePos(
SIMSTEP) : myArrivalPos;
210 const double lengthFwd = (length - myDepartPos - (
213 : myRoute.back()->getLength() - arrivalPos));
214 const double lengthBwd = (length - (myRoute.front()->getLength() - myDepartPos) - (
217 : myRoute.back()->getLength() - arrivalPos));
220 if (myRoute.size() == 1) {
221 if (myDepartPos > myArrivalPos) {
227 if (mayStartForward && mayStartBackward) {
228 length = lengthFwd < lengthBwd ? lengthFwd : lengthBwd;
229 }
else if (mayStartForward) {
231 }
else if (mayStartBackward) {
245 return MAX2(POSITION_EPS, length);
251 const double distance = walkDistance(
true);
253 const SUMOTime duration = myArrived - myDeparted;
255 if (timeLoss < 0 && timeLoss >
TIME2STEPS(-0.1)) {
265 os.
writeAttr(
"duration", myDeparted < 0 ?
"-1" :
277 std::string comment =
"";
278 if (myDestinationStop !=
nullptr) {
279 os.
writeAttr(
toString(myDestinationStop->getElement()), myDestinationStop->getID());
280 if (myDestinationStop->getMyName() !=
"") {
286 if (myWalkingTime > 0) {
288 }
else if (mySpeed > 0) {
291 if (withRouteLength) {
292 if (myDeparted >= 0) {
293 os.
writeAttr(
"routeLength", walkDistance(
true));
298 if (myExitTimes !=
nullptr) {
299 std::vector<std::string> exits;
303 std::vector<std::string> missing(
MAX2(0, (
int)myRoute.size() - (
int)myExitTimes->size()),
"-1");
304 exits.insert(exits.end(), missing.begin(), missing.end());
317 const bool arrived = myRouteStep == myRoute.end() - 1;
318 if (lane !=
nullptr) {
320 const double lastPos = (arrived
325 activateLeaveReminders(person, lane, lastPos, currentTime, arrived);
327 if (myExitTimes !=
nullptr && nextInternal ==
nullptr) {
328 myExitTimes->push_back(currentTime);
330 myMoveReminders.clear();
331 myLastEdgeEntryTime = currentTime;
336 myCurrentInternalEdge = nextInternal;
340 if (myDestinationStop !=
nullptr) {
349 if (nextInternal ==
nullptr) {
352 myCurrentInternalEdge = nextInternal;
363 rem->updateDetector(*person, 0.0, lane->
getLength(), myLastEdgeEntryTime, t, t,
true);
364 rem->notifyLeave(*person, lastPos, notification);
371 const MSLane* nextLane = getSidewalk<MSEdge, MSLane>(
getEdge());
372 if (nextLane !=
nullptr) {
376 myMoveReminders.push_back(rem);
385 return (
int)(myRouteStep - myRoute.begin());
391 return mySpeed >= 0 ? mySpeed : person->
getMaxSpeed();
396 const std::string dest = (getDestinationStop() ==
nullptr ?
398 " stop '" + getDestinationStop()->getID() +
"'" + (
399 getDestinationStop()->getMyName() !=
"" ?
" (" + getDestinationStop()->getMyName() +
")" :
""));
400 return "walking to " + dest;
406 out <<
" " << myDeparted <<
" " << (myRouteStep - myRoute.begin()) <<
" " << myLastEdgeEntryTime;
407 myState->saveState(out);
414 state >> myDeparted >> stepIdx >> myLastEdgeEntryTime;
415 myRouteStep = myRoute.begin() + stepIdx;
417 if (myState->getLane() && !myState->getLane()->isNormal()) {
421 (*myRouteStep)->addTransportable(transportable);
430 const double arrivalPos,
const double dist,
const bool isExit) :
432 myDist(dist), myAmExit(isExit) {
445 return new MSPersonStage_Access(myDestination, myDestinationStop, myArrivalPos, myDist, myAmExit);
453 myDestinationStop->getLane().getEdge().addTransportable(person);
465 return (myAmExit ?
"access from stop '" :
"access to stop '") + getDestinationStop()->getID() +
"'";
471 return myPath.positionAtOffset(myPath.length() * (
double)(now - myDeparted) / (
double)(myEstimatedArrival - myDeparted));
477 return myPath.angleAt2D(0);
500 myStopEdge->removeTransportable(myPerson);
527 prevStop =
dynamic_cast<const MSStageTrip*
>(prior)->getOriginStop();
529 if (prevStop !=
nullptr) {
532 if (accessDist > 0.) {
539 if (accessDist > 0.) {
561 if (nextEdge !=
nullptr) {
562 return nextEdge->
getID();
572 assert(walkingStage !=
nullptr);
582 assert(nextIndex > firstIndex);
598 for (
int i = nextIndex - 1; i >= firstIndex; i--) {
632 myRemoteXYPos = xyPos;
635 myRemotePosLat = posLat;
636 myRemoteAngle = angle;
637 myRemoteEdgeOffset = edgeOffset;
638 myRemoteRoute = route;
639 myLastRemoteAccess = t;
651 return myLastRemoteAccess >= t -
TIME2STEPS(10);
672 assert(s !=
nullptr);
673 s->
getState()->
moveToXY(p, myRemoteXYPos, myRemoteLane, myRemotePos, myRemotePosLat, myRemoteAngle, myRemoteEdgeOffset, myRemoteRoute,
std::vector< const MSEdge * > ConstMSEdgeVector
#define WRITE_WARNINGF(...)
std::string time2string(SUMOTime t)
convert SUMOTime to string
const int VEHPARS_ARRIVALPOS_SET
@ SUMO_ATTR_EDGES
the edges of a route
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static void addPedestrianData(double walkLength, SUMOTime walkDuration, SUMOTime walkTimeLoss)
record tripinfo data for pedestrians
A road/street connecting two junctions.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
const MSJunction * getToJunction() const
const MSJunction * getFromJunction() const
virtual void addTransportable(MSTransportable *t) const
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
Representation of a lane in the micro simulation.
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
double getLength() const
Returns the lane's length.
const PositionVector & getShape() const
Returns this lane's shape.
MSEdge & getEdge() const
Returns the lane's edge.
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Something on a lane to be noticed about vehicle movement.
Notification
Definition of a vehicle state.
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
The simulated network and simulation perfomer.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
static const int BACKWARD
static int canTraverse(int dir, const ConstMSEdgeVector &route)
virtual MSTransportableStateAdapter * add(MSTransportable *transportable, MSStageMoving *stage, SUMOTime now)=0
register the given person as a pedestrian
virtual MSTransportableStateAdapter * loadState(MSTransportable *transportable, MSStageMoving *stage, std::istringstream &state)
load the state of the given transportable
virtual bool usingInternalLanes()=0
whether movements on intersections are modelled
virtual void remove(MSTransportableStateAdapter *state)=0
remove the specified person from the pedestrian simulation
static const int UNDEFINED_DIRECTION
static const double UNSPECIFIED_POS_LAT
the default lateral offset for persons when starting a walk
Changes the wished person speed and position.
void postProcessRemoteControl(MSPerson *p)
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
bool isRemoteAffected(SUMOTime t) const
bool isRemoteControlled() const
SUMOTime execute(SUMOTime currentTime)
Executes the command.
Position getPosition(SUMOTime now) const
returns the position of the transportable
double getSpeed() const
the speed of the person in this stage
MSPersonStage_Access(const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const double dist, const bool isExit)
constructor
void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSStage *previous)
proceeds to the next step
double getAngle(SUMOTime now) const
returns the angle of the transportable
std::string getStageDescription(const bool isPerson) const
returns the stage description as a string
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
~MSPersonStage_Access()
destructor
virtual void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous) const
Called on writing vehroute output.
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
double computeAverageSpeed() const
double walkDistance(bool partial=false) const
compute total walking distance
bool moveToNextEdge(MSTransportable *person, SUMOTime currentTime, int prevDir, MSEdge *nextInternal=nullptr)
move forward and return whether the person arrived
double getMaxSpeed(const MSTransportable *const person) const
accessors to be used by MSPModel
~MSPersonStage_Walking()
destructor
void loadState(MSTransportable *transportable, std::istringstream &state)
Reconstructs the current state.
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSStage *previous)
proceeds to the next step
void activateEntryReminders(MSTransportable *person)
void activateLeaveReminders(MSTransportable *person, const MSLane *lane, double lastPos, SUMOTime t, bool arrived)
int getRoutePosition() const
return index of current edge within route
MSPersonStage_Walking(const std::string &personID, const ConstMSEdgeVector &route, MSStoppingPlace *toStop, SUMOTime walkingTime, double speed, double departPos, double arrivalPos, double departPosLat, int departLane=-1, const std::string &routeID="")
constructor
void abort(MSTransportable *)
abort this stage (TraCI)
void saveState(std::ostringstream &out)
Saves the current state into the given stream.
bool checkAccess(const MSStage *const prior, const bool waitAtStop=true)
Influencer * myInfluencer
An instance of a speed/position influencing instance; built in "getInfluencer".
const MSEdge * getNextEdgePtr() const
returns the next edge ptr if this person is walking and the pedestrian model allows it
void reroute(ConstMSEdgeVector &newEdges, double departPos, int firstIndex, int nextIndex)
set new walk and replace the stages with relative indices in the interval [firstIndex,...
double myChosenSpeedFactor
bool isJammed() const
whether the person is jammed as defined by the current pedestrian model
bool hasInfluencer() const
whether the vehicle is individually influenced (via TraCI or special parameters)
virtual ~MSPerson()
destructor
Influencer & getInfluencer()
Returns the velocity/lane influencer.
const std::string & getNextEdge() const
return the list of internal edges if this person is walking and the pedestrian model allows it
MSPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, const double speedFactor)
constructor
static SumoRNG * getParsingRNG()
get parsing RNG
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
static RandomDistributor< const MSRoute * > * distDictionary(const std::string &id)
Returns the named route distribution.
const MSEdge * getDestination() const
returns the destination edge
virtual double getEdgePos(SUMOTime now) const
MSStoppingPlace * myDestinationStop
the stop to reach by getting transported (if any)
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
MSStageType getStageType() const
virtual const MSEdge * getEdge() const
Returns the current edge.
double myArrivalPos
the position at which we want to arrive
virtual MSTransportableStateAdapter * getState() const
double mySpeed
the speed of the transportable
double myDepartPos
the depart position
A lane area vehicles can halt at.
double getBeginLanePosition() const
Returns the begin position of this stop.
double getAccessDistance(const MSEdge *edge) const
the distance from the access on the given edge to the stop, -1 on failure
double getEndLanePosition() const
Returns the end position of this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
double getAccessPos(const MSEdge *edge) const
the position on the given edge which is connected to this stop, -1 on failure
MSPModel * getMovementModel()
Returns the default movement model for this kind of transportables.
virtual void erase(MSTransportable *transportable)
removes a single transportable
virtual double getEdgePos() const
Return the position on the edge.
const MSLane * getLane() const
Returns the current lane (may be nullptr)
const MSEdge * getDestination() const
Returns the current destination.
MSStageType getStageType(int next) const
the stage type for the nth next stage
MSStage * getCurrentStage() const
Return the current stage.
virtual bool proceed(MSNet *net, SUMOTime time, const bool vehicleArrived=false)
MSTransportablePlan::iterator myStep
the iterator over the route
MSTransportablePlan * myPlan
the plan of the transportable
void removeStage(int next, bool stayInSim=true)
removes the nth next stage
double getArrivalPos() const
returns the final arrival pos
double getPositionOnLane() const
Get the object's position along the lane.
const MSVehicleType & getVehicleType() const
Returns the object's "vehicle" type.
MSStageType getCurrentStageType() const
the current stage type of the transportable
MSStage * getNextStage(int next) const
Return the current stage.
void appendStage(MSStage *stage, int next=-1)
Appends the given stage to the current plan.
const MSEdge * getEdge() const
Returns the current edge.
std::vector< MSStage * > MSTransportablePlan
the structure holding the plan of a transportable
double getMaxSpeed() const
Returns the maximum speed (the minimum of desired and physical maximum speed)
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 transportable to the given position
virtual const MSLane * getLane() const
whether the transportable is jammed
virtual bool isJammed() const
whether the transportable is jammed
virtual const MSEdge * getNextEdge(const MSStageMoving &stage) const =0
return the list of internal edges if the transportable is on an intersection
The car-following model and parameter.
double getLength() const
Get vehicle's length [m].
const std::string & getID() const
Returns the id.
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
A point in 2D or 3D with translation and scaling methods.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
PositionVector reverse() const
reverse position vector
Structure representing possible vehicle parameter.
static double interpretEdgePos(double pos, double maximumValue, SumoXMLAttr attr, const std::string &id, bool silent=false)
Interprets negative edge positions and fits them onto a given edge.
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
static std::string emptyString
An empty string.