Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
TraCIServerAPI_Simulation.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
21// APIs for getting/setting simulation values via TraCI
22/****************************************************************************/
23#include <config.h>
24
27#include <microsim/MSNet.h>
30#include <microsim/MSEdge.h>
31#include <microsim/MSLane.h>
32#include <microsim/MSVehicle.h>
36#include <libsumo/Helper.h>
37#include <libsumo/Simulation.h>
41
42
43// ===========================================================================
44// method definitions
45// ===========================================================================
46bool
48 tcpip::Storage& outputStorage) {
49 const int variable = inputStorage.readUnsignedByte();
50 const std::string id = inputStorage.readString();
52 try {
53 // unlike the other domains we cannot check here first whether libsumo::Simulation can handle it because the implementations for the state variables differ
54 switch (variable) {
57 break;
60 break;
63 break;
66 break;
69 break;
72 break;
75 break;
78 break;
81 break;
84 break;
87 break;
90 break;
93 break;
96 break;
99 break;
102 break;
105 break;
108 break;
111 break;
114 break;
117 break;
120 break;
123 break;
126 break;
129 break;
132 break;
135 break;
138 break;
140 std::vector<libsumo::TraCICollision> collisions = libsumo::Simulation::getCollisions();
142 const int cnt = 1 + (int)collisions.size() * 4;
143 server.getWrapperStorage().writeInt(cnt);
145 server.getWrapperStorage().writeInt((int)collisions.size());
146 for (const auto& c : collisions) {
148 server.getWrapperStorage().writeString(c.collider);
150 server.getWrapperStorage().writeString(c.victim);
152 server.getWrapperStorage().writeString(c.colliderType);
154 server.getWrapperStorage().writeString(c.victimType);
156 server.getWrapperStorage().writeDouble(c.colliderSpeed);
158 server.getWrapperStorage().writeDouble(c.victimSpeed);
160 server.getWrapperStorage().writeString(c.type);
162 server.getWrapperStorage().writeString(c.lane);
164 server.getWrapperStorage().writeDouble(c.pos);
165 }
166 break;
167 }
170 libsumo::TraCIPositionVector tb = libsumo::Simulation::getNetBoundary();
171 server.getWrapperStorage().writeByte(2);
172 server.getWrapperStorage().writeDouble(tb.value[0].x);
173 server.getWrapperStorage().writeDouble(tb.value[0].y);
174 server.getWrapperStorage().writeDouble(tb.value[1].x);
175 server.getWrapperStorage().writeDouble(tb.value[1].y);
176 break;
177 }
179 if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
180 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Position conversion requires a compound object.", outputStorage);
181 }
182 const int compoundSize = inputStorage.readInt();
183 if (compoundSize < 2 || compoundSize > 3) {
184 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Position conversion requires a source position and a position type as parameter.", outputStorage);
185 }
186 if (!commandPositionConversion(server, inputStorage, compoundSize, server.getWrapperStorage(), libsumo::CMD_GET_SIM_VARIABLE)) {
187 return false;
188 }
189 break;
190 }
192 if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
193 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of distance requires a compound object.", outputStorage);
194 }
195 if (inputStorage.readInt() != 3) {
196 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of distance requires two positions and a distance type as parameter.", outputStorage);
197 }
198 if (!commandDistanceRequest(server, inputStorage, server.getWrapperStorage(), libsumo::CMD_GET_SIM_VARIABLE)) {
199 return false;
200 }
201 break;
202 case libsumo::FIND_ROUTE: {
203 if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
204 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a compound object.", outputStorage);
205 }
206 if (inputStorage.readInt() != 5) {
207 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires five parameter.", outputStorage);
208 }
209 std::string from, to, vtype;
210 double depart;
211 if (!server.readTypeCheckingString(inputStorage, from)) {
212 return server.writeErrorStatusCmd(libsumo::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(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as second parameter.", outputStorage);
216 }
217 if (!server.readTypeCheckingString(inputStorage, vtype)) {
218 return server.writeErrorStatusCmd(libsumo::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(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as fourth parameter.", outputStorage);
222 }
223 const int routingMode = StoHelp::readTypedInt(inputStorage, "Retrieval of a route requires an integer as fifth parameter.");
224 libsumo::StorageHelper::writeStage(server.getWrapperStorage(), libsumo::Simulation::findRoute(from, to, vtype, depart, routingMode));
225 break;
226 }
228 if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
229 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of an intermodal route requires a compound object.", outputStorage);
230 }
231 if (inputStorage.readInt() != 13) {
232 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of an intermodal route requires thirteen parameters.", outputStorage);
233 }
234 std::string from, to, modes, ptype, vtype, destStop;
235 double depart, speed, walkFactor, departPos, arrivalPos, departPosLat;
236 if (!server.readTypeCheckingString(inputStorage, from)) {
237 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as first parameter.", outputStorage);
238 }
239 if (!server.readTypeCheckingString(inputStorage, to)) {
240 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as second parameter.", outputStorage);
241 }
242 if (!server.readTypeCheckingString(inputStorage, modes)) {
243 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as third parameter.", outputStorage);
244 }
245 if (!server.readTypeCheckingDouble(inputStorage, depart)) {
246 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as fourth parameter.", outputStorage);
247 }
248 const int routingMode = StoHelp::readTypedInt(inputStorage, "Retrieval of a route requires an integer as fifth parameter.");
249 if (!server.readTypeCheckingDouble(inputStorage, speed)) {
250 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as sixth parameter.", outputStorage);
251 }
252 if (!server.readTypeCheckingDouble(inputStorage, walkFactor)) {
253 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as seventh parameter.", outputStorage);
254 }
255 if (!server.readTypeCheckingDouble(inputStorage, departPos)) {
256 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as eigth parameter.", outputStorage);
257 }
258 if (!server.readTypeCheckingDouble(inputStorage, arrivalPos)) {
259 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as nineth parameter.", outputStorage);
260 }
261 if (!server.readTypeCheckingDouble(inputStorage, departPosLat)) {
262 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a double as tenth parameter.", outputStorage);
263 }
264 if (!server.readTypeCheckingString(inputStorage, ptype)) {
265 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as eleventh parameter.", outputStorage);
266 }
267 if (!server.readTypeCheckingString(inputStorage, vtype)) {
268 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as twelvth parameter.", outputStorage);
269 }
270 if (!server.readTypeCheckingString(inputStorage, destStop)) {
271 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Retrieval of a route requires a string as thirteenth parameter.", outputStorage);
272 }
273 const std::vector<libsumo::TraCIStage>& result = libsumo::Simulation::findIntermodalRoute(from, to, modes, depart, routingMode, speed, walkFactor, departPos, arrivalPos, departPosLat, ptype, vtype, destStop);
275 server.getWrapperStorage().writeInt((int)result.size());
276 for (const libsumo::TraCIStage& s : result) {
278 }
279 break;
280 }
281 default:
282 if (!libsumo::Simulation::handleVariable(id, variable, &server, &inputStorage)) {
283 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, "Get Simulation Variable: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);
284 }
285 }
286 } catch (libsumo::TraCIException& e) {
287 return server.writeErrorStatusCmd(libsumo::CMD_GET_SIM_VARIABLE, e.what(), outputStorage);
288 }
290 server.writeResponseWithLength(outputStorage, server.getWrapperStorage());
291 return true;
292}
293
294
295bool
297 tcpip::Storage& outputStorage) {
298 std::string warning = ""; // additional description for response
299 // variable
300 int variable = inputStorage.readUnsignedByte();
302 && variable != libsumo::CMD_SAVE_SIMSTATE
303 && variable != libsumo::CMD_LOAD_SIMSTATE
304 && variable != libsumo::VAR_PARAMETER
305 && variable != libsumo::VAR_SCALE
306 && variable != libsumo::CMD_MESSAGE
307 ) {
308 return server.writeErrorStatusCmd(libsumo::CMD_SET_SIM_VARIABLE, "Set Simulation Variable: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);
309 }
310 // id
311 std::string id = inputStorage.readString();
312 // process
313 try {
314 switch (variable) {
315 case libsumo::VAR_SCALE: {
316 double value;
317 if (!server.readTypeCheckingDouble(inputStorage, value)) {
318 return server.writeErrorStatusCmd(libsumo::CMD_SET_SIM_VARIABLE, "A double is needed for setting traffic scale.", outputStorage);
319 }
320 if (value < 0.0) {
321 return server.writeErrorStatusCmd(libsumo::CMD_SET_SIM_VARIABLE, "Traffic scale may not be negative.", outputStorage);
322 }
323 libsumo::Simulation::setScale(value);
324 }
325 break;
327 //clear any pending vehicle insertions
328 std::string route;
329 if (!server.readTypeCheckingString(inputStorage, route)) {
330 return server.writeErrorStatusCmd(libsumo::CMD_SET_SIM_VARIABLE, "A string is needed for clearing pending vehicles.", outputStorage);
331 }
332 libsumo::Simulation::clearPending(route);
333 }
334 break;
336 //save current simulation state
337 std::string file;
338 if (!server.readTypeCheckingString(inputStorage, file)) {
339 return server.writeErrorStatusCmd(libsumo::CMD_SET_SIM_VARIABLE, "A string is needed for saving simulation state.", outputStorage);
340 }
341 libsumo::Simulation::saveState(file);
342 }
343 break;
345 //quick-load simulation state
346 std::string file;
347 if (!server.readTypeCheckingString(inputStorage, file)) {
348 return server.writeErrorStatusCmd(libsumo::CMD_SET_SIM_VARIABLE, "A string is needed for loading simulation state.", outputStorage);
349 }
350 double time = libsumo::Simulation::loadState(file);
352 }
353 break;
355 StoHelp::readCompound(inputStorage, 2, "A compound object of size 2 is needed for setting a parameter.");
356 const std::string name = StoHelp::readTypedString(inputStorage, "The name of the parameter must be given as a string.");
357 const std::string value = StoHelp::readTypedString(inputStorage, "The value of the parameter must be given as a string.");
358 libsumo::Simulation::setParameter(id, name, value);
359 break;
360 }
362 std::string msg;
363 if (!server.readTypeCheckingString(inputStorage, msg)) {
364 return server.writeErrorStatusCmd(libsumo::CMD_SET_SIM_VARIABLE, "A string is needed for adding a log message.", outputStorage);
365 }
366 libsumo::Simulation::writeMessage(msg);
367 }
368 break;
369 default:
370 break;
371 }
372 } catch (libsumo::TraCIException& e) {
373 return server.writeErrorStatusCmd(libsumo::CMD_SET_SIM_VARIABLE, e.what(), outputStorage);
374 }
375 server.writeStatusCmd(libsumo::CMD_SET_SIM_VARIABLE, libsumo::RTYPE_OK, warning, outputStorage);
376 return true;
377}
378
379
380void
382 const std::vector<std::string>& ids = server.getVehicleStateChanges().find(state)->second;
384 outputStorage.writeInt((int) ids.size());
385}
386
387
388void
390 const std::vector<std::string>& ids = server.getVehicleStateChanges().find(state)->second;
392 outputStorage.writeStringList(ids);
393}
394
395
396void
398 const std::vector<std::string>& ids = server.getTransportableStateChanges().find(state)->second;
400 outputStorage.writeInt((int)ids.size());
401}
402
403
404void
406 const std::vector<std::string>& ids = server.getTransportableStateChanges().find(state)->second;
408 outputStorage.writeStringList(ids);
409}
410
411
412bool
414 const int compoundSize, tcpip::Storage& outputStorage,
415 const int commandId) {
416 std::pair<MSLane*, double> roadPos;
417 Position cartesianPos;
418 Position geoPos;
419 double z = 0;
420
421 // actual position type that will be converted
422 int srcPosType = inputStorage.readUnsignedByte();
423
424 switch (srcPosType) {
429 const double x = inputStorage.readDouble();
430 const double y = inputStorage.readDouble();
431 if (srcPosType != libsumo::POSITION_2D && srcPosType != libsumo::POSITION_LON_LAT) {
432 z = inputStorage.readDouble();
433 }
434 geoPos.set(x, y);
435 cartesianPos.set(x, y);
436 if (srcPosType == libsumo::POSITION_LON_LAT || srcPosType == libsumo::POSITION_LON_LAT_ALT) {
438 } else {
440 }
441 }
442 break;
444 const std::string roadID = inputStorage.readString();
445 const double pos = inputStorage.readDouble();
446 const int laneIdx = inputStorage.readUnsignedByte();
447 try {
448 // convert edge,offset,laneIdx to cartesian position
449 cartesianPos = geoPos = libsumo::Helper::getLaneChecking(roadID, laneIdx, pos)->geometryPositionAtOffset(pos);
450 z = cartesianPos.z();
452 } catch (libsumo::TraCIException& e) {
453 server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, e.what());
454 return false;
455 }
456 }
457 break;
458 default:
459 server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, "Source position type not supported");
460 return false;
461 }
462
463 int destPosType = 0;
464 if (!server.readTypeCheckingUnsignedByte(inputStorage, destPosType)) {
465 server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, "Destination position type must be of type ubyte.");
466 return false;
467 }
468
470 if (compoundSize == 3) {
471 inputStorage.readUnsignedByte();
472 const std::string& vClassString = inputStorage.readString();
473 if (!SumoVehicleClassStrings.hasString(vClassString)) {
474 server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, "Unknown vehicle class '" + vClassString + "'.");
475 return false;
476 }
477 vClass = SumoVehicleClassStrings.get(vClassString);
478 }
479
480 switch (destPosType) {
482 // convert cartesion position to edge,offset,lane_index
483 roadPos = libsumo::Helper::convertCartesianToRoadMap(cartesianPos, vClass);
484 if (roadPos.first == nullptr) {
485 server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, "No matching lane found.");
486 return false;
487 }
488 // write result that is added to response msg
490 outputStorage.writeString(roadPos.first->getEdge().getID());
491 outputStorage.writeDouble(roadPos.second);
492 outputStorage.writeUnsignedByte(roadPos.first->getIndex());
493 }
494 break;
499 outputStorage.writeUnsignedByte(destPosType);
500 if (destPosType == libsumo::POSITION_LON_LAT || destPosType == libsumo::POSITION_LON_LAT_ALT) {
501 outputStorage.writeDouble(geoPos.x());
502 outputStorage.writeDouble(geoPos.y());
503 } else {
504 outputStorage.writeDouble(cartesianPos.x());
505 outputStorage.writeDouble(cartesianPos.y());
506 }
507 if (destPosType != libsumo::POSITION_2D && destPosType != libsumo::POSITION_LON_LAT) {
508 outputStorage.writeDouble(z);
509 }
510 break;
511 default:
512 server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, "Destination position type not supported");
513 return false;
514 }
515 return true;
516}
517
518
519bool
521 tcpip::Storage& outputStorage, int commandId) {
522 Position pos1;
523 Position pos2;
524 std::pair<const MSLane*, double> roadPos1;
525 std::pair<const MSLane*, double> roadPos2;
526
527 // read position 1
528 int posType = inputStorage.readUnsignedByte();
529 switch (posType) {
531 try {
532 std::string roadID = inputStorage.readString();
533 roadPos1.second = inputStorage.readDouble();
534 roadPos1.first = libsumo::Helper::getLaneChecking(roadID, inputStorage.readUnsignedByte(), roadPos1.second);
535 pos1 = roadPos1.first->geometryPositionAtOffset(roadPos1.second);
536 } catch (libsumo::TraCIException& e) {
537 server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, e.what());
538 return false;
539 }
540 break;
543 double p1x = inputStorage.readDouble();
544 double p1y = inputStorage.readDouble();
545 pos1.set(p1x, p1y);
546 }
547 if (posType == libsumo::POSITION_3D) {
548 inputStorage.readDouble();// z value is ignored
549 }
551 break;
554 double p1x = inputStorage.readDouble();
555 double p1y = inputStorage.readDouble();
556 pos1.set(p1x, p1y);
558 }
559 if (posType == libsumo::POSITION_LON_LAT_ALT) {
560 inputStorage.readDouble();// altitude value is ignored
561 }
563 break;
564 default:
565 server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, "Unknown position format used for distance request");
566 return false;
567 }
568
569 // read position 2
570 posType = inputStorage.readUnsignedByte();
571 switch (posType) {
573 try {
574 std::string roadID = inputStorage.readString();
575 roadPos2.second = inputStorage.readDouble();
576 roadPos2.first = libsumo::Helper::getLaneChecking(roadID, inputStorage.readUnsignedByte(), roadPos2.second);
577 pos2 = roadPos2.first->geometryPositionAtOffset(roadPos2.second);
578 } catch (libsumo::TraCIException& e) {
579 server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, e.what());
580 return false;
581 }
582 break;
585 double p2x = inputStorage.readDouble();
586 double p2y = inputStorage.readDouble();
587 pos2.set(p2x, p2y);
588 }
589 if (posType == libsumo::POSITION_3D) {
590 inputStorage.readDouble();// z value is ignored
591 }
593 break;
596 double p2x = inputStorage.readDouble();
597 double p2y = inputStorage.readDouble();
598 pos2.set(p2x, p2y);
600 }
601 if (posType == libsumo::POSITION_LON_LAT_ALT) {
602 inputStorage.readDouble();// altitude value is ignored
603 }
605 break;
606 default:
607 server.writeStatusCmd(commandId, libsumo::RTYPE_ERR, "Unknown position format used for distance request");
608 return false;
609 }
610
611 // read distance type
612 const int distType = inputStorage.readUnsignedByte();
613
614 double distance = 0.0;
615 if (distType == libsumo::REQUEST_DRIVINGDIST) {
616 distance = libsumo::Helper::getDrivingDistance(roadPos1, roadPos2);
617 } else {
618 // compute air distance (default)
619 distance = pos1.distanceTo(pos2);
620 }
621 // write response command
623 outputStorage.writeDouble(distance);
624 return true;
625}
626
627
628/****************************************************************************/
#define TIME2STEPS(x)
Definition SUMOTime.h:57
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)
Definition ToString.h:56
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
Definition MSLane.h:560
VehicleState
Definition of a vehicle state.
Definition MSNet.h:622
@ 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.
Definition MSNet.h:699
@ 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.
Definition Position.h:37
void set(double x, double y)
set positions x and y
Definition Position.h:82
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimensions
Definition Position.h:263
double x() const
Returns the x-position.
Definition Position.h:52
double z() const
Returns the z-position.
Definition Position.h:62
double y() const
Returns the y-position.
Definition Position.h:57
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.
Definition TraCIServer.h:59
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.
void stateLoaded(SUMOTime targetTime)
updates myTargetTime and resets vehicle state changes after loading a simulation state
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.
static TraCIServer * getInstance()
Definition TraCIServer.h:68
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)
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)
Definition Helper.cpp:472
static std::pair< MSLane *, double > convertCartesianToRoadMap(const Position &pos, const SUMOVehicleClass vClass)
Definition Helper.cpp:436
static const MSLane * getLaneChecking(const std::string &edgeID, int laneIndex, double pos)
Definition Helper.cpp:419
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="")
An error which allows to continue.
Definition TraCIDefs.h:145
virtual std::string readString()
Definition storage.cpp:180
virtual void writeString(const std::string &s)
Definition storage.cpp:197
virtual void writeInt(int)
Definition storage.cpp:321
virtual void writeDouble(double)
Definition storage.cpp:354
virtual int readUnsignedByte()
Definition storage.cpp:155
virtual void writeStringList(const std::vector< std::string > &s)
Definition storage.cpp:247
virtual void writeUnsignedByte(int)
Definition storage.cpp:165
virtual void writeByte(int)
Definition storage.cpp:140
virtual double readDouble()
Definition storage.cpp:362
virtual int readInt()
Definition storage.cpp:311
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 RTYPE_OK
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
A list of positions.
Definition TraCIDefs.h:240
std::vector< TraCIPosition > value
Definition TraCIDefs.h:250