Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
libsumo/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) 2017-2024 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/****************************************************************************/
20// C++ TraCI client API implementation
21/****************************************************************************/
22#include <config.h>
23#ifdef HAVE_VERSION_H
24#include <version.h>
25#endif
36#include <utils/xml/XMLSubSys.h>
37#include <microsim/MSNet.h>
40#include <microsim/MSEdge.h>
41#include <microsim/MSLane.h>
42#include <microsim/MSVehicle.h>
53#include <mesosim/MELoop.h>
54#include <mesosim/MESegment.h>
55#include <netload/NLBuilder.h>
56#include <libsumo/Helper.h>
58#ifdef HAVE_LIBSUMOGUI
59#include "GUI.h"
60#endif
61#include "Simulation.h"
62#include <libsumo/TraCIDefs.h>
63
64
65namespace libsumo {
66// ===========================================================================
67// static member initializations
68// ===========================================================================
69SubscriptionResults Simulation::mySubscriptionResults;
70ContextSubscriptionResults Simulation::myContextSubscriptionResults;
71
72
73// ===========================================================================
74// static member definitions
75// ===========================================================================
76std::pair<int, std::string>
77Simulation::start(const std::vector<std::string>& cmd, int /* port */, int /* numRetries */, const std::string& /* label */, const bool /* verbose */,
78 const std::string& /* traceFile */, bool /* traceGetters */, void* /* _stdout */) {
79#ifdef HAVE_LIBSUMOGUI
80 if (GUI::start(cmd)) {
81 return getVersion();
82 }
83#endif
84 load(std::vector<std::string>(cmd.begin() + 1, cmd.end()));
85 return getVersion();
86}
87
88
89void
90Simulation::load(const std::vector<std::string>& args) {
91#ifdef HAVE_LIBSUMOGUI
92 if (GUI::load(args)) {
93 return;
94 }
95#endif
96 close("Libsumo issued load command.");
97 try {
98 OptionsCont::getOptions().setApplicationName("libsumo", "Eclipse SUMO libsumo Version " VERSION_STRING);
99 gSimulation = true;
101 OptionsIO::setArgs(args);
102 if (NLBuilder::init(true) != nullptr) {
103 const SUMOTime begin = string2time(OptionsCont::getOptions().getString("begin"));
104 MSNet::getInstance()->setCurrentTimeStep(begin); // needed for state loading
105 WRITE_MESSAGEF(TL("Simulation version % started via libsumo with time: %."), VERSION_STRING, time2string(begin));
106 }
107 } catch (ProcessError& e) {
108 throw TraCIException(e.what());
109 }
110}
111
112
113bool
114Simulation::hasGUI() {
115#ifdef HAVE_LIBSUMOGUI
116 return GUI::hasInstance();
117#else
118 return false;
119#endif
120}
121
122
123bool
124Simulation::isLoaded() {
125 return MSNet::hasInstance();
126}
127
128
129void
130Simulation::step(const double time) {
132 const SUMOTime t = TIME2STEPS(time);
133#ifdef HAVE_LIBSUMOGUI
134 if (!GUI::step(t)) {
135#endif
136 if (t == 0) {
138 } else {
139 while (MSNet::getInstance()->getCurrentTimeStep() < t) {
141 }
142 }
143#ifdef HAVE_LIBSUMOGUI
144 }
145#endif
147}
148
149
150void
151Simulation::executeMove() {
153}
154
155
156void
157Simulation::close(const std::string& reason) {
159 if (
160#ifdef HAVE_LIBSUMOGUI
161 !GUI::close(reason) &&
162#endif
165 delete MSNet::getInstance();
167 }
168}
169
170
171void
172Simulation::subscribe(const std::vector<int>& varIDs, double begin, double end, const libsumo::TraCIResults& params) {
173 libsumo::Helper::subscribe(CMD_SUBSCRIBE_SIM_VARIABLE, "", varIDs, begin, end, params);
174}
175
176
177const TraCIResults
178Simulation::getSubscriptionResults() {
179 return mySubscriptionResults[""];
180}
181
182
184
185
186std::pair<int, std::string>
187Simulation::getVersion() {
188 return std::make_pair(libsumo::TRACI_VERSION, "SUMO " VERSION_STRING);
189}
190
191
192std::string
193Simulation::getOption(const std::string& option) {
195 if (!oc.exists(option)) {
196 throw TraCIException("The option " + option + " is unknown.");
197 }
198 return oc.getValueString(option);
199}
200
201
202int
203Simulation::getCurrentTime() {
204 return (int)MSNet::getInstance()->getCurrentTimeStep();
205}
206
207
208double
209Simulation::getTime() {
210 return SIMTIME;
211}
212
213double
214Simulation::getEndTime() {
215 return STEPS2TIME(string2time(OptionsCont::getOptions().getString("end")));
216}
217
218
219int
220Simulation::getLoadedNumber() {
222}
223
224
225std::vector<std::string>
226Simulation::getLoadedIDList() {
228}
229
230
231int
232Simulation::getDepartedNumber() {
234}
235
236
237std::vector<std::string>
238Simulation::getDepartedIDList() {
240}
241
242
243int
244Simulation::getArrivedNumber() {
246}
247
248
249std::vector<std::string>
250Simulation::getArrivedIDList() {
252}
253
254
255int
256Simulation::getParkingStartingVehiclesNumber() {
258}
259
260
261std::vector<std::string>
262Simulation::getParkingStartingVehiclesIDList() {
264}
265
266
267int
268Simulation::getParkingEndingVehiclesNumber() {
270}
271
272
273std::vector<std::string>
274Simulation::getParkingEndingVehiclesIDList() {
276}
277
278
279int
280Simulation::getStopStartingVehiclesNumber() {
282}
283
284
285std::vector<std::string>
286Simulation::getStopStartingVehiclesIDList() {
288}
289
290
291int
292Simulation::getStopEndingVehiclesNumber() {
294}
295
296
297std::vector<std::string>
298Simulation::getStopEndingVehiclesIDList() {
300}
301
302
303int
304Simulation::getCollidingVehiclesNumber() {
306}
307
308
309std::vector<std::string>
310Simulation::getCollidingVehiclesIDList() {
312}
313
314
315int
316Simulation::getEmergencyStoppingVehiclesNumber() {
318}
319
320
321std::vector<std::string>
322Simulation::getEmergencyStoppingVehiclesIDList() {
324}
325
326
327int
328Simulation::getStartingTeleportNumber() {
330}
331
332
333std::vector<std::string>
334Simulation::getStartingTeleportIDList() {
336}
337
338
339int
340Simulation::getEndingTeleportNumber() {
342}
343
344
345std::vector<std::string>
346Simulation::getEndingTeleportIDList() {
348}
349
350int
351Simulation::getDepartedPersonNumber() {
353}
354
355
356std::vector<std::string>
357Simulation::getDepartedPersonIDList() {
359}
360
361
362int
363Simulation::getArrivedPersonNumber() {
365}
366
367
368std::vector<std::string>
369Simulation::getArrivedPersonIDList() {
371}
372
373std::vector<std::string>
374Simulation::getBusStopIDList() {
375 std::vector<std::string> result;
376 for (const auto& pair : MSNet::getInstance()->getStoppingPlaces(SUMO_TAG_BUS_STOP)) {
377 result.push_back(pair.first);
378 }
379 return result;
380}
381
382int
383Simulation::getBusStopWaiting(const std::string& stopID) {
385 if (s == nullptr) {
386 throw TraCIException("Unknown bus stop '" + stopID + "'.");
387 }
388 return s->getTransportableNumber();
389}
390
391std::vector<std::string>
392Simulation::getBusStopWaitingIDList(const std::string& stopID) {
394 if (s == nullptr) {
395 throw TraCIException("Unknown bus stop '" + stopID + "'.");
396 }
397 std::vector<std::string> result;
398 for (const MSTransportable* t : s->getTransportables()) {
399 result.push_back(t->getID());
400 }
401 return result;
402}
403
404
405std::vector<std::string>
406Simulation::getPendingVehicles() {
407 std::vector<std::string> result;
409 result.push_back(veh->getID());
410 }
411 return result;
412}
413
414
415std::vector<libsumo::TraCICollision>
416Simulation::getCollisions() {
417 std::vector<libsumo::TraCICollision> result;
418 for (auto item : MSNet::getInstance()->getCollisions()) {
419 for (const MSNet::Collision& c : item.second) {
421 c2.collider = item.first;
422 c2.victim = c.victim;
423 c2.colliderType = c.colliderType;
424 c2.victimType = c.victimType;
425 c2.colliderSpeed = c.colliderSpeed;
426 c2.victimSpeed = c.victimSpeed;
427 c2.type = c.type;
428 c2.lane = c.lane->getID();
429 c2.pos = c.pos;
430 result.push_back(c2);
431 }
432 }
433 return result;
434}
435
436double
437Simulation::getScale() {
439}
440
441double
442Simulation::getDeltaT() {
443 return TS;
444}
445
446
447TraCIPositionVector
448Simulation::getNetBoundary() {
450 TraCIPositionVector tb;
451 TraCIPosition minV;
452 TraCIPosition maxV;
453 minV.x = b.xmin();
454 maxV.x = b.xmax();
455 minV.y = b.ymin();
456 maxV.y = b.ymax();
457 minV.z = b.zmin();
458 maxV.z = b.zmax();
459 tb.value.push_back(minV);
460 tb.value.push_back(maxV);
461 return tb;
462}
463
464
465int
466Simulation::getMinExpectedNumber() {
467 MSNet* net = MSNet::getInstance();
470 + (net->hasPersons() ? net->getPersonControl().getActiveCount() : 0)
471 + (net->hasContainers() ? net->getContainerControl().getActiveCount() : 0));
472}
473
474
475TraCIPosition
476Simulation::convert2D(const std::string& edgeID, double pos, int laneIndex, bool toGeo) {
477 Position result = Helper::getLaneChecking(edgeID, laneIndex, pos)->geometryPositionAtOffset(pos);
478 if (toGeo) {
480 }
481 result.setz(0.);
482 return Helper::makeTraCIPosition(result);
483}
484
485
486TraCIPosition
487Simulation::convert3D(const std::string& edgeID, double pos, int laneIndex, bool toGeo) {
488 Position result = Helper::getLaneChecking(edgeID, laneIndex, pos)->geometryPositionAtOffset(pos);
489 if (toGeo) {
491 }
492 return Helper::makeTraCIPosition(result, true);
493}
494
495
496TraCIRoadPosition
497Simulation::convertRoad(double x, double y, bool isGeo, const std::string& vClass) {
498 Position pos(x, y);
499 if (isGeo) {
501 }
502 if (!SumoVehicleClassStrings.hasString(vClass)) {
503 throw TraCIException("Unknown vehicle class '" + vClass + "'.");
504 }
505 const SUMOVehicleClass vc = SumoVehicleClassStrings.get(vClass);
506 std::pair<MSLane*, double> roadPos = libsumo::Helper::convertCartesianToRoadMap(pos, vc);
507 if (roadPos.first == nullptr) {
508 throw TraCIException("Cannot convert position to road.");
509 }
510 TraCIRoadPosition result;
511 result.edgeID = roadPos.first->getEdge().getID();
512 result.laneIndex = roadPos.first->getIndex();
513 result.pos = roadPos.second;
514 return result;
515}
516
517
518TraCIPosition
519Simulation::convertGeo(double x, double y, bool fromGeo) {
520 Position pos(x, y);
521 if (fromGeo) {
523 } else {
525 }
526 return Helper::makeTraCIPosition(pos);
527}
528
529
530double
531Simulation::getDistance2D(double x1, double y1, double x2, double y2, bool isGeo, bool isDriving) {
532 Position pos1(x1, y1);
533 Position pos2(x2, y2);
534 if (isGeo) {
537 }
538 if (isDriving) {
539 std::pair<const MSLane*, double> roadPos1 = libsumo::Helper::convertCartesianToRoadMap(pos1, SVC_IGNORING);
540 std::pair<const MSLane*, double> roadPos2 = libsumo::Helper::convertCartesianToRoadMap(pos2, SVC_IGNORING);
541 return Helper::getDrivingDistance(roadPos1, roadPos2);
542 } else {
543 return pos1.distanceTo(pos2);
544 }
545}
546
547
548double
549Simulation::getDistanceRoad(const std::string& edgeID1, double pos1, const std::string& edgeID2, double pos2, bool isDriving) {
550 std::pair<const MSLane*, double> roadPos1 = std::make_pair(libsumo::Helper::getLaneChecking(edgeID1, 0, pos1), pos1);
551 std::pair<const MSLane*, double> roadPos2 = std::make_pair(libsumo::Helper::getLaneChecking(edgeID2, 0, pos2), pos2);
552 if (isDriving) {
553 return Helper::getDrivingDistance(roadPos1, roadPos2);
554 } else {
555 const Position p1 = roadPos1.first->geometryPositionAtOffset(roadPos1.second);
556 const Position p2 = roadPos2.first->geometryPositionAtOffset(roadPos2.second);
557 return p1.distanceTo(p2);
558 }
559}
560
561
562TraCIStage
563Simulation::findRoute(const std::string& from, const std::string& to, const std::string& typeID, const double depart, const int routingMode) {
564 TraCIStage result(STAGE_DRIVING);
565 const MSEdge* const fromEdge = MSEdge::dictionary(from);
566 if (fromEdge == nullptr) {
567 throw TraCIException("Unknown from edge '" + from + "'.");
568 }
569 const MSEdge* const toEdge = MSEdge::dictionary(to);
570 if (toEdge == nullptr) {
571 throw TraCIException("Unknown to edge '" + to + "'.");
572 }
573 MSBaseVehicle* vehicle = nullptr;
574 MSVehicleType* type = MSNet::getInstance()->getVehicleControl().getVType(typeID == "" ? DEFAULT_VTYPE_ID : typeID);
575 if (type == nullptr) {
576 throw TraCIException("The vehicle type '" + typeID + "' is not known.");
577 }
579 pars->id = "simulation.findRoute";
580 try {
581 ConstMSRoutePtr const routeDummy = std::make_shared<MSRoute>("", ConstMSEdgeVector({ fromEdge }), false, nullptr, std::vector<SUMOVehicleParameter::Stop>());
582 vehicle = dynamic_cast<MSBaseVehicle*>(MSNet::getInstance()->getVehicleControl().buildVehicle(pars, routeDummy, type, false));
583 std::string msg;
584 if (!vehicle->hasValidRouteStart(msg)) {
586 throw TraCIException("Invalid departure edge for vehicle type '" + type->getID() + "' (" + msg + ")");
587 }
588 // we need to fix the speed factor here for deterministic results
589 vehicle->setChosenSpeedFactor(type->getSpeedFactor().getParameter()[0]);
590 vehicle->setRoutingMode(routingMode);
591 } catch (ProcessError& e) {
592 throw TraCIException("Invalid departure edge for vehicle type '" + type->getID() + "' (" + e.what() + ")");
593 }
594 ConstMSEdgeVector edges;
595 const SUMOTime dep = depart < 0 ? MSNet::getInstance()->getCurrentTimeStep() : TIME2STEPS(depart);
597 router.compute(fromEdge, toEdge, vehicle, dep, edges);
598 for (const MSEdge* e : edges) {
599 result.edges.push_back(e->getID());
600 }
601 result.travelTime = result.cost = router.recomputeCosts(edges, vehicle, dep, &result.length);
602 if (vehicle != nullptr) {
604 }
605 return result;
606}
607
608
609std::vector<TraCIStage>
610Simulation::findIntermodalRoute(const std::string& from, const std::string& to,
611 const std::string& modes, double depart, const int routingMode, double speed, double walkFactor,
612 double departPos, double arrivalPos, const double departPosLat,
613 const std::string& pType, const std::string& vType, const std::string& destStop) {
614 UNUSED_PARAMETER(departPosLat);
615 std::vector<TraCIStage> result;
616 const MSEdge* const fromEdge = MSEdge::dictionary(from);
617 if (fromEdge == nullptr) {
618 throw TraCIException("Unknown from edge '" + from + "'.");
619 }
620 const MSEdge* const toEdge = MSEdge::dictionary(to);
621 if (toEdge == nullptr) {
622 throw TraCIException("Unknown to edge '" + to + "'.");
623 }
625 SVCPermissions modeSet = 0;
626 std::vector<SUMOVehicleParameter*> pars;
627 if (vType != "") {
628 pars.push_back(new SUMOVehicleParameter());
629 pars.back()->vtypeid = vType;
630 pars.back()->id = vType;
631 modeSet |= SVC_PASSENGER;
632 }
633 for (StringTokenizer st(modes); st.hasNext();) {
634 const std::string mode = st.next();
635 if (mode == toString(PersonMode::CAR)) {
636 pars.push_back(new SUMOVehicleParameter());
637 pars.back()->vtypeid = DEFAULT_VTYPE_ID;
638 pars.back()->id = mode;
639 modeSet |= SVC_PASSENGER;
640 } else if (mode == toString(PersonMode::BICYCLE)) {
641 pars.push_back(new SUMOVehicleParameter());
642 pars.back()->vtypeid = DEFAULT_BIKETYPE_ID;
643 pars.back()->id = mode;
644 modeSet |= SVC_BICYCLE;
645 } else if (mode == toString(PersonMode::TAXI)) {
646 pars.push_back(new SUMOVehicleParameter());
647 pars.back()->vtypeid = DEFAULT_TAXITYPE_ID;
648 pars.back()->id = mode;
649 pars.back()->line = mode;
650 modeSet |= SVC_TAXI;
651 } else if (mode == toString(PersonMode::PUBLIC)) {
652 pars.push_back(nullptr);
653 modeSet |= SVC_BUS;
654 } else if (mode == toString(PersonMode::WALK)) {
655 // do nothing
656 } else {
657 throw TraCIException("Unknown person mode '" + mode + "'.");
658 }
659 }
660 if (pars.empty()) {
661 pars.push_back(nullptr);
662 }
663 // interpret default arguments
664 const MSVehicleType* pedType = vehControl.hasVType(pType) ? vehControl.getVType(pType) : vehControl.getVType(DEFAULT_PEDTYPE_ID);
665 SUMOTime departStep = TIME2STEPS(depart);
666 if (depart < 0) {
667 departStep = MSNet::getInstance()->getCurrentTimeStep();
668 }
669 if (speed < 0) {
670 speed = MIN2(pedType->getMaxSpeed(), pedType->getDesiredMaxSpeed());
671 }
672 if (walkFactor < 0) {
673 walkFactor = OptionsCont::getOptions().getFloat("persontrip.walkfactor");
674 }
675 const double externalFactor = StringUtils::toDouble(pedType->getParameter().getParameter("externalEffortFactor", "100"));
676 if (departPos < 0) {
677 departPos += fromEdge->getLength();
678 }
679 if (arrivalPos == INVALID_DOUBLE_VALUE) {
680 arrivalPos = toEdge->getLength() / 2;
681 } else if (arrivalPos < 0) {
682 arrivalPos += toEdge->getLength();
683 }
684 if (departPos < 0 || departPos >= fromEdge->getLength()) {
685 throw TraCIException("Invalid depart position " + toString(departPos) + " for edge '" + from + "'.");
686 }
687 if (arrivalPos < 0 || arrivalPos >= toEdge->getLength()) {
688 throw TraCIException("Invalid arrival position " + toString(arrivalPos) + " for edge '" + to + "'.");
689 }
690 double minCost = std::numeric_limits<double>::max();
692 for (SUMOVehicleParameter* vehPar : pars) {
693 std::vector<TraCIStage> resultCand;
694 SUMOVehicle* vehicle = nullptr;
695 if (vehPar != nullptr) {
696 MSVehicleType* type = MSNet::getInstance()->getVehicleControl().getVType(vehPar->vtypeid);
697 const bool isTaxi = type != nullptr && type->getID() == DEFAULT_TAXITYPE_ID && vehPar->line == "taxi";
698 if (type == nullptr) {
699 throw TraCIException("Unknown vehicle type '" + vehPar->vtypeid + "'.");
700 }
701 if (type->getVehicleClass() != SVC_IGNORING && (fromEdge->getPermissions() & type->getVehicleClass()) == 0 && !isTaxi) {
702 WRITE_WARNINGF(TL("Ignoring vehicle type '%' when performing intermodal routing because it is not allowed on the start edge '%'."), type->getID(), from);
703 } else {
704 ConstMSRoutePtr const routeDummy = std::make_shared<MSRoute>(vehPar->id, ConstMSEdgeVector({ fromEdge }), false, nullptr, std::vector<SUMOVehicleParameter::Stop>());
705 vehicle = vehControl.buildVehicle(vehPar, routeDummy, type, !MSGlobals::gCheckRoutes);
706 // we need to fix the speed factor here for deterministic results
707 vehicle->setChosenSpeedFactor(type->getSpeedFactor().getParameter()[0]);
708 }
709 }
710 std::vector<MSTransportableRouter::TripItem> items;
711 if (router.compute(fromEdge, toEdge, departPos, "", arrivalPos, destStop,
712 speed * walkFactor, vehicle, modeSet, departStep, items, externalFactor)) {
713 double cost = 0;
714 for (std::vector<MSTransportableRouter::TripItem>::iterator it = items.begin(); it != items.end(); ++it) {
715 if (!it->edges.empty()) {
716 resultCand.push_back(TraCIStage((it->line == "" ? STAGE_WALKING : STAGE_DRIVING), it->vType, it->line, it->destStop));
717 for (const MSEdge* e : it->edges) {
718 resultCand.back().edges.push_back(e->getID());
719 }
720 resultCand.back().travelTime = it->traveltime;
721 resultCand.back().cost = it->cost;
722 resultCand.back().length = it->length;
723 resultCand.back().intended = it->intended;
724 resultCand.back().depart = it->depart;
725 resultCand.back().departPos = it->departPos;
726 resultCand.back().arrivalPos = it->arrivalPos;
727 resultCand.back().description = it->description;
728 }
729 cost += it->cost;
730 }
731 if (cost < minCost) {
732 minCost = cost;
733 result = resultCand;
734 }
735 }
736 if (vehicle != nullptr) {
737 vehControl.deleteVehicle(vehicle, true);
738 }
739 }
740 return result;
741}
742
743
744std::string
745Simulation::getParameter(const std::string& objectID, const std::string& key) {
746 if (StringUtils::startsWith(key, "chargingStation.")) {
747 const std::string attrName = key.substr(16);
749 if (cs == nullptr) {
750 throw TraCIException("Invalid chargingStation '" + objectID + "'");
751 }
752 if (attrName == toString(SUMO_ATTR_TOTALENERGYCHARGED)) {
753 return toString(cs->getTotalCharged());
754 } else if (attrName == toString(SUMO_ATTR_NAME)) {
755 return toString(cs->getMyName());
756 } else if (attrName == "lane") {
757 return cs->getLane().getID();
758 } else if (cs->hasParameter(attrName)) {
759 return cs->getParameter(attrName);
760 } else {
761 throw TraCIException("Invalid chargingStation parameter '" + attrName + "'");
762 }
763 } else if (StringUtils::startsWith(key, "overheadWire.")) {
764 const std::string attrName = key.substr(16);
766 if (cs == 0) {
767 throw TraCIException("Invalid overhead wire '" + objectID + "'");
768 }
769 if (attrName == toString(SUMO_ATTR_TOTALENERGYCHARGED)) {
770 return toString(cs->getTotalCharged());
771 } else if (attrName == toString(SUMO_ATTR_NAME)) {
772 return toString(cs->getMyName());
773 } else {
774 throw TraCIException("Invalid overhead wire parameter '" + attrName + "'");
775 }
776 } else if (StringUtils::startsWith(key, "net.")) {
777 const std::string attrName = key.substr(4);
779 if (attrName == toString(SUMO_ATTR_NET_OFFSET)) {
780 return toString(GeoConvHelper::getFinal().getOffsetBase());
781 } else {
782 throw TraCIException("Invalid net parameter '" + attrName + "'");
783 }
784 } else if (StringUtils::startsWith(key, "stats.")) {
785 if (objectID != "") {
786 throw TraCIException("Simulation parameter '" + key + "' is not supported for object id '" + objectID + "'. Use empty id for stats");
787 }
788 const std::string attrName = key.substr(6);
791 if (attrName == "vehicles.loaded") {
792 return toString(vc.getLoadedVehicleNo());
793 } else if (attrName == "vehicles.inserted") {
794 return toString(vc.getDepartedVehicleNo());
795 } else if (attrName == "vehicles.running") {
796 return toString(vc.getRunningVehicleNo());
797 } else if (attrName == "vehicles.waiting") {
798 return toString(MSNet::getInstance()->getInsertionControl().getWaitingVehicleNo());
799 } else if (attrName == "teleports.total") {
800 return toString(vc.getTeleportCount());
801 } else if (attrName == "teleports.jam") {
802 return toString(vc.getTeleportsJam());
803 } else if (attrName == "teleports.yield") {
804 return toString(vc.getTeleportsYield());
805 } else if (attrName == "teleports.wrongLane") {
806 return toString(vc.getTeleportsWrongLane());
807 } else if (attrName == "safety.collisions") {
808 return toString(vc.getCollisionCount());
809 } else if (attrName == "safety.emergencyStops") {
810 return toString(vc.getEmergencyStops());
811 } else if (attrName == "safety.emergencyBraking") {
813 } else if (attrName == "persons.loaded") {
814 return toString(pc != nullptr ? pc->getLoadedNumber() : 0);
815 } else if (attrName == "persons.running") {
816 return toString(pc != nullptr ? pc->getRunningNumber() : 0);
817 } else if (attrName == "persons.jammed") {
818 return toString(pc != nullptr ? pc->getJammedNumber() : 0);
819 } else if (attrName == "personTeleports.total") {
820 return toString(pc != nullptr ? pc->getTeleportCount() : 0);
821 } else if (attrName == "personTeleports.abortWait") {
822 return toString(pc != nullptr ? pc->getTeleportsAbortWait() : 0);
823 } else if (attrName == "personTeleports.wrongDest") {
824 return toString(pc != nullptr ? pc->getTeleportsWrongDest() : 0);
825 } else {
826 throw TraCIException("Invalid stats parameter '" + attrName + "'");
827 }
828 } else if (StringUtils::startsWith(key, "parkingArea.")) {
829 const std::string attrName = key.substr(12);
831 if (pa == nullptr) {
832 throw TraCIException("Invalid parkingArea '" + objectID + "'");
833 }
834 if (attrName == "capacity") {
835 return toString(pa->getCapacity());
836 } else if (attrName == "occupancy") {
838 } else if (attrName == toString(SUMO_ATTR_NAME)) {
839 return toString(pa->getMyName());
840 } else if (attrName == "lane") {
841 return pa->getLane().getID();
842 } else if (pa->hasParameter(attrName)) {
843 return pa->getParameter(attrName);
844 } else {
845 throw TraCIException("Invalid parkingArea parameter '" + attrName + "'");
846 }
847 } else if (StringUtils::startsWith(key, "busStop.")) {
848 const std::string attrName = key.substr(8);
850 if (bs == nullptr) {
851 throw TraCIException("Invalid busStop '" + objectID + "'");
852 }
853 if (attrName == toString(SUMO_ATTR_NAME)) {
854 return toString(bs->getMyName());
855 } else if (attrName == "lane") {
856 return bs->getLane().getID();
857 } else if (bs->hasParameter(attrName)) {
858 return bs->getParameter(attrName);
859 } else {
860 throw TraCIException("Invalid busStop parameter '" + attrName + "'");
861 }
862 } else if (StringUtils::startsWith(key, "device.tripinfo.")) {
863 if (objectID != "") {
864 throw TraCIException("Simulation parameter '" + key + "' is not supported for object id '" + objectID
865 + "'. Use empty id for global device parameers or vehicle domain for vehicle specific parameters");
866 }
867 const std::string attrName = key.substr(16);
869 } else if (objectID == "") {
870 return MSNet::getInstance()->getParameter(key, "");
871 } else {
872 throw TraCIException("Simulation parameter '" + key + "' is not supported for object id '" + objectID + "'. Use empty id for generic network parameters");
873 }
874}
875
877
878void
879Simulation::setParameter(const std::string& objectID, const std::string& key, const std::string& value) {
880 if (objectID == "") {
881 MSNet::getInstance()->setParameter(key, value);
882 } else {
883 throw TraCIException("Setting simulation parameter '" + key + "' is not supported for object id '" + objectID + "'. Use empty id for generic network parameters");
884 }
885}
886
887void
888Simulation::setScale(double value) {
890}
891
892void
893Simulation::clearPending(const std::string& routeID) {
895}
896
897
898void
899Simulation::saveState(const std::string& fileName) {
900 MSStateHandler::saveState(fileName, MSNet::getInstance()->getCurrentTimeStep());
901}
902
903double
904Simulation::loadState(const std::string& fileName) {
905 long before = PROGRESS_BEGIN_TIME_MESSAGE("Loading state from '" + fileName + "'");
906 try {
907 const SUMOTime newTime = MSNet::getInstance()->loadState(fileName, false);
910 PROGRESS_TIME_MESSAGE(before);
911 return STEPS2TIME(newTime);
912 } catch (const IOError& e) {
913 throw TraCIException("Loading state from '" + fileName + "' failed. " + e.what());
914 } catch (const ProcessError& e) {
915 throw TraCIException("Loading state from '" + fileName + "' failed, check whether SUMO versions match. " + e.what());
916 }
917}
918
919void
920Simulation::writeMessage(const std::string& msg) {
921 WRITE_MESSAGE(msg);
922}
923
924
925void
926Simulation::storeShape(PositionVector& shape) {
928}
929
930
931std::shared_ptr<VariableWrapper>
932Simulation::makeWrapper() {
933 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
934}
935
936
937bool
938Simulation::handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper, tcpip::Storage* paramData) {
939 switch (variable) {
940 case VAR_TIME:
941 return wrapper->wrapDouble(objID, variable, getTime());
942 case VAR_TIME_STEP:
943 return wrapper->wrapInt(objID, variable, (int)getCurrentTime());
944 case VAR_END:
945 return wrapper->wrapDouble(objID, variable, getEndTime());
947 return wrapper->wrapInt(objID, variable, getLoadedNumber());
949 return wrapper->wrapStringList(objID, variable, getLoadedIDList());
951 return wrapper->wrapInt(objID, variable, getDepartedNumber());
953 return wrapper->wrapStringList(objID, variable, getDepartedIDList());
955 return wrapper->wrapInt(objID, variable, getStartingTeleportNumber());
957 return wrapper->wrapStringList(objID, variable, getStartingTeleportIDList());
959 return wrapper->wrapInt(objID, variable, getEndingTeleportNumber());
961 return wrapper->wrapStringList(objID, variable, getEndingTeleportIDList());
963 return wrapper->wrapInt(objID, variable, getArrivedNumber());
965 return wrapper->wrapStringList(objID, variable, getArrivedIDList());
967 return wrapper->wrapInt(objID, variable, getParkingStartingVehiclesNumber());
969 return wrapper->wrapStringList(objID, variable, getParkingStartingVehiclesIDList());
971 return wrapper->wrapInt(objID, variable, getParkingEndingVehiclesNumber());
973 return wrapper->wrapStringList(objID, variable, getParkingEndingVehiclesIDList());
975 return wrapper->wrapInt(objID, variable, getStopStartingVehiclesNumber());
977 return wrapper->wrapStringList(objID, variable, getStopStartingVehiclesIDList());
979 return wrapper->wrapInt(objID, variable, getStopEndingVehiclesNumber());
981 return wrapper->wrapStringList(objID, variable, getStopEndingVehiclesIDList());
983 return wrapper->wrapInt(objID, variable, getCollidingVehiclesNumber());
985 return wrapper->wrapStringList(objID, variable, getCollidingVehiclesIDList());
987 return wrapper->wrapInt(objID, variable, getEmergencyStoppingVehiclesNumber());
989 return wrapper->wrapStringList(objID, variable, getEmergencyStoppingVehiclesIDList());
991 return wrapper->wrapInt(objID, variable, getDepartedPersonNumber());
993 return wrapper->wrapStringList(objID, variable, getDepartedPersonIDList());
995 return wrapper->wrapInt(objID, variable, getArrivedPersonNumber());
997 return wrapper->wrapStringList(objID, variable, getArrivedPersonIDList());
998 case VAR_SCALE:
999 return wrapper->wrapDouble(objID, variable, getScale());
1000 case VAR_DELTA_T:
1001 return wrapper->wrapDouble(objID, variable, getDeltaT());
1002 case VAR_OPTION:
1003 return wrapper->wrapString(objID, variable, getOption(objID));
1005 return wrapper->wrapInt(objID, variable, getMinExpectedNumber());
1007 return wrapper->wrapStringList(objID, variable, getBusStopIDList());
1009 return wrapper->wrapInt(objID, variable, getBusStopWaiting(objID));
1011 return wrapper->wrapStringList(objID, variable, getBusStopWaitingIDList(objID));
1013 return wrapper->wrapStringList(objID, variable, getPendingVehicles());
1015 paramData->readUnsignedByte();
1016 return wrapper->wrapString(objID, variable, getParameter(objID, paramData->readString()));
1018 paramData->readUnsignedByte();
1019 return wrapper->wrapStringPair(objID, variable, getParameterWithKey(objID, paramData->readString()));
1020 default:
1021 return false;
1022 }
1023}
1024}
1025
1026
1027/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:296
#define WRITE_MESSAGEF(...)
Definition MsgHandler.h:298
#define WRITE_MESSAGE(msg)
Definition MsgHandler.h:297
#define PROGRESS_BEGIN_TIME_MESSAGE(msg)
Definition MsgHandler.h:301
#define TL(string)
Definition MsgHandler.h:315
#define PROGRESS_TIME_MESSAGE(before)
Definition MsgHandler.h:302
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition Route.h:32
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:46
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:69
#define STEPS2TIME(x)
Definition SUMOTime.h:55
#define TS
Definition SUMOTime.h:42
#define SIMTIME
Definition SUMOTime.h:62
#define TIME2STEPS(x)
Definition SUMOTime.h:57
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
const std::string DEFAULT_TAXITYPE_ID
const std::string DEFAULT_PEDTYPE_ID
const std::string DEFAULT_VTYPE_ID
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_TAXI
vehicle is a taxi
@ SVC_BUS
vehicle is a bus
const std::string DEFAULT_BIKETYPE_ID
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_OVERHEAD_WIRE_SEGMENT
An overhead wire segment.
@ SUMO_ATTR_NET_OFFSET
@ SUMO_ATTR_TOTALENERGYCHARGED
@ SUMO_ATTR_NAME
bool gSimulation
Definition StdDefs.cpp:30
#define UNUSED_PARAMETER(x)
Definition StdDefs.h:30
T MIN2(T a, T b)
Definition StdDefs.h:76
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM)
Definition TraCIDefs.h:76
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
Definition TraCIDefs.h:123
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
double ymin() const
Returns minimum y-coordinate.
Definition Boundary.cpp:130
double xmin() const
Returns minimum x-coordinate.
Definition Boundary.cpp:118
PositionVector getShape(const bool closeShape) const
get position vector (shape) based on this boundary
Definition Boundary.cpp:447
double zmin() const
Returns minimum z-coordinate.
Definition Boundary.cpp:142
double ymax() const
Returns maximum y-coordinate.
Definition Boundary.cpp:136
double xmax() const
Returns maximum x-coordinate.
Definition Boundary.cpp:124
double zmax() const
Returns maximum z-coordinate.
Definition Boundary.cpp:148
std::vector< double > & getParameter()
Returns the parameters of this distribution.
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.
const Position getOffsetBase() const
Returns the network base.
const Boundary & getConvBoundary() const
Returns the converted boundary.
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation.
bool compute(const E *from, const E *to, const double departPos, const std::string &originStopID, const double arrivalPos, const std::string &stopID, const double speed, const V *const vehicle, const SVCPermissions modeSet, const SUMOTime msTime, std::vector< TripItem > &into, const double externalFactor=0.)
Builds the route between the given edges using the minimum effort at the given time The definition of...
C++ TraCI client API implementation.
Definition Simulation.h:41
The base class for microscopic and mesoscopic vehicles.
void setChosenSpeedFactor(const double factor)
Returns the precomputed factor by which the driver wants to be faster than the speed limit.
void setRoutingMode(int value)
Sets routing behavior.
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
virtual bool hasValidRouteStart(std::string &msg)
checks wether the vehicle can depart on the first edge
double getTotalCharged() const
static std::string getGlobalParameter(const std::string &prefixedKey)
try to retrieve the given parameter from the global statistics. Throw exception for unsupported key
A road/street connecting two junctions.
Definition MSEdge.h:77
SVCPermissions getPermissions() const
Returns the combined permissions of all lanes of this edge.
Definition MSEdge.h:649
double getLength() const
return the length of the edge
Definition MSEdge.h:685
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
Definition MSEdge.cpp:1047
static bool gCheckRoutes
Definition MSGlobals.h:91
const MSVehicleContainer::VehicleVector & getPendingVehicles() const
retrieve vehicles waiting for insertion
void clearPendingVehicles(const std::string &route)
clears out all pending vehicles from a route, "" for all routes
int getPendingFlowCount() const
Returns the number of flows that are still active.
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition MSLane.h:560
The simulated network and simulation perfomer.
Definition MSNet.h:89
SUMOTime loadState(const std::string &fileName, const bool catchExceptions)
load state from file and return new time
Definition MSNet.cpp:1665
@ 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.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:185
const CollisionMap & getCollisions() const
Definition MSNet.h:743
virtual MSTransportableControl & getContainerControl()
Returns the container control.
Definition MSNet.cpp:1198
MSTransportableRouter & getIntermodalRouter(const int rngIndex, const int routingMode=0, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition MSNet.cpp:1545
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition MSNet.h:320
static bool hasInstance()
Returns whether the network was already constructed.
Definition MSNet.h:152
void closeSimulation(SUMOTime start, const std::string &reason="")
Closes the simulation (all files, connections, etc.)
Definition MSNet.cpp:675
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition MSNet.cpp:1380
void setCurrentTimeStep(const SUMOTime step)
Sets the current simulation step (used by state loading)
Definition MSNet.h:328
void simulationStep(const bool onlyMove=false)
Performs a single simulation step.
Definition MSNet.cpp:714
bool hasContainers() const
Returns whether containers are simulated.
Definition MSNet.h:411
bool hasPersons() const
Returns whether persons are simulated.
Definition MSNet.h:395
@ PERSON_DEPARTED
The transportable person has departed (was inserted into the network)
@ PERSON_ARRIVED
The transportable person arrived at his destination (is deleted)
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition MSNet.h:431
MSVehicleRouter & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition MSNet.cpp:1507
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:378
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition MSNet.cpp:1189
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
Definition MSNet.cpp:1415
Definition of overhead wire segment.
double getTotalCharged() const
A lane area vehicles can halt at.
int getCapacity() const
Returns the area capacity.
int getOccupancyIncludingBlocked() const
Returns the area occupancy.
static MSVehicleRouter & getRouterTT(const int rngIndex, SUMOVehicleClass svc, const MSEdgeVector &prohibited=MSEdgeVector())
return the vehicle router instance
static void saveState(const std::string &file, SUMOTime step, bool usePrefix=true)
Saves the current state.
A lane area vehicles can halt at.
std::vector< const MSTransportable * > getTransportables() const
Returns the transportables waiting on this stop.
int getTransportableNumber() const
Returns the number of transportables waiting on this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
const std::string & getMyName() const
int getRunningNumber() const
Returns the number of build and inserted, but not yet deleted transportables.
int getTeleportCount() const
Returns the number of teleports transportables did.
int getLoadedNumber() const
Returns the number of build transportables.
int getTeleportsWrongDest() const
return the number of teleports of transportables riding to the wrong destination
int getJammedNumber() const
Returns the number of times a transportables was jammed.
int getTeleportsAbortWait() const
return the number of teleports due to excessive waiting for a ride
int getActiveCount()
return the number of active transportable objects
The class responsible for building and deletion of vehicles.
bool hasVType(const std::string &id) const
Asks for existence of a vehicle type.
int getRunningVehicleNo() const
Returns the number of build and inserted, but not yet deleted vehicles.
double getScale() const
sets the demand scaling factor
void setScale(double scale)
sets the demand scaling factor
int getLoadedVehicleNo() const
Returns the number of build vehicles.
int getCollisionCount() const
return the number of collisions
int getTeleportsWrongLane() const
return the number of teleports due to vehicles stuck on the wrong lane
int getTeleportsYield() const
return the number of teleports due to vehicles stuck on a minor road
int getEmergencyBrakingCount() const
return the number of emergency stops
int getEmergencyStops() const
return the number of emergency stops
int getDepartedVehicleNo() const
Returns the number of inserted vehicles.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, SumoRNG *rng=nullptr, bool readOnly=false)
Returns the named vehicle type or a sample from the named distribution.
int getActiveVehicleCount() const
Returns the number of build vehicles that have not been removed or need to wait for a passenger or a ...
int getTeleportsJam() const
return the number of teleports due to jamming
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, ConstMSRoutePtr route, MSVehicleType *type, const bool ignoreStopErrors, const VehicleDefinitionSource source=ROUTEFILE, bool addRouteStops=true)
Builds a vehicle, increases the number of built vehicles.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false, bool wasKept=false)
Deletes the vehicle.
int getTeleportCount() const
return the number of teleports (including collisions)
The car-following model and parameter.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
double getMaxSpeed() const
Get vehicle's (technical) maximum speed [m/s].
double getDesiredMaxSpeed() const
Returns the vehicles's desired maximum speed.
const std::string & getID() const
Returns the name of the vehicle type.
const Distribution_Parameterized & getSpeedFactor() const
Returns this type's speed factor.
const SUMOVTypeParameter & getParameter() const
static MSNet * init(const bool isLibsumo=false)
const std::string & getID() const
Returns the id.
Definition Named.h:74
A storage for options typed value containers)
Definition OptionsCont.h:89
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.
bool exists(const std::string &name) const
Returns the information whether the named option is known.
std::string getValueString(const std::string &name) const
Returns the string-value of the named option (all options)
static OptionsCont & getOptions()
Retrieves the options.
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
Definition OptionsIO.cpp:58
bool hasParameter(const std::string &key) const
Returns whether the parameter is set.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimensions
Definition Position.h:266
void setz(double z)
set position z
Definition Position.h:80
A list of positions.
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...
virtual double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
Representation of a vehicle.
Definition SUMOVehicle.h:62
virtual void setChosenSpeedFactor(const double factor)=0
Structure representing possible vehicle parameter.
std::string id
The vehicle's id.
bool hasNext()
returns the information whether further substrings exist
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
static void close()
Closes all of an applications subsystems.
static void init()
Initialises the xml-subsystem.
Definition XMLSubSys.cpp:56
static double getDrivingDistance(std::pair< const MSLane *, double > &roadPos1, std::pair< const MSLane *, double > &roadPos2)
Definition Helper.cpp:455
static TraCIPosition makeTraCIPosition(const Position &position, const bool includeZ=false)
Definition Helper.cpp:377
static void clearStateChanges()
Definition Helper.cpp:719
static void subscribe(const int commandId, const std::string &id, const std::vector< int > &variables, const double beginTime, const double endTime, const libsumo::TraCIResults &params, const int contextDomain=0, const double range=0.)
Definition Helper.cpp:109
static const std::vector< std::string > & getTransportableStateChanges(const MSNet::TransportableState state)
Definition Helper.cpp:713
static void clearSubscriptions()
Definition Helper.cpp:203
static std::pair< MSLane *, double > convertCartesianToRoadMap(const Position &pos, const SUMOVehicleClass vClass)
Definition Helper.cpp:420
static const std::vector< std::string > & getVehicleStateChanges(const MSNet::VehicleState state)
Definition Helper.cpp:707
static void handleSubscriptions(const SUMOTime t)
Definition Helper.cpp:153
static const MSLane * getLaneChecking(const std::string &edgeID, int laneIndex, double pos)
Definition Helper.cpp:403
virtual std::string readString()
Definition storage.cpp:180
virtual int readUnsignedByte()
Definition storage.cpp:155
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int VAR_MIN_EXPECTED_VEHICLES
TRACI_CONST int VAR_STOP_ENDING_VEHICLES_IDS
TRACI_CONST int CMD_SUBSCRIBE_SIM_VARIABLE
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 VAR_COLLIDING_VEHICLES_NUMBER
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
Definition TraCIDefs.h:338
TRACI_CONST int VAR_PARKING_ENDING_VEHICLES_IDS
TRACI_CONST int VAR_PARKING_STARTING_VEHICLES_IDS
TRACI_CONST int VAR_DEPARTED_PERSONS_NUMBER
TRACI_CONST int VAR_END
TRACI_CONST int VAR_ARRIVED_PERSONS_IDS
TRACI_CONST int ROUTING_MODE_AGGREGATED
TRACI_CONST int VAR_TIME
TRACI_CONST int VAR_PENDING_VEHICLES
TRACI_CONST int VAR_BUS_STOP_ID_LIST
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition TraCIDefs.h:337
TRACI_CONST int TRACI_VERSION
TRACI_CONST int VAR_EMERGENCYSTOPPING_VEHICLES_IDS
TRACI_CONST int VAR_BUS_STOP_WAITING_IDS
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int VAR_DEPARTED_VEHICLES_IDS
TRACI_CONST int VAR_TELEPORT_ENDING_VEHICLES_NUMBER
TRACI_CONST int VAR_PARKING_ENDING_VEHICLES_NUMBER
TRACI_CONST int VAR_LOADED_VEHICLES_IDS
TRACI_CONST int VAR_DELTA_T
TRACI_CONST int STAGE_WALKING
TRACI_CONST int VAR_PARAMETER_WITH_KEY
TRACI_CONST int VAR_DEPARTED_PERSONS_IDS
TRACI_CONST int VAR_ARRIVED_PERSONS_NUMBER
TRACI_CONST int VAR_STOP_STARTING_VEHICLES_IDS
TRACI_CONST int VAR_STOP_ENDING_VEHICLES_NUMBER
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 VAR_BUS_STOP_WAITING
TRACI_CONST int VAR_TIME_STEP
TRACI_CONST int VAR_ARRIVED_VEHICLES_IDS
TRACI_CONST int STAGE_DRIVING
TRACI_CONST int VAR_PARKING_STARTING_VEHICLES_NUMBER
TRACI_CONST int VAR_EMERGENCYSTOPPING_VEHICLES_NUMBER
std::map< int, std::shared_ptr< libsumo::TraCIResult > > TraCIResults
{variable->value}
Definition TraCIDefs.h:335
TRACI_CONST int VAR_OPTION
collision tracking
Definition MSNet.h:114
std::string lane
The lane where the collision happended.
Definition TraCIDefs.h:643
std::string type
The type of collision.
Definition TraCIDefs.h:641
std::string collider
The ids of the participating vehicles and persons.
Definition TraCIDefs.h:634
double pos
The position of the collision along the lane.
Definition TraCIDefs.h:645
std::string colliderType
Definition TraCIDefs.h:636