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