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-2018 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 /****************************************************************************/
18 // APIs for getting/setting edge values via TraCI
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <utils/common/StdDefs.h>
29 #include <microsim/MSNet.h>
30 #include <microsim/MSEdgeControl.h>
32 #include <microsim/MSEdge.h>
33 #include <microsim/MSLane.h>
34 #include <microsim/MSVehicle.h>
38 #include <libsumo/Helper.h>
39 #include <libsumo/Simulation.h>
40 #include "TraCIConstants.h"
42 
43 
44 // ===========================================================================
45 // method definitions
46 // ===========================================================================
47 bool
49  tcpip::Storage& outputStorage) {
50  const int variable = inputStorage.readUnsignedByte();
51  const std::string id = inputStorage.readString();
52  server.initWrapper(RESPONSE_GET_SIM_VARIABLE, variable, id);
53  try {
54  switch (variable) {
55  case VAR_TIME:
58  break;
59  case VAR_TIME_STEP:
62  break;
65  break;
68  break;
71  break;
74  break;
77  break;
80  break;
83  break;
86  break;
89  break;
92  break;
95  break;
98  break;
101  break;
104  break;
107  break;
110  break;
113  break;
116  break;
119  break;
122  break;
125  break;
128  break;
129  case VAR_DELTA_T:
132  break;
136  break;
140  break;
141  case VAR_NET_BOUNDING_BOX: {
144  server.getWrapperStorage().writeByte(2);
145  server.getWrapperStorage().writeDouble(tb[0].x);
146  server.getWrapperStorage().writeDouble(tb[0].y);
147  server.getWrapperStorage().writeDouble(tb[1].x);
148  server.getWrapperStorage().writeDouble(tb[1].y);
149  break;
150  }
151  case POSITION_CONVERSION:
152  if (inputStorage.readUnsignedByte() != TYPE_COMPOUND) {
153  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Position conversion requires a compound object.", outputStorage);
154  }
155  if (inputStorage.readInt() != 2) {
156  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Position conversion requires a source position and a position type as parameter.", outputStorage);
157  }
158  if (!commandPositionConversion(server, inputStorage, server.getWrapperStorage(), CMD_GET_SIM_VARIABLE)) {
159  return false;
160  }
161  break;
162  case DISTANCE_REQUEST:
163  if (inputStorage.readUnsignedByte() != TYPE_COMPOUND) {
164  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of distance requires a compound object.", outputStorage);
165  }
166  if (inputStorage.readInt() != 3) {
167  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of distance requires two positions and a distance type as parameter.", outputStorage);
168  }
169  if (!commandDistanceRequest(server, inputStorage, server.getWrapperStorage(), CMD_GET_SIM_VARIABLE)) {
170  return false;
171  }
172  break;
173  case FIND_ROUTE: {
174  if (inputStorage.readUnsignedByte() != TYPE_COMPOUND) {
175  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a compound object.", outputStorage);
176  }
177  if (inputStorage.readInt() != 5) {
178  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires five parameter.", outputStorage);
179  }
180  std::string from, to, vtype;
181  double depart;
182  int routingMode;
183  if (!server.readTypeCheckingString(inputStorage, from)) {
184  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as first parameter.", outputStorage);
185  }
186  if (!server.readTypeCheckingString(inputStorage, to)) {
187  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as second parameter.", outputStorage);
188  }
189  if (!server.readTypeCheckingString(inputStorage, vtype)) {
190  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as third parameter.", outputStorage);
191  }
192  if (!server.readTypeCheckingDouble(inputStorage, depart)) {
193  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as fourth parameter.", outputStorage);
194  }
195  if (!server.readTypeCheckingInt(inputStorage, routingMode)) {
196  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires an integer as fifth parameter.", outputStorage);
197  }
198  writeStage(server.getWrapperStorage(), libsumo::Simulation::findRoute(from, to, vtype, depart, routingMode));
199  break;
200  }
201  case FIND_INTERMODAL_ROUTE: {
202  if (inputStorage.readUnsignedByte() != TYPE_COMPOUND) {
203  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of an intermodal route requires a compound object.", outputStorage);
204  }
205  if (inputStorage.readInt() != 13) {
206  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of an intermodal route requires thirteen parameters.", outputStorage);
207  }
208  std::string from, to, modes, ptype, vtype, destStop;
209  double depart, speed, walkFactor, departPos, arrivalPos, departPosLat;
210  int routingMode;
211  if (!server.readTypeCheckingString(inputStorage, from)) {
212  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as first parameter.", outputStorage);
213  }
214  if (!server.readTypeCheckingString(inputStorage, to)) {
215  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as second parameter.", outputStorage);
216  }
217  if (!server.readTypeCheckingString(inputStorage, modes)) {
218  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as third parameter.", outputStorage);
219  }
220  if (!server.readTypeCheckingDouble(inputStorage, depart)) {
221  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as fourth parameter.", outputStorage);
222  }
223  if (!server.readTypeCheckingInt(inputStorage, routingMode)) {
224  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires an integer as fifth parameter.", outputStorage);
225  }
226  if (!server.readTypeCheckingDouble(inputStorage, speed)) {
227  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as sixth parameter.", outputStorage);
228  }
229  if (!server.readTypeCheckingDouble(inputStorage, walkFactor)) {
230  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as seventh parameter.", outputStorage);
231  }
232  if (!server.readTypeCheckingDouble(inputStorage, departPos)) {
233  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as eigth parameter.", outputStorage);
234  }
235  if (!server.readTypeCheckingDouble(inputStorage, arrivalPos)) {
236  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as nineth parameter.", outputStorage);
237  }
238  if (!server.readTypeCheckingDouble(inputStorage, departPosLat)) {
239  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as tenth parameter.", outputStorage);
240  }
241  if (!server.readTypeCheckingString(inputStorage, ptype)) {
242  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as eleventh parameter.", outputStorage);
243  }
244  if (!server.readTypeCheckingString(inputStorage, vtype)) {
245  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as twelvth parameter.", outputStorage);
246  }
247  if (!server.readTypeCheckingString(inputStorage, destStop)) {
248  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as thirteenth parameter.", outputStorage);
249  }
250  const std::vector<libsumo::TraCIStage> result = libsumo::Simulation::findIntermodalRoute(from, to, modes, depart, routingMode, speed, walkFactor, departPos, arrivalPos, departPosLat, ptype, vtype, destStop);
252  server.getWrapperStorage().writeInt((int)result.size());
253  for (const libsumo::TraCIStage s : result) {
254  writeStage(server.getWrapperStorage(), s);
255  }
256  break;
257  }
258  case VAR_PARAMETER: {
259  std::string paramName = "";
260  if (!server.readTypeCheckingString(inputStorage, paramName)) {
261  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Retrieval of a parameter requires its name.", outputStorage);
262  }
265  break;
266  }
267  default:
268  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, "Get Simulation Variable: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);
269  }
270  } catch (libsumo::TraCIException& e) {
271  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, e.what(), outputStorage);
272  }
273  server.writeStatusCmd(CMD_GET_SIM_VARIABLE, RTYPE_OK, "", outputStorage);
274  server.writeResponseWithLength(outputStorage, server.getWrapperStorage());
275  return true;
276 }
277 
278 
279 bool
281  tcpip::Storage& outputStorage) {
282  std::string warning = ""; // additional description for response
283  // variable
284  int variable = inputStorage.readUnsignedByte();
285  if (variable != CMD_CLEAR_PENDING_VEHICLES
286  && variable != CMD_SAVE_SIMSTATE) {
287  return server.writeErrorStatusCmd(CMD_SET_SIM_VARIABLE, "Set Simulation Variable: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);
288  }
289  // id
290  std::string id = inputStorage.readString();
291  // process
292  try {
293  switch (variable) {
295  //clear any pending vehicle insertions
296  std::string route;
297  if (!server.readTypeCheckingString(inputStorage, route)) {
298  return server.writeErrorStatusCmd(CMD_SET_SIM_VARIABLE, "A string is needed for clearing pending vehicles.", outputStorage);
299  }
301  }
302  break;
303  case CMD_SAVE_SIMSTATE: {
304  //save current simulation state
305  std::string file;
306  if (!server.readTypeCheckingString(inputStorage, file)) {
307  return server.writeErrorStatusCmd(CMD_SET_SIM_VARIABLE, "A string is needed for saving simulation state.", outputStorage);
308  }
310  }
311  break;
312  default:
313  break;
314  }
315  } catch (libsumo::TraCIException& e) {
316  return server.writeErrorStatusCmd(CMD_GET_SIM_VARIABLE, e.what(), outputStorage);
317  }
318  server.writeStatusCmd(CMD_SET_SIM_VARIABLE, RTYPE_OK, warning, outputStorage);
319  return true;
320 }
321 
322 
323 void
325  const std::vector<std::string>& ids = server.getVehicleStateChanges().find(state)->second;
326  outputStorage.writeUnsignedByte(TYPE_INTEGER);
327  outputStorage.writeInt((int) ids.size());
328 }
329 
330 
331 void
333  const std::vector<std::string>& ids = server.getVehicleStateChanges().find(state)->second;
334  outputStorage.writeUnsignedByte(TYPE_STRINGLIST);
335  outputStorage.writeStringList(ids);
336 }
337 
338 
339 void
341  outputStorage.writeUnsignedByte(TYPE_COMPOUND);
342  outputStorage.writeInt(6);
343  outputStorage.writeUnsignedByte(TYPE_INTEGER);
344  outputStorage.writeInt(stage.type);
345  outputStorage.writeUnsignedByte(TYPE_STRING);
346  outputStorage.writeString(stage.line);
347  outputStorage.writeUnsignedByte(TYPE_STRING);
348  outputStorage.writeString(stage.destStop);
349  outputStorage.writeUnsignedByte(TYPE_STRINGLIST);
350  outputStorage.writeStringList(stage.edges);
351  outputStorage.writeUnsignedByte(TYPE_DOUBLE);
352  outputStorage.writeDouble(stage.travelTime);
353  outputStorage.writeUnsignedByte(TYPE_DOUBLE);
354  outputStorage.writeDouble(stage.cost);
355  outputStorage.writeUnsignedByte(TYPE_STRING);
356  outputStorage.writeString(stage.intended);
357  outputStorage.writeUnsignedByte(TYPE_DOUBLE);
358  outputStorage.writeDouble(stage.depart);
359 }
360 
361 
362 bool
364  tcpip::Storage& outputStorage, int commandId) {
365  std::pair<MSLane*, double> roadPos;
366  Position cartesianPos;
367  Position geoPos;
368  double z = 0;
369 
370  // actual position type that will be converted
371  int srcPosType = inputStorage.readUnsignedByte();
372 
373  switch (srcPosType) {
374  case POSITION_2D:
375  case POSITION_3D:
376  case POSITION_LON_LAT:
377  case POSITION_LON_LAT_ALT: {
378  double x = inputStorage.readDouble();
379  double y = inputStorage.readDouble();
380  if (srcPosType != POSITION_2D && srcPosType != POSITION_LON_LAT) {
381  z = inputStorage.readDouble();
382  }
383  geoPos.set(x, y);
384  cartesianPos.set(x, y);
385  if (srcPosType == POSITION_LON_LAT || srcPosType == POSITION_LON_LAT_ALT) {
387  } else {
389  }
390  }
391  break;
392  case POSITION_ROADMAP: {
393  std::string roadID = inputStorage.readString();
394  double pos = inputStorage.readDouble();
395  int laneIdx = inputStorage.readUnsignedByte();
396  try {
397  // convert edge,offset,laneIdx to cartesian position
398  cartesianPos = geoPos = libsumo::Helper::getLaneChecking(roadID, laneIdx, pos)->getShape().positionAtOffset(pos);
399  z = cartesianPos.z();
401  } catch (libsumo::TraCIException& e) {
402  server.writeStatusCmd(commandId, RTYPE_ERR, e.what());
403  return false;
404  }
405  }
406  break;
407  default:
408  server.writeStatusCmd(commandId, RTYPE_ERR, "Source position type not supported");
409  return false;
410  }
411 
412  int destPosType = 0;
413  if (!server.readTypeCheckingUnsignedByte(inputStorage, destPosType)) {
414  server.writeStatusCmd(commandId, RTYPE_ERR, "Destination position type must be of type ubyte.");
415  return false;
416  }
417 
418  switch (destPosType) {
419  case POSITION_ROADMAP: {
420  // convert cartesion position to edge,offset,lane_index
421  roadPos = libsumo::Helper::convertCartesianToRoadMap(cartesianPos);
422  // write result that is added to response msg
423  outputStorage.writeUnsignedByte(POSITION_ROADMAP);
424  outputStorage.writeString(roadPos.first->getEdge().getID());
425  outputStorage.writeDouble(roadPos.second);
426  const std::vector<MSLane*> lanes = roadPos.first->getEdge().getLanes();
427  outputStorage.writeUnsignedByte((int)distance(lanes.begin(), find(lanes.begin(), lanes.end(), roadPos.first)));
428  }
429  break;
430  case POSITION_2D:
431  case POSITION_3D:
432  case POSITION_LON_LAT:
434  outputStorage.writeUnsignedByte(destPosType);
435  if (destPosType == POSITION_LON_LAT || destPosType == POSITION_LON_LAT_ALT) {
436  outputStorage.writeDouble(geoPos.x());
437  outputStorage.writeDouble(geoPos.y());
438  } else {
439  outputStorage.writeDouble(cartesianPos.x());
440  outputStorage.writeDouble(cartesianPos.y());
441  }
442  if (destPosType != POSITION_2D && destPosType != POSITION_LON_LAT) {
443  outputStorage.writeDouble(z);
444  }
445  break;
446  default:
447  server.writeStatusCmd(commandId, RTYPE_ERR, "Destination position type not supported");
448  return false;
449  }
450  return true;
451 }
452 
453 /****************************************************************************/
454 
455 bool
457  tcpip::Storage& outputStorage, int commandId) {
458  Position pos1;
459  Position pos2;
460  std::pair<const MSLane*, double> roadPos1;
461  std::pair<const MSLane*, double> roadPos2;
462 
463  // read position 1
464  int posType = inputStorage.readUnsignedByte();
465  switch (posType) {
466  case POSITION_ROADMAP:
467  try {
468  std::string roadID = inputStorage.readString();
469  roadPos1.second = inputStorage.readDouble();
470  roadPos1.first = libsumo::Helper::getLaneChecking(roadID, inputStorage.readUnsignedByte(), roadPos1.second);
471  pos1 = roadPos1.first->getShape().positionAtOffset(roadPos1.second);
472  } catch (libsumo::TraCIException& e) {
473  server.writeStatusCmd(commandId, RTYPE_ERR, e.what());
474  return false;
475  }
476  break;
477  case POSITION_2D:
478  case POSITION_3D: {
479  double p1x = inputStorage.readDouble();
480  double p1y = inputStorage.readDouble();
481  pos1.set(p1x, p1y);
482  }
483  if (posType == POSITION_3D) {
484  inputStorage.readDouble();// z value is ignored
485  }
487  break;
488  default:
489  server.writeStatusCmd(commandId, RTYPE_ERR, "Unknown position format used for distance request");
490  return false;
491  }
492 
493  // read position 2
494  posType = inputStorage.readUnsignedByte();
495  switch (posType) {
496  case POSITION_ROADMAP:
497  try {
498  std::string roadID = inputStorage.readString();
499  roadPos2.second = inputStorage.readDouble();
500  roadPos2.first = libsumo::Helper::getLaneChecking(roadID, inputStorage.readUnsignedByte(), roadPos2.second);
501  pos2 = roadPos2.first->getShape().positionAtOffset(roadPos2.second);
502  } catch (libsumo::TraCIException& e) {
503  server.writeStatusCmd(commandId, RTYPE_ERR, e.what());
504  return false;
505  }
506  break;
507  case POSITION_2D:
508  case POSITION_3D: {
509  double p2x = inputStorage.readDouble();
510  double p2y = inputStorage.readDouble();
511  pos2.set(p2x, p2y);
512  }
513  if (posType == POSITION_3D) {
514  inputStorage.readDouble();// z value is ignored
515  }
517  break;
518  default:
519  server.writeStatusCmd(commandId, RTYPE_ERR, "Unknown position format used for distance request");
520  return false;
521  }
522 
523  // read distance type
524  int distType = inputStorage.readUnsignedByte();
525 
526  double distance = 0.0;
527  if (distType == REQUEST_DRIVINGDIST) {
528  // compute driving distance
529  if ((roadPos1.first == roadPos2.first) && (roadPos1.second <= roadPos2.second)) {
530  // same edge
531  distance = roadPos2.second - roadPos1.second;
532  } else {
533  ConstMSEdgeVector newRoute;
534  if (roadPos2.first->isInternal()) {
535  distance = roadPos2.second;
536  roadPos2.first = roadPos2.first->getLogicalPredecessorLane();
537  roadPos2.second = roadPos2.first->getLength();
538  }
540  &roadPos1.first->getEdge(), &roadPos2.first->getEdge(), nullptr, MSNet::getInstance()->getCurrentTimeStep(), newRoute);
541  MSRoute route("", newRoute, false, nullptr, std::vector<SUMOVehicleParameter::Stop>());
542  distance += route.getDistanceBetween(roadPos1.second, roadPos2.second, &roadPos1.first->getEdge(), &roadPos2.first->getEdge());
543  }
544  } else {
545  // compute air distance (default)
546  distance = pos1.distanceTo(pos2);
547  }
548  // write response command
549  outputStorage.writeUnsignedByte(TYPE_DOUBLE);
550  outputStorage.writeDouble(distance);
551  return true;
552 }
553 
554 
555 /****************************************************************************/
#define VAR_COLLIDING_VEHICLES_NUMBER
The vehicle has departed (was inserted into the network)
Definition: MSNet.h:498
#define CMD_CLEAR_PENDING_VEHICLES
#define VAR_TIME_STEP
int type
The type of stage (walking, driving, ...)
Definition: TraCIDefs.h:335
#define REQUEST_DRIVINGDIST
static void writeVehicleStateIDs(TraCIServer &server, tcpip::Storage &outputStorage, MSNet::VehicleState state)
static std::pair< MSLane *, double > convertCartesianToRoadMap(Position pos)
Definition: Helper.cpp:290
std::string line
The line or the id of the vehicle type.
Definition: TraCIDefs.h:339
double z() const
Returns the z-position.
Definition: Position.h:67
#define TYPE_COMPOUND
#define VAR_TIME
#define POSITION_2D
#define VAR_PARKING_STARTING_VEHICLES_IDS
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:460
static double getDeltaT()
Definition: Simulation.cpp:275
#define VAR_STOP_ENDING_VEHICLES_IDS
#define VAR_PARKING_ENDING_VEHICLES_NUMBER
static void writeStage(tcpip::Storage &outputStorage, const libsumo::TraCIStage &stage)
#define POSITION_LON_LAT_ALT
std::string destStop
The id of the destination stop.
Definition: TraCIDefs.h:341
double y() const
Returns the y-position.
Definition: Position.h:62
#define RTYPE_OK
#define POSITION_ROADMAP
#define DISTANCE_REQUEST
virtual double readDouble()
#define TYPE_POLYGON
double x() const
Returns the x-position.
Definition: Position.h:57
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E *> &into)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
#define VAR_LOADED_VEHICLES_IDS
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xab: Get Simulation Variable)
bool readTypeCheckingInt(tcpip::Storage &inputStorage, int &into)
Reads the value type and an int, verifying the type.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:165
static std::string getParameter(const std::string &objectID, const std::string &key)
Definition: Simulation.cpp:591
bool readTypeCheckingString(tcpip::Storage &inputStorage, std::string &into)
Reads the value type and a string, verifying the type.
#define TYPE_STRINGLIST
bool readTypeCheckingDouble(tcpip::Storage &inputStorage, double &into)
Reads the value type and a double, verifying the type.
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:456
#define RESPONSE_GET_SIM_VARIABLE
#define POSITION_3D
static const MSLane * getLaneChecking(const std::string &edgeID, int laneIndex, double pos)
Definition: Helper.cpp:273
#define VAR_TELEPORT_STARTING_VEHICLES_IDS
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:72
virtual void writeUnsignedByte(int)
void set(double x, double y)
set positions x and y
Definition: Position.h:87
double depart
intended depart time for public transport ride or -1
Definition: TraCIDefs.h:353
#define POSITION_LON_LAT
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
#define VAR_LOADED_VEHICLES_NUMBER
double cost
effort needed
Definition: TraCIDefs.h:347
#define VAR_STOP_STARTING_VEHICLES_NUMBER
static void writeVehicleStateNumber(TraCIServer &server, tcpip::Storage &outputStorage, MSNet::VehicleState state)
virtual void writeInt(int)
#define VAR_EMERGENCYSTOPPING_VEHICLES_IDS
#define TYPE_STRING
#define SIMTIME
Definition: SUMOTime.h:65
virtual int readUnsignedByte()
The vehicles starts to stop.
Definition: MSNet.h:512
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
#define POSITION_CONVERSION
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:418
#define CMD_SAVE_SIMSTATE
#define VAR_DEPARTED_VEHICLES_NUMBER
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xcb: Set Simulation Variable)
#define VAR_MIN_EXPECTED_VEHICLES
The vehicle arrived at his destination (is deleted)
Definition: MSNet.h:504
The vehicles starts to park.
Definition: MSNet.h:508
The vehicle is involved in a collision.
Definition: MSNet.h:516
virtual int readInt()
The vehicle had to brake harder than permitted.
Definition: MSNet.h:518
#define VAR_STOP_STARTING_VEHICLES_IDS
#define VAR_NET_BOUNDING_BOX
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
static TraCIPositionVector getNetBoundary()
Definition: Simulation.cpp:281
std::vector< std::string > edges
The sequence of edges to travel.
Definition: TraCIDefs.h:343
#define VAR_TELEPORT_STARTING_VEHICLES_NUMBER
virtual void writeByte(int)
virtual void writeStringList(const std::vector< std::string > &s)
static bool commandPositionConversion(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage, int commandId)
#define VAR_TELEPORT_ENDING_VEHICLES_IDS
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:263
#define FIND_ROUTE
The vehicle started to teleport.
Definition: MSNet.h:500
tcpip::Storage & getWrapperStorage()
#define CMD_GET_SIM_VARIABLE
virtual std::string readString()
#define VAR_DEPARTED_VEHICLES_IDS
The vehicle ends to park.
Definition: MSNet.h:510
static void saveState(const std::string &fileName)
Definition: Simulation.cpp:644
bool readTypeCheckingUnsignedByte(tcpip::Storage &inputStorage, int &into)
Reads the value type and an unsigned byte, verifying the type.
#define VAR_DELTA_T
TraCI server used to control sumo by a remote TraCI client.
Definition: TraCIServer.h:62
#define CMD_SET_SIM_VARIABLE
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:494
static bool commandDistanceRequest(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage, int commandId)
The vehicle was built, but has not yet departed.
Definition: MSNet.h:496
#define VAR_ARRIVED_VEHICLES_NUMBER
static int getBusStopWaiting(const std::string &id)
Definition: Simulation.cpp:265
virtual void writeString(const std::string &s)
#define VAR_EMERGENCYSTOPPING_VEHICLES_NUMBER
#define TYPE_DOUBLE
std::string toHex(const T i, std::streamsize numDigits=0)
Definition: ToString.h:59
std::vector< TraCIPosition > TraCIPositionVector
Definition: TraCIDefs.h:145
#define VAR_STOP_ENDING_VEHICLES_NUMBER
const std::map< MSNet::VehicleState, std::vector< std::string > > & getVehicleStateChanges() const
Definition: TraCIServer.h:146
double travelTime
duration of the stage in seconds
Definition: TraCIDefs.h:345
#define VAR_PARKING_ENDING_VEHICLES_IDS
The vehicle ends to stop.
Definition: MSNet.h:514
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
virtual void writeDouble(double)
#define VAR_TELEPORT_ENDING_VEHICLES_NUMBER
static int getMinExpectedNumber()
Definition: Simulation.cpp:295
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation. ...
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimension
Definition: Position.h:234
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
#define VAR_PARKING_STARTING_VEHICLES_NUMBER
std::string intended
id of the intended vehicle for public transport ride
Definition: TraCIDefs.h:351
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:903
void initWrapper(const int domainID, const int variable, const std::string &objID)
static void clearPending(const std::string &routeID="")
Definition: Simulation.cpp:638
#define VAR_PARAMETER
#define VAR_COLLIDING_VEHICLES_IDS
#define RTYPE_ERR
#define TYPE_INTEGER
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
#define VAR_ARRIVED_VEHICLES_IDS
static int getCurrentTime()
Definition: Simulation.cpp:121
The vehicle ended being teleported.
Definition: MSNet.h:502
#define FIND_INTERMODAL_ROUTE
#define VAR_BUS_STOP_WAITING
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:277