61 const std::string
id = inputStorage.
readString();
64 if (!libsumo::Vehicle::handleVariable(
id, variable, &server, &inputStorage)) {
70 if (inputStorage.
readInt() != 2) {
91 if (inputStorage.
readInt() != 2) {
112 std::vector<libsumo::TraCIBestLanesData> bestLanes = libsumo::Vehicle::getBestLanes(
id);
113 tempContent.
writeInt((
int)bestLanes.size());
115 for (std::vector<libsumo::TraCIBestLanesData>::const_iterator i = bestLanes.begin(); i != bestLanes.end(); ++i) {
141 std::vector<libsumo::TraCINextTLSData> nextTLS = libsumo::Vehicle::getNextTLS(
id);
143 const int cnt = 1 + (int)nextTLS.size() * 4;
147 for (std::vector<libsumo::TraCINextTLSData>::iterator it = nextTLS.begin(); it != nextTLS.end(); ++it) {
173 std::vector<libsumo::TraCIConnection> links = libsumo::Vehicle::getNextLinks(
id);
178 tempContent.
writeInt((
int)links.size());
180 for (std::vector<libsumo::TraCIConnection>::const_iterator i = links.begin(); i != links.end(); ++i) {
223 int compoundSize = inputStorage.
readInt();
224 if (compoundSize != 2 && compoundSize != 3) {
236 if (compoundSize == 3) {
249 if (inputStorage.
readInt() != 2) {
258 const std::string roadID = inputStorage.
readString();
259 const double edgePos = inputStorage.
readDouble();
293 const std::pair<int, int> state = libsumo::Vehicle::getLaneChangeState(
id, direction);
316 const std::vector<std::pair<std::string, double> >& neighVehicles = libsumo::Vehicle::getNeighbors(
id, mode);
319 for (
auto& p : neighVehicles) {
329 int parameterCount = inputStorage.
readInt();
333 double leaderMaxDecel;
334 std::string leaderID;
335 if (parameterCount == 5) {
368 int parameterCount = inputStorage.
readInt();
371 double leaderMaxDecel;
372 std::string leaderID;
373 if (parameterCount == 4) {
402 int parameterCount = inputStorage.
readInt();
405 if (parameterCount == 2) {
427 std::vector<libsumo::TraCIJunctionFoe> junctionFoes = libsumo::Vehicle::getJunctionFoes(
id, distance);
429 const int cnt = 1 + (int)junctionFoes.size() * 9;
433 for (std::vector<libsumo::TraCIJunctionFoe>::iterator it = junctionFoes.begin(); it != junctionFoes.end(); ++it) {
471 std::string warning =
"";
515 std::cout <<
SIMTIME <<
" processSet veh=" <<
id <<
"\n";
519 if (sumoVehicle ==
nullptr) {
525 if (v ==
nullptr && shouldExist) {
534 int compoundSize = inputStorage.
readInt();
535 if (compoundSize < 4 || compoundSize > 7) {
557 if (compoundSize >= 5) {
563 if (compoundSize >= 6) {
569 if (compoundSize >= 7) {
574 libsumo::Vehicle::setStop(
id, edgeID, pos, laneIndex, duration, stopFlags, startPos, until);
592 int compoundSize = inputStorage.
readInt();
593 if (compoundSize != 3 && compoundSize != 4) {
609 if (compoundSize == 4) {
614 libsumo::Vehicle::setStopParameter(
id, nextStopIndex, param, value, customParam != 0);
622 int compoundSize = inputStorage.
readInt();
623 if (compoundSize != 1) {
626 std::string parkingAreaID;
630 libsumo::Vehicle::rerouteParkingArea(
id, parkingAreaID);
638 if (inputStorage.
readInt() != 0) {
642 libsumo::Vehicle::resume(
id);
649 int compounds = inputStorage.
readInt();
650 if (compounds != 3 && compounds != 2) {
659 double duration = 0.;
665 if (compounds == 3) {
671 if ((laneIndex < 0 || laneIndex >= (
int)v->
getEdge()->
getLanes().size()) && relative < 1) {
676 libsumo::Vehicle::changeLane(
id, laneIndex, duration);
678 libsumo::Vehicle::changeLaneRelative(
id, laneIndex, duration);
687 libsumo::Vehicle::changeSublane(
id, latDist);
694 if (inputStorage.
readInt() != 2) {
704 double duration = 0.;
711 libsumo::Vehicle::slowDown(
id, newSpeed, duration);
719 libsumo::Vehicle::changeTarget(
id, edgeID);
726 const int nParameter = inputStorage.
readInt();
727 if (nParameter != 5 && nParameter != 6) {
730 double newTimeHeadway = 0;
734 double newSpaceHeadway = 0;
738 double duration = 0.;
742 double changeRate = 0;
751 if (newTimeHeadway == -1 && newSpaceHeadway == -1 && duration == -1 && changeRate == -1 && maxDecel == -1) {
752 libsumo::Vehicle::deactivateGapControl(
id);
754 if (newTimeHeadway <= 0) {
755 if (newTimeHeadway != -1) {
759 if (newSpaceHeadway < 0) {
765 if (changeRate <= 0) {
771 std::string refVehID =
"";
772 if (nParameter == 6) {
777 libsumo::Vehicle::openGap(
id, newTimeHeadway, newSpaceHeadway, duration, changeRate, maxDecel, refVehID);
786 libsumo::Vehicle::setType(
id, vTypeID);
794 libsumo::Vehicle::setRouteID(
id, rid);
798 std::vector<std::string> edgeIDs;
802 libsumo::Vehicle::setRoute(
id, edgeIDs);
809 int parameterCount = inputStorage.
readInt();
812 double endTime = std::numeric_limits<double>::max();
814 if (parameterCount == 4) {
831 }
else if (parameterCount == 2) {
840 }
else if (parameterCount == 1) {
848 libsumo::Vehicle::setAdaptedTraveltime(
id, edgeID, value, begTime, endTime);
855 int parameterCount = inputStorage.
readInt();
858 double endTime = std::numeric_limits<double>::max();
860 if (parameterCount == 4) {
877 }
else if (parameterCount == 2) {
885 }
else if (parameterCount == 1) {
894 libsumo::Vehicle::setEffort(
id, edgeID, value, begTime, endTime);
901 if (inputStorage.
readInt() != 0) {
904 libsumo::Vehicle::rerouteTraveltime(
id,
false);
911 if (inputStorage.
readInt() != 0) {
914 libsumo::Vehicle::rerouteEffort(
id);
922 libsumo::Vehicle::setSignals(
id, signals);
929 const int numArgs = inputStorage.
readInt();
930 if (numArgs < 2 || numArgs > 3) {
950 libsumo::Vehicle::moveTo(
id, laneID, position, reason);
954 double impatience = 0;
958 libsumo::Vehicle::setImpatience(
id, impatience);
966 libsumo::Vehicle::setSpeed(
id, speed);
974 int parameterCount = inputStorage.
readInt();
975 if (parameterCount == 2) {
991 libsumo::Vehicle::setAcceleration(
id, accel, duration);
995 double prevSpeed = 0;
1000 int parameterCount = inputStorage.
readInt();
1001 if (parameterCount == 2) {
1008 }
else if (parameterCount == 1) {
1021 if (prevSpeed < 0) {
1024 libsumo::Vehicle::setPreviousSpeed(
id, prevSpeed, prevAcceleration);
1032 libsumo::Vehicle::setSpeedMode(
id, speedMode);
1036 int laneChangeMode = 0;
1040 libsumo::Vehicle::setLaneChangeMode(
id, laneChangeMode);
1044 int routingMode = 0;
1048 libsumo::Vehicle::setRoutingMode(
id, routingMode);
1056 libsumo::Vehicle::setColor(
id, col);
1063 if (inputStorage.
readInt() != 6) {
1066 std::string vTypeID;
1070 std::string routeID;
1080 depart =
"triggered";
1082 depart =
"containerTriggered";
1091 double departPosCode;
1095 std::string departPos =
toString(departPosCode);
1097 departPos =
"random";
1099 departPos =
"random_free";
1110 double departSpeedCode;
1114 std::string departSpeed =
toString(departSpeedCode);
1116 departSpeed =
"random";
1118 departSpeed =
"max";
1120 departSpeed =
"desired";
1122 departSpeed =
"speedLimit";
1124 departSpeed =
"last";
1126 departSpeed =
"avg";
1133 std::string departLane =
toString(departLaneCode);
1135 departLane =
"random";
1137 departLane =
"free";
1139 departLane =
"allowed";
1141 departLane =
"best";
1143 departLane =
"first";
1145 libsumo::Vehicle::add(
id, routeID, vTypeID, depart, departLane, departPos, departSpeed);
1152 if (inputStorage.
readInt() != 14) {
1155 std::string routeID;
1159 std::string vTypeID;
1167 std::string departLane;
1171 std::string departPos;
1175 std::string departSpeed;
1179 std::string arrivalLane;
1183 std::string arrivalPos;
1187 std::string arrivalSpeed;
1191 std::string fromTaz;
1211 libsumo::Vehicle::add(
id, routeID, vTypeID, depart, departLane, departPos, departSpeed, arrivalLane, arrivalPos, arrivalSpeed,
1212 fromTaz, toTaz, line, personCapacity, personNumber);
1220 libsumo::Vehicle::remove(
id, (
char)why);
1227 const int numArgs = inputStorage.
readInt();
1228 if (numArgs < 5 || numArgs > 7) {
1257 int keepRouteFlag = 1;
1263 double matchThreshold = 100;
1269 libsumo::Vehicle::moveToXY(
id, edgeID, laneNum, x, y, angle, keepRouteFlag, matchThreshold);
1277 libsumo::Vehicle::setSpeedFactor(
id, factor);
1285 libsumo::Vehicle::setLine(
id, line);
1289 std::vector<std::string> edgeIDs;
1293 libsumo::Vehicle::setVia(
id, edgeIDs);
1312 libsumo::Vehicle::setParameter(
id, name, value);
1323 const int itemNo = inputStorage.
readInt();
1345 double duration = -1;
1357 libsumo::Vehicle::highlight(
id, col, size, alphaMax, duration, type);
1361 std::vector<std::string> reservations;
1365 libsumo::Vehicle::dispatchTaxi(
id, reservations);
1373 if (fabs(value) == std::numeric_limits<double>::infinity()) {
1376 bool resetActionOffset = value >= 0.0;
1377 libsumo::Vehicle::setActionStepLength(
id, fabs(value), resetActionOffset);
1385 libsumo::Vehicle::setLateralLanePosition(
id, value);
1389 libsumo::Vehicle::updateBestLanes(
id);
1397 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
1400 libsumo::Vehicle::setMinGap(
id, value);
1408 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
1411 libsumo::Vehicle::setMinGapLat(
id, value);
1437 std::vector<libsumo::TraCINextStopData> nextStops = libsumo::Vehicle::getStops(
id, limit);
1439 const int cnt = 1 + (int)nextStops.size() * 4;
1443 for (std::vector<libsumo::TraCINextStopData>::iterator it = nextStops.begin(); it != nextStops.end(); ++it) {
1444 int legacyStopFlags = (it->stopFlags << 1) + (it->arrival >= 0 ? 1 : 0);
1484 const std::string m1 = replace ?
"Replacing" :
"Inserting";
1485 const std::string m2 = replace ?
"replacement" :
"insertion";
1490 int compoundSize = inputStorage.
readInt();
1491 if (compoundSize != 8 && compoundSize != 9) {
1524 int nextStopIndex = 0;
1529 if (compoundSize == 9) {
1535 libsumo::Vehicle::replaceStop(
id, nextStopIndex, edgeID, pos, laneIndex, duration, stopFlags, startPos, until, teleport);
1537 libsumo::Vehicle::insertStop(
id, nextStopIndex, edgeID, pos, laneIndex, duration, stopFlags, startPos, until, teleport);
@ RANDOM
The lane is chosen randomly.
@ BEST_FREE
The least occupied lane from best lanes.
@ ALLOWED_FREE
The least occupied lane from lanes which allow the continuation.
@ FIRST_ALLOWED
The rightmost lane the vehicle may use.
@ FREE
The least occupied lane is used.
@ RANDOM
A random position is chosen.
@ GIVEN
The position is given.
@ FREE
A free position is chosen.
@ BASE
Back-at-zero position.
@ LAST
Insert behind the last vehicle as close as possible to still allow the specified departSpeed....
@ RANDOM_FREE
If a fixed number of random choices fails, a free position is chosen.
@ RANDOM
The speed is chosen randomly.
@ MAX
The maximum safe speed is used.
@ LIMIT
The maximum lane speed is used (speedLimit)
@ DESIRED
The maximum lane speed is used (speedLimit * speedFactor)
@ LAST
The speed of the last vehicle. Fallback to DepartSpeedDefinition::DESIRED if there is no vehicle on t...
@ AVG
The average speed on the lane. Fallback to DepartSpeedDefinition::DESIRED if there is no vehicle on t...
@ BEGIN
The departure is at simulation start.
@ NOW
The vehicle is discarded if emission fails (not fully implemented yet)
@ SPLIT
The departure is triggered by a train split.
@ CONTAINER_TRIGGERED
The departure is container triggered.
@ TRIGGERED
The departure is person triggered.
std::string toHex(const T i, std::streamsize numDigits=0)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
The base class for microscopic and mesoscopic vehicles.
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
const std::string & getID() const
Returns the name of the vehicle type.
const std::string & getID() const
Returns the id.
Representation of a vehicle.
static void writeNextStops(TraCIServer &server, const std::string &id, int limit, bool full)
helper function to write the response for VAR_NEXT_STOPS and VAR_NEXT_STOPS2
static bool insertReplaceStop(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage, const std::string &id, bool replace)
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc4: Change Vehicle State)
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa4: Get Vehicle Variable)
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.
TraCI server used to control sumo by a remote TraCI client.
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
bool readTypeCheckingString(tcpip::Storage &inputStorage, std::string &into)
Reads the value type and a string, verifying the type.
bool readTypeCheckingByte(tcpip::Storage &inputStorage, int &into)
Reads the value type and a byte, verifying the type.
tcpip::Storage & getWrapperStorage()
bool readTypeCheckingUnsignedByte(tcpip::Storage &inputStorage, int &into)
Reads the value type and an unsigned byte, verifying the type.
void initWrapper(const int domainID, const int variable, const std::string &objID)
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
bool readTypeCheckingInt(tcpip::Storage &inputStorage, int &into)
Reads the value type and an int, verifying the type.
bool readTypeCheckingStringList(tcpip::Storage &inputStorage, std::vector< std::string > &into)
Reads the value type and a string list, verifying the type.
bool readTypeCheckingDouble(tcpip::Storage &inputStorage, double &into)
Reads the value type and a double, verifying the type.
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
bool readTypeCheckingColor(tcpip::Storage &inputStorage, libsumo::TraCIColor &into)
Reads the value type and a color, verifying the type.
An error which allows to continue.
virtual std::string readString()
virtual void writeString(const std::string &s)
virtual void writeInt(int)
virtual void writeDouble(double)
virtual int readUnsignedByte()
virtual void writeStringList(const std::vector< std::string > &s)
virtual void writeChar(unsigned char)
virtual void writeUnsignedByte(int)
virtual void writeByte(int)
virtual void writeStorage(tcpip::Storage &store)
virtual double readDouble()
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int POSITION_3D
TRACI_CONST int POSITION_ROADMAP
TRACI_CONST int VAR_LANECHANGE_MODE
TRACI_CONST int MOVE_AUTOMATIC
TRACI_CONST int VAR_VEHICLECLASS
TRACI_CONST int VAR_IMPATIENCE
TRACI_CONST int VAR_LATALIGNMENT
TRACI_CONST int CMD_CHANGESUBLANE
TRACI_CONST int VAR_ROUTING_MODE
TRACI_CONST int VAR_MINGAP
TRACI_CONST int CMD_TAXI_DISPATCH
TRACI_CONST int VAR_SECURE_GAP
TRACI_CONST int VAR_SHAPECLASS
TRACI_CONST int VAR_EDGE_TRAVELTIME
TRACI_CONST int CMD_GET_VEHICLE_VARIABLE
TRACI_CONST int CMD_RESUME
TRACI_CONST int VAR_ACTIONSTEPLENGTH
TRACI_CONST int VAR_SPEED_FACTOR
TRACI_CONST int MOVE_TO_XY
TRACI_CONST int VAR_FOLLOW_SPEED
TRACI_CONST int TYPE_COMPOUND
TRACI_CONST int VAR_NEXT_TLS
TRACI_CONST int VAR_EDGE_EFFORT
TRACI_CONST int VAR_ROUTE
TRACI_CONST int VAR_BEST_LANES
TRACI_CONST int VAR_HIGHLIGHT
TRACI_CONST int VAR_BOARDING_DURATION
TRACI_CONST int TYPE_UBYTE
TRACI_CONST int CMD_SET_POI_VARIABLE
TRACI_CONST int VAR_MOVE_TO
TRACI_CONST int VAR_UPDATE_BESTLANES
TRACI_CONST int VAR_COLOR
TRACI_CONST int VAR_WIDTH
TRACI_CONST int VAR_STOP_PARAMETER
TRACI_CONST int POSITION_2D
TRACI_CONST int VAR_MAXSPEED
TRACI_CONST int CMD_CHANGETARGET
TRACI_CONST int CMD_REROUTE_TO_PARKING
TRACI_CONST int RESPONSE_GET_VEHICLE_VARIABLE
TRACI_CONST int CMD_REROUTE_TRAVELTIME
TRACI_CONST int TYPE_STRINGLIST
TRACI_CONST int VAR_TAXI_FLEET
TRACI_CONST int TYPE_INTEGER
TRACI_CONST int VAR_PREV_SPEED
TRACI_CONST int VAR_SPEEDSETMODE
TRACI_CONST int CMD_REPLACE_STOP
TRACI_CONST int CMD_SET_VEHICLE_VARIABLE
TRACI_CONST int VAR_LENGTH
TRACI_CONST int VAR_MAXSPEED_LAT
TRACI_CONST int CMD_REROUTE_EFFORT
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int CMD_INSERT_STOP
TRACI_CONST int VAR_STOP_SPEED
TRACI_CONST int VAR_IMPERFECTION
TRACI_CONST int VAR_HEIGHT
TRACI_CONST int VAR_APPARENT_DECEL
TRACI_CONST int REQUEST_DRIVINGDIST
TRACI_CONST int VAR_SPEED
TRACI_CONST int VAR_DECEL
TRACI_CONST int VAR_SIGNALS
TRACI_CONST int VAR_MINGAP_LAT
TRACI_CONST int VAR_NEXT_LINKS
TRACI_CONST int VAR_NEXT_STOPS2
TRACI_CONST int CMD_SLOWDOWN
TRACI_CONST int VAR_ACCELERATION
TRACI_CONST int VAR_ROUTE_ID
TRACI_CONST int TYPE_DOUBLE
TRACI_CONST int DISTANCE_REQUEST
TRACI_CONST int TYPE_BYTE
TRACI_CONST int CMD_OPENGAP
TRACI_CONST int VAR_LANEPOSITION_LAT
TRACI_CONST int CMD_CHANGELANE
TRACI_CONST int RTYPE_ERR
TRACI_CONST int VAR_NEIGHBORS
TRACI_CONST int VAR_EMERGENCY_DECEL
TRACI_CONST int VAR_EMISSIONCLASS
TRACI_CONST int VAR_ACCEL
TRACI_CONST int TYPE_STRING
TRACI_CONST int VAR_NEXT_STOPS
double length
The length than can be driven from that lane without lane change.
double occupation
The traffic density along length.
bool allowsContinuation
Whether this lane allows continuing the route.
int bestLaneOffset
The offset of this lane from the best lane.
std::vector< std::string > continuationLanes
The sequence of lanes that best allows continuing the route without lane change.
std::string laneID
The id of the lane.