45 std::vector<std::string>
48 std::vector<std::string> ids;
51 ids.push_back(i->first);
54 return std::move(ids);
129 std::vector<std::string>
133 throw TraCIException(
"The stage index must be lower than the number of remaining stages.");
136 throw TraCIException(
"The negative stage index must refer to a valid previous stage.");
138 std::vector<std::string> edgeIDs;
139 for(
auto& e : p->
getEdges(nextStageIndex)) {
140 edgeIDs.push_back(e->getID());
150 throw TraCIException(
"The stage index must be lower than the number of remaining stages.");
153 throw TraCIException(
"The negative stage index must refer to a valid previous stage.");
168 if (veh ==
nullptr) {
193 if (vehicleType == 0) {
194 throw TraCIException(
"The vehicle type '" + typeID +
"' is not known.");
201 TraCI_Person::add(
const std::string& personID,
const std::string& edgeID,
double pos,
double departInSecs,
const std::string typeID) {
210 throw TraCIException(
"The person " + personID +
" to add already exists.");
215 vehicleParams.
id = personID;
219 throw TraCIException(
"Invalid type '" + typeID +
"' for person '" + personID +
"'");
224 throw TraCIException(
"Invalid edge '" + edgeID +
"' for person: '" + personID +
"'");
228 const int proc = (int)-depart;
237 +
"' is in the past; using current time " +
time2string(vehicleParams.
depart) +
" instead.");
239 vehicleParams.
depart = depart;
271 throw TraCIException(
"Invalid edge '" + toEdge +
"' for person: '" + personID +
"'");
273 if (lines.size() == 0) {
274 return throw TraCIException(
"Empty lines parameter for person: '" + personID +
"'");
280 throw TraCIException(
"Invalid stopping place id '" + stopID +
"' for person: '" + personID +
"'");
291 throw TraCIException(
"Duration for person: '" + personID +
"' must not be negative");
297 throw TraCIException(
"Invalid stopping place id '" + stopID +
"' for person: '" + personID +
"'");
305 TraCI_Person::appendWalkingStage(
const std::string& personID,
const std::vector<std::string>& edgeIDs,
double arrivalPos,
double duration,
double speed,
const std::string& stopID) {
314 throw TraCIException(
"Empty edge list for walking stage of person '" + personID+
"'.");
316 if (fabs(arrivalPos) > edges.back()->getLength()) {
317 throw TraCIException(
"Invalid arrivalPos for walking stage of person '" + personID +
"'.");
319 if (arrivalPos < 0) {
320 arrivalPos += edges.back()->getLength();
329 throw TraCIException(
"Invalid stopping place id '" + stopID +
"' for person: '" + personID +
"'");
340 throw TraCIException(
"The stage index must be lower than the number of remaining stages.");
342 if (nextStageIndex < 0) {
353 throw TraCIException(
"Person '" + personID +
"' is not currenlty walking.");
362 if (newEdges.empty()) {
363 throw TraCIException(
"Could not find new route for person '" + personID +
"'.");
366 assert(!oldEdges.empty());
368 oldEdges.erase(oldEdges.begin());
370 if (newEdges == oldEdges) {
373 if (newEdges.front() != from) {
375 newEdges.insert(newEdges.begin(), from);
static TraCIPosition getPosition(const std::string &personID)
void setMinGap(const double &minGap)
Set a new value for this type's minimum gap.
double getLength() const
return the length of the edge
double z() const
Returns the z-position.
RGBColor color
The vehicle's color, TraCI may change this.
virtual double getEdgePos() const
Return the position on the edge.
std::map< std::string, MSTransportable * >::const_iterator constVehIt
Definition of the internal transportables map iterator.
static void setLength(const std::string &personID, double length)
static double getLanePosition(const std::string &personID)
A lane area vehicles can halt at.
virtual double getWaitingSeconds() const
the time this transportable spent waiting in seconds
void setSpeed(double speed)
sets the walking speed (ignored in other stages)
const SUMOVehicleParameter & getParameter() const
double x() const
Returns the x-position.
static void setHeight(const std::string &personID, double height)
SUMOVehicle * getVehicle() const
The vehicle associated with this transportable.
std::string time2string(SUMOTime t)
int getNumRemainingStages() const
Return the number of remaining stages (including the current)
MSPedestrianRouterDijkstra & getPedestrianRouter(const MSEdgeVector &prohibited=MSEdgeVector()) const
static int getStage(const std::string &personID, int nextStageIndex=0)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
static std::vector< std::string > getIDList()
const std::string & getID() const
returns the id of the transportable
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...
static MSTransportable * getPerson(const std::string &id)
void setLength(const double &length)
Set a new value for this type's length.
std::vector< const MSEdge * > ConstMSEdgeVector
static std::string getParameter(const std::string &routeID, const std::string ¶m)
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...
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, std::mt19937 *rng) const
Builds a new person.
Tag for the last element in the enum for safe int casting.
#define WRITE_WARNING(msg)
The car-following model and parameter.
static std::string getNextEdge(const std::string &personID)
virtual double getSpeed() const
the current speed of the transportable
static double getWaitingTime(const std::string &personID)
int size() const
Returns the number of known transportables.
unsigned char blue() const
Returns the blue-amount of the color.
void removeStage(int next)
removes the nth next stage
static void setWidth(const std::string &personID, double width)
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
static std::string getRoadID(const std::string &personID)
static void appendWaitingStage(const std::string &personID, double duration, const std::string &description="waiting", const std::string &stopID="")
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
const std::string & getID() const
Returns the id.
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)
const MSVehicleType & getVehicleType() const
static std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0)
static std::string getSingularVType(const std::string &personID)
static void appendDrivingStage(const std::string &personID, const std::string &toEdge, const std::string &lines, const std::string &stopID="")
static std::string getTypeID(const std::string &personID)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
const MSEdge * getEdge() const
Returns the current edge.
static void setParameter(const std::string &personID, const std::string &key, const std::string &value)
Representation of a vehicle.
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
StageType getCurrentStageType() const
the current stage type of the transportable
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
unsigned char alpha() const
Returns the alpha-amount of the color.
void setHeight(const double &height)
Set a new value for this type's height.
static std::string getVehicle(const std::string &personID)
double y() const
Returns the y-position.
SUMOTime depart
The vehicle's departure time.
static void setSpeed(const std::string &personID, double speed)
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
static double getAngle(const std::string &personID)
static void rerouteTraveltime(const std::string &personID)
static void setMinGap(const std::string &personID, double minGap)
static int getRemainingStages(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.
constVehIt loadedEnd() const
Returns the end of the internal transportables map.
void appendStage(Stage *stage, int next=-1)
Appends the given stage to the current plan.
static TraCIColor getColor(const std::string &personID)
double departPos
(optional) The position the vehicle shall depart from
Structure representing possible vehicle parameter.
static double getSpeed(const std::string &personID)
static void setColor(const std::string &personID, const TraCIColor &c)
static void add(const std::string &personID, const std::string &edgeID, double pos, double depart=DEPARTFLAG_NOW, const std::string typeID="DEFAULT_PEDTYPE")
StageType getStageType(int next) const
the stage type for the nth next stage
bool add(MSTransportable *transportable)
Adds a single transportable, returns false if an id clash occured.
void setWidth(const double &width)
Set a new value for this type's width.
ConstMSEdgeVector getEdges(int next) const
Return the edges of the nth next stage.
const std::string & getID() const
Returns the name of the vehicle type.
void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
virtual Position getPosition() const
Return the Network coordinate of the transportable.
static void removeStage(const std::string &personID, int nextStageIndex)
double getArrivalPos() const
returns the final arrival pos
static void setType(const std::string &personID, const std::string &typeID)
void setColor(const RGBColor &color)
Set a new value for this type's color.
unsigned char green() const
Returns the green-amount of the color.
int getNumStages() const
Return the total number stages in this persons plan.
constVehIt loadedBegin() const
Returns the begin of the internal transportables map.
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 MSVehicleType * getVType(std::string id)
unsigned char red() const
Returns the red-amount of the color.
const MSEdge * getArrivalEdge() const
returns the final arrival edge
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.
std::string id
The vehicle's id.