Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
Helper.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
24#include <cstring>
27#include <microsim/MSNet.h>
31#include <microsim/MSEdge.h>
32#include <microsim/MSLane.h>
33#include <microsim/MSLink.h>
35#include <microsim/MSVehicle.h>
42#include <libsumo/TraCIDefs.h>
43#include <libsumo/BusStop.h>
44#include <libsumo/Calibrator.h>
46#include <libsumo/Edge.h>
47#ifdef HAVE_LIBSUMOGUI
48#include <libsumo/GUI.h>
49#endif
51#include <libsumo/Junction.h>
52#include <libsumo/Lane.h>
53#include <libsumo/LaneArea.h>
54#include <libsumo/MeanData.h>
57#include <libsumo/ParkingArea.h>
58#include <libsumo/Person.h>
59#include <libsumo/POI.h>
60#include <libsumo/Polygon.h>
61#include <libsumo/Rerouter.h>
62#include <libsumo/Route.h>
63#include <libsumo/RouteProbe.h>
64#include <libsumo/Simulation.h>
67#include <libsumo/Vehicle.h>
68#include <libsumo/VehicleType.h>
70#include "Helper.h"
71
72#define FAR_AWAY 1000.0
73
74//#define DEBUG_MOVEXY
75//#define DEBUG_MOVEXY_ANGLE
76//#define DEBUG_SURROUNDING
77
78namespace libsumo {
79// ===========================================================================
80// static member initializations
81// ===========================================================================
82std::vector<Subscription> Helper::mySubscriptions;
83Subscription* Helper::myLastContextSubscription = nullptr;
84std::map<int, std::shared_ptr<VariableWrapper> > Helper::myWrapper;
85Helper::VehicleStateListener Helper::myVehicleStateListener;
86Helper::TransportableStateListener Helper::myTransportableStateListener;
88std::map<std::string, MSVehicle*> Helper::myRemoteControlledVehicles;
89std::map<std::string, MSPerson*> Helper::myRemoteControlledPersons;
90
91
92// ===========================================================================
93// static member definitions
94// ===========================================================================
95
96void
98 if (veh != nullptr) {
99 if (veh->isVehicle()) {
100 std::cout << " '" << veh->getID() << "' on lane '" << ((SUMOVehicle*)veh)->getLane()->getID() << "'\n";
101 } else {
102 std::cout << " '" << veh->getID() << "' on edge '" << veh->getEdge()->getID() << "'\n";
103 }
104 }
105}
106
107
108void
109Helper::subscribe(const int commandId, const std::string& id, const std::vector<int>& variables,
110 const double beginTime, const double endTime, const libsumo::TraCIResults& params,
111 const int contextDomain, const double range) {
112 if (variables.empty()) {
113 for (std::vector<libsumo::Subscription>::iterator j = mySubscriptions.begin(); j != mySubscriptions.end();) {
114 if (j->id == id && j->commandId == commandId && j->contextDomain == contextDomain) {
116 } else {
117 ++j;
118 }
119 }
120 return;
121 }
123 std::vector<std::shared_ptr<tcpip::Storage> > parameters;
124 for (const int var : variables) {
125 const auto& p = params.find(var);
126 if (p == params.end()) {
127 parameters.push_back(std::make_shared<tcpip::Storage>());
128 } else {
129 parameters.push_back(libsumo::StorageHelper::toStorage(*p->second));
130 }
131 }
132 const SUMOTime begin = beginTime == INVALID_DOUBLE_VALUE ? 0 : TIME2STEPS(beginTime);
133 const SUMOTime end = endTime == INVALID_DOUBLE_VALUE || endTime > STEPS2TIME(SUMOTime_MAX) ? SUMOTime_MAX : TIME2STEPS(endTime);
134 libsumo::Subscription s(commandId, id, variables, parameters, begin, end, contextDomain, range);
135 if (commandId == libsumo::CMD_SUBSCRIBE_SIM_CONTEXT) {
136 s.range = std::numeric_limits<double>::max();
137 }
138 if (s.variables.size() == 1 && s.variables.front() == -1) {
139 if (contextDomain == 0) {
141 // default for vehicles is edge id and lane position
143 s.parameters.push_back(std::make_shared<tcpip::Storage>());
144 } else if (commandId == libsumo::CMD_SUBSCRIBE_EDGE_VARIABLE ||
149 // default for detectors, edges and lanes is vehicle number
151 } else {
152 // for all others id list
154 }
155 } else {
156 s.variables.clear();
157 s.parameters.clear();
158 }
159 }
161 libsumo::Subscription* modifiedSubscription = nullptr;
162 needNewSubscription(s, mySubscriptions, modifiedSubscription);
163 if (modifiedSubscription->isVehicleToVehicleContextSubscription()
164 || modifiedSubscription->isVehicleToPersonContextSubscription()) {
165 // Set last modified vehicle context subscription active for filter modifications
166 myLastContextSubscription = modifiedSubscription;
167 }
168}
169
170
171void
173 for (auto& wrapper : myWrapper) {
174 wrapper.second->clear();
175 }
176 for (std::vector<libsumo::Subscription>::iterator i = mySubscriptions.begin(); i != mySubscriptions.end();) {
177 const libsumo::Subscription& s = *i;
178 const bool isArrivedVehicle = (s.commandId == CMD_SUBSCRIBE_VEHICLE_VARIABLE || s.commandId == CMD_SUBSCRIBE_VEHICLE_CONTEXT)
182 && MSNet::getInstance()->getPersonControl().get(s.id) == nullptr;
183 if (s.endTime < t || isArrivedVehicle || isArrivedPerson) {
185 continue;
186 }
187 ++i;
188 }
189 for (const libsumo::Subscription& s : mySubscriptions) {
190 if (s.beginTime <= t) {
192 }
193 }
194}
195
196
197bool
198Helper::needNewSubscription(libsumo::Subscription& s, std::vector<Subscription>& subscriptions, libsumo::Subscription*& modifiedSubscription) {
199 for (libsumo::Subscription& o : subscriptions) {
200 if (s.commandId == o.commandId && s.id == o.id &&
201 s.beginTime == o.beginTime && s.endTime == o.endTime &&
202 s.contextDomain == o.contextDomain && s.range == o.range) {
203 std::vector<std::shared_ptr<tcpip::Storage> >::const_iterator k = s.parameters.begin();
204 for (const int v : s.variables) {
205 const int offset = (int)(std::find(o.variables.begin(), o.variables.end(), v) - o.variables.begin());
206 if (offset == (int)o.variables.size() || o.parameters[offset]->size() != (*k)->size() || !std::equal((*k)->begin(), (*k)->end(), o.parameters[offset]->begin())) {
207 o.variables.push_back(v);
208 o.parameters.push_back(*k);
209 }
210 ++k;
211 }
212 modifiedSubscription = &o;
213 return false;
214 }
215 }
216 subscriptions.push_back(s);
217 modifiedSubscription = &subscriptions.back();
218 return true;
219}
220
221
222std::vector<Subscription>::iterator
223Helper::eraseSubscription(std::vector<Subscription>& subscriptions,
224 std::vector<Subscription>::iterator position, Subscription*& lastContextSubscription) {
225 const auto removedIndex = position - subscriptions.begin();
226 const auto contextIndex = lastContextSubscription == nullptr
227 ? -1 : lastContextSubscription - subscriptions.data();
228 if (contextIndex == removedIndex) {
229 lastContextSubscription = nullptr;
230 }
231 auto next = subscriptions.erase(position);
232 if (contextIndex > removedIndex) {
233 // Erasing an earlier entry moves the active context subscription.
234 lastContextSubscription = &subscriptions[contextIndex - 1];
235 }
236 return next;
237}
238
239
240void
242 for (auto& wrapper : myWrapper) {
243 wrapper.second->clear();
244 }
245 mySubscriptions.clear();
247}
248
249
252 if (myLastContextSubscription != nullptr) {
254 } else {
255 // The following code relies on the fact that the filter is 2^(filterType-1),
256 // see Subscription.h and the corresponding TraCIConstants.h.
257 // It is only for getting similar error messages with libsumo and traci.
258 int index = (int)filter;
259 int filterType = 0;
260 if (index != 0) {
261 ++filterType;
262 while (index >>= 1) {
263 ++filterType;
264 }
265 }
266 throw TraCIException("No previous vehicle context subscription exists to apply filter type " + toHex(filterType, 2));
267 }
269}
270
271
272void
274 const int getCommandId = s.contextDomain > 0 ? s.contextDomain : s.commandId - 0x30;
275 std::set<std::string> objIDs;
276 if (s.contextDomain > 0) {
277 if ((s.activeFilters & SUBS_FILTER_NO_RTREE) == 0) {
278 PositionVector shape;
279 findObjectShape(s.commandId, s.id, shape);
280 collectObjectIDsInRange(s.contextDomain, shape, s.range, objIDs);
281 }
282 applySubscriptionFilters(s, objIDs);
283 } else {
284 objIDs.insert(s.id);
285 }
286 if (myWrapper.empty()) {
287 myWrapper[libsumo::CMD_GET_BUSSTOP_VARIABLE] = BusStop::makeWrapper();
288 myWrapper[libsumo::CMD_GET_CALIBRATOR_VARIABLE] = Calibrator::makeWrapper();
289 myWrapper[libsumo::CMD_GET_CHARGINGSTATION_VARIABLE] = ChargingStation::makeWrapper();
290 myWrapper[libsumo::CMD_GET_EDGE_VARIABLE] = Edge::makeWrapper();
291#ifdef HAVE_LIBSUMOGUI
292 myWrapper[libsumo::CMD_GET_GUI_VARIABLE] = GUI::makeWrapper();
293#endif
294 myWrapper[libsumo::CMD_GET_INDUCTIONLOOP_VARIABLE] = InductionLoop::makeWrapper();
295 myWrapper[libsumo::CMD_GET_JUNCTION_VARIABLE] = Junction::makeWrapper();
296 myWrapper[libsumo::CMD_GET_LANE_VARIABLE] = Lane::makeWrapper();
297 myWrapper[libsumo::CMD_GET_LANEAREA_VARIABLE] = LaneArea::makeWrapper();
298 myWrapper[libsumo::CMD_GET_MEANDATA_VARIABLE] = MeanData::makeWrapper();
299 myWrapper[libsumo::CMD_GET_MULTIENTRYEXIT_VARIABLE] = MultiEntryExit::makeWrapper();
300 myWrapper[libsumo::CMD_GET_OVERHEADWIRE_VARIABLE] = OverheadWire::makeWrapper();
301 myWrapper[libsumo::CMD_GET_PARKINGAREA_VARIABLE] = ParkingArea::makeWrapper();
302 myWrapper[libsumo::CMD_GET_PERSON_VARIABLE] = Person::makeWrapper();
303 myWrapper[libsumo::CMD_GET_POI_VARIABLE] = POI::makeWrapper();
304 myWrapper[libsumo::CMD_GET_POLYGON_VARIABLE] = Polygon::makeWrapper();
305 myWrapper[libsumo::CMD_GET_REROUTER_VARIABLE] = Rerouter::makeWrapper();
306 myWrapper[libsumo::CMD_GET_ROUTE_VARIABLE] = Route::makeWrapper();
307 myWrapper[libsumo::CMD_GET_ROUTEPROBE_VARIABLE] = RouteProbe::makeWrapper();
308 myWrapper[libsumo::CMD_GET_SIM_VARIABLE] = Simulation::makeWrapper();
309 myWrapper[libsumo::CMD_GET_TL_VARIABLE] = TrafficLight::makeWrapper();
310 myWrapper[libsumo::CMD_GET_VARIABLESPEEDSIGN_VARIABLE] = VariableSpeedSign::makeWrapper();
311 myWrapper[libsumo::CMD_GET_VEHICLE_VARIABLE] = Vehicle::makeWrapper();
312 myWrapper[libsumo::CMD_GET_VEHICLETYPE_VARIABLE] = VehicleType::makeWrapper();
313 }
314 auto wrapper = myWrapper.find(getCommandId);
315 if (wrapper == myWrapper.end()) {
316 throw TraCIException("Unsupported command " + toHex(getCommandId, 2) + " specified");
317 }
318 std::shared_ptr<VariableWrapper> handler = wrapper->second;
319 VariableWrapper* container = handler.get();
320 if (s.contextDomain > 0) {
321 auto containerWrapper = myWrapper.find(s.commandId + 0x20);
322 if (containerWrapper == myWrapper.end()) {
323 throw TraCIException("Unsupported domain " + toHex(s.commandId + 0x20, 2) + " specified");
324 }
325 container = containerWrapper->second.get();
326 container->setContext(&s.id);
327 } else {
328 container->setContext(nullptr);
329 }
330 for (const std::string& objID : objIDs) {
331 if (!s.variables.empty()) {
332 std::vector<std::shared_ptr<tcpip::Storage> >::const_iterator k = s.parameters.begin();
333 for (const int variable : s.variables) {
334 if (s.contextDomain > 0 && variable == libsumo::TRACI_ID_LIST) {
335 container->empty(objID);
336 } else {
337 (*k)->resetPos();
338 try {
339 if (!handler->handle(objID, variable, container, k->get())) {
340 throw TraCIException("Unsupported variable " + toHex(variable, 2) + " specified");
341 }
342 } catch (const std::invalid_argument&) {
343 throw TraCIException("Unsupported variable " + toHex(variable, 2) + " specified");
344 }
345 ++k;
346 }
347 }
348 } else if (s.contextDomain > 0) {
349 // default for contexts is an empty map (similar to id list)
350 container->empty(objID);
351 }
352 }
353}
354
355
356void
357Helper::fuseLaneCoverage(std::shared_ptr<LaneCoverageInfo> aggregatedLaneCoverage, const std::shared_ptr<LaneCoverageInfo> newLaneCoverage) {
358 for (auto& p : *newLaneCoverage) {
359 const MSLane* lane = p.first;
360 if (aggregatedLaneCoverage->find(lane) == aggregatedLaneCoverage->end()) {
361 // Lane has no coverage in aggregatedLaneCoverage, yet
362 (*aggregatedLaneCoverage)[lane] = (*newLaneCoverage)[lane];
363 } else {
364 // Lane is covered in aggregatedLaneCoverage as well
365 std::pair<double, double>& range1 = (*aggregatedLaneCoverage)[lane];
366 std::pair<double, double>& range2 = (*newLaneCoverage)[lane];
367 std::pair<double, double> hull = std::make_pair(MIN2(range1.first, range2.first), MAX2(range1.second, range2.second));
368 (*aggregatedLaneCoverage)[lane] = hull;
369 }
370 }
371}
372
373
377 for (int i = 0; i < (int)positionVector.size(); ++i) {
378 tp.value.push_back(makeTraCIPosition(positionVector[i]));
379 }
380 return tp;
381}
382
383
387 for (const TraCIPosition& pos : vector.value) {
388 if (std::isnan(pos.x) || std::isnan(pos.y)) {
389 throw libsumo::TraCIException("NaN-Value in shape.");
390 }
391 pv.push_back(Position(pos.x, pos.y));
392 }
393 return pv;
394}
395
396
399 TraCIColor tc;
400 tc.a = color.alpha();
401 tc.b = color.blue();
402 tc.g = color.green();
403 tc.r = color.red();
404 return tc;
405}
406
407
410 return RGBColor((unsigned char)c.r, (unsigned char)c.g, (unsigned char)c.b, (unsigned char)c.a);
411}
412
413
415Helper::makeTraCIPosition(const Position& position, const bool includeZ) {
417 p.x = position.x();
418 p.y = position.y();
419 p.z = includeZ ? position.z() : INVALID_DOUBLE_VALUE;
420 return p;
421}
422
423
426 return Position(tpos.x, tpos.y, tpos.z);
427}
428
429
430MSEdge*
431Helper::getEdge(const std::string& edgeID) {
432 MSEdge* edge = MSEdge::dictionary(edgeID);
433 if (edge == nullptr) {
434 throw TraCIException("Referenced edge '" + edgeID + "' is not known.");
435 }
436 return edge;
437}
438
439
440const MSLane*
441Helper::getLaneChecking(const std::string& edgeID, int laneIndex, double pos) {
442 const MSEdge* edge = MSEdge::dictionary(edgeID);
443 if (edge == nullptr) {
444 throw TraCIException("Unknown edge " + edgeID);
445 }
446 if (laneIndex < 0 || laneIndex >= (int)edge->getLanes().size()) {
447 throw TraCIException("Invalid lane index for " + edgeID);
448 }
449 const MSLane* lane = edge->getLanes()[laneIndex];
450 if (pos < 0 || pos > lane->getLength()) {
451 throw TraCIException("Position on lane invalid");
452 }
453 return lane;
454}
455
456
457std::pair<MSLane*, double>
459 const PositionVector shape({ pos });
460 std::pair<MSLane*, double> result(nullptr, -1);
461 double range = 1000.;
462 const Boundary& netBounds = GeoConvHelper::getFinal().getConvBoundary();
463 const double maxRange = MAX2(1001., netBounds.getWidth() + netBounds.getHeight() + netBounds.distanceTo2D(pos));
464 while (range < maxRange) {
465 std::set<const Named*> lanes;
467 double minDistance = std::numeric_limits<double>::max();
468 for (const Named* named : lanes) {
469 MSLane* lane = const_cast<MSLane*>(dynamic_cast<const MSLane*>(named));
470 if (lane->allowsVehicleClass(vClass)) {
471 // @todo this may be a place where 3D is required but 2D is used
472 double newDistance = lane->getShape().distance2D(pos);
473 newDistance = patchShapeDistance(lane, pos, newDistance, false);
474 if (newDistance < minDistance ||
475 (newDistance == minDistance
476 && result.first != nullptr
477 && lane->getID() < result.first->getID())) {
478 minDistance = newDistance;
479 result.first = lane;
480 }
481 }
482 }
483 if (minDistance < std::numeric_limits<double>::max()) {
484 result.second = result.first->interpolateGeometryPosToLanePos(result.first->getShape().nearest_offset_to_point2D(pos, false));
485 break;
486 }
487 range *= 2;
488 }
489 return result;
490}
491
492
493double
494Helper::getDrivingDistance(std::pair<const MSLane*, double>& roadPos1, std::pair<const MSLane*, double>& roadPos2) {
495 if (roadPos1.first == roadPos2.first && roadPos1.second <= roadPos2.second) {
496 // same edge
497 return roadPos2.second - roadPos1.second;
498 }
499 double distance = 0.0;
500 ConstMSEdgeVector newRoute;
501 while (roadPos2.first->isInternal() && roadPos2.first != roadPos1.first) {
502 distance += roadPos2.second;
503 roadPos2.first = roadPos2.first->getLogicalPredecessorLane();
504 roadPos2.second = roadPos2.first->getLength();
505 }
506 MSNet::getInstance()->getRouterTT(0).compute(&roadPos1.first->getEdge(), &roadPos2.first->getEdge(), nullptr, SIMSTEP, newRoute, true);
507 if (newRoute.empty()) {
509 }
510 MSRoute route("", newRoute, false, nullptr, StopParVector());
511 return distance + route.getDistanceBetween(roadPos1.second, roadPos2.second, roadPos1.first, roadPos2.first);
512}
513
514
516Helper::getVehicle(const std::string& id) {
518 if (sumoVehicle == nullptr) {
519 throw TraCIException("Vehicle '" + id + "' is not known.");
520 }
521 MSBaseVehicle* v = dynamic_cast<MSBaseVehicle*>(sumoVehicle);
522 if (v == nullptr) {
523 throw TraCIException("Vehicle '" + id + "' is not a proper vehicle.");
524 }
525 return v;
526}
527
528
530Helper::getPerson(const std::string& personID) {
532 MSPerson* p = dynamic_cast<MSPerson*>(c.get(personID));
533 if (p == nullptr) {
534 throw TraCIException("Person '" + personID + "' is not known");
535 }
536 return p;
537}
538
540Helper::getTrafficObject(int domain, const std::string& id) {
541 if (domain == CMD_GET_VEHICLE_VARIABLE) {
542 return getVehicle(id);
543 } else if (domain == CMD_GET_PERSON_VARIABLE) {
544 return getPerson(id);
545 } else {
546 throw TraCIException("Cannot retrieve traffic object for domain " + toString(domain));
547 }
548}
549
550const MSVehicleType&
551Helper::getVehicleType(const std::string& vehicleID) {
552 return getVehicle(vehicleID)->getVehicleType();
553}
554
555
557Helper::getTLS(const std::string& id) {
558 if (!MSNet::getInstance()->getTLSControl().knows(id)) {
559 throw TraCIException("Traffic light '" + id + "' is not known");
560 }
561 return MSNet::getInstance()->getTLSControl().get(id);
562}
563
564
566Helper::getStoppingPlace(const std::string& id, const SumoXMLTag type) {
568 if (s == nullptr) {
569 throw TraCIException(toString(type) + " '" + id + "' is not known");
570 }
571 return s;
572}
573
574
576Helper::buildStopParameters(const std::string& edgeOrStoppingPlaceID,
577 double pos, int laneIndex, double startPos, int flags, double duration, double until) {
579 try {
580 checkTimeBounds(duration);
581 checkTimeBounds(until);
582 } catch (ProcessError&) {
583 throw TraCIException("Duration or until parameter exceed the time value range.");
584 }
585 newStop.duration = duration == INVALID_DOUBLE_VALUE ? SUMOTime_MAX : TIME2STEPS(duration);
586 newStop.until = until == INVALID_DOUBLE_VALUE ? -1 : TIME2STEPS(until);
587 newStop.index = STOP_INDEX_FIT;
588 if (newStop.duration >= 0) {
590 }
591 if (newStop.until >= 0) {
592 newStop.parametersSet |= STOP_UNTIL_SET;
593 }
594 if ((flags & 1) != 0) {
597 }
598 if ((flags & 2) != 0) {
599 newStop.triggered = true;
601 }
602 if ((flags & 4) != 0) {
603 newStop.containerTriggered = true;
605 }
606
607 SumoXMLTag stoppingPlaceType = SUMO_TAG_NOTHING;
608 if ((flags & 8) != 0) {
609 stoppingPlaceType = SUMO_TAG_BUS_STOP;
610 }
611 if ((flags & 16) != 0) {
612 stoppingPlaceType = SUMO_TAG_CONTAINER_STOP;
613 }
614 if ((flags & 32) != 0) {
615 stoppingPlaceType = SUMO_TAG_CHARGING_STATION;
616 }
617 if ((flags & 64) != 0) {
618 stoppingPlaceType = SUMO_TAG_PARKING_AREA;
619 }
620 if ((flags & 128) != 0) {
621 stoppingPlaceType = SUMO_TAG_OVERHEAD_WIRE_SEGMENT;
622 }
623
624 if (stoppingPlaceType != SUMO_TAG_NOTHING) {
625 MSStoppingPlace* bs = MSNet::getInstance()->getStoppingPlace(edgeOrStoppingPlaceID, stoppingPlaceType);
626 if (bs == nullptr) {
627 throw TraCIException("The " + toString(stoppingPlaceType) + " '" + edgeOrStoppingPlaceID + "' is not known");
628 }
629 newStop.lane = bs->getLane().getID();
630 newStop.edge = bs->getLane().getEdge().getID();
631 newStop.endPos = bs->getEndLanePosition();
632 newStop.startPos = bs->getBeginLanePosition();
633 switch (stoppingPlaceType) {
635 newStop.busstop = edgeOrStoppingPlaceID;
636 break;
638 newStop.containerstop = edgeOrStoppingPlaceID;
639 break;
641 newStop.chargingStation = edgeOrStoppingPlaceID;
642 break;
644 newStop.parkingarea = edgeOrStoppingPlaceID;
645 break;
647 newStop.overheadWireSegment = edgeOrStoppingPlaceID;
648 break;
649 default:
650 throw TraCIException("Unknown stopping place type '" + toString(stoppingPlaceType) + "'.");
651 }
652 } else {
653 if (startPos == INVALID_DOUBLE_VALUE) {
654 startPos = MAX2(0.0, pos - POSITION_EPS);
655 }
656 if (startPos < 0.) {
657 throw TraCIException("Position on lane must not be negative.");
658 }
659 if (pos < startPos) {
660 throw TraCIException("End position on lane must be after start position.");
661 }
662 // get the actual lane that is referenced by laneIndex
663 MSEdge* road = MSEdge::dictionary(edgeOrStoppingPlaceID);
664 if (road == nullptr) {
665 throw TraCIException("Edge '" + edgeOrStoppingPlaceID + "' is not known.");
666 }
667 const std::vector<MSLane*>& allLanes = road->getLanes();
668 if ((laneIndex < 0) || laneIndex >= (int)(allLanes.size())) {
669 throw TraCIException("No lane with index '" + toString(laneIndex) + "' on edge '" + edgeOrStoppingPlaceID + "'.");
670 }
671 newStop.lane = allLanes[laneIndex]->getID();
672 newStop.edge = allLanes[laneIndex]->getEdge().getID();
673 newStop.endPos = pos;
674 newStop.startPos = startPos;
676 }
677 return newStop;
678}
679
680
683 std::string stoppingPlaceID = "";
684 if (stopPar.busstop != "") {
685 stoppingPlaceID = stopPar.busstop;
686 }
687 if (stopPar.containerstop != "") {
688 stoppingPlaceID = stopPar.containerstop;
689 }
690 if (stopPar.parkingarea != "") {
691 stoppingPlaceID = stopPar.parkingarea;
692 }
693 if (stopPar.chargingStation != "") {
694 stoppingPlaceID = stopPar.chargingStation;
695 }
696 if (stopPar.overheadWireSegment != "") {
697 stoppingPlaceID = stopPar.overheadWireSegment;
698 }
699
700 return TraCINextStopData(stopPar.lane,
701 stopPar.startPos,
702 stopPar.endPos,
703 stoppingPlaceID,
704 stopPar.getFlags(),
705 // negative duration is permitted to indicate that a vehicle cannot
706 // re-enter traffic after parking
707 stopPar.duration != -1 ? STEPS2TIME(stopPar.duration) : INVALID_DOUBLE_VALUE,
708 stopPar.until >= 0 ? STEPS2TIME(stopPar.until) : INVALID_DOUBLE_VALUE,
709 stopPar.arrival >= 0 ? STEPS2TIME(stopPar.arrival) : INVALID_DOUBLE_VALUE,
710 stopPar.started >= 0 ? STEPS2TIME(stopPar.started) : INVALID_DOUBLE_VALUE,
711 stopPar.ended >= 0 ? STEPS2TIME(stopPar.ended) : INVALID_DOUBLE_VALUE,
712 stopPar.split,
713 stopPar.join,
714 stopPar.actType,
715 stopPar.tripId,
716 stopPar.line,
717 stopPar.speed);
718}
719
720
721void
723 // clean up NamedRTrees
724 InductionLoop::cleanup();
725 Junction::cleanup();
726 LaneArea::cleanup();
727 POI::cleanup();
728 Polygon::cleanup();
731 delete myLaneTree;
732 myLaneTree = nullptr;
735}
736
737
738void
745
746
747const std::vector<std::string>&
751
752
753const std::vector<std::string>&
757
758
759void
762 i.second.clear();
763 }
765 i.second.clear();
766 }
767}
768
769
772 try {
773 return c->getCurrentStateInterval();
774 } catch (ProcessError& e) {
775 throw TraCIException(e.what());
776 }
777}
778
779
780void
781Helper::findObjectShape(int domain, const std::string& id, PositionVector& shape) {
782 switch (domain) {
785 shape.push_back(stop->getLane().getShape().positionAtOffset(stop->getBeginLanePosition()));
786 shape.push_back(stop->getLane().getShape().positionAtOffset(stop->getEndLanePosition()));
787 break;
788 }
790 MSCalibrator* const calib = Calibrator::getCalibrator(id);
791 shape.push_back(calib->getLane()->getShape()[0]);
792 break;
793 }
796 shape.push_back(stop->getLane().getShape().positionAtOffset(stop->getBeginLanePosition()));
797 shape.push_back(stop->getLane().getShape().positionAtOffset(stop->getEndLanePosition()));
798 break;
799 }
801 Edge::storeShape(id, shape);
802 break;
804 InductionLoop::storeShape(id, shape);
805 break;
807 Junction::storeShape(id, shape);
808 break;
810 Lane::storeShape(id, shape);
811 break;
813 LaneArea::storeShape(id, shape);
814 break;
816 MSE3Collector* const det = MultiEntryExit::getDetector(id);
817 for (const MSCrossSection& cs : det->getEntries()) {
818 shape.push_back(cs.myLane->getShape().positionAtOffset(cs.myPosition));
819 }
820 for (const MSCrossSection& cs : det->getExits()) {
821 shape.push_back(cs.myLane->getShape().positionAtOffset(cs.myPosition));
822 }
823 break;
824 }
827 shape.push_back(stop->getLane().getShape().positionAtOffset(stop->getBeginLanePosition()));
828 shape.push_back(stop->getLane().getShape().positionAtOffset(stop->getEndLanePosition()));
829 break;
830 }
832 Person::storeShape(id, shape);
833 break;
835 POI::storeShape(id, shape);
836 break;
838 Polygon::storeShape(id, shape);
839 break;
841 Vehicle::storeShape(id, shape);
842 break;
843 default:
844 Simulation::storeShape(shape);
845 break;
846 }
847}
848
849
850void
851Helper::collectObjectIDsInRange(int domain, const PositionVector& shape, double range, std::set<std::string>& into) {
852 std::set<const Named*> objects;
853 collectObjectsInRange(domain, shape, range, objects);
854 for (const Named* obj : objects) {
855 into.insert(obj->getID());
856 }
857}
858
859
860void
861Helper::collectObjectsInRange(int domain, const PositionVector& shape, double range, std::set<const Named*>& into) {
862 const Boundary b = shape.getBoxBoundary().grow(range);
863 const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
864 const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
865 switch (domain) {
867 for (const auto& stop : MSNet::getInstance()->getStoppingPlaces(SUMO_TAG_BUS_STOP)) {
868 if (shape.distance2D(stop.second->getCenterPos()) <= range) {
869 into.insert(stop.second);
870 }
871 }
872 break;
875 if (shape.distance2D(stop.second->getCenterPos()) <= range) {
876 into.insert(stop.second);
877 }
878 }
879 break;
881 for (const auto& calib : MSCalibrator::getInstances()) {
882 if (shape.distance2D(calib.second->getLane()->getShape()[0]) <= range) {
883 into.insert(calib.second);
884 }
885 }
886 break;
888 InductionLoop::getTree()->Search(cmin, cmax, Named::StoringVisitor(into));
889 break;
891 Junction::getTree()->Search(cmin, cmax, Named::StoringVisitor(into));
892 break;
894 LaneArea::getTree()->Search(cmin, cmax, Named::StoringVisitor(into));
895 break;
897 for (const auto& stop : MSNet::getInstance()->getStoppingPlaces(SUMO_TAG_PARKING_AREA)) {
898 if (shape.distance2D(stop.second->getCenterPos()) <= range) {
899 into.insert(stop.second);
900 }
901 }
902 break;
903 }
905 POI::getTree()->Search(cmin, cmax, Named::StoringVisitor(into));
906 break;
908 Polygon::getTree()->Search(cmin, cmax, Named::StoringVisitor(into));
909 break;
914 if (myLaneTree == nullptr) {
917 }
918 MSLane::StoringVisitor lsv(into, shape, range, domain);
919 myLaneTree->Search(cmin, cmax, lsv);
920 }
921 break;
922 default:
923 throw TraCIException("Infeasible context domain (" + toString(domain) + ")");
924 break;
925 }
926}
927
928
929
930void
931Helper::applySubscriptionFilters(const Subscription& s, std::set<std::string>& objIDs) {
932#ifdef DEBUG_SURROUNDING
933 MSBaseVehicle* _veh = getVehicle(s.id);
934 std::cout << SIMTIME << " applySubscriptionFilters for vehicle '" << _veh->getID() << "' on lane '" << _veh->getLane()->getID() << "'"
935 << "\n on edge '" << _veh->getLane()->getEdge().getID() << "' (" << toString(_veh->getLane()->getEdge().getLanes()) << ")\n"
936 << "objIDs = " << toString(objIDs) << std::endl;
937#endif
938
939 if (s.activeFilters == 0) {
940 // No filters set
941 return;
942 }
943
944 MSVehicle* v = dynamic_cast<MSVehicle*>(getVehicle(s.id));
945
946 // Whether vehicles on opposite lanes shall be taken into account
947 const bool disregardOppositeDirection = (s.activeFilters & SUBS_FILTER_NOOPPOSITE) != 0;
948
949 // Check filter specification consistency
950 if (disregardOppositeDirection && (s.activeFilters & SUBS_FILTER_NO_RTREE) == 0) {
951 WRITE_WARNINGF(TL("Ignoring veh '%' no-opposite subscription filter for geographic range object collection. Consider using the 'lanes' filter."), v->getID())
952 }
953 // TODO: Treat case, where ego vehicle is currently on opposite lane
954
955 std::set<const SUMOTrafficObject*> vehs;
957 // Set defaults for upstream/downstream/lateral distances
958 double downstreamDist = s.range, upstreamDist = s.range, lateralDist = s.range;
960 // Specifies maximal downstream distance for vehicles in context subscription result
961 downstreamDist = s.filterDownstreamDist;
962 }
964 // Specifies maximal downstream distance for vehicles in context subscription result
965 upstreamDist = s.filterUpstreamDist;
966 }
968 // Specifies maximal lateral distance for vehicles in context subscription result
969 lateralDist = s.filterLateralDist;
970 }
971 if (v == nullptr) {
972 throw TraCIException("Subscription filter not yet implemented for meso vehicle");
973 }
974 if (!v->isOnRoad()) {
975 return;
976 }
977 const MSLane* vehLane = v->getLane();
978 if (vehLane == nullptr) {
979 return;
980 }
981 MSEdge* vehEdge = &vehLane->getEdge();
982 std::vector<int> filterLanes;
983 if ((s.activeFilters & SUBS_FILTER_LANES) == 0) {
984 // No lane indices are specified (but downstream and/or upstream distance)
985 // -> use only vehicle's current lane as origin for the searches
986 filterLanes = {0};
987 // Lane indices must be specified when leader/follower information is requested.
988 assert((s.activeFilters & SUBS_FILTER_LEAD_FOLLOW) == 0);
989 } else {
990 filterLanes = s.filterLanes;
991 }
992
993#ifdef DEBUG_SURROUNDING
994 std::cout << "Filter lanes: " << toString(filterLanes) << std::endl;
995 std::cout << "Downstream distance: " << downstreamDist << std::endl;
996 std::cout << "Upstream distance: " << upstreamDist << std::endl;
997 std::cout << "Lateral distance: " << lateralDist << std::endl;
998#endif
999
1000 if ((s.activeFilters & SUBS_FILTER_MANEUVER) != 0) {
1001 // Maneuver filters disables road net search for all surrounding vehicles
1002 if ((s.activeFilters & SUBS_FILTER_LEAD_FOLLOW) != 0) {
1003 // Return leader and follower on the specified lanes in context subscription result.
1004 for (int offset : filterLanes) {
1005 MSLane* lane = v->getLane()->getParallelLane(offset, false);
1006 if (lane != nullptr) {
1007 // this is a non-opposite lane
1008 MSVehicle* leader = lane->getLeader(v, v->getPositionOnLane(), v->getBestLanesContinuation(lane), downstreamDist).first;
1009 MSVehicle* follower = lane->getFollower(v, v->getPositionOnLane(), upstreamDist,
1011 vehs.insert(vehs.end(), leader);
1012 vehs.insert(vehs.end(), follower);
1013
1014#ifdef DEBUG_SURROUNDING
1015 std::cout << "Lane at index " << offset << ": '" << lane->getID() << std::endl;
1016 std::cout << "Leader: '" << (leader != nullptr ? leader->getID() : "NULL") << "'" << std::endl;
1017 std::cout << "Follower: '" << (follower != nullptr ? follower->getID() : "NULL") << "'" << std::endl;
1018#endif
1019
1020 } else if (!disregardOppositeDirection && offset > 0) { // TODO: offset<0 may indicate opposite query when vehicle is on opposite itself
1021 // check whether ix points to an opposite lane
1022 const MSEdge* opposite = vehEdge->getOppositeEdge();
1023 if (opposite == nullptr) {
1024#ifdef DEBUG_SURROUNDING
1025 std::cout << "No lane at index " << offset << std::endl;
1026#endif
1027 // no opposite edge
1028 continue;
1029 }
1030 // Index of opposite lane at relative offset
1031 const int ix_opposite = (int)opposite->getLanes().size() - 1 - (vehLane->getIndex() + offset - (int)vehEdge->getLanes().size());
1032 if (ix_opposite < 0) {
1033#ifdef DEBUG_SURROUNDING
1034 std::cout << "No lane on opposite at index " << ix_opposite << std::endl;
1035#endif
1036 // no opposite edge
1037 continue;
1038 }
1039 lane = opposite->getLanes()[ix_opposite];
1040 // Search vehs along opposite lanes (swap upstream and downstream distance)
1041 // XXX transformations for curved geometries
1042 double posOnOpposite = MAX2(0., opposite->getLength() - v->getPositionOnLane());
1043 // Get leader on opposite
1044 vehs.insert(vehs.end(), lane->getFollower(v, posOnOpposite, downstreamDist, MSLane::MinorLinkMode::FOLLOW_NEVER).first);
1045 // Get follower (no search on consecutive lanes
1046 vehs.insert(vehs.end(), lane->getLeader(v, posOnOpposite - v->getLength(), std::vector<MSLane*>()).first);
1047 }
1048 }
1049 }
1050
1054 applySubscriptionFilterLanes(s, vehs, filterLanes, downstreamDist, upstreamDist, disregardOppositeDirection);
1055 }
1057 applySubscriptionFilterLateralDistance(s, vehs, downstreamDist, upstreamDist, lateralDist);
1058 }
1059 }
1060#ifdef DEBUG_SURROUNDING
1061 std::cout << SIMTIME << " applySubscriptionFilters() for veh '" << v->getID() << "'. Found the following vehicles:\n";
1062 for (auto veh : vehs) {
1063 debugPrint(veh);
1064 }
1065#endif
1066 } else if (s.activeFilters & SUBS_FILTER_LATERAL_DIST) {
1067 applySubscriptionFilterLateralDistance(s, vehs, downstreamDist, upstreamDist, lateralDist);
1068 } else {
1069 // No maneuver or lateral distance filters requested, but only lanes filter (directly, or indirectly by specifying downstream or upstream distance)
1070 applySubscriptionFilterLanes(s, vehs, filterLanes, downstreamDist, upstreamDist, disregardOppositeDirection);
1071 }
1072 // Write vehs IDs in objIDs
1073 for (const SUMOTrafficObject* veh : vehs) {
1074 if (veh != nullptr) {
1075 objIDs.insert(objIDs.end(), veh->getID());
1076 }
1077 }
1078 }
1079
1081 // Only return vehicles of the given vClass in context subscription result
1082 auto i = objIDs.begin();
1083 while (i != objIDs.end()) {
1084 MSBaseVehicle* veh = getVehicle(*i);
1085 if ((veh->getVehicleType().getVehicleClass() & s.filterVClasses) == 0) {
1086 i = objIDs.erase(i);
1087 } else {
1088 ++i;
1089 }
1090 }
1091 }
1093 // Only return vehicles of the given vType in context subscription result
1094 auto i = objIDs.begin();
1095 while (i != objIDs.end()) {
1096 MSBaseVehicle* veh = getVehicle(*i);
1097 if (s.filterVTypes.find(veh->getVehicleType().getID()) == s.filterVTypes.end()) {
1098 i = objIDs.erase(i);
1099 } else {
1100 ++i;
1101 }
1102 }
1103 }
1105 // Only return vehicles within field of vision in context subscription result
1107 }
1108}
1109
1110void
1111Helper::applySubscriptionFilterLanes(const Subscription& s, std::set<const SUMOTrafficObject*>& vehs, std::vector<int>& filterLanes, double downstreamDist,
1112 double upstreamDist, bool disregardOppositeDirection) {
1114 WRITE_WARNINGF(TL("Lanes filter is only feasible for context domain 'vehicle' (current is '%'), ignoring filter..."), toHex(s.contextDomain, 2));
1115 return;
1116 }
1117 assert(filterLanes.size() > 0);
1118 MSVehicle* v = dynamic_cast<MSVehicle*>(getVehicle(s.id));
1119 const MSLane* vehLane = v->getLane();
1120 MSEdge* vehEdge = &vehLane->getEdge();
1121 // This is to remember the lanes checked in the driving direction of the vehicle (their opposites can be added in a second pass)
1122 auto checkedLanesInDrivingDir = std::make_shared<LaneCoverageInfo>();
1123 for (int offset : filterLanes) {
1124 MSLane* lane = vehLane->getParallelLane(offset, false);
1125 if (lane != nullptr) {
1126#ifdef DEBUG_SURROUNDING
1127 std::cout << "Checking for surrounding vehicles starting on lane '" << lane->getID() << "' at index " << offset << std::endl;
1128#endif
1129 // Search vehs along this lane
1130 // (Coverage info is collected per origin lane since lanes reached from neighboring lanes may have different distances
1131 // and aborting at previously scanned when coming from a closer origin may prevent scanning of parts that should be included.)
1132 std::shared_ptr<LaneCoverageInfo> checkedLanes = std::make_shared<LaneCoverageInfo>();
1133 const std::set<MSVehicle*> new_vehs =
1134 lane->getSurroundingVehicles(v->getPositionOnLane(), downstreamDist, upstreamDist + v->getLength(), checkedLanes);
1135 vehs.insert(new_vehs.begin(), new_vehs.end());
1136 fuseLaneCoverage(checkedLanesInDrivingDir, checkedLanes);
1137 } else if (!disregardOppositeDirection && offset > 0) {
1138 // Check opposite edge, too
1139 assert(vehLane->getIndex() + offset >= (int)vehEdge->getLanes().size()); // index points beyond this edge
1140 const MSEdge* opposite = vehEdge->getOppositeEdge();
1141 if (opposite == nullptr) {
1142#ifdef DEBUG_SURROUNDING
1143 std::cout << "No opposite edge, thus no lane at index " << offset << std::endl;
1144#endif
1145 // no opposite edge
1146 continue;
1147 }
1148 // Index of opposite lane at relative offset
1149 const int ix_opposite = (int)opposite->getLanes().size() - 1 - (vehLane->getIndex() + offset - (int)vehEdge->getLanes().size());
1150 if (ix_opposite < 0) {
1151#ifdef DEBUG_SURROUNDING
1152 std::cout << "No lane on opposite at index " << ix_opposite << std::endl;
1153#endif
1154 // no opposite edge
1155 continue;
1156 }
1157 lane = opposite->getLanes()[ix_opposite];
1158 // Search vehs along opposite lanes (swap upstream and downstream distance)
1159 const std::set<MSVehicle*> new_vehs = lane->getSurroundingVehicles(lane->getLength() - v->getPositionOnLane(), upstreamDist + v->getLength(),
1160 downstreamDist, std::make_shared<LaneCoverageInfo>());
1161 vehs.insert(new_vehs.begin(), new_vehs.end());
1162 }
1163#ifdef DEBUG_SURROUNDING
1164 else {
1165 std::cout << "No lane at index " << offset << std::endl;
1166 }
1167#endif
1168
1169 if (!disregardOppositeDirection) {
1170 // If opposite should be checked, do this for each lane of the search tree in checkedLanesInDrivingDir
1171 // (For instance, some opposite lanes of these would not be obtained if the ego lane does not have an opposite.)
1172
1173 // Number of opposite lanes to be checked (assumes filterLanes.size()>0, see assertion above) determined as hypothetical offset
1174 // overlap into opposing edge from the vehicle's current lane.
1175 // TODO: offset<0 may indicate opposite query when vehicle is on opposite itself (-> use min_element(filterLanes...) instead, etc)
1176 const int nOpp = MAX2(0, (*std::max_element(filterLanes.begin(), filterLanes.end())) - ((int)vehEdge->getLanes().size() - 1 - vehLane->getIndex()));
1177 // Collect vehicles from opposite lanes
1178 if (nOpp > 0) {
1179 for (auto& laneCov : *checkedLanesInDrivingDir) {
1180 const MSLane* const l = laneCov.first;
1181 if (l == nullptr || l->getEdge().getOppositeEdge() == nullptr) {
1182 continue;
1183 }
1184 const MSEdge* opposite = l->getEdge().getOppositeEdge();
1185 const std::pair<double, double>& range = laneCov.second;
1186 auto leftMostOppositeLaneIt = opposite->getLanes().rbegin();
1187 for (auto oppositeLaneIt = leftMostOppositeLaneIt; oppositeLaneIt != opposite->getLanes().rend(); ++oppositeLaneIt) {
1188 if ((int)(oppositeLaneIt - leftMostOppositeLaneIt) == nOpp) {
1189 break;
1190 }
1191 // Add vehicles from corresponding range on opposite direction
1192 const MSLane* oppositeLane = *oppositeLaneIt;
1193 auto new_vehs = oppositeLane->getVehiclesInRange(l->getLength() - range.second, l->getLength() - range.first);
1194 vehs.insert(new_vehs.begin(), new_vehs.end());
1195 }
1196 }
1197 }
1198 }
1199#ifdef DEBUG_SURROUNDING
1200 std::cout << SIMTIME << " applySubscriptionFilterLanes() for veh '" << v->getID() << "', lane offset '" << offset << "'. Found the following vehicles so far:\n";
1201 for (auto veh : vehs) {
1202 debugPrint(veh);
1203 }
1204#endif
1205 }
1206}
1207
1208void
1209Helper::applySubscriptionFilterTurn(const Subscription& s, std::set<const SUMOTrafficObject*>& vehs) {
1211 WRITE_WARNINGF(TL("Turn filter is only feasible for context domain 'vehicle' (current is '%'), ignoring filter..."), toHex(s.contextDomain, 2));
1212 return;
1213 }
1214 // Get upcoming junctions and vialanes within downstream distance, where foe links exist or at least the link direction is not straight
1215 MSVehicle* v = dynamic_cast<MSVehicle*>(getVehicle(s.id));
1216 const MSLane* lane = v->getLane();
1217 std::vector<const MSLink*> links = lane->getUpcomingLinks(v->getPositionOnLane(), s.filterDownstreamDist, v->getBestLanesContinuation());
1218#ifdef DEBUG_SURROUNDING
1219 std::cout << "Applying turn filter for vehicle '" << v->getID() << "'\n Gathering foes ..." << std::endl;
1220#endif
1221 // Iterate through junctions and find approaching foes within foeDistToJunction.
1222 for (auto& l : links) {
1223#ifdef DEBUG_SURROUNDING
1224 std::cout << " On junction '" << l->getJunction()->getID() << "' (no. foe links = " << l->getFoeLinks().size() << "):" << std::endl;
1225#endif
1226 for (auto& foeLane : l->getFoeLanes()) {
1227 if (foeLane->isCrossing()) {
1228#ifdef DEBUG_SURROUNDING
1229 std::cout << " skipping crossing foeLane '" << foeLane->getID() << "'" << std::endl;
1230#endif
1231 continue;
1232 }
1233#ifdef DEBUG_SURROUNDING
1234 std::cout << " foeLane '" << foeLane->getID() << "'" << std::endl;
1235#endif
1236 // Check vehicles approaching the entry link corresponding to this lane
1237 const MSLink* foeLink = foeLane->getEntryLink();
1238 for (auto& vi : foeLink->getApproaching()) {
1239 if (vi.second.dist <= s.filterFoeDistToJunction) {
1240#ifdef DEBUG_SURROUNDING
1241 std::cout << " Approaching foeLane entry link '" << vi.first->getID() << "'" << std::endl;
1242#endif
1243 vehs.insert(vehs.end(), dynamic_cast<const MSVehicle*>(vi.first));
1244 }
1245 }
1246 // add vehicles currently on the junction
1247 for (const MSVehicle* foe : foeLane->getVehiclesSecure()) {
1248#ifdef DEBUG_SURROUNDING
1249 std::cout << " On foeLane '" << foe->getID() << "'" << std::endl;
1250#endif
1251 vehs.insert(vehs.end(), foe);
1252 }
1253 foeLane->releaseVehicles();
1254 for (auto& laneInfo : foeLane->getIncomingLanes()) {
1255 const MSLane* foeLanePred = laneInfo.lane;
1256 if (foeLanePred->isInternal()) {
1257#ifdef DEBUG_SURROUNDING
1258 std::cout << " foeLanePred '" << foeLanePred->getID() << "'" << std::endl;
1259#endif
1260 for (const MSVehicle* foe : foeLanePred->getVehiclesSecure()) {
1261#ifdef DEBUG_SURROUNDING
1262 std::cout << " On foeLanePred '" << foe->getID() << "'" << std::endl;
1263#endif
1264 vehs.insert(vehs.end(), foe);
1265 }
1266 foeLanePred->releaseVehicles();
1267 }
1268 }
1269 }
1270 }
1271}
1272
1273void
1274Helper::applySubscriptionFilterFieldOfVision(const Subscription& s, std::set<std::string>& objIDs) {
1276 WRITE_WARNINGF(TL("Field of vision opening angle ('%') should be within interval (0, 360), ignoring filter..."), s.filterFieldOfVisionOpeningAngle);
1277 return;
1278 }
1279
1280 MSBaseVehicle* egoVehicle = getVehicle(s.id);
1281 Position egoPosition = egoVehicle->getPosition();
1282 double openingAngle = DEG2RAD(s.filterFieldOfVisionOpeningAngle);
1283
1284#ifdef DEBUG_SURROUNDING
1285 std::cout << "FOVFILTER: ego direction = " << toString(RAD2DEG(egoVehicle->getAngle())) << " (deg)" << std::endl;
1286#endif
1287
1288 auto i = objIDs.begin();
1289 while (i != objIDs.end()) {
1290 if (s.id.compare(*i) == 0) { // skip if this is the ego vehicle
1291 ++i;
1292 continue;
1293 }
1295 double angleEgoToVeh = egoPosition.angleTo2D(obj->getPosition());
1296 double alpha = GeomHelper::angleDiff(egoVehicle->getAngle(), angleEgoToVeh);
1297
1298#ifdef DEBUG_SURROUNDING
1299 const std::string objType = s.isVehicleToPersonContextSubscription() ? "person" : "veh";
1300 std::cout << "FOVFILTER: " << objType << " '" << *i << "' dist = " << toString(egoPosition.distanceTo2D(obj->getPosition())) << std::endl;
1301 std::cout << "FOVFILTER: " << objType << " '" << *i << "' alpha = " << toString(RAD2DEG(alpha)) << " (deg)" << std::endl;
1302#endif
1303
1304 if (abs(alpha) > openingAngle * 0.5) {
1305 i = objIDs.erase(i);
1306 } else {
1307 ++i;
1308 }
1309 }
1310}
1311
1312void
1313Helper::applySubscriptionFilterLateralDistance(const Subscription& s, std::set<const SUMOTrafficObject*>& vehs, double downstreamDist, double upstreamDist,
1314 double lateralDist) {
1315 // collect all vehicles within maximum range of interest to get an upper bound
1316 PositionVector vehShape;
1317 findObjectShape(s.commandId, s.id, vehShape);
1318 double range = MAX3(downstreamDist, upstreamDist, lateralDist);
1319 std::set<std::string> objIDs;
1320 collectObjectIDsInRange(s.contextDomain, vehShape, range, objIDs);
1321
1322#ifdef DEBUG_SURROUNDING
1323 std::cout << "FILTER_LATERAL_DIST: collected object IDs (range " << range << "):" << std::endl;
1324 for (std::string i : objIDs) {
1325 std::cout << i << std::endl;
1326 }
1327#endif
1328
1329 MSVehicle* v = dynamic_cast<MSVehicle*>(getVehicle(s.id));
1330#ifdef DEBUG_SURROUNDING
1331 std::cout << "FILTER_LATERAL_DIST: myLane is '" << v->getLane()->getID() << "', pos " << v->getPositionOnLane() << std::endl;
1332 std::cout << "FILTER_LATERAL_DIST: opposite lane is '" << v->getLane()->getParallelOpposite()->getID() << "'" << std::endl;
1333#endif
1334 double frontPosOnLane = v->getPositionOnLane();
1335 if (v->getLaneChangeModel().isOpposite()) {
1336 frontPosOnLane = v->getLane()->getOppositePos(frontPosOnLane);
1337 }
1338 // 1st pass: downstream (make sure that the whole length of the vehicle is included in the match)
1339 const double backPosOnLane = MAX2(0.0, frontPosOnLane - v->getVehicleType().getLength());
1340 applySubscriptionFilterLateralDistanceSinglePass(s, objIDs, vehs, v->getUpcomingLanesUntil(downstreamDist), backPosOnLane, v->getLateralPositionOnLane(),
1341 true);
1342 // 2nd pass: upstream
1343 applySubscriptionFilterLateralDistanceSinglePass(s, objIDs, vehs, v->getPastLanesUntil(upstreamDist), frontPosOnLane, v->getLateralPositionOnLane(), false);
1344}
1345
1346void
1348 std::set<const SUMOTrafficObject*>& vehs,
1349 const std::vector<const MSLane*>& lanes, double posOnLane, double posLat, bool isDownstream) {
1350 const double streamDist = isDownstream ? s.filterDownstreamDist : s.filterUpstreamDist;
1351 double distRemaining = streamDist;
1352 bool isFirstLane = true;
1353 PositionVector combinedShape;
1354 for (const MSLane* lane : lanes) {
1355#ifdef DEBUG_SURROUNDING
1356 std::cout << "FILTER_LATERAL_DIST: current lane " << (isDownstream ? "down" : "up") << " is '" << lane->getID() << "', length " << lane->getLength()
1357 << ", pos " << posOnLane << ", distRemaining " << distRemaining << std::endl;
1358#endif
1359 PositionVector laneShape = lane->getShape();
1360 if (isFirstLane) {
1361 isFirstLane = false;
1362 double geometryPos = lane->interpolateLanePosToGeometryPos(posOnLane);
1363 if (geometryPos <= POSITION_EPS) {
1364 if (!isDownstream) {
1365 continue;
1366 }
1367 } else {
1368 if (geometryPos >= laneShape.length() - POSITION_EPS) {
1369 laneShape = isDownstream ? PositionVector() : laneShape;
1370 } else {
1371 auto pair = laneShape.splitAt(geometryPos, false);
1372 laneShape = isDownstream ? pair.second : pair.first;
1373 }
1374 }
1375 }
1376 double laneLength = lane->interpolateGeometryPosToLanePos(laneShape.length());
1377 if (distRemaining - laneLength < 0.) {
1378 double geometryPos = lane->interpolateLanePosToGeometryPos(isDownstream ? distRemaining : laneLength - distRemaining);
1379 if (geometryPos > POSITION_EPS && geometryPos < laneShape.length() - POSITION_EPS) {
1380 auto pair = laneShape.splitAt(geometryPos, false);
1381 laneShape = isDownstream ? pair.first : pair.second;
1382 }
1383 }
1384 distRemaining -= laneLength;
1385 try {
1386 laneShape.move2side(-posLat);
1387 } catch (ProcessError&) {
1388 WRITE_WARNINGF(TL("addSubscriptionFilterLateralDistance could not determine shape of lane '%' with a lateral shift of %."),
1389 lane->getID(), toString(posLat));
1390 }
1391#ifdef DEBUG_SURROUNDING
1392 std::cout << " posLat=" << posLat << " laneShape=" << laneShape << "\n";
1393#endif
1394 if (isDownstream) {
1395 combinedShape.append(laneShape);
1396 } else {
1397 combinedShape.prepend(laneShape);
1398 }
1399 if (distRemaining <= POSITION_EPS) {
1400 break;
1401 }
1402 }
1403#ifdef DEBUG_SURROUNDING
1404 std::cout << " combinedShape=" << combinedShape << "\n";
1405#endif
1406 // check remaining objects' distances to the combined shape
1407 auto i = objIDs.begin();
1408 while (i != objIDs.end()) {
1410 double minPerpendicularDist = combinedShape.distance2D(obj->getPosition(), true);
1411#ifdef DEBUG_SURROUNDING
1412 std::cout << (isDownstream ? "DOWN" : "UP") << " obj " << obj->getID() << " perpendicular dist=" << minPerpendicularDist << " filterLateralDist=" << s.filterLateralDist << "\n";
1413#endif
1414 if ((minPerpendicularDist != GeomHelper::INVALID_OFFSET) && (minPerpendicularDist <= s.filterLateralDist)) {
1415 vehs.insert(obj);
1416 i = objIDs.erase(i);
1417 } else {
1418 ++i;
1419 }
1420 }
1421}
1422
1423void
1424Helper::setRemoteControlled(MSVehicle* v, Position xyPos, MSLane* l, double pos, double posLat, double angle,
1425 int edgeOffset, ConstMSEdgeVector route, SUMOTime t) {
1427 v->getInfluencer().setRemoteControlled(xyPos, l, pos, posLat, angle, edgeOffset, route, t);
1428}
1429
1430void
1431Helper::setRemoteControlled(MSPerson* p, Position xyPos, MSLane* l, double pos, double posLat, double angle,
1432 int edgeOffset, ConstMSEdgeVector route, SUMOTime t) {
1434 p->getInfluencer().setRemoteControlled(xyPos, l, pos, posLat, angle, edgeOffset, route, t);
1435}
1436
1437
1438int
1440 int numControlled = 0;
1441 for (auto& controlled : myRemoteControlledVehicles) {
1442 if (MSNet::getInstance()->getVehicleControl().getVehicle(controlled.first) != nullptr) {
1443 controlled.second->getInfluencer().postProcessRemoteControl(controlled.second);
1444 numControlled++;
1445 } else {
1446 WRITE_WARNINGF(TL("Vehicle '%' was removed though being controlled by TraCI"), controlled.first);
1447 }
1448 }
1450 for (auto& controlled : myRemoteControlledPersons) {
1451 if (MSNet::getInstance()->getPersonControl().get(controlled.first) != nullptr) {
1452 controlled.second->getInfluencer().postProcessRemoteControl(controlled.second);
1453 numControlled++;
1454 } else {
1455 WRITE_WARNINGF(TL("Person '%' was removed though being controlled by TraCI"), controlled.first);
1456 }
1457 }
1459 return numControlled;
1460}
1461
1462
1463bool
1464Helper::moveToXYMap(const Position& pos, double maxRouteDistance, bool mayLeaveNetwork, const std::string& origID, const double angle,
1465 double speed, const ConstMSEdgeVector& currentRoute, const int routePosition, const MSLane* currentLane, double currentLanePos, bool onRoad,
1466 SUMOVehicleClass vClass, double currentAngle, bool setLateralPos,
1467 double& bestDistance, MSLane** lane, double& lanePos, int& routeOffset, ConstMSEdgeVector& edges) {
1468 // collect edges around the vehicle/person
1469#ifdef DEBUG_MOVEXY
1470 std::cout << SIMTIME << " moveToXYMap pos=" << pos << " angle=" << angle << " vClass=" << toString(vClass) << "\n";
1471#endif
1472 const MSEdge* const currentRouteEdge = currentRoute[routePosition];
1473 std::set<const Named*> into;
1474 PositionVector shape;
1475 shape.push_back(pos);
1476 collectObjectsInRange(libsumo::CMD_GET_EDGE_VARIABLE, shape, maxRouteDistance, into);
1477 double maxDist = 0;
1478 std::map<MSLane*, LaneUtility, ComparatorNumericalIdLess> lane2utility;
1479 // compute utility for all candidate edges
1480 for (const Named* namedEdge : into) {
1481 const MSEdge* e = dynamic_cast<const MSEdge*>(namedEdge);
1482 if ((e->getPermissions() & vClass) != vClass) {
1483 continue;
1484 }
1485 const MSEdge* prevEdge = nullptr;
1486 const MSEdge* nextEdge = nullptr;
1487 bool onRoute = false;
1488 bool useCurrentAngle = false;
1489 // the next if/the clause sets "onRoute", "prevEdge", and "nextEdge", depending on
1490 // whether the currently seen edge is an internal one or a normal one
1491 if (e->isWalkingArea() || e->isCrossing()) {
1492 // find current intersection along the route
1493 const MSJunction* junction = e->getFromJunction();
1494 for (int i = routePosition; i < (int)currentRoute.size(); i++) {
1495 const MSEdge* cand = currentRoute[i];
1496 if (cand->getToJunction() == junction) {
1497 prevEdge = cand;
1498 if (i + 1 < (int)currentRoute.size()) {
1499 onRoute = true;
1500 nextEdge = currentRoute[i + 1];
1501 }
1502 break;
1503 }
1504 }
1505 if (!onRoute) {
1506 // search backward
1507 for (int i = routePosition - 1; i >= 0; i--) {
1508 const MSEdge* cand = currentRoute[i];
1509 if (cand->getToJunction() == junction) {
1510 onRoute = true;
1511 prevEdge = cand;
1512 nextEdge = currentRoute[i + 1];
1513 break;
1514 }
1515 }
1516 }
1517 if (prevEdge == nullptr) {
1518 // use arbitrary predecessor
1519 if (e->getPredecessors().size() > 0) {
1520 prevEdge = e->getPredecessors().front();
1521 } else if (e->getSuccessors().size() > 1) {
1522 for (MSEdge* e2 : e->getSuccessors()) {
1523 if (e2 != nextEdge) {
1524 prevEdge = e2;
1525 break;
1526 }
1527 }
1528 }
1529 }
1530 if (nextEdge == nullptr) {
1531 if (e->getSuccessors().size() > 0) {
1532 nextEdge = e->getSuccessors().front();
1533 } else if (e->getPredecessors().size() > 1) {
1534 for (MSEdge* e2 : e->getPredecessors()) {
1535 if (e2 != prevEdge) {
1536 nextEdge = e2;
1537 break;
1538 }
1539 }
1540 }
1541 }
1542#ifdef DEBUG_MOVEXY_ANGLE
1543 std::cout << "walkingarea/crossing:" << e->getID() << " prev:" << Named::getIDSecure(prevEdge) << " next:" << Named::getIDSecure(nextEdge)
1544 << " pred=" << toString(e->getPredecessors()) << " succ=" << toString(e->getSuccessors())
1545 << "\n";
1546#endif
1547 } else if (e->isNormal()) {
1548 // a normal edge
1549 //
1550 // check whether the currently seen edge is in the vehicle's route
1551 // - either the one it's on or one of the next edges
1552 ConstMSEdgeVector::const_iterator searchStart = currentRoute.begin() + routePosition;
1553 if (onRoad && currentLane->getEdge().isInternal()) {
1554 ++searchStart;
1555 }
1556 ConstMSEdgeVector::const_iterator edgePos = std::find(searchStart, currentRoute.end(), e);
1557 onRoute = edgePos != currentRoute.end(); // no? -> onRoute is false
1558 if (edgePos == currentRoute.end() - 1 && currentRouteEdge == e) {
1559 // onRoute is false as well if the vehicle is beyond the edge
1560 onRoute &= currentRouteEdge->getLength() > currentLanePos + SPEED2DIST(speed);
1561 }
1562 // save prior and next edges
1563 prevEdge = e;
1564 nextEdge = !onRoute || edgePos == currentRoute.end() - 1 ? nullptr : *(edgePos + 1);
1565#ifdef DEBUG_MOVEXY_ANGLE
1566 std::cout << "normal:" << e->getID() << " prev:" << Named::getIDSecure(prevEdge) << " next:" << Named::getIDSecure(nextEdge) << "\n";
1567#endif
1568 } else if (e->isInternal()) {
1569 // an internal edge
1570 // get the previous edge
1571 prevEdge = e;
1572 while (prevEdge != nullptr && prevEdge->isInternal()) {
1573 MSLane* l = prevEdge->getLanes()[0];
1575 prevEdge = l == nullptr ? nullptr : &l->getEdge();
1576 }
1577 // check whether the previous edge is on the route (was on the route)
1578 ConstMSEdgeVector::const_iterator prevEdgePos = std::find(currentRoute.begin() + routePosition, currentRoute.end(), prevEdge);
1579 nextEdge = e;
1580 while (nextEdge != nullptr && nextEdge->isInternal()) {
1581 nextEdge = nextEdge->getSuccessors()[0]; // should be only one for an internal edge
1582 }
1583 if (prevEdgePos != currentRoute.end() && (prevEdgePos + 1) != currentRoute.end()) {
1584 onRoute = *(prevEdgePos + 1) == nextEdge;
1585 } else {
1586 // we cannot make use of route information and should make
1587 // use of the current angle if the user did not supply an angle
1588 useCurrentAngle = angle == INVALID_DOUBLE_VALUE;
1589 }
1590#ifdef DEBUG_MOVEXY_ANGLE
1591 std::cout << "internal:" << e->getID() << " prev:" << Named::getIDSecure(prevEdge) << " next:" << Named::getIDSecure(nextEdge) << "\n";
1592#endif
1593 }
1594
1595
1596 // weight the lanes...
1597 const bool perpendicular = false;
1598 for (MSLane* const l : e->getLanes()) {
1599 if (!l->allowsVehicleClass(vClass)) {
1600 continue;
1601 }
1602 if (l->getShape().length() == 0) {
1603 // mapping to shapeless lanes is a bad idea
1604 continue;
1605 }
1606 double langle = 180.;
1607 double dist = FAR_AWAY;
1608 double perpendicularDist = FAR_AWAY;
1609 // add some slack to avoid issues from tiny gaps between consecutive lanes
1610 // except when simulating with high precision where the slack can throw of mapping
1611 const double slack = POSITION_EPS * TS;
1612 PositionVector laneShape = l->getShape();
1613 laneShape.extrapolate2D(slack);
1614 double off = laneShape.nearest_offset_to_point2D(pos, true);
1615 if (off != GeomHelper::INVALID_OFFSET) {
1616 perpendicularDist = laneShape.distance2D(pos, true);
1617 perpendicularDist = patchShapeDistance(l, pos, perpendicularDist, true);
1618 }
1619 off = l->getShape().nearest_offset_to_point2D(pos, perpendicular);
1620 if (off != GeomHelper::INVALID_OFFSET) {
1621 dist = l->getShape().distance2D(pos, perpendicular);
1622 dist = patchShapeDistance(l, pos, dist, perpendicular);
1623 langle = GeomHelper::naviDegree(l->getShape().rotationAtOffset(off));
1624 }
1625 // cannot trust lanePos on walkingArea
1626 bool sameEdge = onRoad && e == &currentLane->getEdge() && currentRouteEdge->getLength() > currentLanePos + SPEED2DIST(speed) && !e->isWalkingArea();
1627 /*
1628 const MSEdge* rNextEdge = nextEdge;
1629 while(rNextEdge==0&&lane->getEdge().getPurpose()==MSEdge::EDGEFUNCTION_INTERNAL) {
1630 MSLane* next = lane->getLinkCont()[0]->getLane();
1631 rNextEdge = next == 0 ? 0 : &next->getEdge();
1632 }
1633 */
1634 double dist2 = dist;
1635 if (mayLeaveNetwork && fabs(dist - perpendicularDist) > slack) {
1636 // ambiguous mapping. Don't trust this
1637 dist2 = FAR_AWAY;
1638 }
1639 const double angle2 = useCurrentAngle ? currentAngle : angle;
1640 const double angleDiff = (angle2 == INVALID_DOUBLE_VALUE || l->isWalkingArea() ? 0 : GeomHelper::getMinAngleDiff(angle2, langle));
1641#ifdef DEBUG_MOVEXY_ANGLE
1642 std::cout << std::setprecision(gPrecision)
1643 << " candLane=" << l->getID() << " lAngle=" << langle << " lLength=" << l->getLength()
1644 << " angleDiff=" << angleDiff
1645 << " off=" << off
1646 << " pDist=" << perpendicularDist
1647 << " dist=" << dist
1648 << " dist2=" << dist2
1649 << "\n";
1650 std::cout << l->getID() << " param=" << l->getParameter(SUMO_PARAM_ORIGID, "") << " origID='" << origID << "\n";
1651#endif
1652
1653 bool origIDMatch = l->getParameter(SUMO_PARAM_ORIGID, l->getID()) == origID;
1654 if (origIDMatch && setLateralPos
1655 && perpendicularDist > l->getWidth() / 2) {
1656 origIDMatch = false;
1657 }
1658 lane2utility.emplace(l, LaneUtility(
1659 dist2, perpendicularDist, off, angleDiff,
1660 origIDMatch,
1661 onRoute, sameEdge, prevEdge, nextEdge));
1662 // update scaling value
1663 maxDist = MAX2(maxDist, MIN2(dist, SUMO_const_laneWidth));
1664
1665 }
1666 }
1667
1668 // get the best lane given the previously computed values
1669 double bestValue = 0;
1670 MSLane* bestLane = nullptr;
1671 for (const auto& it : lane2utility) {
1672 MSLane* const l = it.first;
1673 const LaneUtility& u = it.second;
1674 double distN = u.dist > 999 ? -10 : 1. - (u.dist / maxDist);
1675 double angleDiffN = 1. - (u.angleDiff / 180.);
1676 double idN = u.ID ? 1 : 0;
1677 double onRouteN = u.onRoute ? 1 : 0;
1678 double sameEdgeN = u.sameEdge ? MIN2(currentRouteEdge->getLength() / MAX2(NUMERICAL_EPS, speed), (double)1.) : 0;
1679 // distance is more important than angle because the vehicle might be driving in the opposite direction
1680 // also, distance becomes increasingly more important with lower step lengths (because position errors from one step to the next can result in large acceleration/speed errors)
1681 double value = (distN * .5 / TS
1682 + angleDiffN * 0.35 /*.5 */
1683 + idN * 1
1684 + onRouteN * 0.1
1685 + sameEdgeN * 0.1);
1686#ifdef DEBUG_MOVEXY
1687 std::cout << " x; l:" << l->getID() << " d:" << u.dist << " dN:" << distN << " aD:" << angleDiffN <<
1688 " ID:" << idN << " oRN:" << onRouteN << " sEN:" << sameEdgeN << " value:" << value << std::endl;
1689#endif
1690 if (value > bestValue || bestLane == nullptr) {
1691 bestValue = value;
1692 if (u.dist == FAR_AWAY) {
1693 bestLane = nullptr;
1694 } else {
1695 bestLane = l;
1696 }
1697 }
1698 }
1699 // no best lane found, return
1700 if (bestLane == nullptr) {
1701 return false;
1702 }
1703 const LaneUtility& u = lane2utility.find(bestLane)->second;
1704 bestDistance = u.dist;
1705 *lane = bestLane;
1706 lanePos = MAX2(0., MIN2(double((*lane)->getLength() - NUMERICAL_EPS),
1708 bestLane->getShape().nearest_offset_to_point25D(pos, false))));
1709 const MSEdge* prevEdge = u.prevEdge;
1710 if (u.onRoute) {
1711 ConstMSEdgeVector::const_iterator prevEdgePos = std::find(currentRoute.begin(), currentRoute.end(), prevEdge);
1712 routeOffset = (int)std::distance(currentRoute.begin(), prevEdgePos);
1713 //std::cout << SIMTIME << "moveToXYMap currLane=" << currentLane->getID() << " routeOffset=" << routeOffset << " edges=" << toString(edges) << " bestLane=" << bestLane->getID() << " prevEdge=" << prevEdge->getID() << "\n";
1714 } else {
1715 edges.push_back(u.prevEdge);
1716 /*
1717 if(bestLane->getEdge().getPurpose()!=MSEdge::EDGEFUNCTION_INTERNAL) {
1718 edges.push_back(&bestLane->getEdge());
1719 }
1720 */
1721 if (u.nextEdge != nullptr) {
1722 edges.push_back(u.nextEdge);
1723 }
1724 routeOffset = 0;
1725#ifdef DEBUG_MOVEXY_ANGLE
1726 std::cout << SIMTIME << " internal2: lane=" << bestLane->getID() << " prev=" << Named::getIDSecure(u.prevEdge) << " next=" << Named::getIDSecure(u.nextEdge) << "\n";
1727#endif
1728 }
1729 return true;
1730}
1731
1732
1733bool
1734Helper::findCloserLane(const MSEdge* edge, const Position& pos, SUMOVehicleClass vClass, double& bestDistance, MSLane** lane) {
1735 // TODO maybe there is a way to abort this early if the lane already found is good enough but simply
1736 // checking for bestDistance < POSITON_EPS gives ugly order dependencies (#7933), so think twice and profile first
1737 if (edge == nullptr) {
1738 return false;
1739 }
1740 bool newBest = false;
1741 for (MSLane* const candidateLane : edge->getLanes()) {
1742 if (!candidateLane->allowsVehicleClass(vClass)) {
1743 continue;
1744 }
1745 if (candidateLane->getShape().length() == 0) {
1746 // mapping to shapeless lanes is a bad idea
1747 continue;
1748 }
1749 double dist = candidateLane->getShape().distance2D(pos);
1750 dist = patchShapeDistance(candidateLane, pos, dist, false);
1751#ifdef DEBUG_MOVEXY
1752 std::cout << " b at lane " << candidateLane->getID() << " dist:" << dist << " best:" << bestDistance << std::endl;
1753#endif
1754 if (dist < bestDistance || (dist == bestDistance && candidateLane->getNumericalID() < (*lane)->getNumericalID())) {
1755 // is the new distance the best one? keep then...
1756 bestDistance = dist;
1757 *lane = candidateLane;
1758 newBest = true;
1759 }
1760 }
1761 if (edge->isInternal() && edge->getNumLanes() > 1) {
1762 // there is a parallel internal edge that isn't returned by getInternalFollowingEdge but is also usable for the same route
1763 for (const MSLane* const l : edge->getLanes()) {
1764 if (l->getIndex() == 0) {
1765 continue;
1766 }
1767 for (const MSLink* const link : l->getLinkCont()) {
1768 if (link->isInternalJunctionLink()) {
1769 if (findCloserLane(&link->getViaLane()->getEdge(), pos, vClass, bestDistance, lane)) {
1770 newBest = true;
1771 }
1772 }
1773 }
1774 }
1775 }
1776 return newBest;
1777}
1778
1779
1780bool
1781Helper::moveToXYMap_matchingRoutePosition(const Position& pos, const std::string& origID,
1782 const ConstMSEdgeVector& currentRoute, int routeIndex,
1783 SUMOVehicleClass vClass, bool setLateralPos,
1784 double& bestDistance, MSLane** lane, double& lanePos, int& routeOffset) {
1785#ifdef DEBUG_MOVEXY
1786 std::cout << SIMTIME << " moveToXYMap_matchingRoutePosition pos=" << pos << " vClass=" << toString(vClass) << "\n";
1787#endif
1788 //std::cout << "moveToXYMap_matchingRoutePosition pos=" << pos << "\n";
1789 routeOffset = 0;
1790 // routes may be looped which makes routeOffset ambiguous. We first try to
1791 // find the closest upcoming edge on the route and then look for closer passed edges
1792
1793 // look forward along the route
1794 const MSEdge* prev = nullptr;
1795 for (int i = routeIndex; i < (int)currentRoute.size(); ++i) {
1796 const MSEdge* cand = currentRoute[i];
1797 while (prev != nullptr) {
1798 // check internal edge(s)
1799 const MSEdge* internalCand = prev->getInternalFollowingEdge(cand, vClass);
1800#ifdef DEBUG_MOVEXY
1801 std::cout << SIMTIME << " prev=" << Named::getIDSecure(prev) << " cand=" << Named::getIDSecure(cand) << " internal=" << Named::getIDSecure(internalCand) << "\n";
1802#endif
1803 if (findCloserLane(internalCand, pos, vClass, bestDistance, lane)) {
1804 routeOffset = i - 1;
1805 }
1806 prev = internalCand;
1807 }
1808 if (findCloserLane(cand, pos, vClass, bestDistance, lane)) {
1809 routeOffset = i;
1810 }
1811 prev = cand;
1812 }
1813 // look backward along the route
1814 const MSEdge* next = currentRoute[routeIndex];
1815 for (int i = routeIndex; i >= 0; --i) {
1816 const MSEdge* cand = currentRoute[i];
1817 //std::cout << " next=" << next->getID() << " cand=" << cand->getID() << " i=" << i << " routeIndex=" << routeIndex << "\n";
1818 prev = cand;
1819 while (prev != nullptr) {
1820 // check internal edge(s)
1821 const MSEdge* internalCand = prev->getInternalFollowingEdge(next, vClass);
1822 if (findCloserLane(internalCand, pos, vClass, bestDistance, lane)) {
1823 routeOffset = i;
1824 }
1825 prev = internalCand;
1826 }
1827 if (findCloserLane(cand, pos, vClass, bestDistance, lane)) {
1828 routeOffset = i;
1829 }
1830 next = cand;
1831 }
1832 if (vClass == SVC_PEDESTRIAN) {
1833 // consider all crossings and walkingareas along the route
1834 std::map<const MSJunction*, int> routeJunctions;
1835 for (int i = 0; i < (int)currentRoute.size() - 1; ++i) {
1836 routeJunctions[currentRoute[i]->getToJunction()] = i;
1837 }
1838 std::set<const Named*> into;
1839 PositionVector shape;
1840 shape.push_back(pos);
1842 for (const Named* named : into) {
1843 const MSLane* cand = dynamic_cast<const MSLane*>(named);
1844 if ((cand->isWalkingArea() || cand->isCrossing())
1845 && routeJunctions.count(cand->getEdge().getToJunction()) != 0) {
1846 if (findCloserLane(&cand->getEdge(), pos, vClass, bestDistance, lane)) {
1847 routeOffset = routeJunctions[cand->getEdge().getToJunction()];
1848 }
1849 }
1850 }
1851 }
1852
1853 assert(lane != nullptr);
1854 // quit if no solution was found, reporting a failure
1855 if (*lane == nullptr) {
1856#ifdef DEBUG_MOVEXY
1857 std::cout << " b failed - no best route lane" << std::endl;
1858#endif
1859 return false;
1860 }
1861
1862
1863 // position may be inaccurate; let's check the given index, too
1864 // @note: this is enabled for non-internal lanes only, as otherwise the position information may ambiguous
1865 if (!(*lane)->getEdge().isInternal()) {
1866 const std::vector<MSLane*>& lanes = (*lane)->getEdge().getLanes();
1867 for (std::vector<MSLane*>::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
1868 if ((*i)->getParameter(SUMO_PARAM_ORIGID, (*i)->getID()) == origID) {
1869 if (setLateralPos) {
1870 // vehicle might end up on top of another lane with a big
1871 // lateral offset to the lane with origID.
1872 const double dist = (*i)->getShape().distance2D(pos); // get distance
1873 if (dist < (*i)->getWidth() / 2) {
1874 *lane = *i;
1875 break;
1876 }
1877 } else {
1878 *lane = *i;
1879 break;
1880 }
1881 }
1882 }
1883 }
1884 // check position, stuff, we should have the best lane along the route
1885 lanePos = MAX2(0., MIN2(double((*lane)->getLength() - NUMERICAL_EPS),
1886 (*lane)->interpolateGeometryPosToLanePos(
1887 (*lane)->getShape().nearest_offset_to_point25D(pos, false))));
1888 //std::cout << SIMTIME << " moveToXYMap_matchingRoutePosition vehicle=" << veh.getID() << " currLane=" << veh.getLane()->getID() << " routeOffset=" << routeOffset << " edges=" << toString(edges) << " lane=" << (*lane)->getID() << "\n";
1889#ifdef DEBUG_MOVEXY
1890 std::cout << " b ok lane " << (*lane)->getID() << " lanePos:" << lanePos << std::endl;
1891#endif
1892 return true;
1893}
1894
1895
1896double
1897Helper::patchShapeDistance(const MSLane* lane, const Position& pos, double dist, bool wasPerpendicular) {
1898 if (!lane->isWalkingArea() && (wasPerpendicular || lane->getShape().nearest_offset_to_point25D(pos, true) != GeomHelper::INVALID_OFFSET)) {
1899 dist = MAX2(0.0, dist - lane->getWidth() * 0.5);
1900 }
1901 return dist;
1902}
1903
1904
1905int
1907 int distType = 0;
1908 StoHelp::readCompound(data, 2, "Retrieval of distance requires two parameter as compound.");
1909 const int posType = data.readUnsignedByte();
1910 switch (posType) {
1912 roadPos.edgeID = data.readString();
1913 roadPos.pos = data.readDouble();
1914 roadPos.laneIndex = data.readUnsignedByte();
1915 break;
1916 }
1918 case libsumo::POSITION_3D: {
1919 pos.setx(data.readDouble());
1920 pos.sety(data.readDouble());
1921 if (posType == libsumo::POSITION_3D) {
1922 pos.setz(data.readDouble());
1923 }
1924 break;
1925 }
1926 default:
1927 throw TraCIException("Unknown position format used for distance request.");
1928 }
1929 distType = data.readUnsignedByte();
1930 if (distType != libsumo::REQUEST_DRIVINGDIST) {
1931 throw TraCIException("Only driving distance is supported.");
1932 }
1933 return posType;
1934}
1935
1936
1938 : VariableWrapper(handler), myResults(into), myContextResults(context), myActiveResults(&into) {
1939
1940}
1941
1942
1943void
1944Helper::SubscriptionWrapper::setContext(const std::string* const refID) {
1945 myActiveResults = refID == nullptr ? &myResults : &myContextResults[*refID];
1946}
1947
1948
1949void
1951 myActiveResults = &myResults;
1952 myResults.clear();
1953 myContextResults.clear();
1954}
1955
1956
1957bool
1958Helper::SubscriptionWrapper::wrapConnectionVector(const std::string& objID, const int variable, const std::vector<TraCIConnection>& value) {
1959 auto sl = std::make_shared<TraCIConnectionVectorWrapped>();
1960 sl->value = value;
1961 (*myActiveResults)[objID][variable] = sl;
1962 return true;
1963}
1964
1965
1966bool
1967Helper::SubscriptionWrapper::wrapDouble(const std::string& objID, const int variable, const double value) {
1968 (*myActiveResults)[objID][variable] = std::make_shared<TraCIDouble>(value);
1969 return true;
1970}
1971
1972
1973bool
1974Helper::SubscriptionWrapper::wrapInt(const std::string& objID, const int variable, const int value) {
1975 (*myActiveResults)[objID][variable] = std::make_shared<TraCIInt>(value);
1976 return true;
1977}
1978
1979
1980bool
1981Helper::SubscriptionWrapper::wrapString(const std::string& objID, const int variable, const std::string& value) {
1982 (*myActiveResults)[objID][variable] = std::make_shared<TraCIString>(value);
1983 return true;
1984}
1985
1986
1987bool
1988Helper::SubscriptionWrapper::wrapStringList(const std::string& objID, const int variable, const std::vector<std::string>& value) {
1989 auto sl = std::make_shared<TraCIStringList>();
1990 sl->value = value;
1991 (*myActiveResults)[objID][variable] = sl;
1992 return true;
1993}
1994
1995
1996bool
1997Helper::SubscriptionWrapper::wrapDoubleList(const std::string& objID, const int variable, const std::vector<double>& value) {
1998 auto sl = std::make_shared<TraCIDoubleList>();
1999 sl->value = value;
2000 (*myActiveResults)[objID][variable] = sl;
2001 return true;
2002}
2003
2004
2005bool
2006Helper::SubscriptionWrapper::wrapPosition(const std::string& objID, const int variable, const TraCIPosition& value) {
2007 (*myActiveResults)[objID][variable] = std::make_shared<TraCIPosition>(value);
2008 return true;
2009}
2010
2011
2012bool
2013Helper::SubscriptionWrapper::wrapPositionVector(const std::string& objID, const int variable, const TraCIPositionVector& value) {
2014 (*myActiveResults)[objID][variable] = std::make_shared<TraCIPositionVector>(value);
2015 return true;
2016}
2017
2018
2019bool
2020Helper::SubscriptionWrapper::wrapColor(const std::string& objID, const int variable, const TraCIColor& value) {
2021 (*myActiveResults)[objID][variable] = std::make_shared<TraCIColor>(value);
2022 return true;
2023}
2024
2025
2026bool
2027Helper::SubscriptionWrapper::wrapStringDoublePair(const std::string& objID, const int variable, const std::pair<std::string, double>& value) {
2028 (*myActiveResults)[objID][variable] = std::make_shared<TraCIRoadPosition>(value.first, value.second);
2029 return true;
2030}
2031
2032
2033bool
2034Helper::SubscriptionWrapper::wrapStringDoublePairList(const std::string& objID, const int variable, const std::vector<std::pair<std::string, double> >& value) {
2035 auto sl = std::make_shared<TraCIStringDoublePairList>();
2036 sl->value = value;
2037 (*myActiveResults)[objID][variable] = sl;
2038 return true;
2039}
2040
2041
2042bool
2043Helper::SubscriptionWrapper::wrapStringPair(const std::string& objID, const int variable, const std::pair<std::string, std::string>& value) {
2044 auto sl = std::make_shared<TraCIStringList>();
2045 sl->value.push_back(value.first);
2046 sl->value.push_back(value.second);
2047 (*myActiveResults)[objID][variable] = sl;
2048 return true;
2049}
2050
2051
2052bool
2053Helper::SubscriptionWrapper::wrapIntPair(const std::string& objID, const int variable, const std::pair<int, int>& value) {
2054 auto sl = std::make_shared<TraCIIntList>();
2055 sl->value.push_back(value.first);
2056 sl->value.push_back(value.second);
2057 (*myActiveResults)[objID][variable] = sl;
2058 return true;
2059}
2060
2061
2062bool
2063Helper::SubscriptionWrapper::wrapStage(const std::string& objID, const int variable, const TraCIStage& value) {
2064 (*myActiveResults)[objID][variable] = std::make_shared<TraCIStage>(value);
2065 return true;
2066}
2067
2068
2069bool
2070Helper::SubscriptionWrapper::wrapReservationVector(const std::string& objID, const int variable, const std::vector<libsumo::TraCIReservation>& value) {
2071 auto sl = std::make_shared<TraCIReservationVectorWrapped>();
2072 sl->value = value;
2073 (*myActiveResults)[objID][variable] = sl;
2074 return true;
2075}
2076
2077
2078bool
2079Helper::SubscriptionWrapper::wrapLogicVector(const std::string& objID, const int variable, const std::vector<libsumo::TraCILogic>& value) {
2080 auto sl = std::make_shared<TraCILogicVectorWrapped>();
2081 sl->value = value;
2082 (*myActiveResults)[objID][variable] = sl;
2083 return true;
2084}
2085
2086
2087bool
2088Helper::SubscriptionWrapper::wrapLinkVectorVector(const std::string& objID, const int variable, const std::vector<std::vector<libsumo::TraCILink> >& value) {
2089 auto sl = std::make_shared<TraCILinkVectorVectorWrapped>();
2090 sl->value = value;
2091 (*myActiveResults)[objID][variable] = sl;
2092 return true;
2093}
2094
2095
2096bool
2097Helper::SubscriptionWrapper::wrapSignalConstraintVector(const std::string& objID, const int variable, const std::vector<libsumo::TraCISignalConstraint>& value) {
2098 auto sl = std::make_shared<TraCISignalConstraintVectorWrapped>();
2099 sl->value = value;
2100 (*myActiveResults)[objID][variable] = sl;
2101 return true;
2102}
2103
2104
2105bool
2106Helper::SubscriptionWrapper::wrapJunctionFoeVector(const std::string& objID, const int variable, const std::vector<libsumo::TraCIJunctionFoe>& value) {
2107 auto sl = std::make_shared<TraCIJunctionFoeVectorWrapped>();
2108 sl->value = value;
2109 (*myActiveResults)[objID][variable] = sl;
2110 return true;
2111}
2112
2113
2114bool
2115Helper::SubscriptionWrapper::wrapNextStopDataVector(const std::string& objID, const int variable, const std::vector<libsumo::TraCINextStopData>& value) {
2116 auto sl = std::make_shared<TraCINextStopDataVectorWrapped>();
2117 sl->value = value;
2118 (*myActiveResults)[objID][variable] = sl;
2119 return true;
2120}
2121
2122
2123bool
2124Helper::SubscriptionWrapper::wrapVehicleDataVector(const std::string& objID, const int variable, const std::vector<libsumo::TraCIVehicleData>& value) {
2125 auto sl = std::make_shared<TraCIVehicleDataVectorWrapped>();
2126 sl->value = value;
2127 (*myActiveResults)[objID][variable] = sl;
2128 return true;
2129}
2130
2131
2132bool
2133Helper::SubscriptionWrapper::wrapBestLanesDataVector(const std::string& objID, const int variable, const std::vector<libsumo::TraCIBestLanesData>& value) {
2134 auto sl = std::make_shared<TraCIBestLanesDataVectorWrapped>();
2135 sl->value = value;
2136 (*myActiveResults)[objID][variable] = sl;
2137 return true;
2138}
2139
2140
2141bool
2142Helper::SubscriptionWrapper::wrapNextTLSDataVector(const std::string& objID, const int variable, const std::vector<libsumo::TraCINextTLSData>& value) {
2143 auto sl = std::make_shared<TraCINextTLSDataVectorWrapped>();
2144 sl->value = value;
2145 (*myActiveResults)[objID][variable] = sl;
2146 return true;
2147}
2148
2149
2150void
2151Helper::SubscriptionWrapper::empty(const std::string& objID) {
2152 (*myActiveResults)[objID]; // initiate the empty map to track the objectID for TRACI_ID_LIST context subscriptions
2153}
2154
2155
2156void
2157Helper::VehicleStateListener::vehicleStateChanged(const SUMOVehicle* const vehicle, MSNet::VehicleState to, const std::string& /*info*/) {
2158 myVehicleStateChanges[to].push_back(vehicle->getID());
2159}
2160
2161
2162void
2164 myTransportableStateChanges[to].push_back(transportable->getID());
2165}
2166
2167
2168}
2169
2170
2171/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define DEG2RAD(x)
Definition GeomHelper.h:35
#define RAD2DEG(x)
Definition GeomHelper.h:36
#define FAR_AWAY
Definition Helper.cpp:72
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:75
#define LANE_RTREE_QUAL
Definition MSLane.h:1850
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:299
#define TL(string)
Definition MsgHandler.h:316
void checkTimeBounds(const double time)
check the valid SUMOTime range of double input and throw an error if out of bounds
Definition SUMOTime.cpp:188
#define STEPS2TIME(x)
Definition SUMOTime.h:58
#define SPEED2DIST(x)
Definition SUMOTime.h:48
#define SIMSTEP
Definition SUMOTime.h:69
constexpr SUMOTime TIME2STEPS(double x)
Definition SUMOTime.h:60
#define SUMOTime_MAX
Definition SUMOTime.h:34
#define TS
Definition SUMOTime.h:45
#define SIMTIME
Definition SUMOTime.h:70
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_PEDESTRIAN
pedestrian
const int STOP_DURATION_SET
const int STOP_UNTIL_SET
const int STOP_PARKING_SET
std::vector< SUMOVehicleParameter::Stop > StopParVector
const int STOP_START_SET
const int STOP_CONTAINER_TRIGGER_SET
const int STOP_INDEX_FIT
const int STOP_TRIGGER_SET
const int STOP_END_SET
const std::string SUMO_PARAM_ORIGID
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_NOTHING
invalid tag, must be the last one
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_OVERHEAD_WIRE_SEGMENT
An overhead wire segment.
int gPrecision
the precision for floating point outputs
Definition StdDefs.cpp:27
const double SUMO_const_laneWidth
Definition StdDefs.h:52
T MIN2(T a, T b)
Definition StdDefs.h:80
T MAX2(T a, T b)
Definition StdDefs.h:86
T MAX3(T a, T b, T c)
Definition StdDefs.h:100
std::string toHex(const T i, std::streamsize numDigits=0)
Definition ToString.h:89
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:57
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
Boundary & grow(double by)
extends the boundary by the given amount
Definition Boundary.cpp:340
double distanceTo2D(const Position &p) const
returns the euclidean distance in the x-y-plane
Definition Boundary.cpp:262
double getHeight() const
Returns the height of the boundary (y-axis)
Definition Boundary.cpp:157
double getWidth() const
Returns the width of the boudary (x-axis)
Definition Boundary.cpp:151
double ymax() const
Returns maximum y-coordinate.
Definition Boundary.cpp:133
double xmax() const
Returns maximum x-coordinate.
Definition Boundary.cpp:121
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
const Boundary & getConvBoundary() const
Returns the converted boundary.
static const double INVALID_OFFSET
a value to signify offsets outside the range of [0, Line.length()]
Definition GeomHelper.h:50
static double naviDegree(const double angle)
static double angleDiff(const double angle1, const double angle2)
Returns the difference of the second angle to the first angle in radiants.
static double getMinAngleDiff(double angle1, double angle2)
Returns the minimum distance (clockwise/counter-clockwise) between both angles.
The base class for microscopic and mesoscopic vehicles.
double getLength() const
Returns the vehicle's length.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
Calibrates the flow on a segment to a specified one.
const MSLane * getLane() const
AspiredState getCurrentStateInterval() const
static const std::map< std::string, MSCalibrator * > & getInstances()
return all calibrator instances
A simple description of a position on a lane (crossing of a lane)
A detector of vehicles passing an area between entry/exit points.
const CrossSectionVector & getEntries() const
Returns the entry cross sections.
const CrossSectionVector & getExits() const
Returns the exit cross sections.
A road/street connecting two junctions.
Definition MSEdge.h:78
bool isCrossing() const
return whether this edge is a pedestrian crossing
Definition MSEdge.h:275
SVCPermissions getPermissions() const
Returns the combined permissions of all lanes of this edge.
Definition MSEdge.h:659
bool isWalkingArea() const
return whether this edge is walking area
Definition MSEdge.h:289
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition MSEdge.h:169
const MSEdge * getOppositeEdge() const
Returns the opposite direction edge if on exists else a nullptr.
Definition MSEdge.cpp:1423
bool isNormal() const
return whether this edge is an internal edge
Definition MSEdge.h:265
const MSJunction * getToJunction() const
Definition MSEdge.h:428
double getLength() const
return the length of the edge
Definition MSEdge.h:695
const MSJunction * getFromJunction() const
Definition MSEdge.h:424
int getNumLanes() const
Definition MSEdge.h:173
bool isInternal() const
return whether this edge is an internal edge
Definition MSEdge.h:270
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:1117
const MSEdgeVector & getPredecessors() const
Definition MSEdge.h:419
const MSEdge * getInternalFollowingEdge(const MSEdge *followerAfterInternal, SUMOVehicleClass vClass) const
Definition MSEdge.cpp:970
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition MSEdge.cpp:1342
The base class for an intersection.
Definition MSJunction.h:58
Representation of a lane in the micro simulation.
Definition MSLane.h:84
MSLane * getParallelLane(int offset, bool includeOpposite=true) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
Definition MSLane.cpp:2905
std::pair< MSVehicle *const, double > getFollower(const MSVehicle *ego, double egoPos, double dist, MinorLinkMode mLinkMode, bool maxSearchDist=false) const
Find follower vehicle for the given ego vehicle (which may be on the opposite direction lane)
Definition MSLane.cpp:4482
void visit(const MSLane::StoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
Definition MSLane.h:1378
static void fill(RTREE &into)
Fills the given RTree with lane instances.
Definition MSLane.cpp:2578
bool isWalkingArea() const
Definition MSLane.cpp:2693
std::set< MSVehicle * > getVehiclesInRange(const double a, const double b) const
Returns all vehicles on the lane overlapping with the interval [a,b].
Definition MSLane.cpp:4386
double getLength() const
Returns the lane's length.
Definition MSLane.h:632
std::vector< const MSLink * > getUpcomingLinks(double pos, double range, const std::vector< MSLane * > &contLanes) const
Returns all upcoming links within given range along the given (non-internal) continuation lanes measu...
Definition MSLane.cpp:4417
std::set< MSVehicle * > getSurroundingVehicles(double startPos, double downstreamDist, double upstreamDist, std::shared_ptr< LaneCoverageInfo > checkedLanes) const
Returns all vehicles closer than downstreamDist along the road network starting on the given position...
Definition MSLane.cpp:4334
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition MSLane.h:959
int getIndex() const
Returns the lane's index.
Definition MSLane.h:668
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
Definition MSLane.cpp:4477
MSLane * getLogicalPredecessorLane() const
get the most likely predecessor lane (sorted using by_connections_to_sorter). The result is cached in...
Definition MSLane.cpp:3271
bool isCrossing() const
Definition MSLane.cpp:2681
bool isInternal() const
Definition MSLane.cpp:2669
@ FOLLOW_ALWAYS
Definition MSLane.h:1009
@ FOLLOW_NEVER
Definition MSLane.h:1008
double interpolateGeometryPosToLanePos(double geometryPos) const
Definition MSLane.h:567
std::pair< MSVehicle *const, double > getLeader(const MSVehicle *veh, const double vehPos, const std::vector< MSLane * > &bestLaneConts, double dist=-1, bool checkTmpVehicles=false) const
Returns the immediate leader of veh and the distance to veh starting on this lane.
Definition MSLane.cpp:2974
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Definition MSLane.h:484
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
Definition MSLane.h:514
virtual const PositionVector & getShape(bool) const
Definition MSLane.h:294
MSLane * getParallelOpposite() const
return the opposite direction lane of this lanes edge or nullptr
Definition MSLane.cpp:4471
MSEdge & getEdge() const
Returns the lane's edge.
Definition MSLane.h:790
double getWidth() const
Returns the lane's width.
Definition MSLane.h:661
VehicleState
Definition of a vehicle state.
Definition MSNet.h:637
@ ARRIVED
The vehicle arrived at his destination (is deleted)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:201
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Definition MSNet.h:476
MSVehicleRouter & getRouterTT(int rngIndex, const Prohibitions &prohibited={}) const
Definition MSNet.cpp:1659
static bool hasInstance()
Returns whether the network was already constructed.
Definition MSNet.h:159
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition MSNet.cpp:1527
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
Definition MSNet.cpp:1385
void addTransportableStateListener(TransportableStateListener *listener)
Adds a transportable states listener.
Definition MSNet.cpp:1413
TransportableState
Definition of a transportable state.
Definition MSNet.h:714
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:403
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition MSNet.cpp:1317
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
Definition MSNet.cpp:1578
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
Definition MSPerson.cpp:344
Influencer & getInfluencer()
Returns the velocity/lane influencer.
Definition MSPerson.cpp:319
double getDistanceBetween(double fromPos, double toPos, const MSLane *fromLane, const MSLane *toLane, int routePosition=0) const
Compute the distance between 2 given edges on this route, optionally including the length of internal...
Definition MSRoute.cpp:323
A lane area vehicles can halt at.
double getBeginLanePosition() const
Returns the begin position of this stop.
double getEndLanePosition() const
Returns the end position of this stop.
const MSLane & getLane() const
Returns the lane this stop is located at.
Storage for all programs of a single tls.
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
void setRemoteControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
const std::vector< const MSLane * > getUpcomingLanesUntil(double distance) const
Returns the upcoming (best followed by default 0) sequence of lanes to continue the route starting at...
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
Definition MSVehicle.h:605
MSAbstractLaneChangeModel & getLaneChangeModel()
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
const std::vector< const MSLane * > getPastLanesUntil(double distance) const
Returns the sequence of past lanes (right-most on edge) based on the route starting at the current la...
const MSLane * getLane() const
Returns the lane the vehicle is on.
Definition MSVehicle.h:581
Influencer & getInfluencer()
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
Definition MSVehicle.h:413
double getPositionOnLane() const
Get the vehicle's position along the lane.
Definition MSVehicle.h:374
The car-following model and parameter.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
const std::string & getID() const
Returns the name of the vehicle type.
double getLength() const
Get vehicle's length [m].
Allows to store the object; used as context while traveling the rtree in TraCI.
Definition Named.h:89
Base class for objects which have an id.
Definition Named.h:53
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
Definition Named.h:66
const std::string & getID() const
Returns the id.
Definition Named.h:73
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
void setx(double x)
set position x
Definition Position.h:67
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition Position.h:273
double x() const
Returns the x-position.
Definition Position.h:52
void setz(double z)
set position z
Definition Position.h:77
double z() const
Returns the z-position.
Definition Position.h:62
double angleTo2D(const Position &other) const
returns the angle in the plane of the vector pointing from here to the other position (in radians bet...
Definition Position.h:283
void sety(double y)
set position y
Definition Position.h:72
double y() const
Returns the y-position.
Definition Position.h:57
A list of positions.
void append(const PositionVector &v, double sameThreshold=2.0)
double length() const
Returns the length.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
double distance2D(const Position &p, bool perpendicular=false) const
closest 2D-distance to point p (or -1 if perpendicular is true and the point is beyond this vector)
void prepend(const PositionVector &v, double sameThreshold=2.0)
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
std::pair< PositionVector, PositionVector > splitAt(double where, bool use2D=false) const
Returns the two lists made when this list vector is splitted at the given point.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
void extrapolate2D(const double val, const bool onlyFirst=false)
extrapolate position vector in two dimensions (Z is ignored)
double nearest_offset_to_point25D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D projected onto the 3D geometry
unsigned char red() const
Returns the red-amount of the color.
Definition RGBColor.cpp:78
unsigned char alpha() const
Returns the alpha-amount of the color.
Definition RGBColor.cpp:96
unsigned char green() const
Returns the green-amount of the color.
Definition RGBColor.cpp:84
unsigned char blue() const
Returns the blue-amount of the color.
Definition RGBColor.cpp:90
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...
Representation of a vehicle, person, or container.
virtual bool isVehicle() const
Whether it is a vehicle.
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
virtual const MSEdge * getEdge() const =0
Returns the (normal) route edge the object is currently at.
Representation of a vehicle.
Definition SUMOVehicle.h:63
virtual double getAngle() const =0
Get the vehicle's angle.
Definition of vehicle stop (position and duration)
int getFlags() const
return flags as per Vehicle::getStops
SUMOTime started
the time at which this stop was reached
std::string edge
The edge to stop at.
ParkingType parking
whether the vehicle is removed from the net while stopping
std::string lane
The lane to stop at.
double speed
the speed at which this stop counts as reached (waypoint mode)
std::string parkingarea
(Optional) parking area if one is assigned to the stop
std::string split
the id of the vehicle (train portion) that splits of upon reaching this stop
double startPos
The stopping position start.
std::string line
the new line id of the trip within a cyclical public transport route
std::string chargingStation
(Optional) charging station if one is assigned to the stop
std::string overheadWireSegment
(Optional) overhead line segment if one is assigned to the stop
int parametersSet
Information for the output which parameter were set.
int index
at which position in the stops list
std::string join
the id of the vehicle (train portion) to which this vehicle shall be joined
SUMOTime until
The time at which the vehicle may continue its journey.
std::string actType
act Type (only used by Persons) (used by netedit)
bool triggered
whether an arriving person lets the vehicle continue
SUMOTime ended
the time at which this stop was ended
double endPos
The stopping position end.
std::string busstop
(Optional) bus stop if one is assigned to the stop
std::string tripId
id of the trip within a cyclical public transport route
std::string containerstop
(Optional) container stop if one is assigned to the stop
bool containerTriggered
whether an arriving container lets the vehicle continue
SUMOTime arrival
The (expected) time at which the vehicle reaches the stop.
SUMOTime duration
The stopping duration.
const MSEdge * nextEdge
Definition Helper.h:212
const MSEdge * prevEdge
Definition Helper.h:211
bool wrapIntPair(const std::string &objID, const int variable, const std::pair< int, int > &value)
Definition Helper.cpp:2053
bool wrapJunctionFoeVector(const std::string &objID, const int variable, const std::vector< TraCIJunctionFoe > &value)
Definition Helper.cpp:2106
bool wrapDouble(const std::string &objID, const int variable, const double value)
Definition Helper.cpp:1967
void empty(const std::string &objID)
Definition Helper.cpp:2151
bool wrapConnectionVector(const std::string &objID, const int variable, const std::vector< TraCIConnection > &value)
Definition Helper.cpp:1958
bool wrapStringDoublePairList(const std::string &objID, const int variable, const std::vector< std::pair< std::string, double > > &value)
Definition Helper.cpp:2034
bool wrapPositionVector(const std::string &objID, const int variable, const TraCIPositionVector &value)
Definition Helper.cpp:2013
bool wrapLinkVectorVector(const std::string &objID, const int variable, const std::vector< std::vector< TraCILink > > &value)
Definition Helper.cpp:2088
bool wrapSignalConstraintVector(const std::string &objID, const int variable, const std::vector< TraCISignalConstraint > &value)
Definition Helper.cpp:2097
bool wrapColor(const std::string &objID, const int variable, const TraCIColor &value)
Definition Helper.cpp:2020
bool wrapInt(const std::string &objID, const int variable, const int value)
Definition Helper.cpp:1974
bool wrapReservationVector(const std::string &objID, const int variable, const std::vector< TraCIReservation > &value)
Definition Helper.cpp:2070
bool wrapNextTLSDataVector(const std::string &objID, const int variable, const std::vector< TraCINextTLSData > &value)
Definition Helper.cpp:2142
bool wrapBestLanesDataVector(const std::string &objID, const int variable, const std::vector< TraCIBestLanesData > &value)
Definition Helper.cpp:2133
bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)
Definition Helper.cpp:1988
bool wrapPosition(const std::string &objID, const int variable, const TraCIPosition &value)
Definition Helper.cpp:2006
bool wrapString(const std::string &objID, const int variable, const std::string &value)
Definition Helper.cpp:1981
bool wrapLogicVector(const std::string &objID, const int variable, const std::vector< TraCILogic > &value)
Definition Helper.cpp:2079
bool wrapNextStopDataVector(const std::string &objID, const int variable, const std::vector< TraCINextStopData > &value)
Definition Helper.cpp:2115
bool wrapStage(const std::string &objID, const int variable, const TraCIStage &value)
Definition Helper.cpp:2063
bool wrapStringPair(const std::string &objID, const int variable, const std::pair< std::string, std::string > &value)
Definition Helper.cpp:2043
bool wrapStringDoublePair(const std::string &objID, const int variable, const std::pair< std::string, double > &value)
Definition Helper.cpp:2027
SubscriptionWrapper(VariableWrapper::SubscriptionHandler handler, SubscriptionResults &into, ContextSubscriptionResults &context)
Definition Helper.cpp:1937
bool wrapVehicleDataVector(const std::string &objID, const int variable, const std::vector< TraCIVehicleData > &value)
Definition Helper.cpp:2124
void setContext(const std::string *const refID)
Definition Helper.cpp:1944
bool wrapDoubleList(const std::string &objID, const int variable, const std::vector< double > &value)
Definition Helper.cpp:1997
void transportableStateChanged(const MSTransportable *const transportable, MSNet::TransportableState to, const std::string &info="")
Called if a transportable changes its state.
Definition Helper.cpp:2163
std::map< MSNet::TransportableState, std::vector< std::string > > myTransportableStateChanges
Changes in the states of simulated transportables.
Definition Helper.h:278
std::map< MSNet::VehicleState, std::vector< std::string > > myVehicleStateChanges
Changes in the states of simulated vehicles.
Definition Helper.h:271
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to, const std::string &info="")
Called if a vehicle changes its state.
Definition Helper.cpp:2157
static Position makePosition(const TraCIPosition &position)
Definition Helper.cpp:425
static MSEdge * getEdge(const std::string &edgeID)
Definition Helper.cpp:431
static double patchShapeDistance(const MSLane *lane, const Position &pos, double dist, bool wasPerpendicular)
return the distance of pos from the area covered by this lane
Definition Helper.cpp:1897
static void cleanup()
Definition Helper.cpp:722
static double getDrivingDistance(std::pair< const MSLane *, double > &roadPos1, std::pair< const MSLane *, double > &roadPos2)
Definition Helper.cpp:494
static void collectObjectsInRange(int domain, const PositionVector &shape, double range, std::set< const Named * > &into)
Definition Helper.cpp:861
static MSCalibrator::AspiredState getCalibratorState(const MSCalibrator *c)
Definition Helper.cpp:771
static TraCIPosition makeTraCIPosition(const Position &position, const bool includeZ=false)
Definition Helper.cpp:415
static LANE_RTREE_QUAL * myLaneTree
A lookup tree of lanes.
Definition Helper.h:297
static void applySubscriptionFilterTurn(const Subscription &s, std::set< const SUMOTrafficObject * > &vehs)
Apply the subscription filter "turn": Gather upcoming junctions and vialanes within downstream distan...
Definition Helper.cpp:1209
static void findObjectShape(int domain, const std::string &id, PositionVector &shape)
Definition Helper.cpp:781
static void clearStateChanges()
Definition Helper.cpp:760
static PositionVector makePositionVector(const TraCIPositionVector &vector)
Definition Helper.cpp:385
static void fuseLaneCoverage(std::shared_ptr< LaneCoverageInfo > aggregatedLaneCoverage, const std::shared_ptr< LaneCoverageInfo > newLaneCoverage)
Adds lane coverage information from newLaneCoverage into aggregatedLaneCoverage.
Definition Helper.cpp:357
static bool moveToXYMap_matchingRoutePosition(const Position &pos, const std::string &origID, const ConstMSEdgeVector &currentRoute, int routeIndex, SUMOVehicleClass vClass, bool setLateralPos, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset)
Definition Helper.cpp:1781
static void debugPrint(const SUMOTrafficObject *veh)
Definition Helper.cpp:97
static MSPerson * getPerson(const std::string &id)
Definition Helper.cpp:530
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 TraCIPositionVector makeTraCIPositionVector(const PositionVector &positionVector)
helper functions
Definition Helper.cpp:375
static int readDistanceRequest(tcpip::Storage &data, TraCIRoadPosition &roadPos, Position &pos)
Definition Helper.cpp:1906
static const std::vector< std::string > & getTransportableStateChanges(const MSNet::TransportableState state)
Definition Helper.cpp:754
static std::map< int, std::shared_ptr< VariableWrapper > > myWrapper
Map of commandIds -> their executors; applicable if the executor applies to the method footprint.
Definition Helper.h:288
static void clearSubscriptions()
Definition Helper.cpp:241
static MSBaseVehicle * getVehicle(const std::string &id)
Definition Helper.cpp:516
static void applySubscriptionFilterLateralDistanceSinglePass(const Subscription &s, std::set< std::string > &objIDs, std::set< const SUMOTrafficObject * > &vehs, const std::vector< const MSLane * > &lanes, double posOnLane, double posLat, bool isDownstream)
Definition Helper.cpp:1347
static MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag type)
Definition Helper.cpp:566
static TraCIColor makeTraCIColor(const RGBColor &color)
Definition Helper.cpp:398
static void applySubscriptionFilterFieldOfVision(const Subscription &s, std::set< std::string > &objIDs)
Definition Helper.cpp:1274
static Subscription * myLastContextSubscription
The last context subscription.
Definition Helper.h:285
static TraCINextStopData buildStopData(const SUMOVehicleParameter::Stop &stopPar)
Definition Helper.cpp:682
static void registerStateListener()
Definition Helper.cpp:739
static TransportableStateListener myTransportableStateListener
Changes in the states of simulated transportables.
Definition Helper.h:294
static void setRemoteControlled(MSVehicle *v, Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
Definition Helper.cpp:1424
static int postProcessRemoteControl()
return number of remote-controlled entities
Definition Helper.cpp:1439
static void applySubscriptionFilters(const Subscription &s, std::set< std::string > &objIDs)
Filter the given ID-Set (which was obtained from an R-Tree search) according to the filters set by th...
Definition Helper.cpp:931
static std::map< std::string, MSVehicle * > myRemoteControlledVehicles
Definition Helper.h:299
static const MSVehicleType & getVehicleType(const std::string &vehicleID)
Definition Helper.cpp:551
static bool moveToXYMap(const Position &pos, double maxRouteDistance, bool mayLeaveNetwork, const std::string &origID, const double angle, double speed, const ConstMSEdgeVector &currentRoute, const int routePosition, const MSLane *currentLane, double currentLanePos, bool onRoad, SUMOVehicleClass vClass, double currentAngle, bool setLateralPos, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset, ConstMSEdgeVector &edges)
Definition Helper.cpp:1464
static std::pair< MSLane *, double > convertCartesianToRoadMap(const Position &pos, const SUMOVehicleClass vClass)
Definition Helper.cpp:458
static MSTLLogicControl::TLSLogicVariants & getTLS(const std::string &id)
Definition Helper.cpp:557
static SUMOTrafficObject * getTrafficObject(int domain, const std::string &id)
Definition Helper.cpp:540
static VehicleStateListener myVehicleStateListener
Changes in the states of simulated vehicles.
Definition Helper.h:291
static std::vector< Subscription > mySubscriptions
The list of known, still valid subscriptions.
Definition Helper.h:282
static SUMOVehicleParameter::Stop buildStopParameters(const std::string &edgeOrStoppingPlaceID, double pos, int laneIndex, double startPos, int flags, double duration, double until)
Definition Helper.cpp:576
static void handleSingleSubscription(const Subscription &s)
Definition Helper.cpp:273
static void applySubscriptionFilterLateralDistance(const Subscription &s, std::set< const SUMOTrafficObject * > &vehs, double downstreamDist, double upstreamDist, double lateralDist)
Apply the subscription filter "lateral distance": Only return vehicles within the given lateral dista...
Definition Helper.cpp:1313
static const std::vector< std::string > & getVehicleStateChanges(const MSNet::VehicleState state)
Definition Helper.cpp:748
static void collectObjectIDsInRange(int domain, const PositionVector &shape, double range, std::set< std::string > &into)
Definition Helper.cpp:851
static void handleSubscriptions(const SUMOTime t)
Definition Helper.cpp:172
static Subscription * addSubscriptionFilter(SubscriptionFilterType filter)
Definition Helper.cpp:251
static std::vector< Subscription >::iterator eraseSubscription(std::vector< Subscription > &subscriptions, std::vector< Subscription >::iterator position, Subscription *&lastContextSubscription)
Definition Helper.cpp:223
static const MSLane * getLaneChecking(const std::string &edgeID, int laneIndex, double pos)
Definition Helper.cpp:441
static RGBColor makeRGBColor(const TraCIColor &color)
Definition Helper.cpp:409
static void applySubscriptionFilterLanes(const Subscription &s, std::set< const SUMOTrafficObject * > &vehs, std::vector< int > &filterLanes, double downstreamDist, double upstreamDist, bool disregardOppositeDirection)
Apply the subscription filter "lanes": Only return vehicles on list of lanes relative to ego vehicle....
Definition Helper.cpp:1111
static std::map< std::string, MSPerson * > myRemoteControlledPersons
Definition Helper.h:300
static bool needNewSubscription(libsumo::Subscription &s, std::vector< Subscription > &subscriptions, libsumo::Subscription *&modifiedSubscription)
Definition Helper.cpp:198
static bool findCloserLane(const MSEdge *edge, const Position &pos, SUMOVehicleClass vClass, double &bestDistance, MSLane **lane)
Definition Helper.cpp:1734
static int readCompound(tcpip::Storage &ret, int expectedSize=-1, const std::string &error="")
static std::shared_ptr< tcpip::Storage > toStorage(const TraCIResult &v)
Representation of a subscription.
double filterUpstreamDist
Upstream distance specified by the upstream distance filter.
int commandId
commandIdArg The command id of the subscription
std::set< std::string > filterVTypes
vTypes specified by the vTypes filter
double filterFieldOfVisionOpeningAngle
Opening angle (in deg) specified by the field of vision filter.
std::vector< int > filterLanes
lanes specified by the lanes filter
std::string id
The id of the object that is subscribed.
SUMOTime endTime
The end time of the subscription.
int contextDomain
The domain ID of the context.
double filterFoeDistToJunction
Foe distance to junction specified by the turn filter.
bool isVehicleToVehicleContextSubscription() const
SUMOTime beginTime
The begin time of the subscription.
std::vector< int > variables
The subscribed variables.
SVCPermissions filterVClasses
vClasses specified by the vClasses filter,
bool isVehicleToPersonContextSubscription() const
double filterDownstreamDist
Downstream distance specified by the downstream distance filter.
double filterLateralDist
Lateral distance specified by the lateral distance filter.
int activeFilters
Active filters for the subscription (bitset,.
double range
The range of the context.
std::vector< std::shared_ptr< tcpip::Storage > > parameters
The parameters for the subscribed variables.
An error which allows to continue.
Definition TraCIDefs.h:145
virtual void empty(const std::string &)
bool(* SubscriptionHandler)(const std::string &objID, const int variable, VariableWrapper *wrapper, tcpip::Storage *paramData)
Definition of a method to be called for serving an associated commandID.
virtual void setContext(const std::string *const)
virtual std::string readString()
Definition storage.cpp:180
virtual int readUnsignedByte()
Definition storage.cpp:155
virtual double readDouble()
Definition storage.cpp:362
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int LAST_STEP_VEHICLE_NUMBER
TRACI_CONST int POSITION_3D
TRACI_CONST int CMD_GET_CHARGINGSTATION_VARIABLE
TRACI_CONST int POSITION_ROADMAP
TRACI_CONST int CMD_SUBSCRIBE_EDGE_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_LANE_CONTEXT
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int CMD_GET_PARKINGAREA_VARIABLE
TRACI_CONST int CMD_GET_POI_VARIABLE
TRACI_CONST int CMD_GET_TL_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_VEHICLE_CONTEXT
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
Definition TraCIDefs.h:384
TRACI_CONST int CMD_GET_REROUTER_VARIABLE
TRACI_CONST int VAR_ROAD_ID
TRACI_CONST int CMD_GET_VEHICLE_VARIABLE
TRACI_CONST int CMD_GET_EDGE_VARIABLE
TRACI_CONST int CMD_GET_CALIBRATOR_VARIABLE
TRACI_CONST int CMD_GET_PERSON_VARIABLE
TRACI_CONST int CMD_GET_ROUTEPROBE_VARIABLE
TRACI_CONST int CMD_GET_LANEAREA_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_BUSSTOP_CONTEXT
TRACI_CONST int POSITION_2D
TRACI_CONST int CMD_GET_BUSSTOP_VARIABLE
TRACI_CONST int CMD_GET_ROUTE_VARIABLE
TRACI_CONST int CMD_GET_MEANDATA_VARIABLE
TRACI_CONST int CMD_GET_JUNCTION_VARIABLE
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition TraCIDefs.h:383
TRACI_CONST int CMD_GET_VARIABLESPEEDSIGN_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_CALIBRATOR_CONTEXT
TRACI_CONST int VAR_LANEPOSITION
TRACI_CONST int CMD_GET_SIM_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_PERSON_CONTEXT
TRACI_CONST int CMD_GET_VEHICLETYPE_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_CHARGINGSTATION_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_POLYGON_CONTEXT
TRACI_CONST int REQUEST_DRIVINGDIST
TRACI_CONST int CMD_GET_LANE_VARIABLE
TRACI_CONST int CMD_GET_GUI_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_PARKINGAREA_CONTEXT
TRACI_CONST int CMD_GET_POLYGON_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_MULTIENTRYEXIT_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_VEHICLE_VARIABLE
TRACI_CONST int CMD_GET_MULTIENTRYEXIT_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_INDUCTIONLOOP_CONTEXT
SubscriptionFilterType
Filter types for context subscriptions.
@ SUBS_FILTER_LEAD_FOLLOW
@ SUBS_FILTER_UPSTREAM_DIST
@ SUBS_FILTER_VTYPE
@ SUBS_FILTER_NO_RTREE
@ SUBS_FILTER_LANES
@ SUBS_FILTER_NOOPPOSITE
@ SUBS_FILTER_DOWNSTREAM_DIST
@ SUBS_FILTER_LATERAL_DIST
@ SUBS_FILTER_TURN
@ SUBS_FILTER_VCLASS
@ SUBS_FILTER_MANEUVER
@ SUBS_FILTER_FIELD_OF_VISION
TRACI_CONST int CMD_SUBSCRIBE_LANEAREA_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_POI_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_INDUCTIONLOOP_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_SIM_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_MULTIENTRYEXIT_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_LANE_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_PERSON_VARIABLE
TRACI_CONST int CMD_GET_INDUCTIONLOOP_VARIABLE
TRACI_CONST int CMD_GET_OVERHEADWIRE_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_LANEAREA_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_JUNCTION_CONTEXT
std::map< int, std::shared_ptr< libsumo::TraCIResult > > TraCIResults
{variable->value}
Definition TraCIDefs.h:381
TRACI_CONST int CMD_SUBSCRIBE_EDGE_VARIABLE
A 2D or 3D-position, for 2D positions z == INVALID_DOUBLE_VALUE.
Definition TraCIDefs.h:184
A list of positions.
Definition TraCIDefs.h:245
std::vector< TraCIPosition > value
Definition TraCIDefs.h:255
An edgeId, position and laneIndex.
Definition TraCIDefs.h:206