50 const std::string
id = inputStorage.
readString();
140 std::vector<libsumo::TraCICollision> collisions = libsumo::Simulation::getCollisions();
142 const int cnt = 1 + (int)collisions.size() * 4;
146 for (
const auto& c : collisions) {
182 const int compoundSize = inputStorage.
readInt();
183 if (compoundSize < 2 || compoundSize > 3) {
195 if (inputStorage.
readInt() != 3) {
203 const int parameterCount =
StoHelp::readCompound(inputStorage, -1,
"Retrieval of a route requires a compound object.");
204 if (parameterCount < 5 || parameterCount > 7) {
207 const std::string from =
StoHelp::readTypedString(inputStorage,
"Retrieval of a route requires a string as first parameter.");
208 const std::string to =
StoHelp::readTypedString(inputStorage,
"Retrieval of a route requires a string as second parameter.");
209 const std::string vtype =
StoHelp::readTypedString(inputStorage,
"Retrieval of a route requires a string as third parameter.");
210 const double depart =
StoHelp::readTypedDouble(inputStorage,
"Retrieval of a route requires a double as fourth parameter.");
211 const int routingMode =
StoHelp::readTypedInt(inputStorage,
"Retrieval of a route requires an integer as fifth parameter.");
212 double departPos = 0.;
213 if (parameterCount > 5) {
217 if (parameterCount > 6) {
218 arrivalPos =
StoHelp::readTypedDouble(inputStorage,
"Retrieval of a route requires a double as seventh parameter.");
224 StoHelp::readCompound(inputStorage, 13,
"Retrieval of an intermodal route requires thirteen parameters.");
225 const std::string from =
StoHelp::readTypedString(inputStorage,
"Retrieval of a route requires a string as first parameter.");
226 const std::string to =
StoHelp::readTypedString(inputStorage,
"Retrieval of a route requires a string as second parameter.");
227 const std::string modes =
StoHelp::readTypedString(inputStorage,
"Retrieval of a route requires a string as third parameter.");
228 const double depart =
StoHelp::readTypedDouble(inputStorage,
"Retrieval of a route requires a double as fourth parameter.");
229 const int routingMode =
StoHelp::readTypedInt(inputStorage,
"Retrieval of a route requires an integer as fifth parameter.");
230 const double speed =
StoHelp::readTypedDouble(inputStorage,
"Retrieval of a route requires a double as sixth parameter.");
231 const double walkFactor =
StoHelp::readTypedDouble(inputStorage,
"Retrieval of a route requires a double as seventh parameter.");
232 const double departPos =
StoHelp::readTypedDouble(inputStorage,
"Retrieval of a route requires a double as eighth parameter.");
233 const double arrivalPos =
StoHelp::readTypedDouble(inputStorage,
"Retrieval of a route requires a double as ninth parameter.");
234 const double departPosLat =
StoHelp::readTypedDouble(inputStorage,
"Retrieval of a route requires a double as tenth parameter.");
235 const std::string ptype =
StoHelp::readTypedString(inputStorage,
"Retrieval of a route requires a string as eleventh parameter.");
236 const std::string vtype =
StoHelp::readTypedString(inputStorage,
"Retrieval of a route requires a string as twelfth parameter.");
237 const std::string destStop =
StoHelp::readTypedString(inputStorage,
"Retrieval of a route requires a string as thirteenth parameter.");
238 const std::vector<libsumo::TraCIStage>& result = libsumo::Simulation::findIntermodalRoute(from, to, modes, depart, routingMode, speed, walkFactor, departPos, arrivalPos, departPosLat, ptype, vtype, destStop);
247 if (!libsumo::Simulation::handleVariable(
id, variable, &server, &inputStorage)) {
263 std::string warning =
"";
285 libsumo::Simulation::setScale(value);
290 libsumo::Simulation::clearPending(
StoHelp::readTypedString(inputStorage,
"A string is needed for clearing pending vehicles."));
294 libsumo::Simulation::saveState(
StoHelp::readTypedString(inputStorage,
"A string is needed for saving simulation state."));
298 const double time = libsumo::Simulation::loadState(
StoHelp::readTypedString(inputStorage,
"A string is needed for loading simulation state."));
303 StoHelp::readCompound(inputStorage, 2,
"A compound object of size 2 is needed for setting a parameter.");
304 const std::string name =
StoHelp::readTypedString(inputStorage,
"The name of the parameter must be given as a string.");
305 const std::string value =
StoHelp::readTypedString(inputStorage,
"The value of the parameter must be given as a string.");
306 libsumo::Simulation::setParameter(
id, name, value);
310 libsumo::Simulation::writeMessage(
StoHelp::readTypedString(inputStorage,
"A string is needed for adding a log message."));
327 outputStorage.
writeInt((
int) ids.size());
343 outputStorage.
writeInt((
int)ids.size());
358 const int commandId) {
359 std::pair<MSLane*, double> roadPos;
367 switch (srcPosType) {
378 cartesianPos.
set(x, y);
387 const std::string roadID = inputStorage.
readString();
393 z = cartesianPos.
z();
408 if (compoundSize == 3) {
410 const std::string& vClassString = inputStorage.
readString();
418 switch (destPosType) {
422 if (roadPos.first ==
nullptr) {
428 outputStorage.
writeString(roadPos.first->getEdge().getID());
462 std::pair<const MSLane*, double> roadPos1;
463 std::pair<const MSLane*, double> roadPos2;
470 std::string roadID = inputStorage.
readString();
473 pos1 = roadPos1.first->geometryPositionAtOffset(roadPos1.second);
512 std::string roadID = inputStorage.
readString();
515 pos2 = roadPos2.first->geometryPositionAtOffset(roadPos2.second);
552 double distance = 0.0;
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
std::string toHex(const T i, std::streamsize numDigits=0)
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation.
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
VehicleState
Definition of a vehicle state.
@ ENDING_PARKING
The vehicle ends to park.
@ STARTING_STOP
The vehicles starts to stop.
@ BUILT
The vehicle was built, but has not yet departed.
@ STARTING_PARKING
The vehicles starts to park.
@ STARTING_TELEPORT
The vehicle started to teleport.
@ ENDING_STOP
The vehicle ends to stop.
@ ENDING_TELEPORT
The vehicle ended being teleported.
@ ARRIVED
The vehicle arrived at his destination (is deleted)
@ DEPARTED
The vehicle has departed (was inserted into the network)
@ COLLISION
The vehicle is involved in a collision.
@ EMERGENCYSTOP
The vehicle had to brake harder than permitted.
@ MANEUVERING
Vehicle maneuvering either entering or exiting a parking space.
TransportableState
Definition of a transportable state.
@ PERSON_DEPARTED
The transportable person has departed (was inserted into the network)
@ PERSON_ARRIVED
The transportable person arrived at his destination (is deleted)
A point in 2D or 3D with translation and scaling methods.
void set(double x, double y)
set positions x and y
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimensions
double x() const
Returns the x-position.
double z() const
Returns the z-position.
double y() const
Returns the y-position.
static bool commandPositionConversion(TraCIServer &server, tcpip::Storage &inputStorage, const int compoundSize, tcpip::Storage &outputStorage, const int commandId)
static bool commandDistanceRequest(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage, int commandId)
static void writeTransportableStateIDs(TraCIServer &server, tcpip::Storage &outputStorage, MSNet::TransportableState state)
static void writeTransportableStateNumber(TraCIServer &server, tcpip::Storage &outputStorage, MSNet::TransportableState state)
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xcb: Set Simulation Variable)
static void writeVehicleStateIDs(TraCIServer &server, tcpip::Storage &outputStorage, MSNet::VehicleState state)
static void writeVehicleStateNumber(TraCIServer &server, tcpip::Storage &outputStorage, MSNet::VehicleState state)
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xab: Get Simulation Variable)
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.
void stateLoaded(SUMOTime targetTime)
updates myTargetTime and resets vehicle state changes after loading a simulation state
tcpip::Storage & getWrapperStorage()
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.
static TraCIServer * getInstance()
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
const std::map< MSNet::VehicleState, std::vector< std::string > > & getVehicleStateChanges() const
const std::map< MSNet::TransportableState, std::vector< std::string > > & getTransportableStateChanges() const
static double getDrivingDistance(std::pair< const MSLane *, double > &roadPos1, std::pair< const MSLane *, double > &roadPos2)
static std::pair< MSLane *, double > convertCartesianToRoadMap(const Position &pos, const SUMOVehicleClass vClass)
static const MSLane * getLaneChecking(const std::string &edgeID, int laneIndex, double pos)
static int readTypedUnsignedByte(tcpip::Storage &ret, const std::string &error="")
static int readCompound(tcpip::Storage &ret, int expectedSize=-1, const std::string &error="")
static void writeStage(tcpip::Storage &content, const libsumo::TraCIStage &stage)
static int readTypedInt(tcpip::Storage &ret, const std::string &error="")
static std::string readTypedString(tcpip::Storage &ret, const std::string &error="")
static double readTypedDouble(tcpip::Storage &ret, const std::string &error="")
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 double readDouble()
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int CMD_SAVE_SIMSTATE
TRACI_CONST int VAR_STOP_ENDING_VEHICLES_IDS
TRACI_CONST int POSITION_3D
TRACI_CONST int POSITION_ROADMAP
TRACI_CONST int VAR_ARRIVED_VEHICLES_NUMBER
TRACI_CONST int VAR_STOP_STARTING_VEHICLES_NUMBER
TRACI_CONST int VAR_SCALE
TRACI_CONST int VAR_DEPARTED_VEHICLES_NUMBER
TRACI_CONST int CMD_LOAD_SIMSTATE
TRACI_CONST int VAR_COLLIDING_VEHICLES_NUMBER
TRACI_CONST int VAR_COLLISIONS
TRACI_CONST int CMD_CLEAR_PENDING_VEHICLES
TRACI_CONST int VAR_PARKING_ENDING_VEHICLES_IDS
TRACI_CONST int VAR_PARKING_STARTING_VEHICLES_IDS
TRACI_CONST int TYPE_COMPOUND
TRACI_CONST int VAR_PARKING_MANEUVERING_VEHICLES_IDS
TRACI_CONST int FIND_INTERMODAL_ROUTE
TRACI_CONST int VAR_DEPARTED_PERSONS_NUMBER
TRACI_CONST int VAR_PARKING_MANEUVERING_VEHICLES_NUMBER
TRACI_CONST int POSITION_2D
TRACI_CONST int VAR_ARRIVED_PERSONS_IDS
TRACI_CONST int TYPE_POLYGON
TRACI_CONST int VAR_NET_BOUNDING_BOX
TRACI_CONST int TYPE_STRINGLIST
TRACI_CONST int CMD_SET_SIM_VARIABLE
TRACI_CONST int TYPE_INTEGER
TRACI_CONST int POSITION_LON_LAT
TRACI_CONST int VAR_EMERGENCYSTOPPING_VEHICLES_IDS
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int VAR_DEPARTED_VEHICLES_IDS
TRACI_CONST int VAR_TELEPORT_ENDING_VEHICLES_NUMBER
TRACI_CONST int CMD_GET_SIM_VARIABLE
TRACI_CONST int CMD_MESSAGE
TRACI_CONST int VAR_PARKING_ENDING_VEHICLES_NUMBER
TRACI_CONST int VAR_LOADED_VEHICLES_IDS
TRACI_CONST int REQUEST_DRIVINGDIST
TRACI_CONST int VAR_DEPARTED_PERSONS_IDS
TRACI_CONST int VAR_ARRIVED_PERSONS_NUMBER
TRACI_CONST int RESPONSE_GET_SIM_VARIABLE
TRACI_CONST int VAR_STOP_STARTING_VEHICLES_IDS
TRACI_CONST int FIND_ROUTE
TRACI_CONST int VAR_STOP_ENDING_VEHICLES_NUMBER
TRACI_CONST int POSITION_CONVERSION
TRACI_CONST int TYPE_DOUBLE
TRACI_CONST int DISTANCE_REQUEST
TRACI_CONST int VAR_LOADED_VEHICLES_NUMBER
TRACI_CONST int VAR_TELEPORT_ENDING_VEHICLES_IDS
TRACI_CONST int VAR_COLLIDING_VEHICLES_IDS
TRACI_CONST int VAR_TELEPORT_STARTING_VEHICLES_NUMBER
TRACI_CONST int VAR_TELEPORT_STARTING_VEHICLES_IDS
TRACI_CONST int RTYPE_ERR
TRACI_CONST int VAR_ARRIVED_VEHICLES_IDS
TRACI_CONST int VAR_PARKING_STARTING_VEHICLES_NUMBER
TRACI_CONST int POSITION_LON_LAT_ALT
TRACI_CONST int VAR_EMERGENCYSTOPPING_VEHICLES_NUMBER
TRACI_CONST int TYPE_STRING
std::vector< TraCIPosition > value