60 const std::string
id = inputStorage.
readString();
63 if (!libsumo::Vehicle::handleVariable(
id, variable, &server)) {
70 std::pair<std::string, double> leaderInfo = libsumo::Vehicle::getLeader(
id, dist);
84 std::pair<std::string, double> followerInfo = libsumo::Vehicle::getFollower(
id, dist);
97 if (inputStorage.
readInt() != 2) {
118 if (inputStorage.
readInt() != 2) {
139 std::vector<libsumo::TraCIBestLanesData> bestLanes = libsumo::Vehicle::getBestLanes(
id);
140 tempContent.
writeInt((
int)bestLanes.size());
142 for (std::vector<libsumo::TraCIBestLanesData>::const_iterator i = bestLanes.begin(); i != bestLanes.end(); ++i) {
168 std::vector<libsumo::TraCINextTLSData> nextTLS = libsumo::Vehicle::getNextTLS(
id);
170 const int cnt = 1 + (int)nextTLS.size() * 4;
174 for (std::vector<libsumo::TraCINextTLSData>::iterator it = nextTLS.begin(); it != nextTLS.end(); ++it) {
203 if (inputStorage.
readInt() != 2) {
212 const std::string roadID = inputStorage.
readString();
213 const double edgePos = inputStorage.
readDouble();
247 const std::pair<int, int> state = libsumo::Vehicle::getLaneChangeState(
id, direction);
266 std::string paramName =
"";
275 std::string paramName =
"";
292 const std::vector<std::pair<std::string, double> >& neighVehicles = libsumo::Vehicle::getNeighbors(
id, mode);
295 for (
auto& p : neighVehicles) {
305 int parameterCount = inputStorage.
readInt();
309 double leaderMaxDecel;
310 std::string leaderID;
311 if (parameterCount == 5) {
344 int parameterCount = inputStorage.
readInt();
347 double leaderMaxDecel;
348 std::string leaderID;
349 if (parameterCount == 4) {
378 int parameterCount = inputStorage.
readInt();
381 if (parameterCount == 2) {
414 std::string warning =
"";
452 std::cout <<
SIMTIME <<
" processSet veh=" <<
id <<
"\n";
456 if (sumoVehicle ==
nullptr) {
462 if (v ==
nullptr && shouldExist) {
471 int compoundSize = inputStorage.
readInt();
472 if (compoundSize < 4 || compoundSize > 7) {
494 if (compoundSize >= 5) {
500 if (compoundSize >= 6) {
506 if (compoundSize >= 7) {
511 libsumo::Vehicle::setStop(
id, edgeID, pos, laneIndex, duration, stopFlags, startPos, until);
518 int compoundSize = inputStorage.
readInt();
519 if (compoundSize != 8) {
552 int nextStopIndex = 0;
556 libsumo::Vehicle::replaceStop(
id, nextStopIndex, edgeID, pos, laneIndex, duration, stopFlags, startPos, until);
564 int compoundSize = inputStorage.
readInt();
565 if (compoundSize != 1) {
568 std::string parkingAreaID;
572 libsumo::Vehicle::rerouteParkingArea(
id, parkingAreaID);
580 if (inputStorage.
readInt() != 0) {
584 libsumo::Vehicle::resume(
id);
591 int compounds = inputStorage.
readInt();
592 if (compounds != 3 && compounds != 2) {
601 double duration = 0.;
607 if (compounds == 3) {
613 if ((laneIndex < 0 || laneIndex >= (
int)v->
getEdge()->
getLanes().size()) && relative < 1) {
618 libsumo::Vehicle::changeLane(
id, laneIndex, duration);
620 libsumo::Vehicle::changeLaneRelative(
id, laneIndex, duration);
629 libsumo::Vehicle::changeSublane(
id, latDist);
636 if (inputStorage.
readInt() != 2) {
646 double duration = 0.;
653 libsumo::Vehicle::slowDown(
id, newSpeed, duration);
661 libsumo::Vehicle::changeTarget(
id, edgeID);
668 const int nParameter = inputStorage.
readInt();
669 if (nParameter != 5 && nParameter != 6) {
672 double newTimeHeadway = 0;
676 double newSpaceHeadway = 0;
680 double duration = 0.;
684 double changeRate = 0;
693 if (newTimeHeadway == -1 && newSpaceHeadway == -1 && duration == -1 && changeRate == -1 && maxDecel == -1) {
694 libsumo::Vehicle::deactivateGapControl(
id);
696 if (newTimeHeadway <= 0) {
697 if (newTimeHeadway != -1) {
701 if (newSpaceHeadway < 0) {
707 if (changeRate <= 0) {
711 if (maxDecel != -1) {
715 std::string refVehID =
"";
716 if (nParameter == 6) {
721 libsumo::Vehicle::openGap(
id, newTimeHeadway, newSpaceHeadway, duration, changeRate, maxDecel, refVehID);
730 libsumo::Vehicle::setType(
id, vTypeID);
738 libsumo::Vehicle::setRouteID(
id, rid);
742 std::vector<std::string> edgeIDs;
746 libsumo::Vehicle::setRoute(
id, edgeIDs);
753 int parameterCount = inputStorage.
readInt();
756 double endTime = std::numeric_limits<double>::max();
758 if (parameterCount == 4) {
775 }
else if (parameterCount == 2) {
784 }
else if (parameterCount == 1) {
792 libsumo::Vehicle::setAdaptedTraveltime(
id, edgeID, value, begTime, endTime);
799 int parameterCount = inputStorage.
readInt();
802 double endTime = std::numeric_limits<double>::max();
804 if (parameterCount == 4) {
821 }
else if (parameterCount == 2) {
829 }
else if (parameterCount == 1) {
838 libsumo::Vehicle::setEffort(
id, edgeID, value, begTime, endTime);
845 if (inputStorage.
readInt() != 0) {
848 libsumo::Vehicle::rerouteTraveltime(
id);
855 if (inputStorage.
readInt() != 0) {
858 libsumo::Vehicle::rerouteEffort(
id);
866 libsumo::Vehicle::setSignals(
id, signals);
873 const int numArgs = inputStorage.
readInt();
874 if (numArgs < 2 || numArgs > 3) {
894 libsumo::Vehicle::moveTo(
id, laneID, position, reason);
902 libsumo::Vehicle::setSpeed(
id, speed);
906 double prevspeed = 0;
910 libsumo::Vehicle::setPreviousSpeed(
id, prevspeed);
918 libsumo::Vehicle::setSpeedMode(
id, speedMode);
922 int laneChangeMode = 0;
926 libsumo::Vehicle::setLaneChangeMode(
id, laneChangeMode);
934 libsumo::Vehicle::setRoutingMode(
id, routingMode);
942 libsumo::Vehicle::setColor(
id, col);
949 if (inputStorage.
readInt() != 6) {
966 depart =
"triggered";
968 depart =
"containerTriggered";
973 double departPosCode;
977 std::string departPos =
toString(departPosCode);
979 departPos =
"random";
981 departPos =
"random_free";
992 double departSpeedCode;
996 std::string departSpeed =
toString(departSpeedCode);
998 departSpeed =
"random";
1000 departSpeed =
"max";
1002 departSpeed =
"desired";
1004 departSpeed =
"speedLimit";
1011 std::string departLane =
toString(departLaneCode);
1013 departLane =
"random";
1015 departLane =
"free";
1017 departLane =
"allowed";
1019 departLane =
"best";
1021 departLane =
"first";
1023 libsumo::Vehicle::add(
id, routeID, vTypeID, depart, departLane, departPos, departSpeed);
1030 if (inputStorage.
readInt() != 14) {
1033 std::string routeID;
1037 std::string vTypeID;
1045 std::string departLane;
1049 std::string departPos;
1053 std::string departSpeed;
1057 std::string arrivalLane;
1061 std::string arrivalPos;
1065 std::string arrivalSpeed;
1069 std::string fromTaz;
1089 libsumo::Vehicle::add(
id, routeID, vTypeID, depart, departLane, departPos, departSpeed, arrivalLane, arrivalPos, arrivalSpeed,
1090 fromTaz, toTaz, line, personCapacity, personNumber);
1098 libsumo::Vehicle::remove(
id, (
char)why);
1105 const int numArgs = inputStorage.
readInt();
1106 if (numArgs != 5 && numArgs != 6) {
1135 int keepRouteFlag = 1;
1141 libsumo::Vehicle::moveToXY(
id, edgeID, laneNum, x, y, angle, keepRouteFlag);
1149 libsumo::Vehicle::setSpeedFactor(
id, factor);
1157 libsumo::Vehicle::setLine(
id, line);
1161 std::vector<std::string> edgeIDs;
1165 libsumo::Vehicle::setVia(
id, edgeIDs);
1184 libsumo::Vehicle::setParameter(
id, name, value);
1195 const int itemNo = inputStorage.
readInt();
1217 double duration = -1;
1229 libsumo::Vehicle::highlight(
id, col, size, alphaMax, duration, type);
1233 std::vector<std::string> reservations;
1237 libsumo::Vehicle::dispatchTaxi(
id, reservations);
1245 if (fabs(value) == std::numeric_limits<double>::infinity()) {
1248 bool resetActionOffset = value >= 0.0;
1249 libsumo::Vehicle::setActionStepLength(
id, fabs(value), resetActionOffset);
1253 libsumo::Vehicle::updateBestLanes(
id);
1278 std::vector<libsumo::TraCINextStopData> nextStops = libsumo::Vehicle::getStops(
id, limit);
1280 const int cnt = 1 + (int)nextStops.size() * 4;
1284 for (std::vector<libsumo::TraCINextStopData>::iterator it = nextStops.begin(); it != nextStops.end(); ++it) {
1285 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)
@ 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.
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 VAR_LEADER
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_PARAMETER_WITH_KEY
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_FOLLOWER
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.