Eclipse SUMO - Simulation of Urban MObility
TraCIServerAPI_Simulation.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // APIs for getting/setting edge values via TraCI
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <utils/common/StdDefs.h>
28 #include <microsim/MSNet.h>
29 #include <microsim/MSEdgeControl.h>
31 #include <microsim/MSEdge.h>
32 #include <microsim/MSLane.h>
33 #include <microsim/MSVehicle.h>
37 #include <libsumo/Helper.h>
38 #include <libsumo/Simulation.h>
39 #include <libsumo/TraCIConstants.h>
41 
42 
43 // ===========================================================================
44 // method definitions
45 // ===========================================================================
46 bool
48  tcpip::Storage& outputStorage) {
49  const int variable = inputStorage.readUnsignedByte();
50  const std::string id = inputStorage.readString();
51  server.initWrapper(libsumo::RESPONSE_GET_SIM_VARIABLE, variable, id);
52  try {
53  switch (variable) {
54  case libsumo::VAR_TIME:
57  break;
61  break;
64  break;
67  break;
70  break;
73  break;
76  break;
79  break;
82  break;
85  break;
88  break;
91  break;
94  break;
97  break;
100  break;
103  break;
106  break;
109  break;
112  break;
115  break;
118  break;
121  break;
124  break;
127  break;
130  break;
133  break;
137  break;
141  break;
144  break;
148  break;
151  break;
155  server.getWrapperStorage().writeByte(2);
156  server.getWrapperStorage().writeDouble(tb[0].x);
157  server.getWrapperStorage().writeDouble(tb[0].y);
158  server.getWrapperStorage().writeDouble(tb[1].x);
159  server.getWrapperStorage().writeDouble(tb[1].y);
160  break;
161  }
163  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
164  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Position conversion requires a compound object.", outputStorage);
165  }
166  const int compoundSize = inputStorage.readInt();
167  if (compoundSize < 2 || compoundSize > 3) {
168  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Position conversion requires a source position and a position type as parameter.", outputStorage);
169  }
170  if (!commandPositionConversion(server, inputStorage, compoundSize, server.getWrapperStorage(), libsumo::CMD_GET_SIM_VARIABLE)) {
171  return false;
172  }
173  break;
174  }
176  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
177  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of distance requires a compound object.", outputStorage);
178  }
179  if (inputStorage.readInt() != 3) {
180  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of distance requires two positions and a distance type as parameter.", outputStorage);
181  }
182  if (!commandDistanceRequest(server, inputStorage, server.getWrapperStorage(), libsumo::CMD_GET_SIM_VARIABLE)) {
183  return false;
184  }
185  break;
186  case libsumo::FIND_ROUTE: {
187  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
188  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a compound object.", outputStorage);
189  }
190  if (inputStorage.readInt() != 5) {
191  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires five parameter.", outputStorage);
192  }
193  std::string from, to, vtype;
194  double depart;
195  int routingMode;
196  if (!server.readTypeCheckingString(inputStorage, from)) {
197  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as first parameter.", outputStorage);
198  }
199  if (!server.readTypeCheckingString(inputStorage, to)) {
200  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as second parameter.", outputStorage);
201  }
202  if (!server.readTypeCheckingString(inputStorage, vtype)) {
203  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as third parameter.", outputStorage);
204  }
205  if (!server.readTypeCheckingDouble(inputStorage, depart)) {
206  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as fourth parameter.", outputStorage);
207  }
208  if (!server.readTypeCheckingInt(inputStorage, routingMode)) {
209  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires an integer as fifth parameter.", outputStorage);
210  }
211  writeStage(server.getWrapperStorage(), libsumo::Simulation::findRoute(from, to, vtype, depart, routingMode));
212  break;
213  }
215  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
216  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of an intermodal route requires a compound object.", outputStorage);
217  }
218  if (inputStorage.readInt() != 13) {
219  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of an intermodal route requires thirteen parameters.", outputStorage);
220  }
221  std::string from, to, modes, ptype, vtype, destStop;
222  double depart, speed, walkFactor, departPos, arrivalPos, departPosLat;
223  int routingMode;
224  if (!server.readTypeCheckingString(inputStorage, from)) {
225  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as first parameter.", outputStorage);
226  }
227  if (!server.readTypeCheckingString(inputStorage, to)) {
228  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as second parameter.", outputStorage);
229  }
230  if (!server.readTypeCheckingString(inputStorage, modes)) {
231  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as third parameter.", outputStorage);
232  }
233  if (!server.readTypeCheckingDouble(inputStorage, depart)) {
234  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as fourth parameter.", outputStorage);
235  }
236  if (!server.readTypeCheckingInt(inputStorage, routingMode)) {
237  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires an integer as fifth parameter.", outputStorage);
238  }
239  if (!server.readTypeCheckingDouble(inputStorage, speed)) {
240  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as sixth parameter.", outputStorage);
241  }
242  if (!server.readTypeCheckingDouble(inputStorage, walkFactor)) {
243  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as seventh parameter.", outputStorage);
244  }
245  if (!server.readTypeCheckingDouble(inputStorage, departPos)) {
246  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as eigth parameter.", outputStorage);
247  }
248  if (!server.readTypeCheckingDouble(inputStorage, arrivalPos)) {
249  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as nineth parameter.", outputStorage);
250  }
251  if (!server.readTypeCheckingDouble(inputStorage, departPosLat)) {
252  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as tenth parameter.", outputStorage);
253  }
254  if (!server.readTypeCheckingString(inputStorage, ptype)) {
255  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as eleventh parameter.", outputStorage);
256  }
257  if (!server.readTypeCheckingString(inputStorage, vtype)) {
258  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as twelvth parameter.", outputStorage);
259  }
260  if (!server.readTypeCheckingString(inputStorage, destStop)) {
261  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as thirteenth parameter.", outputStorage);
262  }
263  const std::vector<libsumo::TraCIStage>& result = libsumo::Simulation::findIntermodalRoute(from, to, modes, depart, routingMode, speed, walkFactor, departPos, arrivalPos, departPosLat, ptype, vtype, destStop);
265  server.getWrapperStorage().writeInt((int)result.size());
266  for (const libsumo::TraCIStage& s : result) {
267  writeStage(server.getWrapperStorage(), s);
268  }
269  break;
270  }
271  case libsumo::VAR_PARAMETER: {
272  std::string paramName = "";
273  if (!server.readTypeCheckingString(inputStorage, paramName)) {
274  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a parameter requires its name.", outputStorage);
275  }
278  break;
279  }
280  default:
281  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Get Simulation Variable: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);
282  }
283  } catch (libsumo::TraCIException& e) {
284  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, e.what(), outputStorage);
285  }
287  server.writeResponseWithLength(outputStorage, server.getWrapperStorage());
288  return true;
289 }
290 
291 
292 bool
294  tcpip::Storage& outputStorage) {
295  std::string warning = ""; // additional description for response
296  // variable
297  int variable = inputStorage.readUnsignedByte();
299  && variable != libsumo::CMD_SAVE_SIMSTATE
300  && variable != libsumo::CMD_MESSAGE
301  ) {
302  return server.writeErrorStatusCmd(libsumo::CMD_SET_SIM_VARIABLE, "Set Simulation Variable: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);
303  }
304  // id
305  std::string id = inputStorage.readString();
306  // process
307  try {
308  switch (variable) {
310  //clear any pending vehicle insertions
311  std::string route;
312  if (!server.readTypeCheckingString(inputStorage, route)) {
313  return server.writeErrorStatusCmd(libsumo::CMD_SET_SIM_VARIABLE, "A string is needed for clearing pending vehicles.", outputStorage);
314  }
316  }
317  break;
319  //save current simulation state
320  std::string file;
321  if (!server.readTypeCheckingString(inputStorage, file)) {
322  return server.writeErrorStatusCmd(libsumo::CMD_SET_SIM_VARIABLE, "A string is needed for saving simulation state.", outputStorage);
323  }
325  }
326  break;
327  case libsumo::CMD_MESSAGE: {
328  std::string msg;
329  if (!server.readTypeCheckingString(inputStorage, msg)) {
330  return server.writeErrorStatusCmd(libsumo::CMD_SET_SIM_VARIABLE, "A string is needed for adding a log message.", outputStorage);
331  }
333  }
334  break;
335  default:
336  break;
337  }
338  } catch (libsumo::TraCIException& e) {
339  return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, e.what(), outputStorage);
340  }
341  server.writeStatusCmd(libsumo::CMD_SET_SIM_VARIABLE, libsumo::RTYPE_OK, warning, outputStorage);
342  return true;
343 }
344 
345 
346 void
348  const std::vector<std::string>& ids = server.getVehicleStateChanges().find(state)->second;
350  outputStorage.writeInt((int) ids.size());
351 }
352 
353 
354 void
356  const std::vector<std::string>& ids = server.getVehicleStateChanges().find(state)->second;
358  outputStorage.writeStringList(ids);
359 }
360 
361 
362 void
365  outputStorage.writeInt(13);
367  outputStorage.writeInt(stage.type);
369  outputStorage.writeString(stage.vType);
371  outputStorage.writeString(stage.line);
373  outputStorage.writeString(stage.destStop);
375  outputStorage.writeStringList(stage.edges);
377  outputStorage.writeDouble(stage.travelTime);
379  outputStorage.writeDouble(stage.cost);
381  outputStorage.writeDouble(stage.length);
383  outputStorage.writeString(stage.intended);
385  outputStorage.writeDouble(stage.depart);
387  outputStorage.writeDouble(stage.departPos);
389  outputStorage.writeDouble(stage.arrivalPos);
391  outputStorage.writeString(stage.description);
392 }
393 
396  auto* stage = new libsumo::TraCIStage();
397  server.readTypeCheckingInt(inputStorage, stage->type);
398  server.readTypeCheckingString(inputStorage, stage->vType);
399  server.readTypeCheckingString(inputStorage, stage->line);
400  server.readTypeCheckingString(inputStorage, stage->destStop);
401  server.readTypeCheckingStringList(inputStorage, stage->edges);
402  server.readTypeCheckingDouble(inputStorage, stage->travelTime);
403  server.readTypeCheckingDouble(inputStorage, stage->cost);
404  server.readTypeCheckingDouble(inputStorage, stage->length);
405  server.readTypeCheckingString(inputStorage, stage->intended);
406  server.readTypeCheckingDouble(inputStorage, stage->depart);
407  server.readTypeCheckingDouble(inputStorage, stage->departPos);
408  server.readTypeCheckingDouble(inputStorage, stage->arrivalPos);
409  server.readTypeCheckingString(inputStorage, stage->description);
410  return stage;
411 }
412 
413 bool
415  const int compoundSize, tcpip::Storage& outputStorage,
416  const int commandId) {
417  std::pair<MSLane*, double> roadPos;
418  Position cartesianPos;
419  Position geoPos;
420  double z = 0;
421 
422  // actual position type that will be converted
423  int srcPosType = inputStorage.readUnsignedByte();
424 
425  switch (srcPosType) {
430  const double x = inputStorage.readDouble();
431  const double y = inputStorage.readDouble();
432  if (srcPosType != libsumo::POSITION_2D && srcPosType != libsumo::POSITION_LON_LAT) {
433  z = inputStorage.readDouble();
434  }
435  geoPos.set(x, y);
436  cartesianPos.set(x, y);
437  if (srcPosType == libsumo::POSITION_LON_LAT || srcPosType == libsumo::POSITION_LON_LAT_ALT) {
439  } else {
441  }
442  }
443  break;
445  const std::string roadID = inputStorage.readString();
446  const double pos = inputStorage.readDouble();
447  const int laneIdx = inputStorage.readUnsignedByte();
448  try {
449  // convert edge,offset,laneIdx to cartesian position
450  cartesianPos = geoPos = libsumo::Helper::getLaneChecking(roadID, laneIdx, pos)->geometryPositionAtOffset(pos);
451  z = cartesianPos.z();
453  } catch (libsumo::TraCIException& e) {
454  server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, e.what());
455  return false;
456  }
457  }
458  break;
459  default:
460  server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, "Source position type not supported");
461  return false;
462  }
463 
464  int destPosType = 0;
465  if (!server.readTypeCheckingUnsignedByte(inputStorage, destPosType)) {
466  server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, "Destination position type must be of type ubyte.");
467  return false;
468  }
469 
471  if (compoundSize == 3) {
472  inputStorage.readUnsignedByte();
473  const std::string& vClassString = inputStorage.readString();
474  if (!SumoVehicleClassStrings.hasString(vClassString)) {
475  server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, "Unknown vehicle class '" + vClassString + "'.");
476  return false;
477  }
478  vClass = SumoVehicleClassStrings.get(vClassString);
479  }
480 
481  switch (destPosType) {
483  // convert cartesion position to edge,offset,lane_index
484  roadPos = libsumo::Helper::convertCartesianToRoadMap(cartesianPos, vClass);
485  if (roadPos.first == nullptr) {
486  server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, "No matching lane found.");
487  return false;
488  }
489  // write result that is added to response msg
491  outputStorage.writeString(roadPos.first->getEdge().getID());
492  outputStorage.writeDouble(roadPos.second);
493  outputStorage.writeUnsignedByte(roadPos.first->getIndex());
494  }
495  break;
500  outputStorage.writeUnsignedByte(destPosType);
501  if (destPosType == libsumo::POSITION_LON_LAT || destPosType == libsumo::POSITION_LON_LAT_ALT) {
502  outputStorage.writeDouble(geoPos.x());
503  outputStorage.writeDouble(geoPos.y());
504  } else {
505  outputStorage.writeDouble(cartesianPos.x());
506  outputStorage.writeDouble(cartesianPos.y());
507  }
508  if (destPosType != libsumo::POSITION_2D && destPosType != libsumo::POSITION_LON_LAT) {
509  outputStorage.writeDouble(z);
510  }
511  break;
512  default:
513  server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, "Destination position type not supported");
514  return false;
515  }
516  return true;
517 }
518 
519 
520 bool
522  tcpip::Storage& outputStorage, int commandId) {
523  Position pos1;
524  Position pos2;
525  std::pair<const MSLane*, double> roadPos1;
526  std::pair<const MSLane*, double> roadPos2;
527 
528  // read position 1
529  int posType = inputStorage.readUnsignedByte();
530  switch (posType) {
532  try {
533  std::string roadID = inputStorage.readString();
534  roadPos1.second = inputStorage.readDouble();
535  roadPos1.first = libsumo::Helper::getLaneChecking(roadID, inputStorage.readUnsignedByte(), roadPos1.second);
536  pos1 = roadPos1.first->geometryPositionAtOffset(roadPos1.second);
537  } catch (libsumo::TraCIException& e) {
538  server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, e.what());
539  return false;
540  }
541  break;
543  case libsumo::POSITION_3D: {
544  double p1x = inputStorage.readDouble();
545  double p1y = inputStorage.readDouble();
546  pos1.set(p1x, p1y);
547  }
548  if (posType == libsumo::POSITION_3D) {
549  inputStorage.readDouble();// z value is ignored
550  }
552  break;
553  default:
554  server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, "Unknown position format used for distance request");
555  return false;
556  }
557 
558  // read position 2
559  posType = inputStorage.readUnsignedByte();
560  switch (posType) {
562  try {
563  std::string roadID = inputStorage.readString();
564  roadPos2.second = inputStorage.readDouble();
565  roadPos2.first = libsumo::Helper::getLaneChecking(roadID, inputStorage.readUnsignedByte(), roadPos2.second);
566  pos2 = roadPos2.first->geometryPositionAtOffset(roadPos2.second);
567  } catch (libsumo::TraCIException& e) {
568  server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, e.what());
569  return false;
570  }
571  break;
573  case libsumo::POSITION_3D: {
574  double p2x = inputStorage.readDouble();
575  double p2y = inputStorage.readDouble();
576  pos2.set(p2x, p2y);
577  }
578  if (posType == libsumo::POSITION_3D) {
579  inputStorage.readDouble();// z value is ignored
580  }
582  break;
583  default:
584  server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, "Unknown position format used for distance request");
585  return false;
586  }
587 
588  // read distance type
589  int distType = inputStorage.readUnsignedByte();
590 
591  double distance = 0.0;
592  if (distType == libsumo::REQUEST_DRIVINGDIST) {
593  // compute driving distance
594  if ((roadPos1.first == roadPos2.first) && (roadPos1.second <= roadPos2.second)) {
595  // same edge
596  distance = roadPos2.second - roadPos1.second;
597  } else {
598  ConstMSEdgeVector newRoute;
599  while (roadPos2.first->isInternal() && roadPos2.first != roadPos1.first) {
600  distance += roadPos2.second;
601  roadPos2.first = roadPos2.first->getLogicalPredecessorLane();
602  roadPos2.second = roadPos2.first->getLength();
603  }
605  &roadPos1.first->getEdge(), &roadPos2.first->getEdge(), nullptr, MSNet::getInstance()->getCurrentTimeStep(), newRoute, true);
606  if (newRoute.size() == 0) {
608  } else {
609  MSRoute route("", newRoute, false, nullptr, std::vector<SUMOVehicleParameter::Stop>());
610  distance += route.getDistanceBetween(roadPos1.second, roadPos2.second, &roadPos1.first->getEdge(), &roadPos2.first->getEdge());
611  }
612  }
613  } else {
614  // compute air distance (default)
615  distance = pos1.distanceTo(pos2);
616  }
617  // write response command
619  outputStorage.writeDouble(distance);
620  return true;
621 }
622 
623 
624 /****************************************************************************/
TraCIServerAPI_Simulation::commandPositionConversion
static bool commandPositionConversion(TraCIServer &server, tcpip::Storage &inputStorage, const int compoundSize, tcpip::Storage &outputStorage, const int commandId)
Definition: TraCIServerAPI_Simulation.cpp:414
SUMOAbstractRouter::compute
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into, bool silent=false)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
libsumo::RTYPE_OK
TRACI_CONST int RTYPE_OK
Definition: TraCIConstants.h:352
SUMOVehicleClass
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Definition: SUMOVehicleClass.h:133
TraCIServerAPI_Simulation::writeVehicleStateIDs
static void writeVehicleStateIDs(TraCIServer &server, tcpip::Storage &outputStorage, MSNet::VehicleState state)
Definition: TraCIServerAPI_Simulation.cpp:355
tcpip::Storage::readDouble
virtual double readDouble()
libsumo::VAR_EMERGENCYSTOPPING_VEHICLES_IDS
TRACI_CONST int VAR_EMERGENCYSTOPPING_VEHICLES_IDS
Definition: TraCIConstants.h:930
MSNet::getRouterTT
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:968
libsumo::VAR_PARKING_STARTING_VEHICLES_IDS
TRACI_CONST int VAR_PARKING_STARTING_VEHICLES_IDS
Definition: TraCIConstants.h:906
libsumo::VAR_LOADED_VEHICLES_NUMBER
TRACI_CONST int VAR_LOADED_VEHICLES_NUMBER
Definition: TraCIConstants.h:852
libsumo::VAR_STOP_ENDING_VEHICLES_NUMBER
TRACI_CONST int VAR_STOP_ENDING_VEHICLES_NUMBER
Definition: TraCIConstants.h:897
MSNet::VEHICLE_STATE_DEPARTED
The vehicle has departed (was inserted into the network)
Definition: MSNet.h:539
libsumo::CMD_SAVE_SIMSTATE
TRACI_CONST int CMD_SAVE_SIMSTATE
Definition: TraCIConstants.h:936
MSNet.h
libsumo::INVALID_DOUBLE_VALUE
TRACI_CONST double INVALID_DOUBLE_VALUE
Definition: TraCIConstants.h:362
libsumo::POSITION_3D
TRACI_CONST int POSITION_3D
Definition: TraCIConstants.h:318
TraCIServer::readTypeCheckingUnsignedByte
bool readTypeCheckingUnsignedByte(tcpip::Storage &inputStorage, int &into)
Reads the value type and an unsigned byte, verifying the type.
Definition: TraCIServer.cpp:1479
GeoConvHelper::x2cartesian_const
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation.
Definition: GeoConvHelper.cpp:417
libsumo::VAR_TELEPORT_ENDING_VEHICLES_NUMBER
TRACI_CONST int VAR_TELEPORT_ENDING_VEHICLES_NUMBER
Definition: TraCIConstants.h:870
Position::z
double z() const
Returns the z-position.
Definition: Position.h:66
tcpip::Storage::writeUnsignedByte
virtual void writeUnsignedByte(int)
TraCIServerAPI_Simulation::processGet
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xab: Get Simulation Variable)
Definition: TraCIServerAPI_Simulation.cpp:47
libsumo::VAR_TELEPORT_STARTING_VEHICLES_NUMBER
TRACI_CONST int VAR_TELEPORT_STARTING_VEHICLES_NUMBER
Definition: TraCIConstants.h:864
libsumo::Simulation::getMinExpectedNumber
static int getMinExpectedNumber()
Definition: Simulation.cpp:311
TraCIServerAPI_Simulation.h
TraCIServer::readTypeCheckingString
bool readTypeCheckingString(tcpip::Storage &inputStorage, std::string &into)
Reads the value type and a string, verifying the type.
Definition: TraCIServer.cpp:1414
libsumo::VAR_BUS_STOP_WAITING
TRACI_CONST int VAR_BUS_STOP_WAITING
Definition: TraCIConstants.h:813
libsumo::RESPONSE_GET_SIM_VARIABLE
TRACI_CONST int RESPONSE_GET_SIM_VARIABLE
Definition: TraCIConstants.h:256
libsumo::VAR_EMERGENCYSTOPPING_VEHICLES_NUMBER
TRACI_CONST int VAR_EMERGENCYSTOPPING_VEHICLES_NUMBER
Definition: TraCIConstants.h:927
TraCIServer::writeResponseWithLength
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
Definition: TraCIServer.cpp:1366
libsumo::Simulation::getNetBoundary
static TraCIPositionVector getNetBoundary()
Definition: Simulation.cpp:297
libsumo::VAR_TIME
TRACI_CONST int VAR_TIME
Definition: TraCIConstants.h:843
GeoConvHelper.h
ConstMSEdgeVector
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:75
libsumo::CMD_SET_SIM_VARIABLE
TRACI_CONST int CMD_SET_SIM_VARIABLE
Definition: TraCIConstants.h:258
libsumo::VAR_PARAMETER
TRACI_CONST int VAR_PARAMETER
Definition: TraCIConstants.h:939
libsumo::VAR_TIME_STEP
TRACI_CONST int VAR_TIME_STEP
Definition: TraCIConstants.h:846
MSEdge.h
libsumo::TraCIStage::intended
std::string intended
id of the intended vehicle for public transport ride
Definition: TraCIDefs.h:365
MSInsertionControl.h
MSNet::VEHICLE_STATE_ARRIVED
The vehicle arrived at his destination (is deleted)
Definition: MSNet.h:545
TraCIServer::getWrapperStorage
tcpip::Storage & getWrapperStorage()
Definition: TraCIServer.cpp:174
TraCIServerAPI_Simulation::writeStage
static void writeStage(tcpip::Storage &outputStorage, const libsumo::TraCIStage &stage)
Definition: TraCIServerAPI_Simulation.cpp:363
MSRoute
Definition: MSRoute.h:66
libsumo::FIND_ROUTE
TRACI_CONST int FIND_ROUTE
Definition: TraCIConstants.h:964
libsumo::VAR_BUS_STOP_WAITING_IDS
TRACI_CONST int VAR_BUS_STOP_WAITING_IDS
Definition: TraCIConstants.h:816
libsumo::TraCIStage::arrivalPos
double arrivalPos
position on the lane when ending the stage
Definition: TraCIDefs.h:371
TraCIServer::readTypeCheckingDouble
bool readTypeCheckingDouble(tcpip::Storage &inputStorage, double &into)
Reads the value type and a double, verifying the type.
Definition: TraCIServer.cpp:1404
MSNet::VEHICLE_STATE_EMERGENCYSTOP
The vehicle had to brake harder than permitted.
Definition: MSNet.h:559
TraCIServerAPI_Simulation::readStage
static libsumo::TraCIStage * readStage(TraCIServer &server, tcpip::Storage &inputStorage)
Definition: TraCIServerAPI_Simulation.cpp:395
libsumo::Simulation::clearPending
static void clearPending(const std::string &routeID="")
Definition: Simulation.cpp:672
MSVehicle.h
SumoVehicleClassStrings
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
libsumo::Helper::getLaneChecking
static const MSLane * getLaneChecking(const std::string &edgeID, int laneIndex, double pos)
Definition: Helper.cpp:335
libsumo::CMD_CLEAR_PENDING_VEHICLES
TRACI_CONST int CMD_CLEAR_PENDING_VEHICLES
Definition: TraCIConstants.h:933
tcpip::Storage::writeByte
virtual void writeByte(int)
TraCIServer::writeStatusCmd
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
Definition: TraCIServer.cpp:968
TraCIServer::initWrapper
void initWrapper(const int domainID, const int variable, const std::string &objID)
Definition: TraCIServer.cpp:102
TraCIServerAPI_Simulation::processSet
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xcb: Set Simulation Variable)
Definition: TraCIServerAPI_Simulation.cpp:293
libsumo::VAR_STOP_STARTING_VEHICLES_NUMBER
TRACI_CONST int VAR_STOP_STARTING_VEHICLES_NUMBER
Definition: TraCIConstants.h:891
libsumo::TraCIStage::travelTime
double travelTime
duration of the stage in seconds
Definition: TraCIDefs.h:359
tcpip::Storage::readUnsignedByte
virtual int readUnsignedByte()
libsumo::Simulation::writeMessage
static void writeMessage(const std::string &msg)
Definition: Simulation.cpp:683
Simulation.h
tcpip::Storage::writeInt
virtual void writeInt(int)
SIMTIME
#define SIMTIME
Definition: SUMOTime.h:63
MSNet::VEHICLE_STATE_STARTING_PARKING
The vehicles starts to park.
Definition: MSNet.h:549
libsumo::TYPE_DOUBLE
TRACI_CONST int TYPE_DOUBLE
Definition: TraCIConstants.h:335
libsumo::TYPE_POLYGON
TRACI_CONST int TYPE_POLYGON
Definition: TraCIConstants.h:327
libsumo::Simulation::getBusStopWaitingIDList
static std::vector< std::string > getBusStopWaitingIDList(const std::string &id)
Returns the IDs of the transportables on a given bus stop.
Definition: Simulation.cpp:279
tcpip::Storage::readString
virtual std::string readString()
libsumo::VAR_NET_BOUNDING_BOX
TRACI_CONST int VAR_NET_BOUNDING_BOX
Definition: TraCIConstants.h:885
TraCIConstants.h
libsumo::TraCIStage::description
std::string description
arbitrary description string
Definition: TraCIDefs.h:373
tcpip::Storage::readInt
virtual int readInt()
libsumo::POSITION_LON_LAT
TRACI_CONST int POSITION_LON_LAT
Definition: TraCIConstants.h:312
GeoConvHelper::getFinal
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
Definition: GeoConvHelper.h:105
libsumo::TYPE_INTEGER
TRACI_CONST int TYPE_INTEGER
Definition: TraCIConstants.h:333
MSNet::VehicleState
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:535
libsumo::VAR_DEPARTED_VEHICLES_IDS
TRACI_CONST int VAR_DEPARTED_VEHICLES_IDS
Definition: TraCIConstants.h:861
Position::distanceTo
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:233
Position::set
void set(double x, double y)
set positions x and y
Definition: Position.h:86
MSNet::getCurrentTimeStep
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:283
tcpip::Storage::writeStringList
virtual void writeStringList(const std::vector< std::string > &s)
libsumo::TraCIStage::line
std::string line
The line or the id of the vehicle type.
Definition: TraCIDefs.h:353
libsumo::VAR_DELTA_T
TRACI_CONST int VAR_DELTA_T
Definition: TraCIConstants.h:882
libsumo::RTYPE_ERR
TRACI_CONST int RTYPE_ERR
Definition: TraCIConstants.h:356
libsumo::TraCIStage
Definition: TraCIDefs.h:344
libsumo::VAR_PARKING_MANEUVERING_VEHICLES_IDS
TRACI_CONST int VAR_PARKING_MANEUVERING_VEHICLES_IDS
Definition: TraCIConstants.h:912
libsumo::VAR_TELEPORT_ENDING_VEHICLES_IDS
TRACI_CONST int VAR_TELEPORT_ENDING_VEHICLES_IDS
Definition: TraCIConstants.h:873
libsumo::VAR_TELEPORT_STARTING_VEHICLES_IDS
TRACI_CONST int VAR_TELEPORT_STARTING_VEHICLES_IDS
Definition: TraCIConstants.h:867
MSNet::VEHICLE_STATE_COLLISION
The vehicle is involved in a collision.
Definition: MSNet.h:557
toHex
std::string toHex(const T i, std::streamsize numDigits=0)
Definition: ToString.h:57
libsumo::TraCIStage::length
double length
length in m
Definition: TraCIDefs.h:363
MSNet::VEHICLE_STATE_STARTING_TELEPORT
The vehicle started to teleport.
Definition: MSNet.h:541
Helper.h
GeoConvHelper::cartesian2geo
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
Definition: GeoConvHelper.cpp:293
MSNet::VEHICLE_STATE_BUILT
The vehicle was built, but has not yet departed.
Definition: MSNet.h:537
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
Position::x
double x() const
Returns the x-position.
Definition: Position.h:56
libsumo::CMD_GET_SIM_VARIABLE
TRACI_CONST int CMD_GET_SIM_VARIABLE
Definition: TraCIConstants.h:254
MSNet::VEHICLE_STATE_STARTING_STOP
The vehicles starts to stop.
Definition: MSNet.h:553
libsumo::VAR_ARRIVED_VEHICLES_NUMBER
TRACI_CONST int VAR_ARRIVED_VEHICLES_NUMBER
Definition: TraCIConstants.h:876
libsumo::Simulation::getCurrentTime
static int getCurrentTime()
Definition: Simulation.cpp:118
libsumo::POSITION_ROADMAP
TRACI_CONST int POSITION_ROADMAP
Definition: TraCIConstants.h:320
libsumo::DISTANCE_REQUEST
TRACI_CONST int DISTANCE_REQUEST
Definition: TraCIConstants.h:955
libsumo::VAR_STOP_ENDING_VEHICLES_IDS
TRACI_CONST int VAR_STOP_ENDING_VEHICLES_IDS
Definition: TraCIConstants.h:900
libsumo::Simulation::getDeltaT
static double getDeltaT()
Definition: Simulation.cpp:291
TraCIServer::readTypeCheckingStringList
bool readTypeCheckingStringList(tcpip::Storage &inputStorage, std::vector< std::string > &into)
Reads the value type and a string list, verifying the type.
Definition: TraCIServer.cpp:1424
libsumo::TraCIStage::depart
double depart
intended depart time for public transport ride or INVALID_DOUBLE_VALUE
Definition: TraCIDefs.h:367
libsumo::VAR_PARKING_STARTING_VEHICLES_NUMBER
TRACI_CONST int VAR_PARKING_STARTING_VEHICLES_NUMBER
Definition: TraCIConstants.h:903
libsumo::CMD_MESSAGE
TRACI_CONST int CMD_MESSAGE
Definition: TraCIConstants.h:840
libsumo::TraCIException
Definition: TraCIDefs.h:89
libsumo::Simulation::getBusStopIDList
static std::vector< std::string > getBusStopIDList()
Definition: Simulation.cpp:261
libsumo::VAR_COLLIDING_VEHICLES_IDS
TRACI_CONST int VAR_COLLIDING_VEHICLES_IDS
Definition: TraCIConstants.h:924
libsumo::TYPE_STRINGLIST
TRACI_CONST int TYPE_STRINGLIST
Definition: TraCIConstants.h:339
TraCIServer::getVehicleStateChanges
const std::map< MSNet::VehicleState, std::vector< std::string > > & getVehicleStateChanges() const
Definition: TraCIServer.h:135
tcpip::Storage::writeString
virtual void writeString(const std::string &s)
libsumo::Simulation::getBusStopWaiting
static int getBusStopWaiting(const std::string &id)
Definition: Simulation.cpp:270
MSEdgeControl.h
MSNet::VEHICLE_STATE_MANEUVERING
Vehicle maneuvering either entering or exiting a parking space.
Definition: MSNet.h:561
TraCIServer::readTypeCheckingInt
bool readTypeCheckingInt(tcpip::Storage &inputStorage, int &into)
Reads the value type and an int, verifying the type.
Definition: TraCIServer.cpp:1394
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
Position::y
double y() const
Returns the y-position.
Definition: Position.h:61
libsumo::FIND_INTERMODAL_ROUTE
TRACI_CONST int FIND_INTERMODAL_ROUTE
Definition: TraCIConstants.h:967
libsumo::TraCIStage::type
int type
The type of stage (walking, driving, ...)
Definition: TraCIDefs.h:349
MSStateHandler.h
libsumo::POSITION_2D
TRACI_CONST int POSITION_2D
Definition: TraCIConstants.h:314
libsumo::VAR_PARKING_MANEUVERING_VEHICLES_NUMBER
TRACI_CONST int VAR_PARKING_MANEUVERING_VEHICLES_NUMBER
Definition: TraCIConstants.h:909
libsumo::TYPE_STRING
TRACI_CONST int TYPE_STRING
Definition: TraCIConstants.h:337
libsumo::Simulation::saveState
static void saveState(const std::string &fileName)
Definition: Simulation.cpp:678
libsumo::TraCIStage::edges
std::vector< std::string > edges
The sequence of edges to travel.
Definition: TraCIDefs.h:357
libsumo::Simulation::findIntermodalRoute
static std::vector< TraCIStage > findIntermodalRoute(const std::string &fromEdge, const std::string &toEdge, const std::string &modes="", double depart=-1., const int routingMode=0, double speed=-1., double walkFactor=-1., double departPos=0, double arrivalPos=INVALID_DOUBLE_VALUE, const double departPosLat=0, const std::string &pType="", const std::string &vType="", const std::string &destStop="")
Definition: Simulation.cpp:480
libsumo::VAR_DEPARTED_VEHICLES_NUMBER
TRACI_CONST int VAR_DEPARTED_VEHICLES_NUMBER
Definition: TraCIConstants.h:858
MSNet::VEHICLE_STATE_ENDING_PARKING
The vehicle ends to park.
Definition: MSNet.h:551
libsumo::POSITION_CONVERSION
TRACI_CONST int POSITION_CONVERSION
Definition: TraCIConstants.h:952
libsumo::POSITION_LON_LAT_ALT
TRACI_CONST int POSITION_LON_LAT_ALT
Definition: TraCIConstants.h:316
MSNet::VEHICLE_STATE_ENDING_TELEPORT
The vehicle ended being teleported.
Definition: MSNet.h:543
libsumo::Simulation::getParameter
static std::string getParameter(const std::string &objectID, const std::string &key)
Definition: Simulation.cpp:613
libsumo::VAR_PARKING_ENDING_VEHICLES_IDS
TRACI_CONST int VAR_PARKING_ENDING_VEHICLES_IDS
Definition: TraCIConstants.h:918
libsumo::VAR_LOADED_VEHICLES_IDS
TRACI_CONST int VAR_LOADED_VEHICLES_IDS
Definition: TraCIConstants.h:855
config.h
TraCIServer::wrapStringList
bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)
Definition: TraCIServer.cpp:135
libsumo::VAR_STOP_STARTING_VEHICLES_IDS
TRACI_CONST int VAR_STOP_STARTING_VEHICLES_IDS
Definition: TraCIConstants.h:894
TraCIServerAPI_Simulation::commandDistanceRequest
static bool commandDistanceRequest(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage, int commandId)
Definition: TraCIServerAPI_Simulation.cpp:521
libsumo::VAR_ARRIVED_VEHICLES_IDS
TRACI_CONST int VAR_ARRIVED_VEHICLES_IDS
Definition: TraCIConstants.h:879
StdDefs.h
libsumo::VAR_COLLIDING_VEHICLES_NUMBER
TRACI_CONST int VAR_COLLIDING_VEHICLES_NUMBER
Definition: TraCIConstants.h:921
MSLane::geometryPositionAtOffset
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:504
tcpip::Storage::writeDouble
virtual void writeDouble(double)
libsumo::TraCIPositionVector
std::vector< TraCIPosition > TraCIPositionVector
Definition: TraCIDefs.h:149
libsumo::TraCIStage::departPos
double departPos
position on the lane when starting the stage
Definition: TraCIDefs.h:369
TraCIServer
TraCI server used to control sumo by a remote TraCI client.
Definition: TraCIServer.h:61
MSLane.h
libsumo::REQUEST_DRIVINGDIST
TRACI_CONST int REQUEST_DRIVINGDIST
Definition: TraCIConstants.h:375
libsumo::TraCIStage::vType
std::string vType
The vehicle type when using a private car or bike.
Definition: TraCIDefs.h:351
libsumo::VAR_BUS_STOP_ID_LIST
TRACI_CONST int VAR_BUS_STOP_ID_LIST
Definition: TraCIConstants.h:810
libsumo::TraCIStage::destStop
std::string destStop
The id of the destination stop.
Definition: TraCIDefs.h:355
SVC_IGNORING
vehicles ignoring classes
Definition: SUMOVehicleClass.h:135
MSRoute::getDistanceBetween
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true, int routePosition=0) const
Compute the distance between 2 given edges on this route, including the length of internal lanes....
Definition: MSRoute.cpp:278
MSStoppingPlace.h
MSVehicleControl.h
MSNet::VEHICLE_STATE_ENDING_STOP
The vehicle ends to stop.
Definition: MSNet.h:555
libsumo::Helper::convertCartesianToRoadMap
static std::pair< MSLane *, double > convertCartesianToRoadMap(const Position &pos, const SUMOVehicleClass vClass)
Definition: Helper.cpp:352
tcpip::Storage
Definition: storage.h:36
libsumo::VAR_MIN_EXPECTED_VEHICLES
TRACI_CONST int VAR_MIN_EXPECTED_VEHICLES
Definition: TraCIConstants.h:888
libsumo::Simulation::findRoute
static TraCIStage findRoute(const std::string &fromEdge, const std::string &toEdge, const std::string &vType="", const double depart=-1., const int routingMode=0)
Definition: Simulation.cpp:438
libsumo::TraCIStage::cost
double cost
effort needed
Definition: TraCIDefs.h:361
libsumo::VAR_PARKING_ENDING_VEHICLES_NUMBER
TRACI_CONST int VAR_PARKING_ENDING_VEHICLES_NUMBER
Definition: TraCIConstants.h:915
libsumo::TYPE_COMPOUND
TRACI_CONST int TYPE_COMPOUND
Definition: TraCIConstants.h:341
TraCIServerAPI_Simulation::writeVehicleStateNumber
static void writeVehicleStateNumber(TraCIServer &server, tcpip::Storage &outputStorage, MSNet::VehicleState state)
Definition: TraCIServerAPI_Simulation.cpp:347
TraCIServer::writeErrorStatusCmd
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
Definition: TraCIServer.cpp:982