57 double departPos,
double arrivalPos,
double departPosLat) :
59 myWalkingTime(walkingTime) {
61 "person '" + personID +
"' walking from " + route.front()->getID());
63 "person '" + personID +
"' walking to " + route.back()->getID());
64 if (walkingTime > 0) {
76 return new MSPersonStage_Walking(
"dummyID", myRoute, myDestinationStop, myWalkingTime, mySpeed, myDepartPos, myArrivalPos, myDepartPosLat);
83 myRouteStep = myRoute.begin();
84 myLastEdgeEntryTime = now;
85 if (myWalkingTime == 0) {
86 if (!person->
proceed(net, now)) {
93 if (myWalkingTime > 0) {
94 mySpeed = computeAverageSpeed();
99 if (myState ==
nullptr) {
100 pControl.
erase(person);
103 const MSLane*
const lane = getSidewalk<MSEdge, MSLane>(
getEdge());
104 if (lane !=
nullptr) {
107 myMoveReminders.push_back(rem);
111 (*myRouteStep)->addPerson(person);
129 return walkDistance() /
STEPS2TIME(myWalkingTime + 1);
136 for (
const MSEdge* edge : myRoute) {
137 length += edge->getLength();
141 for (ConstMSEdgeVector::const_iterator i = myRoute.begin(); i != myRoute.end() - 1; ++i) {
142 const MSEdge* fromEdge = *i;
143 const MSEdge* toEdge = *(i + 1);
144 const MSLane* from = getSidewalk<MSEdge, MSLane>(fromEdge);
145 const MSLane* to = getSidewalk<MSEdge, MSLane>(toEdge);
148 if (from !=
nullptr && to !=
nullptr) {
171 const double lengthFwd = (length - myDepartPos - (
174 : myRoute.back()->getLength() - myArrivalPos));
175 const double lengthBwd = (length - (myRoute.front()->getLength() - myDepartPos) - (
178 : myRoute.back()->getLength() - myArrivalPos));
180 if (myRoute.size() == 1) {
181 if (myDepartPos > myArrivalPos) {
187 if (mayStartForward && mayStartBackward) {
188 length = lengthFwd < lengthBwd ? lengthFwd : lengthBwd;
189 }
else if (mayStartForward) {
191 }
else if (mayStartBackward) {
205 return MAX2(POSITION_EPS, length);
211 const double distance = walkDistance();
213 const SUMOTime duration = myArrived - myDeparted;
215 if (timeLoss < 0 && timeLoss >
TIME2STEPS(-0.1)) {
224 os.
writeAttr(
"arrivalPos", myArrivalPos);
225 os.
writeAttr(
"duration", myDeparted < 0 ?
"-1" :
237 std::string comment =
"";
238 if (myDestinationStop !=
nullptr) {
240 if (myDestinationStop->getMyName() !=
"") {
244 if (myWalkingTime > 0) {
246 }
else if (mySpeed > 0) {
249 if (withRouteLength) {
250 os.
writeAttr(
"routeLength", walkDistance());
260 const bool arrived = myRouteStep == myRoute.end() - 1;
261 if (lane !=
nullptr) {
263 rem->updateDetector(*person, 0.0, lane->
getLength(), myLastEdgeEntryTime, currentTime, currentTime,
true);
264 rem->notifyLeave(*person,
269 myMoveReminders.clear();
270 myLastEdgeEntryTime = currentTime;
275 myCurrentInternalEdge = nextInternal;
279 if (myDestinationStop !=
nullptr) {
280 myDestinationStop->addTransportable(person);
288 if (nextInternal ==
nullptr) {
291 myCurrentInternalEdge = nextInternal;
292 const MSLane* nextLane = getSidewalk<MSEdge, MSLane>(
getEdge());
293 if (nextLane !=
nullptr) {
297 myMoveReminders.push_back(rem);
313 const std::string dest = (getDestinationStop() ==
nullptr ?
315 " stop '" + getDestinationStop()->getID() +
"'" + (
316 getDestinationStop()->getMyName() !=
"" ?
" (" + getDestinationStop()->getMyName() +
")" :
""));
317 return "walking to " + dest;
323 out <<
" " << myDeparted <<
" " << (myRouteStep - myRoute.begin()) <<
" " << myLastEdgeEntryTime;
324 myState->saveState(out);
331 state >> myDeparted >> stepIdx >> myLastEdgeEntryTime;
332 myRouteStep = myRoute.begin() + stepIdx;
334 (*myRouteStep)->addPerson(transportable);
342 const double arrivalPos,
const double dist,
const bool isExit) :
344 myDist(dist), myAmExit(isExit) {
357 return new MSPersonStage_Access(myDestination, myDestinationStop, myArrivalPos, myDist, myAmExit);
365 myDestinationStop->getLane().getEdge().addPerson(person);
377 return (myAmExit ?
"access from stop '" :
"access to stop '") + getDestinationStop()->getID() +
"'";
383 return myPath.positionAtOffset(myPath.length() * (now - myDeparted) / (myEstimatedArrival - myDeparted));
389 return myPath.angleAt2D(0);
405 myStopEdge->removePerson(myPerson);
429 if (prevStop !=
nullptr) {
432 if (accessDist > 0.) {
439 if (accessDist > 0.) {
460 if (nextEdge !=
nullptr) {
461 return nextEdge->
getID();
471 assert(walkingStage !=
nullptr);
481 assert(nextIndex > firstIndex);
497 for (
int i = nextIndex - 1; i >= firstIndex; i--) {
531 myRemoteXYPos = xyPos;
534 myRemotePosLat = posLat;
535 myRemoteAngle = angle;
536 myRemoteEdgeOffset = edgeOffset;
537 myRemoteRoute = route;
538 myLastRemoteAccess = t;
550 return myLastRemoteAccess >= t -
TIME2STEPS(10);
571 assert(s !=
nullptr);
572 s->
getState()->
moveToXY(p, myRemoteXYPos, myRemoteLane, myRemotePos, myRemotePosLat, myRemoteAngle, myRemoteEdgeOffset, myRemoteRoute,
std::vector< const MSEdge * > ConstMSEdgeVector
std::string time2string(SUMOTime t)
convert SUMOTime to string
@ SUMO_ATTR_EDGES
the edges of a route
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 * getFromJunction() const
const MSJunction * getToJunction() const
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
Representation of a lane in the micro simulation.
double getLength() const
Returns the lane's length.
MSEdge & getEdge() const
Returns the lane's edge.
const PositionVector & getShape() const
Returns this lane's shape.
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Something on a lane to be noticed about vehicle movement.
@ 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).
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
static const int BACKWARD
static int canTraverse(int dir, const ConstMSEdgeVector &route)
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
virtual MSTransportableStateAdapter * add(MSTransportable *transportable, MSStageMoving *stage, SUMOTime now)=0
register the given person as a pedestrian
static const int UNDEFINED_DIRECTION
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
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 getMaxSpeed(const MSTransportable *const person) const
accessors to be used by MSPModel
~MSPersonStage_Walking()
destructor
double walkDistance() const
compute total walking distance
void loadState(MSTransportable *transportable, std::istringstream &state)
Reconstructs the current state.
bool moveToNextEdge(MSTransportable *person, SUMOTime currentTime, MSEdge *nextInternal=nullptr)
move forward and return whether the person arrived
MSPersonStage_Walking(const std::string &personID, const ConstMSEdgeVector &route, MSStoppingPlace *toStop, SUMOTime walkingTime, double speed, double departPos, double arrivalPos, double departPosLat)
constructor
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 abort(MSTransportable *)
abort this stage (TraCI)
void saveState(std::ostringstream &out)
Saves the current state into the given stream.
void checkAccess(const MSStage *const prior, const bool isDisembark=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,...
const double myChosenSpeedFactor
bool hasInfluencer() const
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
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
MSStageType getStageType(int next) const
the stage type for the nth next 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
const MSVehicleType & getVehicleType() const
Returns the object's "vehicle" type.
double getArrivalPos() const
returns the final arrival pos
void removeStage(int next)
removes the nth next stage
MSStageType getCurrentStageType() const
the current stage type of the transportable
const MSEdge * getEdge() const
Returns the current edge.
MSStage * getCurrentStage() const
Return the current stage.
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 MSLane * getLane() const
Returns the current lane (may be nullptr)
std::vector< MSStage * > MSTransportablePlan
the structure holding the plan of a transportable
const MSEdge * getDestination() const
Returns the current destination.
virtual double getSpeedFactor() const
the current speed factor of the transportable (where applicable)
double getMaxSpeed() const
Returns the object's 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 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 getMaxSpeed() const
Get vehicle's maximum speed [m/s].
const std::string & getID() const
Returns the id.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
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.