60 const std::string
id = inputStorage.
readString();
63 if (!libsumo::Vehicle::handleVariable(
id, variable, &server, &inputStorage)) {
69 if (inputStorage.
readInt() != 2) {
90 if (inputStorage.
readInt() != 2) {
111 std::vector<libsumo::TraCIBestLanesData> bestLanes = libsumo::Vehicle::getBestLanes(
id);
112 tempContent.
writeInt((
int)bestLanes.size());
114 for (std::vector<libsumo::TraCIBestLanesData>::const_iterator i = bestLanes.begin(); i != bestLanes.end(); ++i) {
140 std::vector<libsumo::TraCINextTLSData> nextTLS = libsumo::Vehicle::getNextTLS(
id);
142 const int cnt = 1 + (int)nextTLS.size() * 4;
146 for (std::vector<libsumo::TraCINextTLSData>::iterator it = nextTLS.begin(); it != nextTLS.end(); ++it) {
175 if (inputStorage.
readInt() != 2) {
184 const std::string roadID = inputStorage.
readString();
185 const double edgePos = inputStorage.
readDouble();
219 const std::pair<int, int> state = libsumo::Vehicle::getLaneChangeState(
id, direction);
242 const std::vector<std::pair<std::string, double> >& neighVehicles = libsumo::Vehicle::getNeighbors(
id, mode);
245 for (
auto& p : neighVehicles) {
255 int parameterCount = inputStorage.
readInt();
259 double leaderMaxDecel;
260 std::string leaderID;
261 if (parameterCount == 5) {
294 int parameterCount = inputStorage.
readInt();
297 double leaderMaxDecel;
298 std::string leaderID;
299 if (parameterCount == 4) {
328 int parameterCount = inputStorage.
readInt();
331 if (parameterCount == 2) {
364 std::string warning =
"";
402 std::cout <<
SIMTIME <<
" processSet veh=" <<
id <<
"\n";
406 if (sumoVehicle ==
nullptr) {
412 if (v ==
nullptr && shouldExist) {
421 int compoundSize = inputStorage.
readInt();
422 if (compoundSize < 4 || compoundSize > 7) {
444 if (compoundSize >= 5) {
450 if (compoundSize >= 6) {
456 if (compoundSize >= 7) {
461 libsumo::Vehicle::setStop(
id, edgeID, pos, laneIndex, duration, stopFlags, startPos, until);
468 int compoundSize = inputStorage.
readInt();
469 if (compoundSize != 8 && compoundSize != 9) {
502 int nextStopIndex = 0;
507 if (compoundSize == 9) {
512 libsumo::Vehicle::replaceStop(
id, nextStopIndex, edgeID, pos, laneIndex, duration, stopFlags, startPos, until, teleport);
520 int compoundSize = inputStorage.
readInt();
521 if (compoundSize != 1) {
524 std::string parkingAreaID;
528 libsumo::Vehicle::rerouteParkingArea(
id, parkingAreaID);
536 if (inputStorage.
readInt() != 0) {
540 libsumo::Vehicle::resume(
id);
547 int compounds = inputStorage.
readInt();
548 if (compounds != 3 && compounds != 2) {
557 double duration = 0.;
563 if (compounds == 3) {
569 if ((laneIndex < 0 || laneIndex >= (
int)v->
getEdge()->
getLanes().size()) && relative < 1) {
574 libsumo::Vehicle::changeLane(
id, laneIndex, duration);
576 libsumo::Vehicle::changeLaneRelative(
id, laneIndex, duration);
585 libsumo::Vehicle::changeSublane(
id, latDist);
592 if (inputStorage.
readInt() != 2) {
602 double duration = 0.;
609 libsumo::Vehicle::slowDown(
id, newSpeed, duration);
617 libsumo::Vehicle::changeTarget(
id, edgeID);
624 const int nParameter = inputStorage.
readInt();
625 if (nParameter != 5 && nParameter != 6) {
628 double newTimeHeadway = 0;
632 double newSpaceHeadway = 0;
636 double duration = 0.;
640 double changeRate = 0;
649 if (newTimeHeadway == -1 && newSpaceHeadway == -1 && duration == -1 && changeRate == -1 && maxDecel == -1) {
650 libsumo::Vehicle::deactivateGapControl(
id);
652 if (newTimeHeadway <= 0) {
653 if (newTimeHeadway != -1) {
657 if (newSpaceHeadway < 0) {
663 if (changeRate <= 0) {
669 std::string refVehID =
"";
670 if (nParameter == 6) {
675 libsumo::Vehicle::openGap(
id, newTimeHeadway, newSpaceHeadway, duration, changeRate, maxDecel, refVehID);
684 libsumo::Vehicle::setType(
id, vTypeID);
692 libsumo::Vehicle::setRouteID(
id, rid);
696 std::vector<std::string> edgeIDs;
700 libsumo::Vehicle::setRoute(
id, edgeIDs);
707 int parameterCount = inputStorage.
readInt();
710 double endTime = std::numeric_limits<double>::max();
712 if (parameterCount == 4) {
729 }
else if (parameterCount == 2) {
738 }
else if (parameterCount == 1) {
746 libsumo::Vehicle::setAdaptedTraveltime(
id, edgeID, value, begTime, endTime);
753 int parameterCount = inputStorage.
readInt();
756 double endTime = std::numeric_limits<double>::max();
758 if (parameterCount == 4) {
775 }
else if (parameterCount == 2) {
783 }
else if (parameterCount == 1) {
792 libsumo::Vehicle::setEffort(
id, edgeID, value, begTime, endTime);
799 if (inputStorage.
readInt() != 0) {
802 libsumo::Vehicle::rerouteTraveltime(
id);
809 if (inputStorage.
readInt() != 0) {
812 libsumo::Vehicle::rerouteEffort(
id);
820 libsumo::Vehicle::setSignals(
id, signals);
827 const int numArgs = inputStorage.
readInt();
828 if (numArgs < 2 || numArgs > 3) {
848 libsumo::Vehicle::moveTo(
id, laneID, position, reason);
856 libsumo::Vehicle::setSpeed(
id, speed);
860 double prevspeed = 0;
864 libsumo::Vehicle::setPreviousSpeed(
id, prevspeed);
872 libsumo::Vehicle::setSpeedMode(
id, speedMode);
876 int laneChangeMode = 0;
880 libsumo::Vehicle::setLaneChangeMode(
id, laneChangeMode);
888 libsumo::Vehicle::setRoutingMode(
id, routingMode);
896 libsumo::Vehicle::setColor(
id, col);
903 if (inputStorage.
readInt() != 6) {
920 depart =
"triggered";
922 depart =
"containerTriggered";
927 double departPosCode;
931 std::string departPos =
toString(departPosCode);
933 departPos =
"random";
935 departPos =
"random_free";
946 double departSpeedCode;
950 std::string departSpeed =
toString(departSpeedCode);
952 departSpeed =
"random";
956 departSpeed =
"desired";
958 departSpeed =
"speedLimit";
960 departSpeed =
"last";
969 std::string departLane =
toString(departLaneCode);
971 departLane =
"random";
975 departLane =
"allowed";
979 departLane =
"first";
981 libsumo::Vehicle::add(
id, routeID, vTypeID, depart, departLane, departPos, departSpeed);
988 if (inputStorage.
readInt() != 14) {
1003 std::string departLane;
1007 std::string departPos;
1011 std::string departSpeed;
1015 std::string arrivalLane;
1019 std::string arrivalPos;
1023 std::string arrivalSpeed;
1027 std::string fromTaz;
1047 libsumo::Vehicle::add(
id, routeID, vTypeID, depart, departLane, departPos, departSpeed, arrivalLane, arrivalPos, arrivalSpeed,
1048 fromTaz, toTaz, line, personCapacity, personNumber);
1056 libsumo::Vehicle::remove(
id, (
char)why);
1063 const int numArgs = inputStorage.
readInt();
1064 if (numArgs < 5 || numArgs > 7) {
1093 int keepRouteFlag = 1;
1099 double matchThreshold = 100;
1105 libsumo::Vehicle::moveToXY(
id, edgeID, laneNum, x, y, angle, keepRouteFlag, matchThreshold);
1113 libsumo::Vehicle::setSpeedFactor(
id, factor);
1121 libsumo::Vehicle::setLine(
id, line);
1125 std::vector<std::string> edgeIDs;
1129 libsumo::Vehicle::setVia(
id, edgeIDs);
1148 libsumo::Vehicle::setParameter(
id, name, value);
1159 const int itemNo = inputStorage.
readInt();
1181 double duration = -1;
1193 libsumo::Vehicle::highlight(
id, col, size, alphaMax, duration, type);
1197 std::vector<std::string> reservations;
1201 libsumo::Vehicle::dispatchTaxi(
id, reservations);
1209 if (fabs(value) == std::numeric_limits<double>::infinity()) {
1212 bool resetActionOffset = value >= 0.0;
1213 libsumo::Vehicle::setActionStepLength(
id, fabs(value), resetActionOffset);
1217 libsumo::Vehicle::updateBestLanes(
id);
1225 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
1228 libsumo::Vehicle::setMinGapLat(
id, value);
1253 std::vector<libsumo::TraCINextStopData> nextStops = libsumo::Vehicle::getStops(
id, limit);
1255 const int cnt = 1 + (int)nextStops.size() * 4;
1259 for (std::vector<libsumo::TraCINextStopData>::iterator it = nextStops.begin(); it != nextStops.end(); ++it) {
1260 int legacyStopFlags = (it->stopFlags << 1) + (it->arrival >= 0 ? 1 : 0);
@ 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
The position is chosen randomly.
@ 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...
@ DEPART_CONTAINER_TRIGGERED
The departure is container triggered.
@ DEPART_TRIGGERED
The departure is person triggered.
@ DEPART_NOW
The vehicle is discarded if emission fails (not fully implemented yet)
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 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 writeUnsignedByte(int)
virtual void writeByte(int)
virtual void writeStorage(tcpip::Storage &store)
virtual double readDouble()
const unsigned char flag[]
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_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 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 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 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_STOPS2
TRACI_CONST int CMD_SLOWDOWN
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 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.