Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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-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/****************************************************************************/
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>
54#include <mesosim/MELoop.h>
55#include <mesosim/MESegment.h>
56#include <netload/NLBuilder.h>
57#include <libsumo/Helper.h>
60#ifdef HAVE_LIBSUMOGUI
61#include "GUI.h"
62#endif
63#include "Simulation.h"
64#include <libsumo/TraCIDefs.h>
65
66
67namespace libsumo {
68// ===========================================================================
69// static member initializations
70// ===========================================================================
71SubscriptionResults Simulation::mySubscriptionResults;
72ContextSubscriptionResults Simulation::myContextSubscriptionResults;
73#ifdef HAVE_FOX
74FXMutex Simulation::myStepMutex;
75#endif
76
77
78// ===========================================================================
79// static member definitions
80// ===========================================================================
81std::pair<int, std::string>
82Simulation::init(int /* port */, int /* numRetries */, const std::string& /* host */, const std::string& /* label */, FILE* const /* pipe */) {
83 throw TraCIException("Multi client support (including connection switching) is not implemented in libsumo.");
84}
85
86
87std::pair<int, std::string>
88Simulation::start(const std::vector<std::string>& cmd, int /* port */, int /* numRetries */, const std::string& /* label */, const bool /* verbose */,
89 const std::string& /* traceFile */, bool /* traceGetters */, void* /* _stdout */) {
90#ifdef HAVE_LIBSUMOGUI
91 if (GUI::start(cmd)) {
92 return getVersion();
93 }
94#endif
95 load(std::vector<std::string>(cmd.begin() + 1, cmd.end()));
96 return getVersion();
97}
98
99
100bool
101Simulation::isLibsumo() {
102 return true;
103}
104
105
106void
107Simulation::switchConnection(const std::string& /* label */) {
108 throw TraCIException("Multi client support (including connection switching) is not implemented in libsumo.");
109}
110
111
112const std::string&
113Simulation::getLabel() {
114 throw TraCIException("Multi client support (including connection switching) is not implemented in libsumo.");
115}
116
117
118void
119Simulation::setOrder(int /* order */) {
120 throw TraCIException("Multi client support (including connection switching) is not implemented in libsumo.");
121}
122
123
124void
125Simulation::load(const std::vector<std::string>& args) {
126#ifdef HAVE_LIBSUMOGUI
127 if (GUI::load(args)) {
128 return;
129 }
130#endif
131 close("Libsumo issued load command.");
132 try {
133 OptionsCont::getOptions().setApplicationName("libsumo", "Eclipse SUMO libsumo Version " VERSION_STRING);
134 gSimulation = true;
136 OptionsIO::setArgs(args);
137 if (NLBuilder::init(true) != nullptr) {
138 const SUMOTime begin = string2time(OptionsCont::getOptions().getString("begin"));
139 MSNet::getInstance()->setCurrentTimeStep(begin); // needed for state loading
140 WRITE_MESSAGEF(TL("Simulation version % started via libsumo with time: %."), VERSION_STRING, time2string(begin));
141 }
142 } catch (ProcessError& e) {
143 throw TraCIException(e.what());
144 }
145}
146
147
148bool
149Simulation::hasGUI() {
150#ifdef HAVE_LIBSUMOGUI
151 return GUI::hasInstance();
152#else
153 return false;
154#endif
155}
156
157
158bool
159Simulation::isLoaded() {
160 return MSNet::hasInstance();
161}
162
163
164void
165Simulation::step(const double time) {
166#ifdef HAVE_FOX
167 FXMutexLock lock(myStepMutex);
168#endif
170 const SUMOTime t = TIME2STEPS(time);
171#ifdef HAVE_LIBSUMOGUI
172 if (!GUI::step(t)) {
173#endif
174 if (t == 0) {
176 } else {
177 while (SIMSTEP < t) {
179 }
180 }
181#ifdef HAVE_LIBSUMOGUI
182 }
183#endif
185}
186
187
188void
189Simulation::executeMove() {
191}
192
193
194void
195Simulation::close(const std::string& reason) {
197 if (
198#ifdef HAVE_LIBSUMOGUI
199 !GUI::close(reason) &&
200#endif
203 delete MSNet::getInstance();
205 }
206}
207
208
209void
210Simulation::subscribe(const std::vector<int>& varIDs, double begin, double end, const libsumo::TraCIResults& parameters) {
211 libsumo::Helper::subscribe(CMD_SUBSCRIBE_SIM_VARIABLE, "", varIDs, begin, end, parameters);
212}
213
214
215const TraCIResults
216Simulation::getSubscriptionResults() {
217 return mySubscriptionResults[""];
218}
219
220
222
223
224std::pair<int, std::string>
225Simulation::getVersion() {
226 return std::make_pair(libsumo::TRACI_VERSION, "SUMO " VERSION_STRING);
227}
228
229
230std::string
231Simulation::getOption(const std::string& option) {
233 if (!oc.exists(option)) {
234 throw TraCIException("The option " + option + " is unknown.");
235 }
236 return oc.getValueString(option);
237}
238
239
240int
241Simulation::getCurrentTime() {
242 return (int)MSNet::getInstance()->getCurrentTimeStep();
243}
244
245
246double
247Simulation::getTime() {
248 return SIMTIME;
249}
250
251double
252Simulation::getEndTime() {
253 return STEPS2TIME(string2time(OptionsCont::getOptions().getString("end")));
254}
255
256
257int
258Simulation::getLoadedNumber() {
260}
261
262
263std::vector<std::string>
264Simulation::getLoadedIDList() {
266}
267
268
269int
270Simulation::getDepartedNumber() {
272}
273
274
275std::vector<std::string>
276Simulation::getDepartedIDList() {
278}
279
280
281int
282Simulation::getArrivedNumber() {
284}
285
286
287std::vector<std::string>
288Simulation::getArrivedIDList() {
290}
291
292
293int
294Simulation::getParkingStartingVehiclesNumber() {
296}
297
298
299std::vector<std::string>
300Simulation::getParkingStartingVehiclesIDList() {
302}
303
304
305int
306Simulation::getParkingEndingVehiclesNumber() {
308}
309
310
311std::vector<std::string>
312Simulation::getParkingEndingVehiclesIDList() {
314}
315
316
317int
318Simulation::getStopStartingVehiclesNumber() {
320}
321
322
323std::vector<std::string>
324Simulation::getStopStartingVehiclesIDList() {
326}
327
328
329int
330Simulation::getStopEndingVehiclesNumber() {
332}
333
334
335std::vector<std::string>
336Simulation::getStopEndingVehiclesIDList() {
338}
339
340
341int
342Simulation::getCollidingVehiclesNumber() {
344}
345
346
347std::vector<std::string>
348Simulation::getCollidingVehiclesIDList() {
350}
351
352
353int
354Simulation::getEmergencyStoppingVehiclesNumber() {
356}
357
358
359std::vector<std::string>
360Simulation::getEmergencyStoppingVehiclesIDList() {
362}
363
364
365int
366Simulation::getStartingTeleportNumber() {
368}
369
370
371std::vector<std::string>
372Simulation::getStartingTeleportIDList() {
374}
375
376
377int
378Simulation::getEndingTeleportNumber() {
380}
381
382
383std::vector<std::string>
384Simulation::getEndingTeleportIDList() {
386}
387
388int
389Simulation::getDepartedPersonNumber() {
391}
392
393
394std::vector<std::string>
395Simulation::getDepartedPersonIDList() {
397}
398
399
400int
401Simulation::getArrivedPersonNumber() {
403}
404
405
406std::vector<std::string>
407Simulation::getArrivedPersonIDList() {
409}
410
411std::vector<std::string>
412Simulation::getBusStopIDList() {
413 std::vector<std::string> result;
414 for (const auto& pair : MSNet::getInstance()->getStoppingPlaces(SUMO_TAG_BUS_STOP)) {
415 result.push_back(pair.first);
416 }
417 return result;
418}
419
420int
421Simulation::getBusStopWaiting(const std::string& stopID) {
423 if (s == nullptr) {
424 throw TraCIException("Unknown bus stop '" + stopID + "'.");
425 }
426 return s->getTransportableNumber();
427}
428
429std::vector<std::string>
430Simulation::getBusStopWaitingIDList(const std::string& stopID) {
432 if (s == nullptr) {
433 throw TraCIException("Unknown bus stop '" + stopID + "'.");
434 }
435 std::vector<std::string> result;
436 for (const MSTransportable* t : s->getTransportables()) {
437 result.push_back(t->getID());
438 }
439 return result;
440}
441
442
443std::vector<std::string>
444Simulation::getPendingVehicles() {
445 std::vector<std::string> result;
447 result.push_back(veh->getID());
448 }
449 return result;
450}
451
452
453std::vector<libsumo::TraCICollision>
454Simulation::getCollisions() {
455 std::vector<libsumo::TraCICollision> result;
456 for (auto item : MSNet::getInstance()->getCollisions()) {
457 for (const MSNet::Collision& c : item.second) {
459 c2.collider = item.first;
460 c2.victim = c.victim;
461 c2.colliderType = c.colliderType;
462 c2.victimType = c.victimType;
463 c2.colliderSpeed = c.colliderSpeed;
464 c2.victimSpeed = c.victimSpeed;
465 c2.type = c.type;
466 c2.lane = c.lane->getID();
467 c2.pos = c.pos;
468 result.push_back(c2);
469 }
470 }
471 return result;
472}
473
474double
475Simulation::getScale() {
477}
478
479double
480Simulation::getDeltaT() {
481 return TS;
482}
483
484
485TraCIPositionVector
486Simulation::getNetBoundary() {
488 TraCIPositionVector tb;
489 TraCIPosition minV;
490 TraCIPosition maxV;
491 minV.x = b.xmin();
492 maxV.x = b.xmax();
493 minV.y = b.ymin();
494 maxV.y = b.ymax();
495 minV.z = b.zmin();
496 maxV.z = b.zmax();
497 tb.value.push_back(minV);
498 tb.value.push_back(maxV);
499 return tb;
500}
501
502
503int
504Simulation::getMinExpectedNumber() {
505 MSNet* net = MSNet::getInstance();
508 + (net->hasPersons() ? net->getPersonControl().getActiveCount() : 0)
509 + (net->hasContainers() ? net->getContainerControl().getActiveCount() : 0)
511}
512
513
514TraCIPosition
515Simulation::convert2D(const std::string& edgeID, double pos, int laneIndex, bool toGeo) {
516 Position result = Helper::getLaneChecking(edgeID, laneIndex, pos)->geometryPositionAtOffset(pos);
517 if (toGeo) {
519 }
520 result.setz(0.);
521 return Helper::makeTraCIPosition(result);
522}
523
524
525TraCIPosition
526Simulation::convert3D(const std::string& edgeID, double pos, int laneIndex, bool toGeo) {
527 Position result = Helper::getLaneChecking(edgeID, laneIndex, pos)->geometryPositionAtOffset(pos);
528 if (toGeo) {
530 }
531 return Helper::makeTraCIPosition(result, true);
532}
533
534
535TraCIRoadPosition
536Simulation::convertRoad(double x, double y, bool isGeo, const std::string& vClass) {
537 Position pos(x, y);
538 if (isGeo) {
540 }
541 if (!SumoVehicleClassStrings.hasString(vClass)) {
542 throw TraCIException("Unknown vehicle class '" + vClass + "'.");
543 }
544 const SUMOVehicleClass vc = SumoVehicleClassStrings.get(vClass);
545 std::pair<MSLane*, double> roadPos = libsumo::Helper::convertCartesianToRoadMap(pos, vc);
546 if (roadPos.first == nullptr) {
547 throw TraCIException("Cannot convert position to road.");
548 }
549 TraCIRoadPosition result;
550 result.edgeID = roadPos.first->getEdge().getID();
551 result.laneIndex = roadPos.first->getIndex();
552 result.pos = roadPos.second;
553 return result;
554}
555
556
557TraCIPosition
558Simulation::convertGeo(double x, double y, bool fromGeo) {
559 Position pos(x, y);
560 if (fromGeo) {
562 } else {
564 }
565 return Helper::makeTraCIPosition(pos);
566}
567
568
569double
570Simulation::getDistance2D(double x1, double y1, double x2, double y2, bool isGeo, bool isDriving) {
571 Position pos1(x1, y1);
572 Position pos2(x2, y2);
573 if (isGeo) {
576 }
577 if (isDriving) {
578 std::pair<const MSLane*, double> roadPos1 = libsumo::Helper::convertCartesianToRoadMap(pos1, SVC_IGNORING);
579 std::pair<const MSLane*, double> roadPos2 = libsumo::Helper::convertCartesianToRoadMap(pos2, SVC_IGNORING);
580 return Helper::getDrivingDistance(roadPos1, roadPos2);
581 } else {
582 return pos1.distanceTo(pos2);
583 }
584}
585
586
587double
588Simulation::getDistanceRoad(const std::string& edgeID1, double pos1, const std::string& edgeID2, double pos2, bool isDriving) {
589 std::pair<const MSLane*, double> roadPos1 = std::make_pair(libsumo::Helper::getLaneChecking(edgeID1, 0, pos1), pos1);
590 std::pair<const MSLane*, double> roadPos2 = std::make_pair(libsumo::Helper::getLaneChecking(edgeID2, 0, pos2), pos2);
591 if (isDriving) {
592 return Helper::getDrivingDistance(roadPos1, roadPos2);
593 } else {
594 const Position p1 = roadPos1.first->geometryPositionAtOffset(roadPos1.second);
595 const Position p2 = roadPos2.first->geometryPositionAtOffset(roadPos2.second);
596 return p1.distanceTo(p2);
597 }
598}
599
600
601TraCIStage
602Simulation::findRoute(const std::string& from, const std::string& to, const std::string& typeID, const double depart, const int routingMode) {
603 TraCIStage result(STAGE_DRIVING);
604 const MSEdge* const fromEdge = MSEdge::dictionary(from);
605 if (fromEdge == nullptr) {
606 throw TraCIException("Unknown from edge '" + from + "'.");
607 }
608 const MSEdge* const toEdge = MSEdge::dictionary(to);
609 if (toEdge == nullptr) {
610 throw TraCIException("Unknown to edge '" + to + "'.");
611 }
612 MSBaseVehicle* vehicle = nullptr;
613 MSVehicleType* type = MSNet::getInstance()->getVehicleControl().getVType(typeID == "" ? DEFAULT_VTYPE_ID : typeID);
614 if (type == nullptr) {
615 throw TraCIException("The vehicle type '" + typeID + "' is not known.");
616 }
618 pars->id = "simulation.findRoute";
619 try {
620 ConstMSRoutePtr const routeDummy = std::make_shared<MSRoute>("", ConstMSEdgeVector({ fromEdge }), false, nullptr, std::vector<SUMOVehicleParameter::Stop>());
621 vehicle = dynamic_cast<MSBaseVehicle*>(MSNet::getInstance()->getVehicleControl().buildVehicle(pars, routeDummy, type, false));
622 std::string msg;
623 if (!vehicle->hasValidRouteStart(msg)) {
626 throw TraCIException("Invalid departure edge for vehicle type '" + type->getID() + "' (" + msg + ")");
627 }
628 // we need to fix the speed factor here for deterministic results
629 vehicle->setChosenSpeedFactor(type->getSpeedFactor().getParameter()[0]);
630 vehicle->setRoutingMode(routingMode);
631 } catch (ProcessError& e) {
632 throw TraCIException("Invalid departure edge for vehicle type '" + type->getID() + "' (" + e.what() + ")");
633 }
634 ConstMSEdgeVector edges;
635 const SUMOTime dep = depart < 0 ? MSNet::getInstance()->getCurrentTimeStep() : TIME2STEPS(depart);
637 router.compute(fromEdge, toEdge, vehicle, dep, edges);
638 for (const MSEdge* e : edges) {
639 result.edges.push_back(e->getID());
640 }
641 result.travelTime = result.cost = router.recomputeCosts(edges, vehicle, dep, &result.length);
642 if (vehicle != nullptr) {
645 }
646 return result;
647}
648
649
650std::vector<TraCIStage>
651Simulation::findIntermodalRoute(const std::string& from, const std::string& to,
652 const std::string& modes, double depart, const int routingMode, double speed, double walkFactor,
653 double departPos, double arrivalPos, const double departPosLat,
654 const std::string& pType, const std::string& vType, const std::string& destStop) {
655 UNUSED_PARAMETER(departPosLat);
656 std::vector<TraCIStage> result;
657 const MSEdge* const fromEdge = MSEdge::dictionary(from);
658 if (fromEdge == nullptr) {
659 throw TraCIException("Unknown from edge '" + from + "'.");
660 }
661 const MSEdge* const toEdge = MSEdge::dictionary(to);
662 if (toEdge == nullptr) {
663 throw TraCIException("Unknown to edge '" + to + "'.");
664 }
666 SVCPermissions modeSet = 0;
667 std::vector<SUMOVehicleParameter*> pars;
668 if (vType != "") {
669 pars.push_back(new SUMOVehicleParameter());
670 pars.back()->vtypeid = vType;
671 pars.back()->id = vType;
672 modeSet |= SVC_PASSENGER;
673 }
674 for (StringTokenizer st(modes); st.hasNext();) {
675 const std::string mode = st.next();
676 if (mode == toString(PersonMode::CAR)) {
677 pars.push_back(new SUMOVehicleParameter());
678 pars.back()->vtypeid = DEFAULT_VTYPE_ID;
679 pars.back()->id = mode;
680 modeSet |= SVC_PASSENGER;
681 } else if (mode == toString(PersonMode::BICYCLE)) {
682 pars.push_back(new SUMOVehicleParameter());
683 pars.back()->vtypeid = DEFAULT_BIKETYPE_ID;
684 pars.back()->id = mode;
685 modeSet |= SVC_BICYCLE;
686 } else if (mode == toString(PersonMode::TAXI)) {
687 pars.push_back(new SUMOVehicleParameter());
688 pars.back()->vtypeid = DEFAULT_TAXITYPE_ID;
689 pars.back()->id = mode;
690 pars.back()->line = mode;
691 modeSet |= SVC_TAXI;
692 } else if (mode == toString(PersonMode::PUBLIC)) {
693 pars.push_back(nullptr);
694 modeSet |= SVC_BUS;
695 } else if (mode == toString(PersonMode::WALK)) {
696 // do nothing
697 } else {
698 throw TraCIException("Unknown person mode '" + mode + "'.");
699 }
700 }
701 if (pars.empty()) {
702 pars.push_back(nullptr);
703 }
704 // interpret default arguments
705 const MSVehicleType* pedType = vehControl.hasVType(pType) ? vehControl.getVType(pType) : vehControl.getVType(DEFAULT_PEDTYPE_ID);
706 SUMOTime departStep = TIME2STEPS(depart);
707 if (depart < 0) {
708 departStep = MSNet::getInstance()->getCurrentTimeStep();
709 }
710 if (speed < 0) {
711 speed = MIN2(pedType->getMaxSpeed(), pedType->getDesiredMaxSpeed());
712 }
713 if (walkFactor < 0) {
714 walkFactor = OptionsCont::getOptions().getFloat("persontrip.walkfactor");
715 }
716 const double externalFactor = StringUtils::toDouble(pedType->getParameter().getParameter("externalEffortFactor", "100"));
717 if (departPos < 0) {
718 departPos += fromEdge->getLength();
719 }
720 if (arrivalPos == INVALID_DOUBLE_VALUE) {
721 arrivalPos = toEdge->getLength() / 2;
722 } else if (arrivalPos < 0) {
723 arrivalPos += toEdge->getLength();
724 }
725 if (departPos < 0 || departPos >= fromEdge->getLength()) {
726 throw TraCIException("Invalid depart position " + toString(departPos) + " for edge '" + from + "'.");
727 }
728 if (arrivalPos < 0 || arrivalPos >= toEdge->getLength()) {
729 throw TraCIException("Invalid arrival position " + toString(arrivalPos) + " for edge '" + to + "'.");
730 }
731 double minCost = std::numeric_limits<double>::max();
733 for (SUMOVehicleParameter* vehPar : pars) {
734 std::vector<TraCIStage> resultCand;
735 SUMOVehicle* vehicle = nullptr;
736 if (vehPar != nullptr) {
737 MSVehicleType* type = MSNet::getInstance()->getVehicleControl().getVType(vehPar->vtypeid);
738 const bool isTaxi = type != nullptr && type->getID() == DEFAULT_TAXITYPE_ID && vehPar->line == "taxi";
739 if (type == nullptr) {
740 throw TraCIException("Unknown vehicle type '" + vehPar->vtypeid + "'.");
741 }
742 if (type->getVehicleClass() != SVC_IGNORING && (fromEdge->getPermissions() & type->getVehicleClass()) == 0 && !isTaxi) {
743 WRITE_WARNINGF(TL("Ignoring vehicle type '%' when performing intermodal routing because it is not allowed on the start edge '%'."), type->getID(), from);
744 } else {
745 ConstMSRoutePtr const routeDummy = std::make_shared<MSRoute>(vehPar->id, ConstMSEdgeVector({ fromEdge }), false, nullptr, std::vector<SUMOVehicleParameter::Stop>());
746 vehicle = vehControl.buildVehicle(vehPar, routeDummy, type, !MSGlobals::gCheckRoutes);
747 // we need to fix the speed factor here for deterministic results
748 vehicle->setChosenSpeedFactor(type->getSpeedFactor().getParameter()[0]);
749 }
750 }
751 std::vector<MSTransportableRouter::TripItem> items;
752 if (router.compute(fromEdge, toEdge, departPos, "", arrivalPos, destStop,
753 speed * walkFactor, vehicle, modeSet, departStep, items, externalFactor)) {
754 double cost = 0;
755 for (std::vector<MSTransportableRouter::TripItem>::iterator it = items.begin(); it != items.end(); ++it) {
756 if (!it->edges.empty()) {
757 resultCand.push_back(TraCIStage((it->line == "" ? STAGE_WALKING : STAGE_DRIVING), it->vType, it->line, it->destStop));
758 for (const MSEdge* e : it->edges) {
759 resultCand.back().edges.push_back(e->getID());
760 }
761 resultCand.back().travelTime = it->traveltime;
762 resultCand.back().cost = it->cost;
763 resultCand.back().length = it->length;
764 resultCand.back().intended = it->intended;
765 resultCand.back().depart = it->depart;
766 resultCand.back().departPos = it->departPos;
767 resultCand.back().arrivalPos = it->arrivalPos;
768 resultCand.back().description = it->description;
769 }
770 cost += it->cost;
771 }
772 if (cost < minCost) {
773 minCost = cost;
774 result = resultCand;
775 }
776 }
777 if (vehicle != nullptr) {
778 vehControl.deleteVehicle(vehicle, true);
779 vehControl.discountRoutingVehicle();
780 }
781 }
782 return result;
783}
784
785
786std::string
787Simulation::getParameter(const std::string& objectID, const std::string& key) {
788 if (StringUtils::startsWith(key, "chargingStation.")) {
789 const std::string attrName = key.substr(16);
791 if (cs == nullptr) {
792 throw TraCIException("Invalid chargingStation '" + objectID + "'");
793 }
794 if (attrName == toString(SUMO_ATTR_TOTALENERGYCHARGED)) {
795 return toString(cs->getTotalCharged());
796 } else if (attrName == toString(SUMO_ATTR_NAME)) {
797 return toString(cs->getMyName());
798 } else if (attrName == "lane") {
799 return cs->getLane().getID();
800 } else if (cs->hasParameter(attrName)) {
801 return cs->getParameter(attrName);
802 } else {
803 throw TraCIException("Invalid chargingStation parameter '" + attrName + "'");
804 }
805 } else if (StringUtils::startsWith(key, "overheadWire.")) {
806 const std::string attrName = key.substr(16);
808 if (cs == 0) {
809 throw TraCIException("Invalid overhead wire '" + objectID + "'");
810 }
811 if (attrName == toString(SUMO_ATTR_TOTALENERGYCHARGED)) {
812 return toString(cs->getTotalCharged());
813 } else if (attrName == toString(SUMO_ATTR_NAME)) {
814 return toString(cs->getMyName());
815 } else {
816 throw TraCIException("Invalid overhead wire parameter '" + attrName + "'");
817 }
818 } else if (StringUtils::startsWith(key, "net.")) {
819 const std::string attrName = key.substr(4);
820 if (attrName == toString(SUMO_ATTR_NET_OFFSET)) {
821 return toString(GeoConvHelper::getFinal().getOffsetBase());
822 } else {
823 throw TraCIException("Invalid net parameter '" + attrName + "'");
824 }
825 } else if (StringUtils::startsWith(key, "stats.")) {
826 if (objectID != "") {
827 throw TraCIException("Simulation parameter '" + key + "' is not supported for object id '" + objectID + "'. Use empty id for stats");
828 }
829 const std::string attrName = key.substr(6);
832 if (attrName == "vehicles.loaded") {
833 return toString(vc.getLoadedVehicleNo());
834 } else if (attrName == "vehicles.inserted") {
835 return toString(vc.getDepartedVehicleNo());
836 } else if (attrName == "vehicles.running") {
837 return toString(vc.getRunningVehicleNo());
838 } else if (attrName == "vehicles.waiting") {
839 return toString(MSNet::getInstance()->getInsertionControl().getWaitingVehicleNo());
840 } else if (attrName == "teleports.total") {
841 return toString(vc.getTeleportCount());
842 } else if (attrName == "teleports.jam") {
843 return toString(vc.getTeleportsJam());
844 } else if (attrName == "teleports.yield") {
845 return toString(vc.getTeleportsYield());
846 } else if (attrName == "teleports.wrongLane") {
847 return toString(vc.getTeleportsWrongLane());
848 } else if (attrName == "safety.collisions") {
849 return toString(vc.getCollisionCount());
850 } else if (attrName == "safety.emergencyStops") {
851 return toString(vc.getEmergencyStops());
852 } else if (attrName == "safety.emergencyBraking") {
854 } else if (attrName == "persons.loaded") {
855 return toString(pc != nullptr ? pc->getLoadedNumber() : 0);
856 } else if (attrName == "persons.running") {
857 return toString(pc != nullptr ? pc->getRunningNumber() : 0);
858 } else if (attrName == "persons.jammed") {
859 return toString(pc != nullptr ? pc->getJammedNumber() : 0);
860 } else if (attrName == "personTeleports.total") {
861 return toString(pc != nullptr ? pc->getTeleportCount() : 0);
862 } else if (attrName == "personTeleports.abortWait") {
863 return toString(pc != nullptr ? pc->getTeleportsAbortWait() : 0);
864 } else if (attrName == "personTeleports.wrongDest") {
865 return toString(pc != nullptr ? pc->getTeleportsWrongDest() : 0);
866 } else {
867 throw TraCIException("Invalid stats parameter '" + attrName + "'");
868 }
869 } else if (StringUtils::startsWith(key, "parkingArea.")) {
870 const std::string attrName = key.substr(12);
872 if (pa == nullptr) {
873 throw TraCIException("Invalid parkingArea '" + objectID + "'");
874 }
875 if (attrName == "capacity") {
876 return toString(pa->getCapacity());
877 } else if (attrName == "occupancy") {
879 } else if (attrName == toString(SUMO_ATTR_NAME)) {
880 return toString(pa->getMyName());
881 } else if (attrName == "lane") {
882 return pa->getLane().getID();
883 } else if (pa->hasParameter(attrName)) {
884 return pa->getParameter(attrName);
885 } else {
886 throw TraCIException("Invalid parkingArea parameter '" + attrName + "'");
887 }
888 } else if (StringUtils::startsWith(key, "busStop.")) {
889 const std::string attrName = key.substr(8);
891 if (bs == nullptr) {
892 throw TraCIException("Invalid busStop '" + objectID + "'");
893 }
894 if (attrName == toString(SUMO_ATTR_NAME)) {
895 return toString(bs->getMyName());
896 } else if (attrName == "lane") {
897 return bs->getLane().getID();
898 } else if (bs->hasParameter(attrName)) {
899 return bs->getParameter(attrName);
900 } else {
901 throw TraCIException("Invalid busStop parameter '" + attrName + "'");
902 }
903 } else if (StringUtils::startsWith(key, "device.tripinfo.")) {
904 if (objectID != "") {
905 throw TraCIException("Simulation parameter '" + key + "' is not supported for object id '" + objectID
906 + "'. Use empty id for global device parameers or vehicle domain for vehicle specific parameters");
907 }
908 const std::string attrName = key.substr(16);
910 } else if (objectID == "") {
911 return MSNet::getInstance()->getParameter(key, "");
912 } else {
913 throw TraCIException("Simulation parameter '" + key + "' is not supported for object id '" + objectID + "'. Use empty id for generic network parameters");
914 }
915}
916
918
919void
920Simulation::setParameter(const std::string& objectID, const std::string& key, const std::string& value) {
921 if (objectID == "") {
922 MSNet::getInstance()->setParameter(key, value);
923 } else {
924 throw TraCIException("Setting simulation parameter '" + key + "' is not supported for object id '" + objectID + "'. Use empty id for generic network parameters");
925 }
926}
927
928void
929Simulation::setScale(double value) {
931}
932
933void
934Simulation::clearPending(const std::string& routeID) {
936}
937
938
939void
940Simulation::saveState(const std::string& fileName) {
941 MSStateHandler::saveState(fileName, MSNet::getInstance()->getCurrentTimeStep());
942}
943
944double
945Simulation::loadState(const std::string& fileName) {
946 long before = PROGRESS_BEGIN_TIME_MESSAGE("Loading state from '" + fileName + "'");
947 try {
948 const SUMOTime newTime = MSNet::getInstance()->loadState(fileName, false);
951 PROGRESS_TIME_MESSAGE(before);
952 return STEPS2TIME(newTime);
953 } catch (const IOError& e) {
954 throw TraCIException("Loading state from '" + fileName + "' failed. " + e.what());
955 } catch (const ProcessError& e) {
956 throw TraCIException("Loading state from '" + fileName + "' failed, check whether SUMO versions match. " + e.what());
957 }
958}
959
960void
961Simulation::writeMessage(const std::string& msg) {
962 WRITE_MESSAGE(msg);
963}
964
965
966void
967Simulation::storeShape(PositionVector& shape) {
969}
970
971
972std::shared_ptr<VariableWrapper>
973Simulation::makeWrapper() {
974 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
975}
976
977
978bool
979Simulation::handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper, tcpip::Storage* paramData) {
980 switch (variable) {
981 case VAR_TIME:
982 return wrapper->wrapDouble(objID, variable, getTime());
983 case VAR_TIME_STEP:
984 return wrapper->wrapInt(objID, variable, (int)getCurrentTime());
985 case VAR_END:
986 return wrapper->wrapDouble(objID, variable, getEndTime());
988 return wrapper->wrapInt(objID, variable, getLoadedNumber());
990 return wrapper->wrapStringList(objID, variable, getLoadedIDList());
992 return wrapper->wrapInt(objID, variable, getDepartedNumber());
994 return wrapper->wrapStringList(objID, variable, getDepartedIDList());
996 return wrapper->wrapInt(objID, variable, getStartingTeleportNumber());
998 return wrapper->wrapStringList(objID, variable, getStartingTeleportIDList());
1000 return wrapper->wrapInt(objID, variable, getEndingTeleportNumber());
1002 return wrapper->wrapStringList(objID, variable, getEndingTeleportIDList());
1004 return wrapper->wrapInt(objID, variable, getArrivedNumber());
1006 return wrapper->wrapStringList(objID, variable, getArrivedIDList());
1008 return wrapper->wrapInt(objID, variable, getParkingStartingVehiclesNumber());
1010 return wrapper->wrapStringList(objID, variable, getParkingStartingVehiclesIDList());
1012 return wrapper->wrapInt(objID, variable, getParkingEndingVehiclesNumber());
1014 return wrapper->wrapStringList(objID, variable, getParkingEndingVehiclesIDList());
1016 return wrapper->wrapInt(objID, variable, getStopStartingVehiclesNumber());
1018 return wrapper->wrapStringList(objID, variable, getStopStartingVehiclesIDList());
1020 return wrapper->wrapInt(objID, variable, getStopEndingVehiclesNumber());
1022 return wrapper->wrapStringList(objID, variable, getStopEndingVehiclesIDList());
1024 return wrapper->wrapInt(objID, variable, getCollidingVehiclesNumber());
1026 return wrapper->wrapStringList(objID, variable, getCollidingVehiclesIDList());
1028 return wrapper->wrapInt(objID, variable, getEmergencyStoppingVehiclesNumber());
1030 return wrapper->wrapStringList(objID, variable, getEmergencyStoppingVehiclesIDList());
1032 return wrapper->wrapInt(objID, variable, getDepartedPersonNumber());
1034 return wrapper->wrapStringList(objID, variable, getDepartedPersonIDList());
1036 return wrapper->wrapInt(objID, variable, getArrivedPersonNumber());
1038 return wrapper->wrapStringList(objID, variable, getArrivedPersonIDList());
1039 case VAR_SCALE:
1040 return wrapper->wrapDouble(objID, variable, getScale());
1041 case VAR_DELTA_T:
1042 return wrapper->wrapDouble(objID, variable, getDeltaT());
1043 case VAR_OPTION:
1044 return wrapper->wrapString(objID, variable, getOption(objID));
1046 return wrapper->wrapInt(objID, variable, getMinExpectedNumber());
1048 return wrapper->wrapStringList(objID, variable, getBusStopIDList());
1050 return wrapper->wrapInt(objID, variable, getBusStopWaiting(objID));
1052 return wrapper->wrapStringList(objID, variable, getBusStopWaitingIDList(objID));
1054 return wrapper->wrapStringList(objID, variable, getPendingVehicles());
1055 case VAR_PARAMETER:
1056 return wrapper->wrapString(objID, variable, getParameter(objID, StoHelp::readTypedString(*paramData)));
1058 return wrapper->wrapStringPair(objID, variable, getParameterWithKey(objID, StoHelp::readTypedString(*paramData)));
1059 default:
1060 return false;
1061 }
1062}
1063}
1064
1065
1066/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:288
#define WRITE_MESSAGEF(...)
Definition MsgHandler.h:290
#define WRITE_MESSAGE(msg)
Definition MsgHandler.h:289
#define PROGRESS_BEGIN_TIME_MESSAGE(msg)
Definition MsgHandler.h:293
#define TL(string)
Definition MsgHandler.h:305
#define PROGRESS_TIME_MESSAGE(before)
Definition MsgHandler.h:294
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:91
#define STEPS2TIME(x)
Definition SUMOTime.h:55
#define SIMSTEP
Definition SUMOTime.h:61
#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
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:77
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
Definition TraCIDefs.h:124
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
double ymin() const
Returns minimum y-coordinate.
Definition Boundary.cpp:127
double xmin() const
Returns minimum x-coordinate.
Definition Boundary.cpp:115
PositionVector getShape(const bool closeShape) const
get position vector (shape) based on this boundary
Definition Boundary.cpp:444
double zmin() const
Returns minimum z-coordinate.
Definition Boundary.cpp:139
double ymax() const
Returns maximum y-coordinate.
Definition Boundary.cpp:133
double xmax() const
Returns maximum x-coordinate.
Definition Boundary.cpp:121
double zmax() const
Returns maximum z-coordinate.
Definition Boundary.cpp:145
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 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 bool hasServableReservations()
check whether there are still (servable) reservations in the system
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:1712
@ 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:186
const CollisionMap & getCollisions() const
Definition MSNet.h:748
virtual MSTransportableControl & getContainerControl()
Returns the container control.
Definition MSNet.cpp:1210
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition MSNet.h:325
static bool hasInstance()
Returns whether the network was already constructed.
Definition MSNet.h:157
void closeSimulation(SUMOTime start, const std::string &reason="")
Closes the simulation (all files, connections, etc.)
Definition MSNet.cpp:687
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition MSNet.cpp:1404
void setCurrentTimeStep(const SUMOTime step)
Sets the current simulation step (used by state loading)
Definition MSNet.h:333
void simulationStep(const bool onlyMove=false)
Performs a single simulation step.
Definition MSNet.cpp:726
MSTransportableRouter & getIntermodalRouter(int rngIndex, const int routingMode=0, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition MSNet.cpp:1578
bool hasContainers() const
Returns whether containers are simulated.
Definition MSNet.h:416
bool hasPersons() const
Returns whether persons are simulated.
Definition MSNet.h:400
@ 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:436
MSVehicleRouter & getRouterTT(int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition MSNet.cpp:1531
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:383
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition MSNet.cpp:1201
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
Definition MSNet.cpp:1439
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:263
void setz(double z)
set position z
Definition Position.h:77
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:472
static TraCIPosition makeTraCIPosition(const Position &position, const bool includeZ=false)
Definition Helper.cpp:393
static void clearStateChanges()
Definition Helper.cpp:736
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:730
static void clearSubscriptions()
Definition Helper.cpp:222
static std::pair< MSLane *, double > convertCartesianToRoadMap(const Position &pos, const SUMOVehicleClass vClass)
Definition Helper.cpp:436
static const std::vector< std::string > & getVehicleStateChanges(const MSNet::VehicleState state)
Definition Helper.cpp:724
static void handleSubscriptions(const SUMOTime t)
Definition Helper.cpp:172
static const MSLane * getLaneChecking(const std::string &edgeID, int laneIndex, double pos)
Definition Helper.cpp:419
static std::string readTypedString(tcpip::Storage &ret, const std::string &error="")
#define UNUSED_PARAMETER(x)
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:379
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:378
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:376
TRACI_CONST int VAR_OPTION
collision tracking
Definition MSNet.h:114
std::string lane
The lane where the collision happended.
Definition TraCIDefs.h:840
std::string type
The type of collision.
Definition TraCIDefs.h:838
std::string collider
The ids of the participating vehicles and persons.
Definition TraCIDefs.h:831
double pos
The position of the collision along the lane.
Definition TraCIDefs.h:842
std::string colliderType
Definition TraCIDefs.h:833