40 #define FAR_AWAY 1000.0 49 std::vector<std::string>
52 std::vector<std::string> ids;
55 ids.push_back(i->first);
58 return std::move(ids);
133 std::vector<std::string>
137 throw TraCIException(
"The stage index must be lower than the number of remaining stages.");
140 throw TraCIException(
"The negative stage index must refer to a valid previous stage.");
142 std::vector<std::string> edgeIDs;
143 for (
auto& e : p->
getEdges(nextStageIndex)) {
144 edgeIDs.push_back(e->getID());
154 throw TraCIException(
"The stage index must be lower than the number of remaining stages.");
157 throw TraCIException(
"The negative stage index must refer to a valid previous stage.");
172 if (veh ==
nullptr) {
197 if (vehicleType == 0) {
198 throw TraCIException(
"The vehicle type '" + typeID +
"' is not known.");
205 Person::add(
const std::string& personID,
const std::string& edgeID,
double pos,
double departInSecs,
const std::string typeID) {
214 throw TraCIException(
"The person " + personID +
" to add already exists.");
219 vehicleParams.
id = personID;
223 throw TraCIException(
"Invalid type '" + typeID +
"' for person '" + personID +
"'");
228 throw TraCIException(
"Invalid edge '" + edgeID +
"' for person: '" + personID +
"'");
232 const int proc = (int) - depart;
241 +
"' is in the past; using current time " +
time2string(vehicleParams.
depart) +
" instead.");
243 vehicleParams.
depart = depart;
275 throw TraCIException(
"Invalid edge '" + toEdge +
"' for person: '" + personID +
"'");
277 if (lines.size() == 0) {
278 return throw TraCIException(
"Empty lines parameter for person: '" + personID +
"'");
284 throw TraCIException(
"Invalid stopping place id '" + stopID +
"' for person: '" + personID +
"'");
295 throw TraCIException(
"Duration for person: '" + personID +
"' must not be negative");
301 throw TraCIException(
"Invalid stopping place id '" + stopID +
"' for person: '" + personID +
"'");
309 Person::appendWalkingStage(
const std::string& personID,
const std::vector<std::string>& edgeIDs,
double arrivalPos,
double duration,
double speed,
const std::string& stopID) {
318 throw TraCIException(
"Empty edge list for walking stage of person '" + personID +
"'.");
320 if (fabs(arrivalPos) > edges.back()->getLength()) {
321 throw TraCIException(
"Invalid arrivalPos for walking stage of person '" + personID +
"'.");
323 if (arrivalPos < 0) {
324 arrivalPos += edges.back()->getLength();
333 throw TraCIException(
"Invalid stopping place id '" + stopID +
"' for person: '" + personID +
"'");
344 throw TraCIException(
"The stage index must be lower than the number of remaining stages.");
346 if (nextStageIndex < 0) {
357 throw TraCIException(
"Person '" + personID +
"' is not currenlty walking.");
366 if (newEdges.empty()) {
367 throw TraCIException(
"Could not find new route for person '" + personID +
"'.");
370 assert(!oldEdges.empty());
372 oldEdges.erase(oldEdges.begin());
374 if (newEdges == oldEdges) {
377 if (newEdges.front() != from) {
379 newEdges.insert(newEdges.begin(), from);
386 Person::moveTo(
const std::string& personID,
const std::string& edgeID,
double ) {
411 Person::moveToXY(
const std::string& personID,
const std::string& edgeID,
const double x,
const double y,
double angle,
const int keepRouteFlag) {
413 bool keepRoute = (keepRouteFlag == 1);
414 bool mayLeaveNetwork = (keepRouteFlag == 2);
417 const double origAngle = angle;
422 while (angle >= 360.) {
432 std::cout <<
" want pos:" << pos <<
" edgeID:" << edgeID <<
" origAngle:" << origAngle <<
" angle:" << angle <<
" keepRoute:" << keepRoute << std::endl;
438 double lanePosLat = 0;
439 double bestDistance = std::numeric_limits<double>::max();
442 double maxRouteDistance = 100;
465 bestDistance, &lane, lanePos, routeOffset);
470 speed, ev, routeIndex, currentLane, p->
getEdgePos(),
true,
471 bestDistance, &lane, lanePos, routeOffset, edges);
473 if ((found && bestDistance <= maxRouteDistance) || mayLeaveNetwork) {
478 lanePosLat = perpDist;
479 if (!mayLeaveNetwork) {
487 WRITE_WARNING(
"Could not determine position on lane '" + lane->
getID() +
" at lateral position " +
toString(-lanePosLat) +
".");
491 lanePosLat = -lanePosLat;
499 assert((found && lane != 0) || (!found && lane == 0));
518 throw TraCIException(
"Could not map person '" + personID +
"' no road found within " +
toString(maxRouteDistance) +
"m.");
520 throw TraCIException(
"Could not map person '" + personID +
"' distance to road is " +
toString(bestDistance) +
".");
static void moveTo(const std::string &personID, const std::string &edgeID, double position)
SUMOVehicle * getVehicle() const
The vehicle associated with this transportable.
static std::string getNextEdge(const std::string &personID)
void setMinGap(const double &minGap)
Set a new value for this type's minimum gap.
static double gLateralResolution
RGBColor color
The vehicle's color, TraCI may change this.
std::map< std::string, MSTransportable * >::const_iterator constVehIt
Definition of the internal transportables map iterator.
double getArrivalPos() const
returns the final arrival pos
double z() const
Returns the z-position.
double distance2D(const Position &p, bool perpendicular=false) const
closest 2D-distance to point p (or -1 if perpendicular is true and the point is beyond this vector) ...
static void setRemoteControlled(MSVehicle *v, Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
const MSEdge * getEdge() const
Returns the current edge.
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
A lane area vehicles can halt at.
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
virtual double getEdgePos() const
Return the position on the edge.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
unsigned char alpha() const
Returns the alpha-amount of the color.
double y() const
Returns the y-position.
static void setHeight(const std::string &personID, double height)
static void setMinGap(const std::string &personID, double minGap)
static void setType(const std::string &personID, const std::string &typeID)
std::string time2string(SUMOTime t)
double x() const
Returns the x-position.
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position ...
int size() const
Returns the number of known transportables.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
static void moveToXY(const std::string &personID, const std::string &edgeID, const double x, const double y, double angle, const int keepRouteFlag)
const std::string & getNextEdge() const
return the list of internal edges if this person is walking and the pedestrian model allows it ...
static std::string getSingularVType(const std::string &personID)
MSPedestrianRouterDijkstra & getPedestrianRouter(const MSEdgeVector &prohibited=MSEdgeVector()) const
static std::vector< std::string > getIDList()
const PositionVector & getShape() const
Returns this lane's shape.
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary...
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
unsigned char blue() const
Returns the blue-amount of the color.
void setLength(const double &length)
Set a new value for this type's length.
std::vector< const MSEdge * > ConstMSEdgeVector
static std::string getTypeID(const std::string &personID)
const std::string & getID() const
Returns the id.
virtual double getSpeed() const
the current speed of the transportable
ConstMSEdgeVector getEdges(int next) const
Return the edges of the nth next stage.
const SUMOVehicleParameter & getParameter() const
double getLength() const
return the length of the edge
Tag for the last element in the enum for safe int casting.
static double getLanePosition(const std::string &personID)
void reroute(ConstMSEdgeVector &newEdges)
set new walk
double getWidth() const
Returns the lane's width.
int getNumRemainingStages() const
Return the number of remaining stages (including the current)
#define WRITE_WARNING(msg)
static void appendDrivingStage(const std::string &personID, const std::string &toEdge, const std::string &lines, const std::string &stopID="")
The car-following model and parameter.
static int getRemainingStages(const std::string &personID)
static std::string getVehicle(const std::string &personID)
void removeStage(int next)
removes the nth next stage
static MSPerson * getPerson(const std::string &id)
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
A road/street connecting two junctions.
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
static double naviDegree(const double angle)
MSTransportable::Stage * getCurrentStage() const
Return the current stage.
static MSVehicleType * getVType(std::string id)
static TraCIPosition getPosition(const std::string &personID)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static void add(const std::string &personID, const std::string &edgeID, double pos, double depart=DEPARTFLAG_NOW, const std::string typeID="DEFAULT_PEDTYPE")
Representation of a vehicle.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
A point in 2D or 3D with translation and scaling methods.
ConstMSEdgeVector getEdges() const
the edges of the current stage
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
void setHeight(const double &height)
Set a new value for this type's height.
constVehIt loadedBegin() const
Returns the begin of the internal transportables map.
SUMOTime depart
The vehicle's departure time.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
const std::string & getID() const
returns the id of the transportable
static void setParameter(const std::string &personID, const std::string &key, const std::string &value)
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
static void setColor(const std::string &personID, const TraCIColor &c)
const ConstMSEdgeVector & getRoute() const
static std::string getParameter(const std::string &routeID, const std::string ¶m)
void move2side(double amount)
move position vector to side using certain ammount
static void setSpeed(const std::string &personID, double speed)
#define INVALID_DOUBLE_VALUE
static TraCIColor getColor(const std::string &personID)
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, std::mt19937 *rng=0)
Returns the named vehicle type or a sample from the named distribution.
const std::vector< const MSEdge * >::iterator getRouteStep() const
static bool moveToXYMap(const Position &pos, double maxRouteDistance, bool mayLeaveNetwork, const std::string &origID, const double angle, double speed, const ConstMSEdgeVector ¤tRoute, const int routePosition, MSLane *currentLane, double currentLanePos, bool onRoad, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset, ConstMSEdgeVector &edges)
static std::string getRoadID(const std::string &personID)
void appendStage(Stage *stage, int next=-1)
Appends the given stage to the current plan.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
std::string getCurrentStageDescription() const
Returns the current stage description as a string.
double departPos
(optional) The position the vehicle shall depart from
static void removeStage(const std::string &personID, int nextStageIndex)
Structure representing possible vehicle parameter.
double compute(const E *from, const E *to, double departPos, double arrivalPos, double speed, SUMOTime msTime, const N *onlyNode, std::vector< const E *> &into, bool allEdges=false)
Builds the route between the given edges using the minimum effort at the given time The definition of...
static double getWaitingTime(const std::string &personID)
virtual Position getPosition() const
Return the Network coordinate of the transportable.
unsigned char green() const
Returns the green-amount of the color.
bool add(MSTransportable *transportable)
Adds a single transportable, returns false if an id clash occured.
const std::string & getID() const
Returns the name of the vehicle type.
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
void setWidth(const double &width)
Set a new value for this type's width.
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
constVehIt loadedEnd() const
Returns the end of the internal transportables map.
StageType getStageType(int next) const
the stage type for the nth next stage
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
static int getStage(const std::string &personID, int nextStageIndex=0)
static void appendWaitingStage(const std::string &personID, double duration, const std::string &description="waiting", const std::string &stopID="")
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
const MSEdge * getArrivalEdge() const
returns the final arrival edge
static std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0)
unsigned char red() const
Returns the red-amount of the color.
const MSVehicleType & getVehicleType() const
void setColor(const RGBColor &color)
Set a new value for this type's color.
virtual double getWaitingSeconds() const
the time this transportable spent waiting in seconds
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, std::mt19937 *rng) const
Builds a new person.
static void appendWalkingStage(const std::string &personID, const std::vector< std::string > &edgeIDs, double arrivalPos, double duration=-1, double speed=-1, const std::string &stopID="")
static void setWidth(const std::string &personID, double width)
static void setLength(const std::string &personID, double length)
static double getSpeed(const std::string &personID)
static void rerouteTraveltime(const std::string &personID)
Representation of a lane in the micro simulation.
static void parseEdgesList(const std::string &desc, ConstMSEdgeVector &into, const std::string &rid)
Parses the given string assuming it contains a list of edge ids divided by spaces.
virtual const std::string & getID() const =0
Get the vehicle's ID.
DepartDefinition
Possible ways to depart.
static bool moveToXYMap_matchingRoutePosition(const Position &pos, const std::string &origID, const ConstMSEdgeVector ¤tRoute, int routeIndex, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset)
static double getAngle(const std::string &personID)
int getNumStages() const
Return the total number stages in this persons plan.
std::string id
The vehicle's id.
StageType getCurrentStageType() const
the current stage type of the transportable