57 double departPos,
double arrivalPos,
double departPosLat,
int departLane) :
59 myWalkingTime(walkingTime),
60 myExitTimes(nullptr) {
62 "person '" + personID +
"' walking from " + route.front()->getID());
64 "person '" + personID +
"' walking to " + route.back()->getID());
65 if (walkingTime > 0) {
78 return new MSPersonStage_Walking(
"dummyID", myRoute, myDestinationStop, myWalkingTime, mySpeed, myDepartPos, myArrivalPos, myDepartPosLat);
85 myRouteStep = myRoute.begin();
86 myLastEdgeEntryTime = now;
87 if (myWalkingTime == 0) {
88 if (!person->
proceed(net, now)) {
95 if (myWalkingTime > 0) {
96 mySpeed = computeAverageSpeed();
101 if (myState ==
nullptr) {
102 pControl.
erase(person);
105 const MSLane*
const lane = getSidewalk<MSEdge, MSLane>(
getEdge());
106 if (lane !=
nullptr) {
109 myMoveReminders.push_back(rem);
114 myExitTimes =
new std::vector<SUMOTime>();
116 (*myRouteStep)->addPerson(person);
134 return walkDistance() /
STEPS2TIME(myWalkingTime + 1);
141 for (
const MSEdge* edge : myRoute) {
142 length += edge->getLength();
146 for (ConstMSEdgeVector::const_iterator i = myRoute.begin(); i != myRoute.end() - 1; ++i) {
147 const MSEdge* fromEdge = *i;
148 const MSEdge* toEdge = *(i + 1);
149 const MSLane* from = getSidewalk<MSEdge, MSLane>(fromEdge);
150 const MSLane* to = getSidewalk<MSEdge, MSLane>(toEdge);
153 if (from !=
nullptr && to !=
nullptr) {
176 const double lengthFwd = (length - myDepartPos - (
179 : myRoute.back()->getLength() - myArrivalPos));
180 const double lengthBwd = (length - (myRoute.front()->getLength() - myDepartPos) - (
183 : myRoute.back()->getLength() - myArrivalPos));
185 if (myRoute.size() == 1) {
186 if (myDepartPos > myArrivalPos) {
192 if (mayStartForward && mayStartBackward) {
193 length = lengthFwd < lengthBwd ? lengthFwd : lengthBwd;
194 }
else if (mayStartForward) {
196 }
else if (mayStartBackward) {
210 return MAX2(POSITION_EPS, length);
216 const double distance = walkDistance();
218 const SUMOTime duration = myArrived - myDeparted;
220 if (timeLoss < 0 && timeLoss >
TIME2STEPS(-0.1)) {
230 os.
writeAttr(
"duration", myDeparted < 0 ?
"-1" :
242 std::string comment =
"";
243 if (myDestinationStop !=
nullptr) {
244 os.
writeAttr(
toString(myDestinationStop->getElement()), myDestinationStop->getID());
245 if (myDestinationStop->getMyName() !=
"") {
249 if (myWalkingTime > 0) {
251 }
else if (mySpeed > 0) {
254 if (withRouteLength) {
255 os.
writeAttr(
"routeLength", walkDistance());
257 if (myExitTimes !=
nullptr) {
258 std::vector<std::string> exits;
262 std::vector<std::string> missing(
MAX2(0, (
int)myRoute.size() - (
int)myExitTimes->size()),
"-1");
263 exits.insert(exits.end(), missing.begin(), missing.end());
276 const bool arrived = myRouteStep == myRoute.end() - 1;
277 if (lane !=
nullptr) {
279 const double lastPos = (arrived
287 rem->updateDetector(*person, 0.0, lane->
getLength(), myLastEdgeEntryTime, currentTime, currentTime,
true);
291 if (myExitTimes !=
nullptr && nextInternal ==
nullptr) {
292 myExitTimes->push_back(currentTime);
294 myMoveReminders.clear();
295 myLastEdgeEntryTime = currentTime;
300 myCurrentInternalEdge = nextInternal;
304 if (myDestinationStop !=
nullptr) {
305 myDestinationStop->addTransportable(person);
313 if (nextInternal ==
nullptr) {
316 myCurrentInternalEdge = nextInternal;
317 const MSLane* nextLane = getSidewalk<MSEdge, MSLane>(
getEdge());
318 if (nextLane !=
nullptr) {
322 myMoveReminders.push_back(rem);
338 const std::string dest = (getDestinationStop() ==
nullptr ?
340 " stop '" + getDestinationStop()->getID() +
"'" + (
341 getDestinationStop()->getMyName() !=
"" ?
" (" + getDestinationStop()->getMyName() +
")" :
""));
342 return "walking to " + dest;
348 out <<
" " << myDeparted <<
" " << (myRouteStep - myRoute.begin()) <<
" " << myLastEdgeEntryTime;
349 myState->saveState(out);
356 state >> myDeparted >> stepIdx >> myLastEdgeEntryTime;
357 myRouteStep = myRoute.begin() + stepIdx;
359 (*myRouteStep)->addPerson(transportable);
367 const double arrivalPos,
const double dist,
const bool isExit) :
369 myDist(dist), myAmExit(isExit) {
382 return new MSPersonStage_Access(myDestination, myDestinationStop, myArrivalPos, myDist, myAmExit);
390 myDestinationStop->getLane().getEdge().addPerson(person);
402 return (myAmExit ?
"access from stop '" :
"access to stop '") + getDestinationStop()->getID() +
"'";
408 return myPath.positionAtOffset(myPath.length() * (now - myDeparted) / (myEstimatedArrival - myDeparted));
414 return myPath.angleAt2D(0);
432 myStopEdge->removePerson(myPerson);
457 prevStop =
dynamic_cast<const MSStageTrip*
>(prior)->getOriginStop();
459 if (prevStop !=
nullptr) {
462 if (accessDist > 0.) {
469 if (accessDist > 0.) {
491 if (nextEdge !=
nullptr) {
492 return nextEdge->
getID();
502 assert(walkingStage !=
nullptr);
512 assert(nextIndex > firstIndex);
528 for (
int i = nextIndex - 1; i >= firstIndex; i--) {
562 myRemoteXYPos = xyPos;
565 myRemotePosLat = posLat;
566 myRemoteAngle = angle;
567 myRemoteEdgeOffset = edgeOffset;
568 myRemoteRoute = route;
569 myLastRemoteAccess = t;
581 return myLastRemoteAccess >= t -
TIME2STEPS(10);
602 assert(s !=
nullptr);
603 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
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 * 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.
MSPersonStage_Walking(const std::string &personID, const ConstMSEdgeVector &route, MSStoppingPlace *toStop, SUMOTime walkingTime, double speed, double departPos, double arrivalPos, double departPosLat, int departLane=-1)
constructor
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
double computeAverageSpeed() const
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
double walkDistance() const
compute total walking distance
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 abort(MSTransportable *)
abort this stage (TraCI)
void saveState(std::ostringstream &out)
Saves the current state into the given stream.
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 checkAccess(const MSStage *const prior, const bool isDisembark=true)
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
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
void removeStage(int next, bool stayInSim=true)
removes the nth next stage
const MSVehicleType & getVehicleType() const
Returns the object's "vehicle" type.
double getArrivalPos() const
returns the final arrival pos
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].
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 & 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.