 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
62 const std::string
id = inputStorage.
readString();
86 if (inputStorage.
readInt() != 2) {
107 if (inputStorage.
readInt() != 2) {
129 tempContent.
writeInt((
int)bestLanes.size());
131 for (std::vector<libsumo::TraCIBestLanesData>::const_iterator i = bestLanes.begin(); i != bestLanes.end(); ++i) {
159 const int cnt = 1 + (int)nextTLS.size() * 4;
163 for (std::vector<libsumo::TraCINextTLSData>::iterator it = nextTLS.begin(); it != nextTLS.end(); ++it) {
178 const int cnt = 1 + (int)nextStops.size() * 4;
182 for (std::vector<libsumo::TraCINextStopData>::iterator it = nextStops.begin(); it != nextStops.end(); ++it) {
202 if (inputStorage.
readInt() != 2) {
214 std::string roadID = inputStorage.
readString();
259 std::string paramName =
"";
275 for (
auto& p : neighVehicles) {
297 std::string warning =
"";
333 std::cout <<
SIMTIME <<
" processSet veh=" <<
id <<
"\n";
337 if (sumoVehicle ==
nullptr) {
342 MSVehicle* v = dynamic_cast<MSVehicle*>(sumoVehicle);
343 if (v ==
nullptr && shouldExist) {
352 int compoundSize = inputStorage.
readInt();
353 if (compoundSize < 4 || compoundSize > 7) {
375 if (compoundSize >= 5) {
381 if (compoundSize >= 6) {
387 if (compoundSize >= 7) {
400 int compoundSize = inputStorage.
readInt();
401 if (compoundSize != 1) {
404 std::string parkingAreaID;
416 if (inputStorage.
readInt() != 0) {
427 int compounds = inputStorage.
readInt();
428 if (compounds != 3 && compounds != 2) {
437 double duration = 0.;
443 if (compounds == 3) {
449 if ((laneIndex < 0 || laneIndex >= (
int)v->
getEdge()->
getLanes().size()) && relative < 1) {
472 if (inputStorage.
readInt() != 2) {
482 double duration = 0.;
504 const int nParameter = inputStorage.
readInt();
505 if (nParameter != 5 && nParameter != 6) {
508 double newTimeHeadway = 0;
512 double newSpaceHeadway = 0;
516 double duration = 0.;
520 double changeRate = 0;
529 if (newTimeHeadway == -1 && newSpaceHeadway == -1 && duration == -1 && changeRate == -1 && maxDecel == -1) {
532 if (newTimeHeadway <= 0) {
533 if (newTimeHeadway != -1) {
537 if (newSpaceHeadway < 0) {
543 if (changeRate <= 0) {
547 if (maxDecel != -1) {
551 std::string refVehID =
"";
552 if (nParameter == 6) {
578 std::vector<std::string> edgeIDs;
589 int parameterCount = inputStorage.
readInt();
592 double endTime = std::numeric_limits<double>::max();
594 if (parameterCount == 4) {
611 }
else if (parameterCount == 2) {
620 }
else if (parameterCount == 1) {
635 int parameterCount = inputStorage.
readInt();
638 double endTime = std::numeric_limits<double>::max();
640 if (parameterCount == 4) {
657 }
else if (parameterCount == 2) {
665 }
else if (parameterCount == 1) {
681 if (inputStorage.
readInt() != 0) {
691 if (inputStorage.
readInt() != 0) {
709 if (inputStorage.
readInt() != 2) {
743 int laneChangeMode = 0;
763 libsumo::Vehicle::setColor(
id, col);
770 if (inputStorage.
readInt() != 6) {
787 depart =
"triggered";
789 depart =
"containerTriggered";
794 double departPosCode;
798 std::string departPos =
toString(departPosCode);
800 departPos =
"random";
802 departPos =
"random_free";
813 double departSpeedCode;
817 std::string departSpeed =
toString(departSpeedCode);
819 departSpeed =
"random";
823 departSpeed =
"desired";
825 departSpeed =
"speedLimit";
832 std::string departLane =
toString(departLaneCode);
834 departLane =
"random";
838 departLane =
"allowed";
842 departLane =
"first";
851 if (inputStorage.
readInt() != 14) {
866 std::string departLane;
870 std::string departPos;
874 std::string departSpeed;
878 std::string arrivalLane;
882 std::string arrivalPos;
886 std::string arrivalSpeed;
910 libsumo::Vehicle::add(
id, routeID, vTypeID, depart, departLane, departPos, departSpeed, arrivalLane, arrivalPos, arrivalSpeed,
911 fromTaz, toTaz, line, personCapacity, personNumber);
926 const int numArgs = inputStorage.
readInt();
927 if (numArgs != 5 && numArgs != 6) {
956 int keepRouteFlag = 1;
970 libsumo::Vehicle::setSpeedFactor(
id, factor);
982 std::vector<std::string> edgeIDs;
1038 double duration = -1;
1058 if (fabs(value) == std::numeric_limits<double>::infinity()) {
1061 bool resetActionOffset = value >= 0.0;
1062 libsumo::Vehicle::setActionStepLength(
id, fabs(value), resetActionOffset);
static void highlight(const std::string &vehicleID, const TraCIColor &col, double size, const int alphaMax, const double duration, const int type)
static void setSpeed(const std::string &vehicleID, double speed)
TRACI_CONST int VAR_SPEEDSETMODE
TRACI_CONST int VAR_HEIGHT
static void setStop(const std::string &vehicleID, const std::string &edgeID, double pos=1., int laneIndex=0, double duration=INVALID_DOUBLE_VALUE, int flags=STOP_DEFAULT, double startPos=INVALID_DOUBLE_VALUE, double until=INVALID_DOUBLE_VALUE)
static void setLaneChangeMode(const std::string &vehicleID, int laneChangeMode)
virtual double readDouble()
const std::string & getID() const
Returns the name of the vehicle type.
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc4: Change Vehicle State)
static void openGap(const std::string &vehicleID, double newTimeHeadway, double newSpaceHeadway, double duration, double changeRate, double maxDecel=INVALID_DOUBLE_VALUE, const std::string &referenceVehID="")
static double getEffort(const std::string &vehicleID, double time, const std::string &edgeID)
TRACI_CONST int VAR_EMISSIONCLASS
TRACI_CONST double INVALID_DOUBLE_VALUE
static std::pair< int, int > getLaneChangeState(const std::string &vehicleID, int direction)
TRACI_CONST int VAR_MINGAP
TRACI_CONST int POSITION_3D
bool readTypeCheckingUnsignedByte(tcpip::Storage &inputStorage, int &into)
Reads the value type and an unsigned byte, verifying the type.
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
TRACI_CONST int VAR_MAXSPEED
virtual void writeUnsignedByte(int)
TRACI_CONST int VAR_COLOR
bool readTypeCheckingColor(tcpip::Storage &inputStorage, libsumo::TraCIColor &into)
Reads the value type and a color, verifying the type.
static void resume(const std::string &vehicleID)
TRACI_CONST int VAR_SIGNALS
TRACI_CONST int CMD_SET_POI_VARIABLE
int bestLaneOffset
The offset of this lane from the best lane.
static void setRouteID(const std::string &vehicleID, const std::string &routeID)
bool readTypeCheckingString(tcpip::Storage &inputStorage, std::string &into)
Reads the value type and a string, verifying the type.
TRACI_CONST int VAR_WIDTH
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
The least occupied lane from best lanes.
Insert behind the last vehicle as close as possible to still allow the specified departSpeed....
Representation of a vehicle.
TRACI_CONST int CMD_CHANGETARGET
TRACI_CONST int VAR_VEHICLECLASS
TRACI_CONST int VAR_HIGHLIGHT
TRACI_CONST int VAR_PARAMETER
static void moveTo(const std::string &vehicleID, const std::string &laneID, double position)
TRACI_CONST int VAR_ACCEL
TRACI_CONST int TYPE_BYTE
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
TRACI_CONST int VAR_EDGE_TRAVELTIME
TRACI_CONST int VAR_MOVE_TO
TRACI_CONST int VAR_LEADER
TRACI_CONST int VAR_ROUTE_ID
static void deactivateGapControl(const std::string &vehicleID)
TRACI_CONST int VAR_NEIGHBORS
tcpip::Storage & getWrapperStorage()
TRACI_CONST int CMD_REROUTE_EFFORT
TRACI_CONST int CMD_GET_VEHICLE_VARIABLE
TRACI_CONST int CMD_SET_VEHICLE_VARIABLE
static std::vector< TraCIBestLanesData > getBestLanes(const std::string &vehicleID)
bool readTypeCheckingDouble(tcpip::Storage &inputStorage, double &into)
Reads the value type and a double, verifying the type.
The maximum lane speed is used (speedLimit)
bool allowsContinuation
Whether this lane allows continuing the route.
virtual void writeByte(int)
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
The least occupied lane from lanes which allow the continuation.
static double getDrivingDistance(const std::string &vehicleID, const std::string &edgeID, double position, int laneIndex=0)
TRACI_CONST int VAR_BEST_LANES
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
static bool setVariable(const int cmd, const int variable, const std::string &id, TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value for the given type.
static void changeSublane(const std::string &vehicleID, double latDist)
void initWrapper(const int domainID, const int variable, const std::string &objID)
static void setSignals(const std::string &vehicleID, int signals)
TRACI_CONST int VAR_MINGAP_LAT
virtual int readUnsignedByte()
The lane is chosen randomly.
virtual void writeInt(int)
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
double occupation
The traffic density along length.
TRACI_CONST int VAR_LATALIGNMENT
TRACI_CONST int TYPE_DOUBLE
static void rerouteParkingArea(const std::string &vehicleID, const std::string &parkingAreaID)
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa4: Get Vehicle Variable)
static void setParameter(const std::string &vehicleID, const std::string &key, const std::string &value)
virtual std::string readString()
bool readTypeCheckingByte(tcpip::Storage &inputStorage, int &into)
Reads the value type and a byte, verifying the type.
A free position is chosen.
TRACI_CONST int TYPE_INTEGER
The maximum lane speed is used (speedLimit * speedFactor)
double length
The length than can be driven from that lane without lane change.
static void setRoute(const std::string &vehicleID, const std::vector< std::string > &edgeIDs)
virtual void writeStorage(tcpip::Storage &store)
virtual void writeStringList(const std::vector< std::string > &s)
TRACI_CONST int RTYPE_ERR
TRACI_CONST int CMD_CHANGESUBLANE
static std::string getParameter(const std::string &vehicleID, const std::string &key)
static void updateBestLanes(const std::string &vehicleID)
std::string toHex(const T i, std::streamsize numDigits=0)
TRACI_CONST int CMD_CHANGELANE
std::string laneID
The id of the lane.
The departure is person triggered.
TRACI_CONST int POSITION_ROADMAP
TRACI_CONST int RESPONSE_GET_VEHICLE_VARIABLE
static void remove(const std::string &vehicleID, char reason=REMOVE_VAPORIZED)
The speed is chosen randomly.
TRACI_CONST int DISTANCE_REQUEST
The position is chosen randomly.
TRACI_CONST int VAR_SPEED_FACTOR
TRACI_CONST int VAR_NEXT_STOPS
static std::string getTypeID(const std::string &vehicleID)
bool readTypeCheckingStringList(tcpip::Storage &inputStorage, std::vector< std::string > &into)
Reads the value type and a string list, verifying the type.
TRACI_CONST int CMD_SLOWDOWN
TRACI_CONST int VAR_LENGTH
static void changeLane(const std::string &vehicleID, int laneIndex, double duration)
TRACI_CONST int VAR_EMERGENCY_DECEL
static void slowDown(const std::string &vehicleID, double speed, double duration)
static void changeTarget(const std::string &vehicleID, const std::string &edgeID)
TRACI_CONST int TYPE_STRINGLIST
static std::vector< TraCINextStopData > getNextStops(const std::string &vehicleID)
virtual void writeString(const std::string &s)
static void setLine(const std::string &vehicleID, const std::string &line)
static void rerouteTraveltime(const std::string &vehicleID, const bool currentTravelTimes=true)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static void rerouteEffort(const std::string &vehicleID)
TRACI_CONST int VAR_SHAPECLASS
TRACI_CONST int CMD_REROUTE_TO_PARKING
static void setSpeedMode(const std::string &vehicleID, int speedMode)
bool readTypeCheckingInt(tcpip::Storage &inputStorage, int &into)
Reads the value type and an int, verifying the type.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
TRACI_CONST int VAR_LANECHANGE_MODE
TRACI_CONST int POSITION_2D
TRACI_CONST int CMD_OPENGAP
static double getDrivingDistance2D(const std::string &vehicleID, double x, double y)
TRACI_CONST int TYPE_STRING
TRACI_CONST int VAR_EDGE_EFFORT
TRACI_CONST int VAR_NEXT_TLS
If a fixed number of random choices fails, a free position is chosen.
static void setEffort(const std::string &vehicleID, const std::string &edgeID, double effort=INVALID_DOUBLE_VALUE, double begSeconds=0, double endSeconds=std::numeric_limits< double >::max())
static double getAdaptedTraveltime(const std::string &vehicleID, double time, const std::string &edgeID)
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
TRACI_CONST int VAR_DECEL
TRACI_CONST int TYPE_UBYTE
static void setType(const std::string &vehicleID, const std::string &typeID)
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
The maximum safe speed is used.
TRACI_CONST int MOVE_TO_XY
TRACI_CONST int VAR_IMPERFECTION
TRACI_CONST int VAR_SPEED
static void setAdaptedTraveltime(const std::string &vehicleID, const std::string &edgeID, double time=INVALID_DOUBLE_VALUE, double begSeconds=0, double endSeconds=std::numeric_limits< double >::max())
virtual void writeDouble(double)
TRACI_CONST int VAR_APPARENT_DECEL
std::vector< std::string > continuationLanes
The sequence of lanes that best allows continuing the route without lane change.
static std::vector< std::pair< std::string, double > > getNeighbors(const std::string &vehicleID, const int mode)
TraCI server used to control sumo by a remote TraCI client.
TRACI_CONST int VAR_MAXSPEED_LAT
TRACI_CONST int REQUEST_DRIVINGDIST
The departure is container triggered.
TRACI_CONST int CMD_RESUME
TRACI_CONST int VAR_ACTIONSTEPLENGTH
static void setRoutingMode(const std::string &vehicleID, int routingMode)
const std::string & getID() const
Returns the id.
static std::pair< std::string, double > getLeader(const std::string &vehicleID, double dist=0.)
The least occupied lane is used.
static void setVia(const std::string &vehicleID, const std::vector< std::string > &via)
The rightmost lane the vehicle may use.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
static std::vector< TraCINextTLSData > getNextTLS(const std::string &vehicleID)
The vehicle is discarded if emission fails (not fully implemented yet)
TRACI_CONST int CMD_REROUTE_TRAVELTIME
TRACI_CONST int VAR_ROUTING_MODE
static void changeLaneRelative(const std::string &vehicleID, int indexOffset, double duration)
static void add(const std::string &vehicleID, const std::string &routeID, const std::string &typeID="DEFAULT_VEHTYPE", const std::string &depart="now", const std::string &departLane="first", const std::string &departPos="base", const std::string &departSpeed="0", const std::string &arrivalLane="current", const std::string &arrivalPos="max", const std::string &arrivalSpeed="current", const std::string &fromTaz="", const std::string &toTaz="", const std::string &line="", int personCapacity=4, int personNumber=0)
TRACI_CONST int VAR_UPDATE_BESTLANES
static void moveToXY(const std::string &vehicleID, const std::string &edgeID, const int laneIndex, const double x, const double y, double angle=INVALID_DOUBLE_VALUE, const int keepRoute=1)
Representation of a vehicle in the micro simulation.
TRACI_CONST int TYPE_COMPOUND
TRACI_CONST int VAR_ROUTE
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.