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) {
176 int compoundSize = inputStorage.
readInt();
177 if (compoundSize != 2) {
196 if (inputStorage.
readInt() != 2) {
205 const std::string roadID = inputStorage.
readString();
206 const double edgePos = inputStorage.
readDouble();
240 const std::pair<int, int> state = libsumo::Vehicle::getLaneChangeState(
id, direction);
263 const std::vector<std::pair<std::string, double> >& neighVehicles = libsumo::Vehicle::getNeighbors(
id, mode);
266 for (
auto& p : neighVehicles) {
276 int parameterCount = inputStorage.
readInt();
280 double leaderMaxDecel;
281 std::string leaderID;
282 if (parameterCount == 5) {
315 int parameterCount = inputStorage.
readInt();
318 double leaderMaxDecel;
319 std::string leaderID;
320 if (parameterCount == 4) {
349 int parameterCount = inputStorage.
readInt();
352 if (parameterCount == 2) {
385 std::string warning =
"";
425 std::cout <<
SIMTIME <<
" processSet veh=" <<
id <<
"\n";
429 if (sumoVehicle ==
nullptr) {
435 if (v ==
nullptr && shouldExist) {
444 int compoundSize = inputStorage.
readInt();
445 if (compoundSize < 4 || compoundSize > 7) {
467 if (compoundSize >= 5) {
473 if (compoundSize >= 6) {
479 if (compoundSize >= 7) {
484 libsumo::Vehicle::setStop(
id, edgeID, pos, laneIndex, duration, stopFlags, startPos, until);
502 int compoundSize = inputStorage.
readInt();
503 if (compoundSize != 3) {
518 libsumo::Vehicle::setStopParameter(
id, nextStopIndex, param, value);
526 int compoundSize = inputStorage.
readInt();
527 if (compoundSize != 1) {
530 std::string parkingAreaID;
534 libsumo::Vehicle::rerouteParkingArea(
id, parkingAreaID);
542 if (inputStorage.
readInt() != 0) {
546 libsumo::Vehicle::resume(
id);
553 int compounds = inputStorage.
readInt();
554 if (compounds != 3 && compounds != 2) {
563 double duration = 0.;
569 if (compounds == 3) {
575 if ((laneIndex < 0 || laneIndex >= (
int)v->
getEdge()->
getLanes().size()) && relative < 1) {
580 libsumo::Vehicle::changeLane(
id, laneIndex, duration);
582 libsumo::Vehicle::changeLaneRelative(
id, laneIndex, duration);
591 libsumo::Vehicle::changeSublane(
id, latDist);
598 if (inputStorage.
readInt() != 2) {
608 double duration = 0.;
615 libsumo::Vehicle::slowDown(
id, newSpeed, duration);
623 libsumo::Vehicle::changeTarget(
id, edgeID);
630 const int nParameter = inputStorage.
readInt();
631 if (nParameter != 5 && nParameter != 6) {
634 double newTimeHeadway = 0;
638 double newSpaceHeadway = 0;
642 double duration = 0.;
646 double changeRate = 0;
655 if (newTimeHeadway == -1 && newSpaceHeadway == -1 && duration == -1 && changeRate == -1 && maxDecel == -1) {
656 libsumo::Vehicle::deactivateGapControl(
id);
658 if (newTimeHeadway <= 0) {
659 if (newTimeHeadway != -1) {
663 if (newSpaceHeadway < 0) {
669 if (changeRate <= 0) {
675 std::string refVehID =
"";
676 if (nParameter == 6) {
681 libsumo::Vehicle::openGap(
id, newTimeHeadway, newSpaceHeadway, duration, changeRate, maxDecel, refVehID);
690 libsumo::Vehicle::setType(
id, vTypeID);
698 libsumo::Vehicle::setRouteID(
id, rid);
702 std::vector<std::string> edgeIDs;
706 libsumo::Vehicle::setRoute(
id, edgeIDs);
713 int parameterCount = inputStorage.
readInt();
716 double endTime = std::numeric_limits<double>::max();
718 if (parameterCount == 4) {
735 }
else if (parameterCount == 2) {
744 }
else if (parameterCount == 1) {
752 libsumo::Vehicle::setAdaptedTraveltime(
id, edgeID, value, begTime, endTime);
759 int parameterCount = inputStorage.
readInt();
762 double endTime = std::numeric_limits<double>::max();
764 if (parameterCount == 4) {
781 }
else if (parameterCount == 2) {
789 }
else if (parameterCount == 1) {
798 libsumo::Vehicle::setEffort(
id, edgeID, value, begTime, endTime);
805 if (inputStorage.
readInt() != 0) {
808 libsumo::Vehicle::rerouteTraveltime(
id,
false);
815 if (inputStorage.
readInt() != 0) {
818 libsumo::Vehicle::rerouteEffort(
id);
826 libsumo::Vehicle::setSignals(
id, signals);
833 const int numArgs = inputStorage.
readInt();
834 if (numArgs < 2 || numArgs > 3) {
854 libsumo::Vehicle::moveTo(
id, laneID, position, reason);
862 libsumo::Vehicle::setSpeed(
id, speed);
870 int parameterCount = inputStorage.
readInt();
871 if (parameterCount == 2) {
887 libsumo::Vehicle::setAcceleration(
id, accel, duration);
891 double prevSpeed = 0;
896 int parameterCount = inputStorage.
readInt();
897 if (parameterCount == 2) {
904 }
else if (parameterCount == 1) {
920 libsumo::Vehicle::setPreviousSpeed(
id, prevSpeed, prevAcceleration);
928 libsumo::Vehicle::setSpeedMode(
id, speedMode);
932 int laneChangeMode = 0;
936 libsumo::Vehicle::setLaneChangeMode(
id, laneChangeMode);
944 libsumo::Vehicle::setRoutingMode(
id, routingMode);
952 libsumo::Vehicle::setColor(
id, col);
959 if (inputStorage.
readInt() != 6) {
976 depart =
"triggered";
978 depart =
"containerTriggered";
983 double departPosCode;
987 std::string departPos =
toString(departPosCode);
989 departPos =
"random";
991 departPos =
"random_free";
1002 double departSpeedCode;
1006 std::string departSpeed =
toString(departSpeedCode);
1008 departSpeed =
"random";
1010 departSpeed =
"max";
1012 departSpeed =
"desired";
1014 departSpeed =
"speedLimit";
1016 departSpeed =
"last";
1018 departSpeed =
"avg";
1025 std::string departLane =
toString(departLaneCode);
1027 departLane =
"random";
1029 departLane =
"free";
1031 departLane =
"allowed";
1033 departLane =
"best";
1035 departLane =
"first";
1037 libsumo::Vehicle::add(
id, routeID, vTypeID, depart, departLane, departPos, departSpeed);
1044 if (inputStorage.
readInt() != 14) {
1047 std::string routeID;
1051 std::string vTypeID;
1059 std::string departLane;
1063 std::string departPos;
1067 std::string departSpeed;
1071 std::string arrivalLane;
1075 std::string arrivalPos;
1079 std::string arrivalSpeed;
1083 std::string fromTaz;
1103 libsumo::Vehicle::add(
id, routeID, vTypeID, depart, departLane, departPos, departSpeed, arrivalLane, arrivalPos, arrivalSpeed,
1104 fromTaz, toTaz, line, personCapacity, personNumber);
1112 libsumo::Vehicle::remove(
id, (
char)why);
1119 const int numArgs = inputStorage.
readInt();
1120 if (numArgs < 5 || numArgs > 7) {
1149 int keepRouteFlag = 1;
1155 double matchThreshold = 100;
1161 libsumo::Vehicle::moveToXY(
id, edgeID, laneNum, x, y, angle, keepRouteFlag, matchThreshold);
1169 libsumo::Vehicle::setSpeedFactor(
id, factor);
1177 libsumo::Vehicle::setLine(
id, line);
1181 std::vector<std::string> edgeIDs;
1185 libsumo::Vehicle::setVia(
id, edgeIDs);
1204 libsumo::Vehicle::setParameter(
id, name, value);
1215 const int itemNo = inputStorage.
readInt();
1237 double duration = -1;
1249 libsumo::Vehicle::highlight(
id, col, size, alphaMax, duration, type);
1253 std::vector<std::string> reservations;
1257 libsumo::Vehicle::dispatchTaxi(
id, reservations);
1265 if (fabs(value) == std::numeric_limits<double>::infinity()) {
1268 bool resetActionOffset = value >= 0.0;
1269 libsumo::Vehicle::setActionStepLength(
id, fabs(value), resetActionOffset);
1273 libsumo::Vehicle::updateBestLanes(
id);
1281 if (value < 0.0 || fabs(value) == std::numeric_limits<double>::infinity()) {
1284 libsumo::Vehicle::setMinGapLat(
id, value);
1310 std::vector<libsumo::TraCINextStopData> nextStops = libsumo::Vehicle::getStops(
id, limit);
1312 const int cnt = 1 + (int)nextStops.size() * 4;
1316 for (std::vector<libsumo::TraCINextStopData>::iterator it = nextStops.begin(); it != nextStops.end(); ++it) {
1317 int legacyStopFlags = (it->stopFlags << 1) + (it->arrival >= 0 ? 1 : 0);
1357 const std::string m1 = replace ?
"Replacing" :
"Inserting";
1358 const std::string m2 = replace ?
"replacement" :
"insertion";
1363 int compoundSize = inputStorage.
readInt();
1364 if (compoundSize != 8 && compoundSize != 9) {
1397 int nextStopIndex = 0;
1402 if (compoundSize == 9) {
1408 libsumo::Vehicle::replaceStop(
id, nextStopIndex, edgeID, pos, laneIndex, duration, stopFlags, startPos, until, teleport);
1410 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
The position is set by the vehroute device.
@ 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...
@ NOW
The vehicle is discarded if emission fails (not fully implemented yet)
@ 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 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 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_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 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.