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 =
"";
514 std::cout <<
SIMTIME <<
" processSet veh=" <<
id <<
"\n";
518 if (sumoVehicle ==
nullptr) {
524 if (v ==
nullptr && shouldExist) {
533 int compoundSize = inputStorage.
readInt();
534 if (compoundSize < 4 || compoundSize > 7) {
556 if (compoundSize >= 5) {
562 if (compoundSize >= 6) {
568 if (compoundSize >= 7) {
573 libsumo::Vehicle::setStop(
id, edgeID, pos, laneIndex, duration, stopFlags, startPos, until);
591 int compoundSize = inputStorage.
readInt();
592 if (compoundSize != 3 && compoundSize != 4) {
608 if (compoundSize == 4) {
613 libsumo::Vehicle::setStopParameter(
id, nextStopIndex, param, value, customParam != 0);
621 int compoundSize = inputStorage.
readInt();
622 if (compoundSize != 1) {
625 std::string parkingAreaID;
629 libsumo::Vehicle::rerouteParkingArea(
id, parkingAreaID);
637 if (inputStorage.
readInt() != 0) {
641 libsumo::Vehicle::resume(
id);
648 int compounds = inputStorage.
readInt();
649 if (compounds != 3 && compounds != 2) {
658 double duration = 0.;
664 if (compounds == 3) {
670 if ((laneIndex < 0 || laneIndex >= (
int)v->
getEdge()->
getLanes().size()) && relative < 1) {
675 libsumo::Vehicle::changeLane(
id, laneIndex, duration);
677 libsumo::Vehicle::changeLaneRelative(
id, laneIndex, duration);
686 libsumo::Vehicle::changeSublane(
id, latDist);
693 if (inputStorage.
readInt() != 2) {
703 double duration = 0.;
710 libsumo::Vehicle::slowDown(
id, newSpeed, duration);
718 libsumo::Vehicle::changeTarget(
id, edgeID);
725 const int nParameter = inputStorage.
readInt();
726 if (nParameter != 5 && nParameter != 6) {
729 double newTimeHeadway = 0;
733 double newSpaceHeadway = 0;
737 double duration = 0.;
741 double changeRate = 0;
750 if (newTimeHeadway == -1 && newSpaceHeadway == -1 && duration == -1 && changeRate == -1 && maxDecel == -1) {
751 libsumo::Vehicle::deactivateGapControl(
id);
753 if (newTimeHeadway <= 0) {
754 if (newTimeHeadway != -1) {
758 if (newSpaceHeadway < 0) {
764 if (changeRate <= 0) {
770 std::string refVehID =
"";
771 if (nParameter == 6) {
776 libsumo::Vehicle::openGap(
id, newTimeHeadway, newSpaceHeadway, duration, changeRate, maxDecel, refVehID);
785 libsumo::Vehicle::setType(
id, vTypeID);
793 libsumo::Vehicle::setRouteID(
id, rid);
797 std::vector<std::string> edgeIDs;
801 libsumo::Vehicle::setRoute(
id, edgeIDs);
808 int parameterCount = inputStorage.
readInt();
811 double endTime = std::numeric_limits<double>::max();
813 if (parameterCount == 4) {
830 }
else if (parameterCount == 2) {
839 }
else if (parameterCount == 1) {
847 libsumo::Vehicle::setAdaptedTraveltime(
id, edgeID, value, begTime, endTime);
854 int parameterCount = inputStorage.
readInt();
857 double endTime = std::numeric_limits<double>::max();
859 if (parameterCount == 4) {
876 }
else if (parameterCount == 2) {
884 }
else if (parameterCount == 1) {
893 libsumo::Vehicle::setEffort(
id, edgeID, value, begTime, endTime);
900 if (inputStorage.
readInt() != 0) {
903 libsumo::Vehicle::rerouteTraveltime(
id,
false);
910 if (inputStorage.
readInt() != 0) {
913 libsumo::Vehicle::rerouteEffort(
id);
921 libsumo::Vehicle::setSignals(
id, signals);
928 const int numArgs = inputStorage.
readInt();
929 if (numArgs < 2 || numArgs > 3) {
949 libsumo::Vehicle::moveTo(
id, laneID, position, reason);
953 double impatience = 0;
957 libsumo::Vehicle::setImpatience(
id, impatience);
965 libsumo::Vehicle::setSpeed(
id, speed);
973 int parameterCount = inputStorage.
readInt();
974 if (parameterCount == 2) {
990 libsumo::Vehicle::setAcceleration(
id, accel, duration);
994 double prevSpeed = 0;
999 int parameterCount = inputStorage.
readInt();
1000 if (parameterCount == 2) {
1007 }
else if (parameterCount == 1) {
1020 if (prevSpeed < 0) {
1023 libsumo::Vehicle::setPreviousSpeed(
id, prevSpeed, prevAcceleration);
1031 libsumo::Vehicle::setSpeedMode(
id, speedMode);
1035 int laneChangeMode = 0;
1039 libsumo::Vehicle::setLaneChangeMode(
id, laneChangeMode);
1043 int routingMode = 0;
1047 libsumo::Vehicle::setRoutingMode(
id, routingMode);
1055 libsumo::Vehicle::setColor(
id, col);
1062 if (inputStorage.
readInt() != 6) {
1065 std::string vTypeID;
1069 std::string routeID;
1079 depart =
"triggered";
1081 depart =
"containerTriggered";
1090 double departPosCode;
1094 std::string departPos =
toString(departPosCode);
1096 departPos =
"random";
1098 departPos =
"random_free";
1109 double departSpeedCode;
1113 std::string departSpeed =
toString(departSpeedCode);
1115 departSpeed =
"random";
1117 departSpeed =
"max";
1119 departSpeed =
"desired";
1121 departSpeed =
"speedLimit";
1123 departSpeed =
"last";
1125 departSpeed =
"avg";
1132 std::string departLane =
toString(departLaneCode);
1134 departLane =
"random";
1136 departLane =
"free";
1138 departLane =
"allowed";
1140 departLane =
"best";
1142 departLane =
"first";
1144 libsumo::Vehicle::add(
id, routeID, vTypeID, depart, departLane, departPos, departSpeed);
1151 if (inputStorage.
readInt() != 14) {
1154 std::string routeID;
1158 std::string vTypeID;
1166 std::string departLane;
1170 std::string departPos;
1174 std::string departSpeed;
1178 std::string arrivalLane;
1182 std::string arrivalPos;
1186 std::string arrivalSpeed;
1190 std::string fromTaz;
1210 libsumo::Vehicle::add(
id, routeID, vTypeID, depart, departLane, departPos, departSpeed, arrivalLane, arrivalPos, arrivalSpeed,
1211 fromTaz, toTaz, line, personCapacity, personNumber);
1219 libsumo::Vehicle::remove(
id, (
char)why);
1226 const int numArgs = inputStorage.
readInt();
1227 if (numArgs < 5 || numArgs > 7) {
1256 int keepRouteFlag = 1;
1262 double matchThreshold = 100;
1268 libsumo::Vehicle::moveToXY(
id, edgeID, laneNum, x, y, angle, keepRouteFlag, matchThreshold);
1276 libsumo::Vehicle::setSpeedFactor(
id, factor);
1284 libsumo::Vehicle::setLine(
id, line);
1288 std::vector<std::string> edgeIDs;
1292 libsumo::Vehicle::setVia(
id, edgeIDs);
1311 libsumo::Vehicle::setParameter(
id, name, value);
1322 const int itemNo = inputStorage.
readInt();
1344 double duration = -1;
1356 libsumo::Vehicle::highlight(
id, col, size, alphaMax, duration, type);
1360 std::vector<std::string> reservations;
1364 libsumo::Vehicle::dispatchTaxi(
id, reservations);
1372 if (fabs(value) == std::numeric_limits<double>::infinity()) {
1375 bool resetActionOffset = value >= 0.0;
1376 libsumo::Vehicle::setActionStepLength(
id, fabs(value), resetActionOffset);
1384 libsumo::Vehicle::setLateralLanePosition(
id, value);
1388 libsumo::Vehicle::updateBestLanes(
id);
1396 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
1399 libsumo::Vehicle::setMinGapLat(
id, value);
1425 std::vector<libsumo::TraCINextStopData> nextStops = libsumo::Vehicle::getStops(
id, limit);
1427 const int cnt = 1 + (int)nextStops.size() * 4;
1431 for (std::vector<libsumo::TraCINextStopData>::iterator it = nextStops.begin(); it != nextStops.end(); ++it) {
1432 int legacyStopFlags = (it->stopFlags << 1) + (it->arrival >= 0 ? 1 : 0);
1472 const std::string m1 = replace ?
"Replacing" :
"Inserting";
1473 const std::string m2 = replace ?
"replacement" :
"insertion";
1478 int compoundSize = inputStorage.
readInt();
1479 if (compoundSize != 8 && compoundSize != 9) {
1512 int nextStopIndex = 0;
1517 if (compoundSize == 9) {
1523 libsumo::Vehicle::replaceStop(
id, nextStopIndex, edgeID, pos, laneIndex, duration, stopFlags, startPos, until, teleport);
1525 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.