60 double departPos,
double arrivalPos,
double departPosLat,
int departLane,
61 const std::string& routeID) :
63 myWalkingTime(walkingTime),
65 myInternalDistance(0) {
67 "person '" + personID +
"' walking from edge '" + route.front()->getID() +
"'");
69 "person '" + personID +
"' walking to edge '" + route.back()->getID() +
"'");
70 if (walkingTime > 0) {
83 std::vector<const MSEdge*> route = myRoute;
84 double departPos = myDepartPos;
85 double arrivalPos = myArrivalPos;
86 int departLane = myDepartLane;
89 if (departPos > route[0]->getLength()) {
90 WRITE_WARNINGF(
TL(
"Adjusting departPos for cloned walk with routeDistribution '%'"), myRouteID);
91 departPos = route[0]->getLength();
93 if (arrivalPos > route.back()->getLength()) {
94 WRITE_WARNINGF(
TL(
"Adjusting arrivalPos for cloned walk with routeDistribution '%'"), myRouteID);
95 arrivalPos = route.back()->getLength();
97 if (departLane >= route[0]->getNumLanes()) {
98 WRITE_WARNINGF(
TL(
"Adjusting departLane for cloned walk with routeDistribution '%'"), myRouteID);
99 departLane = route[0]->getNumLanes() - 1;
102 return new MSPersonStage_Walking(
"dummyID", route, myDestinationStop, myWalkingTime, mySpeed, departPos, arrivalPos, myDepartPosLat, departLane, myRouteID);
109 myRouteStep = myRoute.begin();
110 myLastEdgeEntryTime = now;
111 if (myWalkingTime == 0) {
112 if (!person->
proceed(net, now)) {
119 if (myWalkingTime > 0) {
120 mySpeed = computeAverageSpeed();
125 if (myState ==
nullptr) {
126 pControl.
erase(person);
129 const MSLane*
const lane = getSidewalk<MSEdge, MSLane>(
getEdge());
130 if (lane !=
nullptr) {
133 myMoveReminders.push_back(rem);
138 myExitTimes =
new std::vector<SUMOTime>();
140 (*myRouteStep)->addTransportable(person);
158 return walkDistance() /
STEPS2TIME(myWalkingTime + 1);
165 if (stage !=
nullptr) {
174 auto endIt = partial && myArrived < 0 ? myRouteStep + 1 : myRoute.end();
175 for (ConstMSEdgeVector::const_iterator i = myRoute.begin(); i != endIt; ++i) {
176 length += (*i)->getLength();
179 if (myInternalDistance > 0) {
180 length += myInternalDistance;
183 for (ConstMSEdgeVector::const_iterator i = myRoute.begin(); i != endIt - 1; ++i) {
184 const MSEdge* fromEdge = *i;
185 const MSEdge* toEdge = *(i + 1);
186 const MSLane* from = getSidewalk<MSEdge, MSLane>(fromEdge);
187 const MSLane* to = getSidewalk<MSEdge, MSLane>(toEdge);
190 if (from !=
nullptr && to !=
nullptr) {
215 const double arrivalPos = partial && myArrived < 0 ?
getEdgePos(
SIMSTEP) : myArrivalPos;
216 const double lengthFwd = (length - myDepartPos - (
219 : myRoute.back()->getLength() - arrivalPos));
220 const double lengthBwd = (length - (myRoute.front()->getLength() - myDepartPos) - (
223 : myRoute.back()->getLength() - arrivalPos));
226 if (myRoute.size() == 1) {
227 if (myDepartPos > myArrivalPos) {
233 if (mayStartForward && mayStartBackward) {
234 length = lengthFwd < lengthBwd ? lengthFwd : lengthBwd;
235 }
else if (mayStartForward) {
237 }
else if (mayStartBackward) {
251 return MAX2(POSITION_EPS, length);
257 const double distance = walkDistance(
true);
259 const SUMOTime duration = myArrived - myDeparted;
261 if (timeLoss < 0 && timeLoss >
TIME2STEPS(-0.1)) {
271 os.
writeAttr(
"duration", myDeparted < 0 ?
"-1" :
283 std::string comment =
"";
284 if (myDestinationStop !=
nullptr) {
285 os.
writeAttr(
toString(myDestinationStop->getElement()), myDestinationStop->getID());
286 if (myDestinationStop->getMyName() !=
"") {
292 if (myWalkingTime > 0) {
294 }
else if (mySpeed > 0) {
297 if (withRouteLength) {
298 if (myDeparted >= 0) {
299 os.
writeAttr(
"routeLength", walkDistance(
true));
304 if (myExitTimes !=
nullptr) {
305 std::vector<std::string> exits;
309 std::vector<std::string> missing(
MAX2(0, (
int)myRoute.size() - (
int)myExitTimes->size()),
"-1");
310 exits.insert(exits.end(), missing.begin(), missing.end());
323 const bool arrived = myRouteStep == myRoute.end() - 1;
324 if (lane !=
nullptr) {
326 const double lastPos = (arrived
331 activateLeaveReminders(person, lane, lastPos, currentTime, arrived);
333 if (myExitTimes !=
nullptr && nextInternal ==
nullptr) {
334 myExitTimes->push_back(currentTime);
336 myMoveReminders.clear();
337 myLastEdgeEntryTime = currentTime;
339 if (myCurrentInternalEdge !=
nullptr) {
340 myInternalDistance += (myState->getPathLength() == 0 ? myCurrentInternalEdge->getLength() : myState->getPathLength());
345 myCurrentInternalEdge = nextInternal;
349 if (myDestinationStop !=
nullptr) {
358 if (nextInternal ==
nullptr) {
361 myCurrentInternalEdge = nextInternal;
372 rem->updateDetector(*person, 0.0, lane->
getLength(), myLastEdgeEntryTime, t, t,
true);
373 rem->notifyLeave(*person, lastPos, notification);
380 const MSLane* nextLane = getSidewalk<MSEdge, MSLane>(
getEdge());
381 if (nextLane !=
nullptr) {
385 myMoveReminders.push_back(rem);
394 return (
int)(myRouteStep - myRoute.begin());
400 return mySpeed >= 0 ? mySpeed : person->
getMaxSpeed();
405 const std::string dest = (getDestinationStop() ==
nullptr ?
407 " stop '" + getDestinationStop()->getID() +
"'" + (
408 getDestinationStop()->getMyName() !=
"" ?
" (" + getDestinationStop()->getMyName() +
")" :
""));
409 return "walking to " + dest;
415 out <<
" " << myDeparted <<
" " << (myRouteStep - myRoute.begin()) <<
" " << myLastEdgeEntryTime;
416 myState->saveState(out);
423 state >> myDeparted >> stepIdx >> myLastEdgeEntryTime;
424 myRouteStep = myRoute.begin() + stepIdx;
426 if (myState->getLane() && !myState->getLane()->isNormal()) {
430 (*myRouteStep)->addTransportable(transportable);
439 const double arrivalPos,
const double dist,
const bool isExit) :
441 myDist(dist), myAmExit(isExit) {
454 return new MSPersonStage_Access(myDestination, myDestinationStop, myArrivalPos, myDist, myAmExit);
463 myDestinationStop->getLane().getEdge().addTransportable(person);
475 return (myAmExit ?
"access from stop '" :
"access to stop '") + getDestinationStop()->getID() +
"'";
481 return myPath.positionAtOffset(myPath.length() * (
double)(now - myDeparted) / (
double)(myEstimatedArrival - myDeparted));
487 return myPath.angleAt2D(0);
511 myStopEdge->removeTransportable(myPerson);
538 prevStop =
dynamic_cast<const MSStageTrip*
>(prior)->getOriginStop();
540 if (prevStop !=
nullptr) {
543 if (accessDist > 0.) {
550 if (accessDist > 0.) {
572 if (nextEdge !=
nullptr) {
573 return nextEdge->
getID();
583 assert(walkingStage !=
nullptr);
593 assert(nextIndex > firstIndex);
609 for (
int i = nextIndex - 1; i >= firstIndex; i--) {
643 myRemoteXYPos = xyPos;
646 myRemotePosLat = posLat;
647 myRemoteAngle = angle;
648 myRemoteEdgeOffset = edgeOffset;
649 myRemoteRoute = route;
650 myLastRemoteAccess = t;
662 return myLastRemoteAccess >= t -
TIME2STEPS(10);
683 assert(s !=
nullptr);
684 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.
virtual const PositionVector & getShape(bool) const
MSEdge & getEdge() const
Returns the lane's edge.
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, ConstMSRoutePtr route)
Adds a route to the dictionary.
static RandomDistributor< ConstMSRoutePtr > * 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.
Position getCenterPos() const
the position in the middle of the stop shape
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.
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.