Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
libsumo/Vehicle.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2012-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
19// C++ Vehicle API
20/****************************************************************************/
21#include <config.h>
22
35#include <microsim/MSStop.h>
36#include <microsim/MSVehicle.h>
41#include <microsim/MSNet.h>
42#include <microsim/MSEdge.h>
43#include <microsim/MSLane.h>
48#include <mesosim/MEVehicle.h>
50#include <libsumo/TraCIDefs.h>
52#include "Helper.h"
53#include "Route.h"
54#include "Polygon.h"
55#include "Vehicle.h"
56
57#define CALL_MICRO_FUN(veh, fun, mesoResult) ((dynamic_cast<MSVehicle*>(veh) == nullptr ? (mesoResult) : dynamic_cast<MSVehicle*>(veh)->fun))
58#define CALL_MESO_FUN(veh, fun, microResult) ((dynamic_cast<MEVehicle*>(veh) == nullptr ? (microResult) : dynamic_cast<MEVehicle*>(veh)->fun))
59
60// ===========================================================================
61// debug defines
62// ===========================================================================
63//#define DEBUG_NEIGHBORS
64//#define DEBUG_DYNAMIC_SHAPES
65//#define DEBUG_MOVEXY
66#define DEBUG_COND (veh->isSelected())
67
68
69
70namespace libsumo {
71// ===========================================================================
72// static member initializations
73// ===========================================================================
74SubscriptionResults Vehicle::mySubscriptionResults;
75ContextSubscriptionResults Vehicle::myContextSubscriptionResults;
76
77
78// ===========================================================================
79// static member definitions
80// ===========================================================================
81bool
82Vehicle::isVisible(const SUMOVehicle* veh) {
83 return veh->isOnRoad() || veh->isParking() || veh->wasRemoteControlled();
84}
85
86
87bool
88Vehicle::isOnInit(const std::string& vehID) {
90 return sumoVehicle == nullptr || sumoVehicle->getLane() == nullptr;
91}
92
93
94std::vector<std::string>
95Vehicle::getIDList() {
96 std::vector<std::string> ids;
98 for (MSVehicleControl::constVehIt i = c.loadedVehBegin(); i != c.loadedVehEnd(); ++i) {
99 if (isVisible((*i).second)) {
100 ids.push_back((*i).first);
101 }
102 }
103 return ids;
104}
105
106int
107Vehicle::getIDCount() {
108 return (int)getIDList().size();
109}
110
111
112double
113Vehicle::getSpeed(const std::string& vehID) {
114 MSBaseVehicle* veh = Helper::getVehicle(vehID);
115 return isVisible(veh) ? veh->getSpeed() : INVALID_DOUBLE_VALUE;
116}
117
118double
119Vehicle::getLateralSpeed(const std::string& vehID) {
120 MSBaseVehicle* veh = Helper::getVehicle(vehID);
121 return isVisible(veh) ? CALL_MICRO_FUN(veh, getLaneChangeModel().getSpeedLat(), 0) : INVALID_DOUBLE_VALUE;
122}
123
124
125double
126Vehicle::getAcceleration(const std::string& vehID) {
127 MSBaseVehicle* veh = Helper::getVehicle(vehID);
128 return isVisible(veh) ? CALL_MICRO_FUN(veh, getAcceleration(), 0) : INVALID_DOUBLE_VALUE;
129}
130
131
132double
133Vehicle::getSpeedWithoutTraCI(const std::string& vehID) {
134 MSBaseVehicle* veh = Helper::getVehicle(vehID);
135 return isVisible(veh) ? CALL_MICRO_FUN(veh, getSpeedWithoutTraciInfluence(), veh->getSpeed()) : INVALID_DOUBLE_VALUE;
136}
137
138
139TraCIPosition
140Vehicle::getPosition(const std::string& vehID, const bool includeZ) {
141 MSBaseVehicle* veh = Helper::getVehicle(vehID);
142 if (isVisible(veh)) {
143 return Helper::makeTraCIPosition(veh->getPosition(), includeZ);
144 }
145 return TraCIPosition();
146}
147
148
149TraCIPosition
150Vehicle::getPosition3D(const std::string& vehID) {
151 return getPosition(vehID, true);
152}
153
154
155double
156Vehicle::getAngle(const std::string& vehID) {
157 MSBaseVehicle* veh = Helper::getVehicle(vehID);
158 return isVisible(veh) ? GeomHelper::naviDegree(veh->getAngle()) : INVALID_DOUBLE_VALUE;
159}
160
161
162double
163Vehicle::getSlope(const std::string& vehID) {
164 MSBaseVehicle* veh = Helper::getVehicle(vehID);
165 return (veh->isOnRoad() || veh->isParking()) ? veh->getSlope() : INVALID_DOUBLE_VALUE;
166}
167
168
169std::string
170Vehicle::getRoadID(const std::string& vehID) {
171 MSBaseVehicle* veh = Helper::getVehicle(vehID);
172 return isVisible(veh) ? CALL_MICRO_FUN(veh, getLane()->getEdge().getID(), veh->getEdge()->getID()) : "";
173}
174
175
176std::string
177Vehicle::getLaneID(const std::string& vehID) {
178 MSBaseVehicle* veh = Helper::getVehicle(vehID);
179 return veh->isOnRoad() ? CALL_MICRO_FUN(veh, getLane()->getID(), "") : "";
180}
181
182
183int
184Vehicle::getLaneIndex(const std::string& vehID) {
185 MSBaseVehicle* veh = Helper::getVehicle(vehID);
186 if (veh->isOnRoad()) {
187 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
188 if (microVeh != nullptr) {
189 return microVeh->getLane()->getIndex();
190 } else {
191 MEVehicle* mesoVeh = dynamic_cast<MEVehicle*>(veh);
192 return mesoVeh->getQueIndex();
193 }
194 } else {
195 return INVALID_INT_VALUE;
196 }
197}
198
199std::string
200Vehicle::getSegmentID(const std::string& vehID) {
201 MSBaseVehicle* veh = Helper::getVehicle(vehID);
202 return veh->isOnRoad() ? CALL_MESO_FUN(veh, getSegment()->getID(), "") : "";
203}
204
205int
206Vehicle::getSegmentIndex(const std::string& vehID) {
207 MSBaseVehicle* veh = Helper::getVehicle(vehID);
208 return veh->isOnRoad() ? CALL_MESO_FUN(veh, getSegment()->getIndex(), INVALID_INT_VALUE) : INVALID_INT_VALUE;
209}
210
211std::string
212Vehicle::getTypeID(const std::string& vehID) {
213 return Helper::getVehicleType(vehID).getID();
214}
215
216
217std::string
218Vehicle::getRouteID(const std::string& vehID) {
219 return Helper::getVehicle(vehID)->getRoute().getID();
220}
221
222
223double
224Vehicle::getDeparture(const std::string& vehID) {
225 MSBaseVehicle* veh = Helper::getVehicle(vehID);
227}
228
229
230double
231Vehicle::getDepartDelay(const std::string& vehID) {
232 return STEPS2TIME(Helper::getVehicle(vehID)->getDepartDelay());
233}
234
235
236int
237Vehicle::getRouteIndex(const std::string& vehID) {
238 MSBaseVehicle* veh = Helper::getVehicle(vehID);
239 return veh->hasDeparted() ? veh->getRoutePosition() : INVALID_INT_VALUE;
240}
241
242
243TraCIColor
244Vehicle::getColor(const std::string& vehID) {
245 return Helper::makeTraCIColor(Helper::getVehicle(vehID)->getParameter().color);
246}
247
248double
249Vehicle::getLanePosition(const std::string& vehID) {
250 MSBaseVehicle* veh = Helper::getVehicle(vehID);
251 return (veh->isOnRoad() || veh->isParking()) ? veh->getPositionOnLane() : INVALID_DOUBLE_VALUE;
252}
253
254double
255Vehicle::getLateralLanePosition(const std::string& vehID) {
256 MSBaseVehicle* veh = Helper::getVehicle(vehID);
257 return veh->isOnRoad() ? CALL_MICRO_FUN(veh, getLateralPositionOnLane(), 0) : INVALID_DOUBLE_VALUE;
258}
259
260double
261Vehicle::getCO2Emission(const std::string& vehID) {
262 MSBaseVehicle* veh = Helper::getVehicle(vehID);
263 return isVisible(veh) ? veh->getEmissions<PollutantsInterface::CO2>() : INVALID_DOUBLE_VALUE;
264}
265
266double
267Vehicle::getCOEmission(const std::string& vehID) {
268 MSBaseVehicle* veh = Helper::getVehicle(vehID);
269 return isVisible(veh) ? veh->getEmissions<PollutantsInterface::CO>() : INVALID_DOUBLE_VALUE;
270}
271
272double
273Vehicle::getHCEmission(const std::string& vehID) {
274 MSBaseVehicle* veh = Helper::getVehicle(vehID);
275 return isVisible(veh) ? veh->getEmissions<PollutantsInterface::HC>() : INVALID_DOUBLE_VALUE;
276}
277
278double
279Vehicle::getPMxEmission(const std::string& vehID) {
280 MSBaseVehicle* veh = Helper::getVehicle(vehID);
281 return isVisible(veh) ? veh->getEmissions<PollutantsInterface::PM_X>() : INVALID_DOUBLE_VALUE;
282}
283
284double
285Vehicle::getNOxEmission(const std::string& vehID) {
286 MSBaseVehicle* veh = Helper::getVehicle(vehID);
287 return isVisible(veh) ? veh->getEmissions<PollutantsInterface::NO_X>() : INVALID_DOUBLE_VALUE;
288}
289
290double
291Vehicle::getFuelConsumption(const std::string& vehID) {
292 MSBaseVehicle* veh = Helper::getVehicle(vehID);
293 return isVisible(veh) ? veh->getEmissions<PollutantsInterface::FUEL>() : INVALID_DOUBLE_VALUE;
294}
295
296double
297Vehicle::getNoiseEmission(const std::string& vehID) {
298 MSBaseVehicle* veh = Helper::getVehicle(vehID);
299 return isVisible(veh) ? veh->getHarmonoise_NoiseEmissions() : INVALID_DOUBLE_VALUE;
300}
301
302double
303Vehicle::getElectricityConsumption(const std::string& vehID) {
304 MSBaseVehicle* veh = Helper::getVehicle(vehID);
305 return isVisible(veh) ? veh->getEmissions<PollutantsInterface::ELEC>() : INVALID_DOUBLE_VALUE;
306}
307
308int
309Vehicle::getPersonNumber(const std::string& vehID) {
310 return Helper::getVehicle(vehID)->getPersonNumber();
311}
312
313int
314Vehicle::getPersonCapacity(const std::string& vehID) {
316}
317
318
319double
320Vehicle::getBoardingDuration(const std::string& vehID) {
321 return STEPS2TIME(Helper::getVehicleType(vehID).getLoadingDuration(true));
322}
323
324
325std::vector<std::string>
326Vehicle::getPersonIDList(const std::string& vehID) {
327 return Helper::getVehicle(vehID)->getPersonIDList();
328}
329
330std::pair<std::string, double>
331Vehicle::getLeader(const std::string& vehID, double dist) {
332 MSBaseVehicle* veh = Helper::getVehicle(vehID);
333 if (veh->isOnRoad()) {
334 std::pair<const MSVehicle* const, double> leaderInfo = veh->getLeader(dist, false);
335 const std::string leaderID = leaderInfo.first != nullptr ? leaderInfo.first->getID() : "";
336 double gap = leaderInfo.second;
337 if (leaderInfo.first != nullptr
338 && leaderInfo.first->getLane() != nullptr
339 && leaderInfo.first->getLane()->isInternal()
340 && veh->getLane() != nullptr
341 && (!veh->getLane()->isInternal()
342 || (veh->getLane()->getLinkCont().front()->getIndex() != leaderInfo.first->getLane()->getLinkCont().front()->getIndex()))) {
343 // leader is a linkLeader (see MSLink::getLeaderInfo)
344 // avoid internal gap values which may be negative (or -inf)
345 gap = MAX2(0.0, gap);
346 }
347 return std::make_pair(leaderID, gap);
348 } else {
349 return std::make_pair("", -1);
350 }
351}
352
353
354std::pair<std::string, double>
355Vehicle::getFollower(const std::string& vehID, double dist) {
356 MSBaseVehicle* veh = Helper::getVehicle(vehID);
357 if (veh->isOnRoad()) {
358 std::pair<const MSVehicle* const, double> leaderInfo = veh->getFollower(dist);
359 return std::make_pair(
360 leaderInfo.first != nullptr ? leaderInfo.first->getID() : "",
361 leaderInfo.second);
362 } else {
363 return std::make_pair("", -1);
364 }
365}
366
367
368std::vector<TraCIJunctionFoe>
369Vehicle::getJunctionFoes(const std::string& vehID, double dist) {
370 std::vector<TraCIJunctionFoe> result;
371 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
372 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
373 if (veh == nullptr) {
374 WRITE_WARNING("getJunctionFoes not applicable for meso");
375 } else if (veh->isOnRoad()) {
376 if (dist == 0) {
377 dist = veh->getCarFollowModel().brakeGap(veh->getSpeed()) + veh->getVehicleType().getMinGap();
378 }
379 const std::vector<const MSLane*> internalLanes;
380 // distance to the end of the lane
381 double curDist = -veh->getPositionOnLane();
382 for (const MSLane* lane : veh->getUpcomingLanesUntil(dist)) {
383 curDist += lane->getLength();
384 if (lane->isInternal()) {
385 const MSLink* exitLink = lane->getLinkCont().front();
386 int foeIndex = 0;
387 const std::vector<MSLink::ConflictInfo>& conflicts = exitLink->getConflicts();
388 const MSJunctionLogic* logic = exitLink->getJunction()->getLogic();
389 for (const MSLane* foeLane : exitLink->getFoeLanes()) {
390 const MSLink::ConflictInfo& ci = conflicts[foeIndex];
392 continue;
393 }
394 const double distBehindCrossing = ci.lengthBehindCrossing;
395 const MSLink* foeExitLink = foeLane->getLinkCont().front();
396 const double distToCrossing = curDist - distBehindCrossing;
397 const double foeDistBehindCrossing = ci.getFoeLengthBehindCrossing(foeExitLink);
398 for (auto item : foeExitLink->getApproaching()) {
399 const SUMOVehicle* foe = item.first;
400 TraCIJunctionFoe jf;
401 jf.foeId = foe->getID();
402 jf.egoDist = distToCrossing;
403 // approach information is from the start of the previous step
404 // but the foe vehicle then moved within that steop
405 const double prevFoeDist = SPEED2DIST(MSGlobals::gSemiImplicitEulerUpdate
406 ? foe->getSpeed()
407 : (foe->getSpeed() + foe->getPreviousSpeed()) / 2);
408 jf.foeDist = item.second.dist - foeDistBehindCrossing - prevFoeDist;
409 jf.egoExitDist = jf.egoDist + ci.conflictSize;
410 jf.foeExitDist = jf.foeDist + ci.getFoeConflictSize(foeExitLink);
411 jf.egoLane = lane->getID();
412 jf.foeLane = foeLane->getID();
413 jf.egoResponse = logic->getResponseFor(exitLink->getIndex()).test(foeExitLink->getIndex());
414 jf.foeResponse = logic->getResponseFor(foeExitLink->getIndex()).test(exitLink->getIndex());
415 result.push_back(jf);
416 }
417 foeIndex++;
418 }
419 }
420 }
421 }
422 return result;
423}
424
425
426double
427Vehicle::getWaitingTime(const std::string& vehID) {
428 return STEPS2TIME(Helper::getVehicle(vehID)->getWaitingTime());
429}
430
431
432double
433Vehicle::getAccumulatedWaitingTime(const std::string& vehID) {
434 MSBaseVehicle* veh = Helper::getVehicle(vehID);
435 return CALL_MICRO_FUN(veh, getAccumulatedWaitingSeconds(), INVALID_DOUBLE_VALUE);
436}
437
438
439double
440Vehicle::getAdaptedTraveltime(const std::string& vehID, double time, const std::string& edgeID) {
441 MSEdge* edge = Helper::getEdge(edgeID);
442 double value = INVALID_DOUBLE_VALUE;
444 return value;
445}
446
447
448double
449Vehicle::getEffort(const std::string& vehID, double time, const std::string& edgeID) {
450 MSEdge* edge = Helper::getEdge(edgeID);
451 double value = INVALID_DOUBLE_VALUE;
453 return value;
454}
455
456
457bool
458Vehicle::isRouteValid(const std::string& vehID) {
459 std::string msg;
460 return Helper::getVehicle(vehID)->hasValidRoute(msg);
461}
462
463
464std::vector<std::string>
465Vehicle::getRoute(const std::string& vehID) {
466 std::vector<std::string> result;
467 MSBaseVehicle* veh = Helper::getVehicle(vehID);
468 const MSRoute& r = veh->getRoute();
469 for (MSRouteIterator i = r.begin(); i != r.end(); ++i) {
470 result.push_back((*i)->getID());
471 }
472 return result;
473}
474
475
476int
477Vehicle::getSignals(const std::string& vehID) {
478 MSBaseVehicle* veh = Helper::getVehicle(vehID);
479 return CALL_MICRO_FUN(veh, getSignals(), MSVehicle::VEH_SIGNAL_NONE);
480}
481
482
483std::vector<TraCIBestLanesData>
484Vehicle::getBestLanes(const std::string& vehID) {
485 std::vector<TraCIBestLanesData> result;
486 MSVehicle* veh = dynamic_cast<MSVehicle*>(Helper::getVehicle(vehID));
487 if (veh != nullptr && veh->isOnRoad()) {
488 for (const MSVehicle::LaneQ& lq : veh->getBestLanes()) {
489 TraCIBestLanesData bld;
490 bld.laneID = lq.lane->getID();
491 bld.length = lq.length;
492 bld.occupation = lq.nextOccupation;
493 bld.bestLaneOffset = lq.bestLaneOffset;
494 bld.allowsContinuation = lq.allowsContinuation;
495 for (const MSLane* const lane : lq.bestContinuations) {
496 if (lane != nullptr) {
497 bld.continuationLanes.push_back(lane->getID());
498 }
499 }
500 result.emplace_back(bld);
501 }
502 }
503 return result;
504}
505
506
507std::vector<TraCINextTLSData>
508Vehicle::getNextTLS(const std::string& vehID) {
509 std::vector<TraCINextTLSData> result;
510 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
511 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
512 if (veh != nullptr) {
513 int view = 1;
514 double seen = veh->getEdge()->getLength() - veh->getPositionOnLane();
515 if (vehicle->isOnRoad()) {
516 const MSLane* lane = veh->getLane();
517 const std::vector<MSLane*>& bestLaneConts = veh->getBestLanesContinuation(lane);
518 seen = lane->getLength() - veh->getPositionOnLane();
519 std::vector<MSLink*>::const_iterator linkIt = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
520 while (!lane->isLinkEnd(linkIt)) {
521 if (!lane->getEdge().isInternal()) {
522 if ((*linkIt)->isTLSControlled()) {
523 TraCINextTLSData ntd;
524 ntd.id = (*linkIt)->getTLLogic()->getID();
525 ntd.tlIndex = (*linkIt)->getTLIndex();
526 ntd.dist = seen;
527 ntd.state = (char)(*linkIt)->getState();
528 result.push_back(ntd);
529 }
530 }
531 lane = (*linkIt)->getViaLaneOrLane();
532 if (!lane->getEdge().isInternal()) {
533 view++;
534 }
535 seen += lane->getLength();
536 linkIt = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
537 }
538 }
539 // consider edges beyond bestLanes
540 const int remainingEdges = (int)(veh->getRoute().end() - veh->getCurrentRouteEdge()) - view;
541 //std::cout << SIMTIME << " remainingEdges=" << remainingEdges << " seen=" << seen << " view=" << view << " best=" << toString(bestLaneConts) << "\n";
542 for (int i = 0; i < remainingEdges; i++) {
543 const MSEdge* prev = *(veh->getCurrentRouteEdge() + view + i - 1);
544 const MSEdge* next = *(veh->getCurrentRouteEdge() + view + i);
545 const std::vector<MSLane*>* allowed = prev->allowedLanes(*next, veh->getVClass());
546 if (allowed != nullptr && allowed->size() != 0) {
547 for (const MSLink* const link : allowed->front()->getLinkCont()) {
548 if (&link->getLane()->getEdge() == next) {
549 if (link->isTLSControlled()) {
550 TraCINextTLSData ntd;
551 ntd.id = link->getTLLogic()->getID();
552 ntd.tlIndex = link->getTLIndex();
553 ntd.dist = seen;
554 ntd.state = (char)link->getState();
555 result.push_back(ntd);
556 }
557 seen += next->getLength() + link->getInternalLengthsAfter();
558 break;
559 }
560 }
561 } else {
562 // invalid route, cannot determine nextTLS
563 break;
564 }
565 }
566
567 } else {
568 WRITE_WARNING("getNextTLS not yet implemented for meso");
569 }
570 return result;
571}
572
573std::vector<TraCINextStopData>
574Vehicle::getNextStops(const std::string& vehID) {
575 return getStops(vehID, 0);
576}
577
578std::vector<libsumo::TraCIConnection>
579Vehicle::getNextLinks(const std::string& vehID) {
580 std::vector<libsumo::TraCIConnection> result;
581 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
582 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
583 if (!vehicle->isOnRoad()) {
584 return result;
585 }
586 if (veh != nullptr) {
587 const MSLane* lane = veh->getLane();
588 const std::vector<MSLane*>& bestLaneConts = veh->getBestLanesContinuation(lane);
589 int view = 1;
590 const SUMOTime currTime = MSNet::getInstance()->getCurrentTimeStep();
591 std::vector<MSLink*>::const_iterator linkIt = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
592 while (!lane->isLinkEnd(linkIt)) {
593 if (!lane->getEdge().isInternal()) {
594 const MSLink* link = (*linkIt);
595 const std::string approachedLane = link->getLane() != nullptr ? link->getLane()->getID() : "";
596 const bool hasPrio = link->havePriority();
597 const double speed = MIN2(lane->getSpeedLimit(), link->getLane()->getSpeedLimit());
598 const bool isOpen = link->opened(currTime, speed, speed, veh->getLength(),
600 veh->getWaitingTime(), veh->getLateralPositionOnLane(), nullptr, false, veh);
601 const bool hasFoe = link->hasApproachingFoe(currTime, currTime, 0, SUMOVTypeParameter::getDefaultDecel());
602 const std::string approachedInternal = link->getViaLane() != nullptr ? link->getViaLane()->getID() : "";
603 const std::string state = SUMOXMLDefinitions::LinkStates.getString(link->getState());
604 const std::string direction = SUMOXMLDefinitions::LinkDirections.getString(link->getDirection());
605 const double length = link->getLength();
606 result.push_back(TraCIConnection(approachedLane, hasPrio, isOpen, hasFoe, approachedInternal, state, direction, length));
607 }
608 lane = (*linkIt)->getViaLaneOrLane();
609 if (!lane->getEdge().isInternal()) {
610 view++;
611 }
612 linkIt = MSLane::succLinkSec(*veh, view, *lane, bestLaneConts);
613 }
614 // consider edges beyond bestLanes
615 const int remainingEdges = (int)(veh->getRoute().end() - veh->getCurrentRouteEdge()) - view;
616 for (int i = 0; i < remainingEdges; i++) {
617 const MSEdge* prev = *(veh->getCurrentRouteEdge() + view + i - 1);
618 const MSEdge* next = *(veh->getCurrentRouteEdge() + view + i);
619 const std::vector<MSLane*>* allowed = prev->allowedLanes(*next, veh->getVClass());
620 if (allowed != nullptr && allowed->size() != 0) {
621 for (const MSLink* const link : allowed->front()->getLinkCont()) {
622 if (&link->getLane()->getEdge() == next) {
623 const std::string approachedLane = link->getLane() != nullptr ? link->getLane()->getID() : "";
624 const bool hasPrio = link->havePriority();
625 const double speed = MIN2(lane->getSpeedLimit(), link->getLane()->getSpeedLimit());
626 const bool isOpen = link->opened(currTime, speed, speed, veh->getLength(),
628 veh->getWaitingTime(), veh->getLateralPositionOnLane(), nullptr, false, veh);
629 const bool hasFoe = link->hasApproachingFoe(currTime, currTime, 0, SUMOVTypeParameter::getDefaultDecel());
630 const std::string approachedInternal = link->getViaLane() != nullptr ? link->getViaLane()->getID() : "";
631 const std::string state = SUMOXMLDefinitions::LinkStates.getString(link->getState());
632 const std::string direction = SUMOXMLDefinitions::LinkDirections.getString(link->getDirection());
633 const double length = link->getLength();
634 result.push_back(TraCIConnection(approachedLane, hasPrio, isOpen, hasFoe, approachedInternal, state, direction, length));
635 }
636 }
637 } else {
638 // invalid route, cannot determine nextTLS
639 break;
640 }
641 }
642 } else {
643 WRITE_WARNING("getNextLinks not yet implemented for meso");
644 }
645 return result;
646}
647
648std::vector<TraCINextStopData>
649Vehicle::getStops(const std::string& vehID, int limit) {
650 std::vector<TraCINextStopData> result;
651 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
652 if (limit < 0) {
653 // return past stops up to the given limit
654 const std::vector<SUMOVehicleParameter::Stop>& pastStops = vehicle->getPastStops();
655 const int n = (int)pastStops.size();
656 for (int i = MAX2(0, n + limit); i < n; i++) {
657 result.push_back(Helper::buildStopData(pastStops[i]));
658 }
659 } else {
660 for (const MSStop& stop : vehicle->getStops()) {
661 if (!stop.pars.collision) {
662 TraCINextStopData nsd = Helper::buildStopData(stop.pars);
663 nsd.duration = STEPS2TIME(stop.duration);
664 result.push_back(nsd);
665 if (limit > 0 && (int)result.size() >= limit) {
666 break;
667 }
668 }
669 }
670 }
671 return result;
672}
673
674
675int
676Vehicle::getStopState(const std::string& vehID) {
677 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
678 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
679 if (veh == nullptr) {
680 WRITE_WARNING("getStopState not yet implemented for meso");
681 return 0;
682 }
683 int result = 0;
684 if (veh->isStopped()) {
685 const MSStop& stop = veh->getNextStop();
686 result = stop.getStateFlagsOld();
687 }
688 return result;
689}
690
691
692double
693Vehicle::getDistance(const std::string& vehID) {
694 MSBaseVehicle* veh = Helper::getVehicle(vehID);
695 if (veh->hasDeparted()) {
696 return veh->getOdometer();
697 } else {
699 }
700}
701
702
703double
704Vehicle::getDrivingDistance(const std::string& vehID, const std::string& edgeID, double pos, int laneIndex) {
705 MSBaseVehicle* veh = Helper::getVehicle(vehID);
706 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
707 if (veh->isOnRoad()) {
708 const MSLane* lane = microVeh != nullptr ? veh->getLane() : veh->getEdge()->getLanes()[0];
709 double distance = veh->getRoute().getDistanceBetween(veh->getPositionOnLane(), pos,
710 lane, Helper::getLaneChecking(edgeID, laneIndex, pos), veh->getRoutePosition());
711 if (distance == std::numeric_limits<double>::max()) {
713 }
714 return distance;
715 } else {
717 }
718}
719
720
721double
722Vehicle::getDrivingDistance2D(const std::string& vehID, double x, double y) {
723 MSBaseVehicle* veh = Helper::getVehicle(vehID);
724 if (veh == nullptr) {
726 }
727 if (veh->isOnRoad()) {
728 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
729 const MSLane* lane = microVeh != nullptr ? veh->getLane() : veh->getEdge()->getLanes()[0];
730 std::pair<MSLane*, double> roadPos = Helper::convertCartesianToRoadMap(Position(x, y), veh->getVehicleType().getVehicleClass());
731 double distance = veh->getRoute().getDistanceBetween(veh->getPositionOnLane(), roadPos.second,
732 lane, roadPos.first, veh->getRoutePosition());
733 if (distance == std::numeric_limits<double>::max()) {
735 }
736 return distance;
737 } else {
739 }
740}
741
742
743double
744Vehicle::getAllowedSpeed(const std::string& vehID) {
745 MSBaseVehicle* veh = Helper::getVehicle(vehID);
746 return veh->isOnRoad() ? CALL_MICRO_FUN(veh, getLane()->getVehicleMaxSpeed(veh), veh->getEdge()->getVehicleMaxSpeed(veh)) : INVALID_DOUBLE_VALUE;
747}
748
749
750double
751Vehicle::getSpeedFactor(const std::string& vehID) {
753}
754
755
756int
757Vehicle::getSpeedMode(const std::string& vehID) {
758 MSBaseVehicle* veh = Helper::getVehicle(vehID);
759 return CALL_MICRO_FUN(veh, getInfluencer().getSpeedMode(), INVALID_INT_VALUE);
760}
761
762
763int
764Vehicle::getLaneChangeMode(const std::string& vehID) {
765 MSBaseVehicle* veh = Helper::getVehicle(vehID);
766 return CALL_MICRO_FUN(veh, getInfluencer().getLaneChangeMode(), INVALID_INT_VALUE);
767}
768
769
770int
771Vehicle::getRoutingMode(const std::string& vehID) {
772 return Helper::getVehicle(vehID)->getRoutingMode();
773}
774
775
776std::string
777Vehicle::getLine(const std::string& vehID) {
778 return Helper::getVehicle(vehID)->getParameter().line;
779}
780
781
782std::vector<std::string>
783Vehicle::getVia(const std::string& vehID) {
784 return Helper::getVehicle(vehID)->getParameter().via;
785}
786
787
788std::pair<int, int>
789Vehicle::getLaneChangeState(const std::string& vehID, int direction) {
790 MSBaseVehicle* veh = Helper::getVehicle(vehID);
791 auto undefined = std::make_pair((int)LCA_UNKNOWN, (int)LCA_UNKNOWN);
792 return veh->isOnRoad() ? CALL_MICRO_FUN(veh, getLaneChangeModel().getSavedState(direction), undefined) : undefined;
793}
794
795
796std::string
797Vehicle::getParameter(const std::string& vehID, const std::string& key) {
798 MSBaseVehicle* veh = Helper::getVehicle(vehID);
799 std::string error;
800 std::string result = veh->getPrefixedParameter(key, error);
801 if (error != "") {
802 throw TraCIException(error);
803 }
804 return result;
805}
806
807
809
810
811std::vector<std::pair<std::string, double> >
812Vehicle::getNeighbors(const std::string& vehID, const int mode) {
813 int dir = (1 & mode) != 0 ? -1 : 1;
814 bool queryLeaders = (2 & mode) != 0;
815 bool blockersOnly = (4 & mode) != 0;
816 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
817 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
818 std::vector<std::pair<std::string, double> > result;
819 if (veh == nullptr) {
820 return result;
821 }
822#ifdef DEBUG_NEIGHBORS
823 if (DEBUG_COND) {
824 std::cout << "getNeighbors() for veh '" << vehID << "': dir=" << dir
825 << ", queryLeaders=" << queryLeaders
826 << ", blockersOnly=" << blockersOnly << std::endl;
827 }
828#endif
829 if (veh->getLaneChangeModel().isOpposite()) {
830 // getParallelLane works relative to lane forward direction
831 dir *= -1;
832 }
833
834 MSLane* targetLane = veh->getLane()->getParallelLane(dir);
835 if (targetLane == nullptr) {
836 return result;
837 }
838 // need to recompute leaders and followers (#8119)
839 const bool opposite = &veh->getLane()->getEdge() != &targetLane->getEdge();
840 MSLeaderDistanceInfo neighbors(targetLane->getWidth(), nullptr, 0.);
841 if (queryLeaders) {
842 if (opposite) {
843 double pos = targetLane->getOppositePos(veh->getPositionOnLane());
844 neighbors = targetLane->getFollowersOnConsecutive(veh, pos, true);
845 } else {
846 targetLane->addLeaders(veh, veh->getPositionOnLane(), neighbors);
847 }
848 } else {
849 if (opposite) {
850 double pos = targetLane->getOppositePos(veh->getPositionOnLane());
851 targetLane->addLeaders(veh, pos, neighbors);
852 neighbors.fixOppositeGaps(true);
853 } else {
854 neighbors = targetLane->getFollowersOnConsecutive(veh, veh->getBackPositionOnLane(), true);
855 }
856 }
857 if (blockersOnly) {
858 // filter out vehicles that aren't blocking
859 MSLeaderDistanceInfo blockers(targetLane->getWidth(), nullptr, 0.);
860 for (int i = 0; i < neighbors.numSublanes(); i++) {
861 CLeaderDist n = neighbors[i];
862 if (n.first != nullptr) {
863 const MSVehicle* follower = veh;
864 const MSVehicle* leader = n.first;
865 if (!queryLeaders) {
866 std::swap(follower, leader);
867 }
868 const double secureGap = (follower->getCarFollowModel().getSecureGap(
869 follower, leader, follower->getSpeed(), leader->getSpeed(), leader->getCarFollowModel().getMaxDecel())
870 * follower->getLaneChangeModel().getSafetyFactor());
871 if (n.second < secureGap) {
872 blockers.addLeader(n.first, n.second, 0, i);
873 }
874 }
875 }
876 neighbors = blockers;
877 }
878
879 if (neighbors.hasVehicles()) {
880 for (int i = 0; i < neighbors.numSublanes(); i++) {
881 CLeaderDist n = neighbors[i];
882 if (n.first != nullptr &&
883 // avoid duplicates
884 (result.size() == 0 || result.back().first != n.first->getID())) {
885 result.push_back(std::make_pair(n.first->getID(), n.second));
886 }
887 }
888 }
889 return result;
890}
891
892
893double
894Vehicle::getFollowSpeed(const std::string& vehID, double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) {
895 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
896 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
897 if (veh == nullptr) {
898 WRITE_ERROR("getFollowSpeed not applicable for meso");
900 }
901 MSVehicle* leader = dynamic_cast<MSVehicle*>(MSNet::getInstance()->getVehicleControl().getVehicle(leaderID));
902 return veh->getCarFollowModel().followSpeed(veh, speed, gap, leaderSpeed, leaderMaxDecel, leader, MSCFModel::CalcReason::FUTURE);
903}
904
905
906double
907Vehicle::getSecureGap(const std::string& vehID, double speed, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) {
908 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
909 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
910 if (veh == nullptr) {
911 WRITE_ERROR("getSecureGap not applicable for meso");
913 }
914 MSVehicle* leader = dynamic_cast<MSVehicle*>(MSNet::getInstance()->getVehicleControl().getVehicle(leaderID));
915 return veh->getCarFollowModel().getSecureGap(veh, leader, speed, leaderSpeed, leaderMaxDecel);
916}
917
918
919double
920Vehicle::getStopSpeed(const std::string& vehID, const double speed, double gap) {
921 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
922 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
923 if (veh == nullptr) {
924 WRITE_ERROR("getStopSpeed not applicable for meso");
926 }
927 return veh->getCarFollowModel().stopSpeed(veh, speed, gap, MSCFModel::CalcReason::FUTURE);
928}
929
930double
931Vehicle::getStopDelay(const std::string& vehID) {
932 return Helper::getVehicle(vehID)->getStopDelay();
933}
934
935
936double
937Vehicle::getImpatience(const std::string& vehID) {
938 return Helper::getVehicle(vehID)->getImpatience();
939}
940
941
942double
943Vehicle::getStopArrivalDelay(const std::string& vehID) {
944 double result = Helper::getVehicle(vehID)->getStopArrivalDelay();
945 if (result == INVALID_DOUBLE) {
947 } else {
948 return result;
949 }
950}
951
952double
953Vehicle::getTimeLoss(const std::string& vehID) {
954 return Helper::getVehicle(vehID)->getTimeLossSeconds();
955}
956
957std::vector<std::string>
958Vehicle::getTaxiFleet(int taxiState) {
959 std::vector<std::string> result;
960 for (MSDevice_Taxi* taxi : MSDevice_Taxi::getFleet()) {
961 if (taxi->getHolder().hasDeparted()) {
962 if (taxiState == -1
963 || (taxiState == 0 && taxi->getState() == 0)
964 || (taxiState != 0 && (taxi->getState() & taxiState) == taxiState)) {
965 result.push_back(taxi->getHolder().getID());
966 }
967 }
968 }
969 return result;
970}
971
972std::vector<std::string>
973Vehicle::getLoadedIDList() {
974 std::vector<std::string> ids;
976 for (MSVehicleControl::constVehIt i = c.loadedVehBegin(); i != c.loadedVehEnd(); ++i) {
977 ids.push_back(i->first);
978 }
979 return ids;
980}
981
982std::vector<std::string>
983Vehicle::getTeleportingIDList() {
984 std::vector<std::string> ids;
986 for (MSVehicleControl::constVehIt i = c.loadedVehBegin(); i != c.loadedVehEnd(); ++i) {
987 SUMOVehicle* veh = i->second;
988 if (veh->hasDeparted() && !isVisible(veh)) {
989 ids.push_back(veh->getID());
990 }
991 }
992 return ids;
993}
994
995std::string
996Vehicle::getEmissionClass(const std::string& vehID) {
997 return PollutantsInterface::getName(Helper::getVehicleType(vehID).getEmissionClass());
998}
999
1000std::string
1001Vehicle::getShapeClass(const std::string& vehID) {
1002 return getVehicleShapeName(Helper::getVehicleType(vehID).getGuiShape());
1003}
1004
1005
1006double
1007Vehicle::getLength(const std::string& vehID) {
1008 return Helper::getVehicleType(vehID).getLength();
1009}
1010
1011
1012double
1013Vehicle::getAccel(const std::string& vehID) {
1015}
1016
1017
1018double
1019Vehicle::getDecel(const std::string& vehID) {
1021}
1022
1023
1024double Vehicle::getEmergencyDecel(const std::string& vehID) {
1026}
1027
1028
1029double Vehicle::getApparentDecel(const std::string& vehID) {
1031}
1032
1033
1034double Vehicle::getActionStepLength(const std::string& vehID) {
1036}
1037
1038
1039double Vehicle::getLastActionTime(const std::string& vehID) {
1040 MSBaseVehicle* veh = Helper::getVehicle(vehID);
1041 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
1042 if (microVeh != nullptr) {
1043 return STEPS2TIME(microVeh->getLastActionTime());
1044 } else {
1045 MEVehicle* mesoVeh = dynamic_cast<MEVehicle*>(veh);
1046 return STEPS2TIME(mesoVeh->getEventTime());
1047 }
1048}
1049
1050
1051double
1052Vehicle::getTau(const std::string& vehID) {
1054}
1055
1056
1057double
1058Vehicle::getImperfection(const std::string& vehID) {
1060}
1061
1062
1063double
1064Vehicle::getSpeedDeviation(const std::string& vehID) {
1066}
1067
1068
1069std::string
1070Vehicle::getVehicleClass(const std::string& vehID) {
1071 return toString(Helper::getVehicleType(vehID).getVehicleClass());
1072}
1073
1074
1075double
1076Vehicle::getMinGap(const std::string& vehID) {
1077 return Helper::getVehicleType(vehID).getMinGap();
1078}
1079
1080
1081double
1082Vehicle::getMinGapLat(const std::string& vehID) {
1083 try {
1084 return StringUtils::toDouble(getParameter(vehID, "laneChangeModel.minGapLat"));
1085 } catch (const TraCIException&) {
1086 // legacy behavior
1087 return Helper::getVehicleType(vehID).getMinGapLat();
1088 }
1089}
1090
1091
1092double
1093Vehicle::getMaxSpeed(const std::string& vehID) {
1094 return Helper::getVehicleType(vehID).getMaxSpeed();
1095}
1096
1097
1098double
1099Vehicle::getMaxSpeedLat(const std::string& vehID) {
1100 return Helper::getVehicleType(vehID).getMaxSpeedLat();
1101}
1102
1103
1104std::string
1105Vehicle::getLateralAlignment(const std::string& vehID) {
1106 return toString(Helper::getVehicleType(vehID).getPreferredLateralAlignment());
1107}
1108
1109
1110double
1111Vehicle::getWidth(const std::string& vehID) {
1112 return Helper::getVehicleType(vehID).getWidth();
1113}
1114
1115
1116double
1117Vehicle::getHeight(const std::string& vehID) {
1118 return Helper::getVehicleType(vehID).getHeight();
1119}
1120
1121
1122double
1123Vehicle::getMass(const std::string& vehID) {
1124 return Helper::getVehicleType(vehID).getMass();
1125}
1126
1127
1128void
1129Vehicle::setStop(const std::string& vehID,
1130 const std::string& edgeID,
1131 double pos,
1132 int laneIndex,
1133 double duration,
1134 int flags,
1135 double startPos,
1136 double until) {
1137 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1139 pos, laneIndex, startPos, flags, duration, until);
1140 std::string error;
1141 if (!vehicle->addTraciStop(stopPars, error)) {
1142 throw TraCIException(error);
1143 }
1144}
1145
1146
1147void
1148Vehicle::replaceStop(const std::string& vehID,
1149 int nextStopIndex,
1150 const std::string& edgeID,
1151 double pos,
1152 int laneIndex,
1153 double duration,
1154 int flags,
1155 double startPos,
1156 double until,
1157 int teleport) {
1158 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1159 std::string error;
1160 if (edgeID == "") {
1161 // only remove stop
1162 const bool ok = vehicle->abortNextStop(nextStopIndex);
1163 if (teleport != 0) {
1164 if (!vehicle->rerouteBetweenStops(nextStopIndex, "traci:replaceStop", (teleport & 1), error)) {
1165 throw TraCIException("Stop replacement failed for vehicle '" + vehID + "' (" + error + ").");
1166 }
1167 } else {
1168 MSVehicle* msVeh = dynamic_cast<MSVehicle*>(vehicle);
1169 if (msVeh->getLane() != nullptr) {
1170 msVeh->updateBestLanes(true);
1171 }
1172 }
1173 if (!ok) {
1174 throw TraCIException("Stop replacement failed for vehicle '" + vehID + "' (invalid nextStopIndex).");
1175 }
1176 } else {
1178 pos, laneIndex, startPos, flags, duration, until);
1179
1180 if (!vehicle->replaceStop(nextStopIndex, stopPars, "traci:replaceStop", teleport != 0, error)) {
1181 throw TraCIException("Stop replacement failed for vehicle '" + vehID + "' (" + error + ").");
1182 }
1183 }
1184}
1185
1186
1187void
1188Vehicle::insertStop(const std::string& vehID,
1189 int nextStopIndex,
1190 const std::string& edgeID,
1191 double pos,
1192 int laneIndex,
1193 double duration,
1194 int flags,
1195 double startPos,
1196 double until,
1197 int teleport) {
1198 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1200 pos, laneIndex, startPos, flags, duration, until);
1201
1202 std::string error;
1203 if (!vehicle->insertStop(nextStopIndex, stopPars, "traci:insertStop", teleport != 0, error)) {
1204 throw TraCIException("Stop insertion failed for vehicle '" + vehID + "' (" + error + ").");
1205 }
1206}
1207
1208
1209std::string
1210Vehicle::getStopParameter(const std::string& vehID, int nextStopIndex, const std::string& param, bool customParam) {
1211 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1212 try {
1213 if (nextStopIndex >= (int)vehicle->getStops().size() || (nextStopIndex < 0 && -nextStopIndex > (int)vehicle->getPastStops().size())) {
1214 throw ProcessError("Invalid stop index " + toString(nextStopIndex)
1215 + " (has " + toString(vehicle->getPastStops().size()) + " past stops and " + toString(vehicle->getStops().size()) + " remaining stops)");
1216
1217 }
1218 const SUMOVehicleParameter::Stop& pars = (nextStopIndex >= 0
1219 ? vehicle->getStop(nextStopIndex).pars
1220 : vehicle->getPastStops()[vehicle->getPastStops().size() + nextStopIndex]);
1221 if (customParam) {
1222 // custom user parameter
1223 return pars.getParameter(param, "");
1224 }
1225
1226 if (param == toString(SUMO_ATTR_EDGE)) {
1227 return pars.edge;
1228 } else if (param == toString(SUMO_ATTR_LANE)) {
1230 } else if (param == toString(SUMO_ATTR_BUS_STOP)
1231 || param == toString(SUMO_ATTR_TRAIN_STOP)) {
1232 return pars.busstop;
1233 } else if (param == toString(SUMO_ATTR_CONTAINER_STOP)) {
1234 return pars.containerstop;
1235 } else if (param == toString(SUMO_ATTR_CHARGING_STATION)) {
1236 return pars.chargingStation;
1237 } else if (param == toString(SUMO_ATTR_PARKING_AREA)) {
1238 return pars.parkingarea;
1239 } else if (param == toString(SUMO_ATTR_STARTPOS)) {
1240 return toString(pars.startPos);
1241 } else if (param == toString(SUMO_ATTR_ENDPOS)) {
1242 return toString(pars.endPos);
1243 } else if (param == toString(SUMO_ATTR_POSITION_LAT)) {
1244 return toString(pars.posLat == INVALID_DOUBLE ? INVALID_DOUBLE_VALUE : pars.posLat);
1245 } else if (param == toString(SUMO_ATTR_ARRIVAL)) {
1246 return pars.arrival < 0 ? "-1" : time2string(pars.arrival);
1247 } else if (param == toString(SUMO_ATTR_DURATION)) {
1248 return pars.duration < 0 ? "-1" : time2string(pars.duration);
1249 } else if (param == toString(SUMO_ATTR_UNTIL)) {
1250 return pars.until < 0 ? "-1" : time2string(pars.until);
1251 } else if (param == toString(SUMO_ATTR_EXTENSION)) {
1252 return pars.extension < 0 ? "-1" : time2string(pars.extension);
1253 } else if (param == toString(SUMO_ATTR_INDEX)) {
1254 return toString(nextStopIndex + vehicle->getPastStops().size());
1255 } else if (param == toString(SUMO_ATTR_PARKING)) {
1256 return toString(pars.parking);
1257 } else if (param == toString(SUMO_ATTR_TRIGGERED)) {
1258 return joinToString(pars.getTriggers(), " ");
1259 } else if (param == toString(SUMO_ATTR_EXPECTED)) {
1260 return joinToString(pars.awaitedPersons, " ");
1261 } else if (param == toString(SUMO_ATTR_EXPECTED_CONTAINERS)) {
1262 return joinToString(pars.awaitedContainers, " ");
1263 } else if (param == toString(SUMO_ATTR_PERMITTED)) {
1264 return joinToString(pars.permitted, " ");
1265 } else if (param == toString(SUMO_ATTR_ACTTYPE)) {
1266 return pars.actType;
1267 } else if (param == toString(SUMO_ATTR_TRIP_ID)) {
1268 return pars.tripId;
1269 } else if (param == toString(SUMO_ATTR_SPLIT)) {
1270 return pars.split;
1271 } else if (param == toString(SUMO_ATTR_JOIN)) {
1272 return pars.join;
1273 } else if (param == toString(SUMO_ATTR_LINE)) {
1274 return pars.line;
1275 } else if (param == toString(SUMO_ATTR_SPEED)) {
1276 return toString(pars.speed);
1277 } else if (param == toString(SUMO_ATTR_STARTED)) {
1278 return pars.started < 0 ? "-1" : time2string(pars.started);
1279 } else if (param == toString(SUMO_ATTR_ENDED)) {
1280 return pars.ended < 0 ? "-1" : time2string(pars.ended);
1281 } else if (param == toString(SUMO_ATTR_ONDEMAND)) {
1282 return toString(pars.onDemand);
1283 } else if (param == toString(SUMO_ATTR_JUMP)) {
1284 return pars.jump < 0 ? "-1" : time2string(pars.jump);
1285 } else if (param == toString(SUMO_ATTR_JUMP_UNTIL)) {
1286 return pars.jumpUntil < 0 ? "-1" : time2string(pars.jumpUntil);
1287 } else {
1288 throw ProcessError(TLF("Unsupported parameter '%'", param));
1289 }
1290 } catch (ProcessError& e) {
1291 throw TraCIException("Could not get stop parameter for vehicle '" + vehID + "' (" + e.what() + ")");
1292 }
1293}
1294
1295
1296
1297void
1298Vehicle::setStopParameter(const std::string& vehID, int nextStopIndex,
1299 const std::string& param, const std::string& value,
1300 bool customParam) {
1301 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1302 try {
1303 MSStop& stop = vehicle->getStop(nextStopIndex);
1305 if (customParam) {
1306 pars.setParameter(param, value);
1307 return;
1308 }
1309 std::string error;
1310 if (param == toString(SUMO_ATTR_EDGE)
1311 || param == toString(SUMO_ATTR_BUS_STOP)
1312 || param == toString(SUMO_ATTR_TRAIN_STOP)
1315 || param == toString(SUMO_ATTR_PARKING_AREA)
1316 || param == toString(SUMO_ATTR_LANE)
1317 ) {
1318 int laneIndex = stop.lane->getIndex();
1319 int flags = pars.getFlags() & 3;
1320 std::string edgeOrStopID = value;
1321 if (param == toString(SUMO_ATTR_LANE)) {
1322 laneIndex = StringUtils::toInt(value);
1323 edgeOrStopID = pars.edge;
1324 } else if (param == toString(SUMO_ATTR_BUS_STOP)
1325 || param == toString(SUMO_ATTR_TRAIN_STOP)) {
1326 flags |= 8;
1327 } else if (param == toString(SUMO_ATTR_CONTAINER_STOP)) {
1328 flags |= 16;
1329 } else if (param == toString(SUMO_ATTR_CHARGING_STATION)) {
1330 flags |= 32;
1331 } else if (param == toString(SUMO_ATTR_PARKING_AREA)) {
1332 flags |= 64;
1333 }
1334 // special case: replace stop
1335 replaceStop(vehID, nextStopIndex, edgeOrStopID, pars.endPos, laneIndex, STEPS2TIME(pars.duration),
1336 flags, pars.startPos, STEPS2TIME(pars.until), 0);
1337
1338 } else if (param == toString(SUMO_ATTR_STARTPOS)) {
1339 pars.startPos = StringUtils::toDouble(value);
1341 } else if (param == toString(SUMO_ATTR_ENDPOS)) {
1342 pars.endPos = StringUtils::toDouble(value);
1344 } else if (param == toString(SUMO_ATTR_POSITION_LAT)) {
1345 pars.posLat = StringUtils::toDouble(value);
1347 } else if (param == toString(SUMO_ATTR_ARRIVAL)) {
1348 pars.arrival = string2time(value);
1350 } else if (param == toString(SUMO_ATTR_DURATION)) {
1351 pars.duration = string2time(value);
1353 // also update dynamic value
1354 stop.initPars(pars);
1355 } else if (param == toString(SUMO_ATTR_UNTIL)) {
1356 pars.until = string2time(value);
1358 } else if (param == toString(SUMO_ATTR_EXTENSION)) {
1359 pars.extension = string2time(value);
1361 } else if (param == toString(SUMO_ATTR_INDEX)) {
1362 throw TraCIException("Changing stop index is not supported");
1363 } else if (param == toString(SUMO_ATTR_PARKING)) {
1366 } else if (param == toString(SUMO_ATTR_TRIGGERED)) {
1367 if (pars.speed > 0 && value != "") {
1368 throw ProcessError(TLF("Waypoint (speed = %) at index % does not support triggers", pars.speed, nextStopIndex));
1369 }
1370 SUMOVehicleParameter::parseStopTriggers(StringTokenizer(value).getVector(), false, pars);
1372 // also update dynamic value
1373 stop.initPars(pars);
1374 } else if (param == toString(SUMO_ATTR_EXPECTED)) {
1375 pars.awaitedPersons = StringTokenizer(value).getSet();
1377 // also update dynamic value
1378 stop.initPars(pars);
1379 } else if (param == toString(SUMO_ATTR_EXPECTED_CONTAINERS)) {
1382 // also update dynamic value
1383 stop.initPars(pars);
1384 } else if (param == toString(SUMO_ATTR_PERMITTED)) {
1385 pars.permitted = StringTokenizer(value).getSet();
1387 } else if (param == toString(SUMO_ATTR_ACTTYPE)) {
1388 pars.actType = value;
1389 } else if (param == toString(SUMO_ATTR_TRIP_ID)) {
1390 pars.tripId = value;
1392 } else if (param == toString(SUMO_ATTR_SPLIT)) {
1393 pars.split = value;
1395 } else if (param == toString(SUMO_ATTR_JOIN)) {
1396 pars.join = value;
1398 // also update dynamic value
1399 stop.initPars(pars);
1400 } else if (param == toString(SUMO_ATTR_LINE)) {
1401 pars.line = value;
1403 } else if (param == toString(SUMO_ATTR_SPEED)) {
1404 const double speed = StringUtils::toDouble(value);
1405 if (speed > 0 && pars.getTriggers().size() > 0) {
1406 throw ProcessError(TLF("Triggered stop at index % cannot be changed into a waypoint by setting speed to %", nextStopIndex, speed));
1407 }
1408 pars.speed = speed;
1410 } else if (param == toString(SUMO_ATTR_STARTED)) {
1411 pars.started = string2time(value);
1413 } else if (param == toString(SUMO_ATTR_ENDED)) {
1414 pars.ended = string2time(value);
1416 } else if (param == toString(SUMO_ATTR_ONDEMAND)) {
1417 pars.onDemand = StringUtils::toBool(value);
1419 } else if (param == toString(SUMO_ATTR_JUMP)) {
1420 pars.jump = string2time(value);
1422 } else if (param == toString(SUMO_ATTR_JUMP_UNTIL)) {
1423 pars.jumpUntil = string2time(value);
1425 } else {
1426 throw ProcessError(TLF("Unsupported parameter '%'", param));
1427 }
1428 } catch (ProcessError& e) {
1429 throw TraCIException("Could not set stop parameter for vehicle '" + vehID + "' (" + e.what() + ")");
1430 }
1431}
1432
1433
1434void
1435Vehicle::rerouteParkingArea(const std::string& vehID, const std::string& parkingAreaID) {
1436 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1437 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1438 if (veh == nullptr) {
1439 WRITE_WARNING("rerouteParkingArea not yet implemented for meso");
1440 return;
1441 }
1442 std::string error;
1443 // Forward command to vehicle
1444 if (!veh->rerouteParkingArea(parkingAreaID, error)) {
1445 throw TraCIException(error);
1446 }
1447}
1448
1449void
1450Vehicle::resume(const std::string& vehID) {
1451 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1452 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1453 if (veh == nullptr) {
1454 WRITE_WARNING("resume not yet implemented for meso");
1455 return;
1456 }
1457 if (!veh->hasStops()) {
1458 throw TraCIException("Failed to resume vehicle '" + veh->getID() + "', it has no stops.");
1459 }
1460 if (!veh->resumeFromStopping()) {
1461 const MSStop& sto = veh->getNextStop();
1462 std::ostringstream strs;
1463 strs << "reached: " << sto.reached;
1464 strs << ", duration:" << sto.duration;
1465 strs << ", edge:" << (*sto.edge)->getID();
1466 strs << ", startPos: " << sto.pars.startPos;
1467 std::string posStr = strs.str();
1468 throw TraCIException("Failed to resume from stopping for vehicle '" + veh->getID() + "', " + posStr);
1469 }
1470}
1471
1472
1473void
1474Vehicle::changeTarget(const std::string& vehID, const std::string& edgeID) {
1475 MSBaseVehicle* veh = Helper::getVehicle(vehID);
1476 const MSEdge* destEdge = MSEdge::dictionary(edgeID);
1477 const bool onInit = isOnInit(vehID);
1478 if (destEdge == nullptr) {
1479 throw TraCIException("Destination edge '" + edgeID + "' is not known.");
1480 }
1481 // change the final edge of the route and reroute
1482 try {
1483 const bool success = veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:changeTarget",
1484 veh->getRouterTT(), onInit, false, false, destEdge);
1485 if (!success) {
1486 throw TraCIException("ChangeTarget failed for vehicle '" + veh->getID() + "', destination edge '" + edgeID + "' unreachable.");
1487 }
1488 } catch (ProcessError& e) {
1489 throw TraCIException(e.what());
1490 }
1491}
1492
1493
1494void
1495Vehicle::changeLane(const std::string& vehID, int laneIndex, double duration) {
1496 try {
1497 checkTimeBounds(duration);
1498 } catch (ProcessError&) {
1499 throw TraCIException("Duration parameter exceeds the time value range.");
1500 }
1501 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1502 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1503 if (veh == nullptr) {
1504 WRITE_ERROR("changeLane not applicable for meso");
1505 return;
1506 }
1507
1508 std::vector<std::pair<SUMOTime, int> > laneTimeLine;
1509 laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
1510 laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), laneIndex));
1511 veh->getInfluencer().setLaneTimeLine(laneTimeLine);
1512}
1513
1514void
1515Vehicle::changeLaneRelative(const std::string& vehID, int indexOffset, double duration) {
1516 try {
1517 checkTimeBounds(duration);
1518 } catch (ProcessError&) {
1519 throw TraCIException("Duration parameter exceeds the time value range.");
1520 }
1521 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1522 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1523 if (veh == nullptr) {
1524 WRITE_ERROR("changeLaneRelative not applicable for meso");
1525 return;
1526 }
1527
1528 std::vector<std::pair<SUMOTime, int> > laneTimeLine;
1529 int laneIndex = veh->getLaneIndex() + indexOffset;
1530 if (laneIndex < 0 && !veh->getLaneChangeModel().isOpposite()) {
1531 if (veh->getLaneIndex() == -1) {
1532 WRITE_WARNINGF(TL("Ignoring changeLaneRelative for vehicle '%' that isn't on the road"), vehID);
1533 } else {
1534 WRITE_WARNINGF(TL("Ignoring indexOffset % for vehicle '%' on laneIndex %."), indexOffset, vehID, veh->getLaneIndex());
1535 }
1536 } else {
1537 laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), laneIndex));
1538 laneTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), laneIndex));
1539 veh->getInfluencer().setLaneTimeLine(laneTimeLine);
1540 }
1541}
1542
1543
1544void
1545Vehicle::changeSublane(const std::string& vehID, double latDist) {
1546 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1547 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1548 if (veh == nullptr) {
1549 WRITE_ERROR("changeSublane not applicable for meso");
1550 return;
1551 }
1552
1553 veh->getInfluencer().setSublaneChange(latDist);
1554}
1555
1556
1557void
1558Vehicle::add(const std::string& vehID,
1559 const std::string& routeID,
1560 const std::string& typeID,
1561 const std::string& depart,
1562 const std::string& departLane,
1563 const std::string& departPos,
1564 const std::string& departSpeed,
1565 const std::string& arrivalLane,
1566 const std::string& arrivalPos,
1567 const std::string& arrivalSpeed,
1568 const std::string& fromTaz,
1569 const std::string& toTaz,
1570 const std::string& line,
1571 int /*personCapacity*/,
1572 int personNumber) {
1574 if (veh != nullptr) {
1575 throw TraCIException("The vehicle '" + vehID + "' to add already exists.");
1576 }
1577
1578 SUMOVehicleParameter vehicleParams;
1579 vehicleParams.id = vehID;
1580 MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(typeID);
1581 if (!vehicleType) {
1582 throw TraCIException("Invalid type '" + typeID + "' for vehicle '" + vehID + "'.");
1583 }
1584 if (typeID != "DEFAULT_VEHTYPE") {
1585 vehicleParams.vtypeid = typeID;
1586 vehicleParams.parametersSet |= VEHPARS_VTYPE_SET;
1587 }
1589 WRITE_WARNINGF(TL("Internal routes receive an ID starting with '!' and must not be referenced in other vehicle or flow definitions. Please remove all references to route '%' in case it is internal."), routeID);
1590 }
1591 ConstMSRoutePtr route = MSRoute::dictionary(routeID);
1592 if (!route) {
1593 if (routeID == "") {
1594 // assume, route was intentionally left blank because the caller
1595 // intends to control the vehicle remotely
1596 SUMOVehicleClass vclass = vehicleType->getVehicleClass();
1597 const std::string dummyRouteID = "DUMMY_ROUTE_" + SumoVehicleClassStrings.getString(vclass);
1598 route = MSRoute::dictionary(dummyRouteID);
1599 if (route == nullptr) {
1600 for (MSEdge* e : MSEdge::getAllEdges()) {
1601 if (e->getFunction() == SumoXMLEdgeFunc::NORMAL && (e->getPermissions() & vclass) == vclass) {
1602 std::vector<std::string> edges;
1603 edges.push_back(e->getID());
1604 libsumo::Route::add(dummyRouteID, edges);
1605 break;
1606 }
1607 }
1608 }
1609 route = MSRoute::dictionary(dummyRouteID);
1610 if (!route) {
1611 throw TraCIException("Could not build dummy route for vehicle class: '" + SumoVehicleClassStrings.getString(vehicleType->getVehicleClass()) + "'");
1612 }
1613 } else {
1614 throw TraCIException("Invalid route '" + routeID + "' for vehicle '" + vehID + "'.");
1615 }
1616 }
1617 // check if the route implies a trip
1618 if (route->getEdges().size() == 2) {
1619 const MSEdgeVector& succ = route->getEdges().front()->getSuccessors();
1620 if (std::find(succ.begin(), succ.end(), route->getEdges().back()) == succ.end()) {
1621 vehicleParams.parametersSet |= VEHPARS_FORCE_REROUTE;
1622 }
1623 }
1624 if (fromTaz != "" || toTaz != "") {
1625 vehicleParams.parametersSet |= VEHPARS_FORCE_REROUTE;
1626 }
1627 std::string error;
1628 if (!SUMOVehicleParameter::parseDepart(depart, "vehicle", vehID, vehicleParams.depart, vehicleParams.departProcedure, error)) {
1629 throw TraCIException(error);
1630 }
1631 if (vehicleParams.departProcedure == DepartDefinition::GIVEN && vehicleParams.depart < MSNet::getInstance()->getCurrentTimeStep()) {
1632 vehicleParams.depart = MSNet::getInstance()->getCurrentTimeStep();
1633 WRITE_WARNINGF(TL("Departure time for vehicle '%' is in the past; using current time instead."), vehID);
1634 } else if (vehicleParams.departProcedure == DepartDefinition::NOW) {
1635 vehicleParams.depart = MSNet::getInstance()->getCurrentTimeStep();
1636 }
1637 if (!SUMOVehicleParameter::parseDepartLane(departLane, "vehicle", vehID, vehicleParams.departLane, vehicleParams.departLaneProcedure, error)) {
1638 throw TraCIException(error);
1639 }
1640 if (!SUMOVehicleParameter::parseDepartPos(departPos, "vehicle", vehID, vehicleParams.departPos, vehicleParams.departPosProcedure, error)) {
1641 throw TraCIException(error);
1642 }
1643 if (!SUMOVehicleParameter::parseDepartSpeed(departSpeed, "vehicle", vehID, vehicleParams.departSpeed, vehicleParams.departSpeedProcedure, error)) {
1644 throw TraCIException(error);
1645 }
1646 if (!SUMOVehicleParameter::parseArrivalLane(arrivalLane, "vehicle", vehID, vehicleParams.arrivalLane, vehicleParams.arrivalLaneProcedure, error)) {
1647 throw TraCIException(error);
1648 }
1649 if (!SUMOVehicleParameter::parseArrivalPos(arrivalPos, "vehicle", vehID, vehicleParams.arrivalPos, vehicleParams.arrivalPosProcedure, error)) {
1650 throw TraCIException(error);
1651 }
1652 if (!SUMOVehicleParameter::parseArrivalSpeed(arrivalSpeed, "vehicle", vehID, vehicleParams.arrivalSpeed, vehicleParams.arrivalSpeedProcedure, error)) {
1653 throw TraCIException(error);
1654 }
1655 // mark non-default attributes
1656 if (departLane != "first") {
1657 vehicleParams.parametersSet |= VEHPARS_DEPARTLANE_SET;
1658 }
1659 if (departPos != "base") {
1660 vehicleParams.parametersSet |= VEHPARS_DEPARTPOS_SET;
1661 }
1662 if (departSpeed != "0") {
1663 vehicleParams.parametersSet |= VEHPARS_DEPARTSPEED_SET;
1664 }
1665 if (arrivalLane != "current") {
1666 vehicleParams.parametersSet |= VEHPARS_ARRIVALLANE_SET;
1667 }
1668 if (arrivalPos != "max") {
1669 vehicleParams.parametersSet |= VEHPARS_ARRIVALPOS_SET;
1670 }
1671 if (arrivalSpeed != "current") {
1672 vehicleParams.parametersSet |= VEHPARS_ARRIVALSPEED_SET;
1673 }
1674 if (fromTaz != "") {
1675 vehicleParams.parametersSet |= VEHPARS_FROM_TAZ_SET;
1676 }
1677 if (toTaz != "") {
1678 vehicleParams.parametersSet |= VEHPARS_TO_TAZ_SET;
1679 }
1680 if (line != "") {
1681 vehicleParams.parametersSet |= VEHPARS_LINE_SET;
1682 }
1683 if (personNumber != 0) {
1685 }
1686 // build vehicle
1687 vehicleParams.fromTaz = fromTaz;
1688 vehicleParams.toTaz = toTaz;
1689 vehicleParams.line = line;
1690 //vehicleParams.personCapacity = personCapacity;
1691 vehicleParams.personNumber = personNumber;
1692
1693 SUMOVehicleParameter* params = new SUMOVehicleParameter(vehicleParams);
1694 SUMOVehicle* vehicle = nullptr;
1695 try {
1697 if (fromTaz == "" && !route->getEdges().front()->validateDepartSpeed(*vehicle)) {
1699 throw TraCIException("Departure speed for vehicle '" + vehID + "' is too high for the departure edge '" + route->getEdges().front()->getID() + "'.");
1700 }
1701 std::string msg;
1702 if (vehicle->getRouteValidity(true, true, &msg) != MSBaseVehicle::ROUTE_VALID) {
1704 throw TraCIException("Vehicle '" + vehID + "' has no valid route (" + msg + "). ");
1705 }
1706 MSNet::getInstance()->getVehicleControl().addVehicle(vehicleParams.id, vehicle);
1709 }
1710 } catch (ProcessError& e) {
1711 if (vehicle != nullptr) {
1713 }
1714 throw TraCIException(e.what());
1715 }
1716}
1717
1718
1719void
1720Vehicle::moveToXY(const std::string& vehID, const std::string& edgeID, const int laneIndex,
1721 const double x, const double y, double angle, const int keepRoute, double matchThreshold) {
1722 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1723 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1724 if (veh == nullptr) {
1725 WRITE_WARNING("moveToXY not yet implemented for meso");
1726 return;
1727 }
1728 const bool doKeepRoute = (keepRoute & 1) != 0 && veh->getID() != "VTD_EGO";
1729 const bool mayLeaveNetwork = (keepRoute & 2) != 0;
1730 const bool ignorePermissions = (keepRoute & 4) != 0;
1731 const bool setLateralPos = (MSGlobals::gLateralResolution > 0 || mayLeaveNetwork);
1732 SUMOVehicleClass vClass = ignorePermissions ? SVC_IGNORING : veh->getVClass();
1733 // process
1734 const std::string origID = edgeID + "_" + toString(laneIndex);
1735 // @todo add an interpretation layer for OSM derived origID values (without lane index)
1736 Position pos(x, y);
1737#ifdef DEBUG_MOVEXY
1738 const double origAngle = angle;
1739#endif
1740 // angle must be in [0,360] because it will be compared against those returned by naviDegree()
1741 // angle set to INVALID_DOUBLE_VALUE is ignored in the evaluated and later set to the angle of the matched lane
1742 if (angle != INVALID_DOUBLE_VALUE) {
1743 while (angle >= 360.) {
1744 angle -= 360.;
1745 }
1746 while (angle < 0.) {
1747 angle += 360.;
1748 }
1749 }
1750
1751#ifdef DEBUG_MOVEXY
1752 std::cout << std::endl << SIMTIME << " moveToXY veh=" << veh->getID() << " vehPos=" << veh->getPosition()
1753 << " lane=" << Named::getIDSecure(veh->getLane()) << " lanePos=" << vehicle->getPositionOnLane() << std::endl;
1754 std::cout << " wantedPos=" << pos << " origID=" << origID << " laneIndex=" << laneIndex << " origAngle=" << origAngle << " angle=" << angle << " keepRoute=" << keepRoute << std::endl;
1755#endif
1756
1757 ConstMSEdgeVector edges;
1758 MSLane* lane = nullptr;
1759 double lanePos;
1760 double lanePosLat = 0;
1761 double bestDistance = std::numeric_limits<double>::max();
1762 int routeOffset = 0;
1763 bool found;
1764 double maxRouteDistance = matchThreshold;
1765 /* EGO vehicle is known to have a fixed route. @todo make this into a parameter of the TraCI call */
1766 if (doKeepRoute) {
1767 // case a): vehicle is on its earlier route
1768 // we additionally assume it is moving forward (SUMO-limit);
1769 // note that the route ("edges") is not changed in this case
1770
1772 veh->getRoute().getEdges(), veh->getRoutePosition(),
1773 vClass, setLateralPos,
1774 bestDistance, &lane, lanePos, routeOffset);
1775 // @note silenty ignoring mapping failure
1776 } else {
1777 const double speed = pos.distanceTo2D(veh->getPosition()); // !!!veh->getSpeed();
1778 found = Helper::moveToXYMap(pos, maxRouteDistance, mayLeaveNetwork, origID, angle,
1779 speed, veh->getRoute().getEdges(), veh->getRoutePosition(), veh->getLane(), veh->getPositionOnLane(), veh->isOnRoad(),
1780 vClass, GeomHelper::naviDegree(veh->getAngle()), setLateralPos,
1781 bestDistance, &lane, lanePos, routeOffset, edges);
1782 }
1783 if ((found && bestDistance <= maxRouteDistance) || mayLeaveNetwork) {
1784 // optionally compute lateral offset
1785 pos.setz(veh->getPosition().z());
1786 if (found && setLateralPos) {
1787 const double perpDist = lane->getShape().distance2D(pos, false);
1788 if (perpDist != GeomHelper::INVALID_OFFSET) {
1789 lanePosLat = perpDist;
1790 if (!mayLeaveNetwork) {
1791 lanePosLat = MIN2(lanePosLat, 0.5 * (lane->getWidth() + veh->getVehicleType().getWidth() - MSGlobals::gLateralResolution));
1792 }
1793 // figure out whether the offset is to the left or to the right
1794 PositionVector tmp = lane->getShape();
1795 try {
1796 tmp.move2side(-lanePosLat); // moved to left
1797 } catch (ProcessError&) {
1798 WRITE_WARNINGF(TL("Could not determine position on lane '%' at lateral position %."), lane->getID(), toString(-lanePosLat));
1799 }
1800 //std::cout << " lane=" << lane->getID() << " posLat=" << lanePosLat << " shape=" << lane->getShape() << " tmp=" << tmp << " tmpDist=" << tmp.distance2D(pos) << "\n";
1801 if (tmp.distance2D(pos) > perpDist) {
1802 lanePosLat = -lanePosLat;
1803 }
1804 }
1805 pos.setz(lane->geometryPositionAtOffset(lanePos).z());
1806 }
1807 if (found && !mayLeaveNetwork && MSGlobals::gLateralResolution < 0) {
1808 // mapped position may differ from pos
1809 pos = lane->geometryPositionAtOffset(lanePos, -lanePosLat);
1810 }
1811 assert((found && lane != 0) || (!found && lane == 0));
1812 assert(!std::isnan(lanePos));
1813 if (angle == INVALID_DOUBLE_VALUE) {
1814 if (lane != nullptr) {
1815 angle = GeomHelper::naviDegree(lane->getShape().rotationAtOffset(lanePos));
1816 } else {
1817 // compute angle outside road network from old and new position
1818 angle = GeomHelper::naviDegree(veh->getPosition().angleTo2D(pos));
1819 }
1820 }
1821 // use the best we have
1822#ifdef DEBUG_MOVEXY
1823 std::cout << SIMTIME << " veh=" << vehID + " moveToXYResult lane='" << Named::getIDSecure(lane) << "' lanePos=" << lanePos << " lanePosLat=" << lanePosLat << "\n";
1824#endif
1825 Helper::setRemoteControlled(veh, pos, lane, lanePos, lanePosLat, angle, routeOffset, edges, MSNet::getInstance()->getCurrentTimeStep());
1826 if (!veh->isOnRoad()) {
1828 }
1829 } else {
1830 if (lane == nullptr) {
1831 throw TraCIException("Could not map vehicle '" + vehID + "', no road found within " + toString(maxRouteDistance) + "m.");
1832 } else {
1833 throw TraCIException("Could not map vehicle '" + vehID + "', distance to road is " + toString(bestDistance) + ".");
1834 }
1835 }
1836}
1837
1838void
1839Vehicle::slowDown(const std::string& vehID, double speed, double duration) {
1840 try {
1841 checkTimeBounds(duration);
1842 } catch (ProcessError&) {
1843 throw TraCIException("Duration parameter exceeds the time value range.");
1844 }
1845 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1846 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1847 if (veh == nullptr) {
1848 WRITE_ERROR("slowDown not applicable for meso");
1849 return;
1850 }
1851
1852 std::vector<std::pair<SUMOTime, double> > speedTimeLine;
1853 speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), veh->getSpeed()));
1854 speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), speed));
1855 veh->getInfluencer().setSpeedTimeLine(speedTimeLine);
1856}
1857
1858void
1859Vehicle::openGap(const std::string& vehID, double newTimeHeadway, double newSpaceHeadway, double duration, double changeRate, double maxDecel, const std::string& referenceVehID) {
1860 try {
1861 checkTimeBounds(duration);
1862 } catch (ProcessError&) {
1863 throw TraCIException("Duration parameter exceeds the time value range.");
1864 }
1865 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1866 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1867 if (veh == nullptr) {
1868 WRITE_ERROR("openGap not applicable for meso");
1869 return;
1870 }
1871
1872 MSVehicle* refVeh = nullptr;
1873 if (referenceVehID != "") {
1874 refVeh = dynamic_cast<MSVehicle*>(Helper::getVehicle(referenceVehID));
1875 }
1876 const double originalTau = veh->getVehicleType().getCarFollowModel().getHeadwayTime();
1877 if (newTimeHeadway == -1) {
1878 newTimeHeadway = originalTau;
1879 }
1880 if (originalTau > newTimeHeadway) {
1881 WRITE_WARNING("Ignoring openGap(). New time headway must not be smaller than the original.");
1882 return;
1883 }
1884 veh->getInfluencer().activateGapController(originalTau, newTimeHeadway, newSpaceHeadway, duration, changeRate, maxDecel, refVeh);
1885}
1886
1887void
1888Vehicle::deactivateGapControl(const std::string& vehID) {
1889 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1890 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1891 if (veh == nullptr) {
1892 WRITE_ERROR("deactivateGapControl not applicable for meso");
1893 return;
1894 }
1895
1896 if (veh->hasInfluencer()) {
1898 }
1899}
1900
1901void
1902Vehicle::requestToC(const std::string& vehID, double leadTime) {
1903 setParameter(vehID, "device.toc.requestToC", toString(leadTime));
1904}
1905
1906void
1907Vehicle::setSpeed(const std::string& vehID, double speed) {
1908 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1909 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1910 if (veh == nullptr) {
1911 WRITE_WARNING("setSpeed not yet implemented for meso");
1912 return;
1913 }
1914
1915 std::vector<std::pair<SUMOTime, double> > speedTimeLine;
1916 if (speed >= 0) {
1917 speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), speed));
1918 speedTimeLine.push_back(std::make_pair(SUMOTime_MAX - DELTA_T, speed));
1919 }
1920 veh->getInfluencer().setSpeedTimeLine(speedTimeLine);
1921}
1922
1923void
1924Vehicle::setAcceleration(const std::string& vehID, double acceleration, double duration) {
1925 try {
1926 checkTimeBounds(duration);
1927 } catch (ProcessError&) {
1928 throw TraCIException("Duration parameter exceeds the time value range.");
1929 }
1930 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1931 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1932 if (veh == nullptr) {
1933 WRITE_WARNING("setAcceleration not yet implemented for meso");
1934 return;
1935 }
1936
1937 double targetSpeed = std::max(veh->getSpeed() + acceleration * duration, 0.0);
1938 std::vector<std::pair<SUMOTime, double>> speedTimeLine;
1939 speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep(), veh->getSpeed()));
1940 speedTimeLine.push_back(std::make_pair(MSNet::getInstance()->getCurrentTimeStep() + TIME2STEPS(duration), targetSpeed));
1941 veh->getInfluencer().setSpeedTimeLine(speedTimeLine);
1942}
1943
1944void
1945Vehicle::setPreviousSpeed(const std::string& vehID, double prevSpeed, double prevAcceleration) {
1946 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1947 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1948 if (veh == nullptr) {
1949 WRITE_WARNING("setPreviousSpeed not yet implemented for meso");
1950 return;
1951 }
1952 if (prevAcceleration == INVALID_DOUBLE_VALUE) {
1953 prevAcceleration = std::numeric_limits<double>::min();
1954 }
1955 veh->setPreviousSpeed(prevSpeed, prevAcceleration);
1956}
1957
1958void
1959Vehicle::setSpeedMode(const std::string& vehID, int speedMode) {
1960 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1961 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1962 if (veh == nullptr) {
1963 WRITE_WARNING("setSpeedMode not yet implemented for meso");
1964 return;
1965 }
1966
1967 veh->getInfluencer().setSpeedMode(speedMode);
1968}
1969
1970void
1971Vehicle::setLaneChangeMode(const std::string& vehID, int laneChangeMode) {
1972 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
1973 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
1974 if (veh == nullptr) {
1975 WRITE_ERROR("setLaneChangeMode not applicable for meso");
1976 return;
1977 }
1978
1979 veh->getInfluencer().setLaneChangeMode(laneChangeMode);
1980}
1981
1982void
1983Vehicle::setRoutingMode(const std::string& vehID, int routingMode) {
1984 Helper::getVehicle(vehID)->setRoutingMode(routingMode);
1985}
1986
1987void
1988Vehicle::setType(const std::string& vehID, const std::string& typeID) {
1989 MSVehicleType* vehicleType = MSNet::getInstance()->getVehicleControl().getVType(typeID);
1990 if (vehicleType == nullptr) {
1991 throw TraCIException("Vehicle type '" + typeID + "' is not known");
1992 }
1993 MSBaseVehicle* veh = Helper::getVehicle(vehID);
1994 veh->replaceVehicleType(vehicleType);
1995 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
1996 if (microVeh != nullptr && microVeh->isOnRoad()) {
1997 microVeh->updateBestLanes(true);
1998 microVeh->updateLaneBruttoSum();
1999 }
2000}
2001
2002void
2003Vehicle::setRouteID(const std::string& vehID, const std::string& routeID) {
2004 MSBaseVehicle* veh = Helper::getVehicle(vehID);
2006 if (r == nullptr) {
2007 throw TraCIException("The route '" + routeID + "' is not known.");
2008 }
2010 WRITE_WARNINGF(TL("Internal routes receive an ID starting with '!' and must not be referenced in other vehicle or flow definitions. Please remove all references to route '%' in case it is internal."), routeID);
2011 }
2012 std::string msg;
2013 if (!veh->hasValidRoute(msg, r)) {
2014 WRITE_WARNINGF(TL("Invalid route replacement for vehicle '%'. %"), veh->getID(), msg);
2016 throw TraCIException("Route replacement failed for " + veh->getID());
2017 }
2018 }
2019
2020 std::string errorMsg;
2021 if (!veh->replaceRoute(r, "traci:setRouteID", veh->getLane() == nullptr, 0, true, true, &errorMsg)) {
2022 throw TraCIException("Route replacement failed for vehicle '" + veh->getID() + "' (" + errorMsg + ").");
2023 }
2024}
2025
2026void
2027Vehicle::setRoute(const std::string& vehID, const std::string& edgeID) {
2028 setRoute(vehID, std::vector<std::string>({edgeID}));
2029}
2030
2031
2032void
2033Vehicle::setRoute(const std::string& vehID, const std::vector<std::string>& edgeIDs) {
2034 MSBaseVehicle* veh = Helper::getVehicle(vehID);
2035 ConstMSEdgeVector edges;
2036 const bool onInit = veh->getLane() == nullptr;
2037 try {
2038 MSEdge::parseEdgesList(edgeIDs, edges, "<unknown>");
2039 if (edges.size() > 0 && edges.front()->isInternal()) {
2040 if (edges.size() == 1) {
2041 // avoid crashing due to lack of normal edges in route (#5390)
2042 edges.push_back(edges.back()->getLanes()[0]->getNextNormal());
2043 } else {
2044 // avoid internal edge in final route
2045 if (edges.front() == &veh->getLane()->getEdge()) {
2046 edges.erase(edges.begin());
2047 }
2048 }
2049 }
2050 } catch (ProcessError& e) {
2051 throw TraCIException("Invalid edge list for vehicle '" + veh->getID() + "' (" + e.what() + ")");
2052 }
2053 std::string errorMsg;
2054 if (!veh->replaceRouteEdges(edges, -1, 0, "traci:setRoute", onInit, true, true, &errorMsg)) {
2055 throw TraCIException("Route replacement failed for vehicle '" + veh->getID() + "' (" + errorMsg + ").");
2056 }
2057}
2058
2059
2060void
2061Vehicle::setLateralLanePosition(const std::string& vehID, double posLat) {
2062 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
2063 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
2064 if (veh != nullptr) {
2065 veh->setLateralPositionOnLane(posLat);
2066 } else {
2067 WRITE_ERROR("setLateralLanePosition not applicable for meso");
2068 }
2069}
2070
2071
2072void
2073Vehicle::updateBestLanes(const std::string& vehID) {
2074 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
2075 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
2076 if (veh == nullptr) {
2077 WRITE_ERROR("updateBestLanes not applicable for meso");
2078 return;
2079 }
2080 if (veh->isOnRoad()) {
2081 veh->updateBestLanes(true);
2082 }
2083}
2084
2085
2086void
2087Vehicle::setAdaptedTraveltime(const std::string& vehID, const std::string& edgeID,
2088 double time, double begSeconds, double endSeconds) {
2089 MSBaseVehicle* veh = Helper::getVehicle(vehID);
2090 MSEdge* edge = MSEdge::dictionary(edgeID);
2091 if (edge == nullptr) {
2092 throw TraCIException("Edge '" + edgeID + "' is not known.");
2093 }
2094 if (time != INVALID_DOUBLE_VALUE) {
2095 // add time
2096 if (begSeconds == 0 && endSeconds == std::numeric_limits<double>::max()) {
2097 // clean up old values before setting whole range
2098 while (veh->getWeightsStorage().knowsTravelTime(edge)) {
2100 }
2101 }
2102 veh->getWeightsStorage().addTravelTime(edge, begSeconds, endSeconds, time);
2103 } else {
2104 // remove time
2105 while (veh->getWeightsStorage().knowsTravelTime(edge)) {
2107 }
2108 }
2109}
2110
2111
2112void
2113Vehicle::setEffort(const std::string& vehID, const std::string& edgeID,
2114 double effort, double begSeconds, double endSeconds) {
2115 MSBaseVehicle* veh = Helper::getVehicle(vehID);
2116 MSEdge* edge = MSEdge::dictionary(edgeID);
2117 if (edge == nullptr) {
2118 throw TraCIException("Edge '" + edgeID + "' is not known.");
2119 }
2120 if (effort != INVALID_DOUBLE_VALUE) {
2121 // add effort
2122 if (begSeconds == 0 && endSeconds == std::numeric_limits<double>::max()) {
2123 // clean up old values before setting whole range
2124 while (veh->getWeightsStorage().knowsEffort(edge)) {
2125 veh->getWeightsStorage().removeEffort(edge);
2126 }
2127 }
2128 veh->getWeightsStorage().addEffort(edge, begSeconds, endSeconds, effort);
2129 } else {
2130 // remove effort
2131 while (veh->getWeightsStorage().knowsEffort(edge)) {
2132 veh->getWeightsStorage().removeEffort(edge);
2133 }
2134 }
2135}
2136
2137
2138void
2139Vehicle::rerouteTraveltime(const std::string& vehID, const bool currentTravelTimes) {
2140 MSBaseVehicle* veh = Helper::getVehicle(vehID);
2141 const int routingMode = veh->getRoutingMode();
2142 if (currentTravelTimes && routingMode == ROUTING_MODE_DEFAULT) {
2144 }
2145 veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:rerouteTraveltime",
2146 veh->getRouterTT(), isOnInit(vehID));
2147 if (currentTravelTimes && routingMode == ROUTING_MODE_DEFAULT) {
2148 veh->setRoutingMode(routingMode);
2149 }
2150}
2151
2152
2153void
2154Vehicle::rerouteEffort(const std::string& vehID) {
2155 MSBaseVehicle* veh = Helper::getVehicle(vehID);
2156 veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:rerouteEffort",
2157 MSNet::getInstance()->getRouterEffort(veh->getRNGIndex()), isOnInit(vehID));
2158}
2159
2160
2161void
2162Vehicle::setSignals(const std::string& vehID, int signals) {
2163 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
2164 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
2165 if (veh == nullptr) {
2166 WRITE_ERROR("setSignals not applicable for meso");
2167 return;
2168 }
2169
2170 // set influencer to make the change persistent
2171 veh->getInfluencer().setSignals(signals);
2172 // set them now so that getSignals returns the correct value
2173 veh->switchOffSignal(0x0fffffff);
2174 if (signals >= 0) {
2175 veh->switchOnSignal(signals);
2176 }
2177}
2178
2179
2180void
2181Vehicle::moveTo(const std::string& vehID, const std::string& laneID, double pos, int reason) {
2182 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
2183 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
2184 if (veh == nullptr) {
2185 WRITE_WARNING("moveTo not yet implemented for meso");
2186 return;
2187 }
2188
2189 MSLane* l = MSLane::dictionary(laneID);
2190 if (l == nullptr) {
2191 throw TraCIException("Unknown lane '" + laneID + "'.");
2192 }
2193 if (veh->getLane() == l) {
2195 return;
2196 }
2197 MSEdge* destinationEdge = &l->getEdge();
2198 const MSEdge* destinationRouteEdge = destinationEdge->getNormalBefore();
2199 if (!veh->isOnRoad() && veh->getParameter().wasSet(VEHPARS_FORCE_REROUTE) && veh->getRoute().getEdges().size() == 2) {
2200 // it's a trip that wasn't routeted yet (likely because the vehicle was added in this step. Find a route now
2201 veh->reroute(MSNet::getInstance()->getCurrentTimeStep(), "traci:moveTo-tripInsertion",
2202 veh->getRouterTT(), true);
2203 }
2204 // find edge in the remaining route
2205 MSRouteIterator it = std::find(veh->getCurrentRouteEdge(), veh->getRoute().end(), destinationRouteEdge);
2206 if (it == veh->getRoute().end()) {
2207 // find edge in the edges that were already passed
2208 it = std::find(veh->getRoute().begin(), veh->getRoute().end(), destinationRouteEdge);
2209 }
2210 if (it == veh->getRoute().end() ||
2211 // internal edge must continue the route
2212 (destinationEdge->isInternal() &&
2213 ((it + 1) == veh->getRoute().end()
2214 || l->getNextNormal() != *(it + 1)))) {
2215 throw TraCIException("Lane '" + laneID + "' is not on the route of vehicle '" + vehID + "'.");
2216 }
2217 Position oldPos = vehicle->getPosition();
2219 if (veh->getLane() != nullptr) {
2220 // correct odometer which gets incremented via onRemovalFromNet->leaveLane
2221 veh->addToOdometer(-veh->getLane()->getLength());
2223 } else {
2224 veh->setTentativeLaneAndPosition(l, pos);
2225 }
2226 const int oldRouteIndex = veh->getRoutePosition();
2227 const int newRouteIndex = (int)(it - veh->getRoute().begin());
2228 if (oldRouteIndex > newRouteIndex) {
2229 // more odometer correction needed
2230 veh->addToOdometer(-l->getLength());
2231 }
2232 veh->resetRoutePosition(newRouteIndex, veh->getParameter().departLaneProcedure);
2233 if (!veh->isOnRoad()) {
2236 }
2237 MSMoveReminder::Notification moveReminderReason;
2238 if (veh->hasDeparted()) {
2239 if (reason == MOVE_TELEPORT) {
2240 moveReminderReason = MSMoveReminder::NOTIFICATION_TELEPORT;
2241 } else if (reason == MOVE_NORMAL) {
2242 moveReminderReason = MSMoveReminder::NOTIFICATION_JUNCTION;
2243 } else if (reason == MOVE_AUTOMATIC) {
2244 Position newPos = l->geometryPositionAtOffset(pos);
2245 const double dist = newPos.distanceTo2D(oldPos);
2246 if (dist < SPEED2DIST(veh->getMaxSpeed())) {
2247 moveReminderReason = MSMoveReminder::NOTIFICATION_JUNCTION;
2248 } else {
2249 moveReminderReason = MSMoveReminder::NOTIFICATION_TELEPORT;
2250 }
2251 } else {
2252 throw TraCIException("Invalid moveTo reason '" + toString(reason) + "' for vehicle '" + vehID + "'.");
2253 }
2254 } else {
2255 moveReminderReason = MSMoveReminder::NOTIFICATION_DEPARTED;
2256 }
2257 l->forceVehicleInsertion(veh, pos, moveReminderReason);
2258}
2259
2260
2261void
2262Vehicle::setActionStepLength(const std::string& vehID, double actionStepLength, bool resetActionOffset) {
2263 if (actionStepLength < 0.0) {
2264 WRITE_ERROR("Invalid action step length (<0). Ignoring command setActionStepLength().");
2265 return;
2266 }
2267 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
2268 MSVehicle* veh = dynamic_cast<MSVehicle*>(vehicle);
2269 if (veh == nullptr) {
2270 WRITE_ERROR("setActionStepLength not applicable for meso");
2271 return;
2272 }
2273
2274 if (actionStepLength == 0.) {
2275 veh->resetActionOffset();
2276 } else {
2277 veh->setActionStepLength(actionStepLength, resetActionOffset);
2278 }
2279}
2280
2281
2282void
2283Vehicle::setBoardingDuration(const std::string& vehID, double boardingDuration) {
2284 try {
2285 checkTimeBounds(boardingDuration);
2286 } catch (ProcessError&) {
2287 throw TraCIException("BoardingDuration parameter exceeds the time value range.");
2288 }
2290}
2291
2292
2293void
2294Vehicle::setImpatience(const std::string& vehID, double impatience) {
2295 MSBaseVehicle* vehicle = Helper::getVehicle(vehID);
2296 const double normalImpatience = vehicle->getImpatience();
2297 vehicle->getBaseInfluencer().setExtraImpatience(impatience - normalImpatience);
2298}
2299
2300
2301void
2302Vehicle::remove(const std::string& vehID, char reason) {
2303 MSBaseVehicle* veh = Helper::getVehicle(vehID);
2305 switch (reason) {
2306 case REMOVE_TELEPORT:
2307 // XXX semantics unclear
2308 // n = MSMoveReminder::NOTIFICATION_TELEPORT;
2310 break;
2311 case REMOVE_PARKING:
2312 // XXX semantics unclear
2313 // n = MSMoveReminder::NOTIFICATION_PARKING;
2315 break;
2316 case REMOVE_ARRIVED:
2318 break;
2319 case REMOVE_VAPORIZED:
2321 break;
2324 break;
2325 default:
2326 throw TraCIException("Unknown removal status.");
2327 }
2328 if (veh->hasDeparted()) {
2329 veh->onRemovalFromNet(n);
2330 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
2331 if (microVeh != nullptr) {
2332 if (veh->getLane() != nullptr) {
2333 microVeh->getMutableLane()->removeVehicle(dynamic_cast<MSVehicle*>(veh), n);
2334 }
2336 }
2338 } else {
2341 }
2342}
2343
2344
2345void
2346Vehicle::setColor(const std::string& vehID, const TraCIColor& col) {
2348 p.color.set((unsigned char)col.r, (unsigned char)col.g, (unsigned char)col.b, (unsigned char)col.a);
2350}
2351
2352
2353void
2354Vehicle::setSpeedFactor(const std::string& vehID, double factor) {
2356}
2357
2358
2359void
2360Vehicle::setLine(const std::string& vehID, const std::string& line) {
2361 Helper::getVehicle(vehID)->getParameter().line = line;
2362}
2363
2364
2365void
2366Vehicle::setVia(const std::string& vehID, const std::vector<std::string>& edgeList) {
2367 MSBaseVehicle* veh = Helper::getVehicle(vehID);
2368 try {
2369 // ensure edges exist
2370 ConstMSEdgeVector edges;
2371 MSEdge::parseEdgesList(edgeList, edges, "<via-edges>");
2372 } catch (ProcessError& e) {
2373 throw TraCIException(e.what());
2374 }
2375 veh->getParameter().via = edgeList;
2376}
2377
2378
2379void
2380Vehicle::setLength(const std::string& vehID, double length) {
2382}
2383
2384
2385void
2386Vehicle::setMaxSpeed(const std::string& vehID, double speed) {
2388}
2389
2390
2391void
2392Vehicle::setVehicleClass(const std::string& vehID, const std::string& clazz) {
2393 MSBaseVehicle* veh = Helper::getVehicle(vehID);
2395 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
2396 if (microVeh != nullptr && microVeh->isOnRoad()) {
2397 microVeh->updateBestLanes(true);
2398 }
2399}
2400
2401
2402void
2403Vehicle::setShapeClass(const std::string& vehID, const std::string& clazz) {
2405}
2406
2407
2408void
2409Vehicle::setEmissionClass(const std::string& vehID, const std::string& clazz) {
2411}
2412
2413
2414void
2415Vehicle::setWidth(const std::string& vehID, double width) {
2417}
2418
2419
2420void
2421Vehicle::setHeight(const std::string& vehID, double height) {
2423}
2424
2425
2426void
2427Vehicle::setMass(const std::string& vehID, double mass) {
2429}
2430
2431
2432void
2433Vehicle::setMinGap(const std::string& vehID, double minGap) {
2434 MSBaseVehicle* veh = Helper::getVehicle(vehID);
2435 veh->getSingularType().setMinGap(minGap);
2436 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
2437 if (microVeh != nullptr && microVeh->isOnRoad()) {
2438 microVeh->updateLaneBruttoSum();
2439 }
2440}
2441
2442
2443void
2444Vehicle::setAccel(const std::string& vehID, double accel) {
2446}
2447
2448
2449void
2450Vehicle::setDecel(const std::string& vehID, double decel) {
2451 VehicleType::setDecel(Helper::getVehicle(vehID)->getSingularType().getID(), decel);
2452}
2453
2454
2455void
2456Vehicle::setEmergencyDecel(const std::string& vehID, double decel) {
2457 VehicleType::setEmergencyDecel(Helper::getVehicle(vehID)->getSingularType().getID(), decel);
2458}
2459
2460
2461void
2462Vehicle::setApparentDecel(const std::string& vehID, double decel) {
2464}
2465
2466
2467void
2468Vehicle::setImperfection(const std::string& vehID, double imperfection) {
2469 Helper::getVehicle(vehID)->getSingularType().setImperfection(imperfection);
2470}
2471
2472
2473void
2474Vehicle::setTau(const std::string& vehID, double tau) {
2476}
2477
2478
2479void
2480Vehicle::setMinGapLat(const std::string& vehID, double minGapLat) {
2481 try {
2482 setParameter(vehID, "laneChangeModel.minGapLat", toString(minGapLat));
2483 } catch (TraCIException&) {
2484 // legacy behavior
2485 Helper::getVehicle(vehID)->getSingularType().setMinGapLat(minGapLat);
2486 }
2487}
2488
2489
2490void
2491Vehicle::setMaxSpeedLat(const std::string& vehID, double speed) {
2493}
2494
2495
2496void
2497Vehicle::setLateralAlignment(const std::string& vehID, const std::string& latAlignment) {
2498 double lao;
2500 if (SUMOVTypeParameter::parseLatAlignment(latAlignment, lao, lad)) {
2502 } else {
2503 throw TraCIException("Unknown value '" + latAlignment + "' when setting latAlignment for vehID '" + vehID + "';\n must be one of (\"right\", \"center\", \"arbitrary\", \"nice\", \"compact\", \"left\" or a float)");
2504 }
2505}
2506
2507
2508void
2509Vehicle::setParameter(const std::string& vehID, const std::string& key, const std::string& value) {
2510 MSBaseVehicle* veh = Helper::getVehicle(vehID);
2511 MSVehicle* microVeh = dynamic_cast<MSVehicle*>(veh);
2512 if (StringUtils::startsWith(key, "device.")) {
2513 StringTokenizer tok(key, ".");
2514 if (tok.size() < 3) {
2515 throw TraCIException("Invalid device parameter '" + key + "' for vehicle '" + vehID + "'");
2516 }
2517 try {
2518 veh->setDeviceParameter(tok.get(1), key.substr(tok.get(0).size() + tok.get(1).size() + 2), value);
2519 } catch (InvalidArgument& e) {
2520 throw TraCIException("Vehicle '" + vehID + "' does not support device parameter '" + key + "' (" + e.what() + ").");
2521 }
2522 } else if (StringUtils::startsWith(key, "laneChangeModel.")) {
2523 if (microVeh == nullptr) {
2524 throw TraCIException("Meso Vehicle '" + vehID + "' does not support laneChangeModel parameters.");
2525 }
2526 const std::string attrName = key.substr(16);
2527 if (attrName == toString(SUMO_ATTR_LCA_CONTRIGHT)) {
2528 // special case: not used within lcModel
2529 veh->getSingularType().setLcContRight(value);
2530 } else {
2531 try {
2532 microVeh->getLaneChangeModel().setParameter(attrName, value);
2533 } catch (InvalidArgument& e) {
2534 throw TraCIException("Vehicle '" + vehID + "' does not support laneChangeModel parameter '" + key + "' (" + e.what() + ").");
2535 }
2536 }
2537 } else if (StringUtils::startsWith(key, "carFollowModel.")) {
2538 if (microVeh == nullptr) {
2539 throw TraCIException("Meso Vehicle '" + vehID + "' does not support carFollowModel parameters.");
2540 }
2541 try {
2542 veh->setCarFollowModelParameter(key, value);
2543 } catch (InvalidArgument& e) {
2544 throw TraCIException("Vehicle '" + vehID + "' does not support carFollowModel parameter '" + key + "' (" + e.what() + ").");
2545 }
2546 } else if (StringUtils::startsWith(key, "junctionModel.")) {
2547 try {
2548 // use the whole key (including junctionModel prefix)
2549 veh->setJunctionModelParameter(key, value);
2550 } catch (InvalidArgument& e) {
2551 // error message includes id since it is also used for xml input
2552 throw TraCIException(e.what());
2553 }
2554 } else if (StringUtils::startsWith(key, "has.") && StringUtils::endsWith(key, ".device")) {
2555 StringTokenizer tok(key, ".");
2556 if (tok.size() != 3) {
2557 throw TraCIException("Invalid request for device status change. Expected format is 'has.DEVICENAME.device'");
2558 }
2559 const std::string deviceName = tok.get(1);
2560 bool create;
2561 try {
2562 create = StringUtils::toBool(value);
2563 } catch (BoolFormatException&) {
2564 throw TraCIException("Changing device status requires a 'true' or 'false'");
2565 }
2566 if (!create) {
2567 throw TraCIException("Device removal is not supported for device of type '" + deviceName + "'");
2568 }
2569 try {
2570 veh->createDevice(deviceName);
2571 } catch (InvalidArgument& e) {
2572 throw TraCIException("Cannot create vehicle device (" + std::string(e.what()) + ").");
2573 }
2574 } else {
2575 ((SUMOVehicleParameter&)veh->getParameter()).setParameter(key, value);
2576 }
2577}
2578
2579
2580void
2581Vehicle::highlight(const std::string& vehID, const TraCIColor& col, double size, const int alphaMax, const double duration, const int type) {
2582
2583 // NOTE: Code is duplicated in large parts in POI.cpp
2584 MSBaseVehicle* veh = Helper::getVehicle(vehID);
2585
2586 // Center of the highlight circle
2587 Position center = veh->getPosition();
2588 const double l2 = veh->getLength() * 0.5;
2589 center.sub(cos(veh->getAngle())*l2, sin(veh->getAngle())*l2);
2590 // Size of the highlight circle
2591 if (size <= 0) {
2592 size = veh->getLength() * 0.7;
2593 }
2594 // Make polygon shape
2595 const unsigned int nPoints = 34;
2596 const PositionVector circlePV = GeomHelper::makeRing(size, size + 1., center, nPoints);
2597 TraCIPositionVector circle = Helper::makeTraCIPositionVector(circlePV);
2598
2599#ifdef DEBUG_DYNAMIC_SHAPES
2600 std::cout << SIMTIME << " Vehicle::highlight() for vehicle '" << vehID << "'\n"
2601 << " circle: " << circlePV << std::endl;
2602#endif
2603
2604 // Find a free polygon id
2605 int i = 0;
2606 std::string polyID = veh->getID() + "_hl" + toString(i);
2607 while (Polygon::exists(polyID)) {
2608 polyID = veh->getID() + "_hl" + toString(++i);
2609 }
2610 // Line width
2611 double lw = 0.;
2612 // Layer
2613 double lyr = 0.;
2614 if (MSNet::getInstance()->isGUINet()) {
2615 lyr = GLO_VEHICLE + 0.01;
2616 lyr += (type + 1) / 257.;
2617 }
2618 // Make Polygon
2619 Polygon::addHighlightPolygon(vehID, type, polyID, circle, col, true, "highlight", (int)lyr, lw);
2620
2621 // Animation time line
2622 double maxAttack = 1.0; // maximal fade-in time
2623 std::vector<double> timeSpan;
2624 if (duration > 0.) {
2625 timeSpan = {0, MIN2(maxAttack, duration / 3.), 2.*duration / 3., duration};
2626 }
2627 // Alpha time line
2628 std::vector<double> alphaSpan;
2629 if (alphaMax > 0.) {
2630 alphaSpan = {0., (double) alphaMax, (double)(alphaMax) / 3., 0.};
2631 }
2632 // Attach dynamics
2633 Polygon::addDynamics(polyID, vehID, timeSpan, alphaSpan, false, true);
2634}
2635
2636void
2637Vehicle::dispatchTaxi(const std::string& vehID, const std::vector<std::string>& reservations) {
2638 MSBaseVehicle* veh = Helper::getVehicle(vehID);
2639 MSDevice_Taxi* taxi = static_cast<MSDevice_Taxi*>(veh->getDevice(typeid(MSDevice_Taxi)));
2640 if (!veh->hasDeparted()) {
2641 throw TraCIException("Vehicle '" + vehID + "' has not yet departed");
2642 }
2643 if (taxi == nullptr) {
2644 throw TraCIException("Vehicle '" + vehID + "' is not a taxi");
2645 }
2647 if (dispatcher == nullptr) {
2648 throw TraCIException("Cannot dispatch taxi because no reservations have been made");
2649 }
2650 MSDispatch_TraCI* traciDispatcher = dynamic_cast<MSDispatch_TraCI*>(dispatcher);
2651 if (traciDispatcher == nullptr) {
2652 throw TraCIException("device.taxi.dispatch-algorithm 'traci' has not been loaded");
2653 }
2654 if (reservations.size() == 0) {
2655 throw TraCIException("No reservations have been specified for vehicle '" + vehID + "'");
2656 }
2657 try {
2658 traciDispatcher->interpretDispatch(taxi, reservations);
2659 } catch (InvalidArgument& e) {
2660 throw TraCIException("Could not interpret reservations for vehicle '" + vehID + "' (" + e.what() + ").");
2661 }
2662}
2663
2665
2666
2667void
2668Vehicle::subscribeLeader(const std::string& vehID, double dist, double begin, double end) {
2669 subscribe(vehID, std::vector<int>({ libsumo::VAR_LEADER }), begin, end,
2670 libsumo::TraCIResults({ {libsumo::VAR_LEADER, std::make_shared<libsumo::TraCIDouble>(dist)} }));
2671}
2672
2673
2674void
2675Vehicle::addSubscriptionFilterLanes(const std::vector<int>& lanes, bool noOpposite, double downstreamDist, double upstreamDist) {
2677 if (s != nullptr) {
2678 s->filterLanes = lanes;
2679 }
2680 if (noOpposite) {
2681 addSubscriptionFilterNoOpposite();
2682 }
2683 if (downstreamDist != INVALID_DOUBLE_VALUE) {
2684 addSubscriptionFilterDownstreamDistance(downstreamDist);
2685 }
2686 if (upstreamDist != INVALID_DOUBLE_VALUE) {
2687 addSubscriptionFilterUpstreamDistance(upstreamDist);
2688 }
2689}
2690
2691
2692void
2693Vehicle::addSubscriptionFilterNoOpposite() {
2695}
2696
2697
2698void
2699Vehicle::addSubscriptionFilterDownstreamDistance(double dist) {
2701 if (s != nullptr) {
2702 s->filterDownstreamDist = dist;
2703 }
2704}
2705
2706
2707void
2708Vehicle::addSubscriptionFilterUpstreamDistance(double dist) {
2710 if (s != nullptr) {
2711 s->filterUpstreamDist = dist;
2712 }
2713}
2714
2715
2716void
2717Vehicle::addSubscriptionFilterCFManeuver(double downstreamDist, double upstreamDist) {
2718 addSubscriptionFilterLeadFollow(std::vector<int>({0}));
2719 if (downstreamDist != INVALID_DOUBLE_VALUE) {
2720 addSubscriptionFilterDownstreamDistance(downstreamDist);
2721 }
2722 if (upstreamDist != INVALID_DOUBLE_VALUE) {
2723 addSubscriptionFilterUpstreamDistance(upstreamDist);
2724 }
2725
2726}
2727
2728
2729void
2730Vehicle::addSubscriptionFilterLCManeuver(int direction, bool noOpposite, double downstreamDist, double upstreamDist) {
2731 std::vector<int> lanes;
2732 if (direction == INVALID_INT_VALUE) {
2733 // Using default: both directions
2734 lanes = std::vector<int>({-1, 0, 1});
2735 } else if (direction != -1 && direction != 1) {
2736 WRITE_WARNINGF(TL("Ignoring lane change subscription filter with non-neighboring lane offset direction=%."), direction);
2737 } else {
2738 lanes = std::vector<int>({0, direction});
2739 }
2740 addSubscriptionFilterLeadFollow(lanes);
2741 if (noOpposite) {
2742 addSubscriptionFilterNoOpposite();
2743 }
2744 if (downstreamDist != INVALID_DOUBLE_VALUE) {
2745 addSubscriptionFilterDownstreamDistance(downstreamDist);
2746 }
2747 if (upstreamDist != INVALID_DOUBLE_VALUE) {
2748 addSubscriptionFilterUpstreamDistance(upstreamDist);
2749 }
2750}
2751
2752
2753void
2754Vehicle::addSubscriptionFilterLeadFollow(const std::vector<int>& lanes) {
2756 addSubscriptionFilterLanes(lanes);
2757}
2758
2759
2760void
2761Vehicle::addSubscriptionFilterTurn(double downstreamDist, double foeDistToJunction) {
2763 if (downstreamDist != INVALID_DOUBLE_VALUE) {
2764 addSubscriptionFilterDownstreamDistance(downstreamDist);
2765 }
2766 if (foeDistToJunction != INVALID_DOUBLE_VALUE) {
2767 s->filterFoeDistToJunction = foeDistToJunction;
2768 }
2769}
2770
2771
2772void
2773Vehicle::addSubscriptionFilterVClass(const std::vector<std::string>& vClasses) {
2775 if (s != nullptr) {
2776 s->filterVClasses = parseVehicleClasses(vClasses);
2777 }
2778}
2779
2780
2781void
2782Vehicle::addSubscriptionFilterVType(const std::vector<std::string>& vTypes) {
2784 if (s != nullptr) {
2785 s->filterVTypes.insert(vTypes.begin(), vTypes.end());
2786 }
2787}
2788
2789
2790void
2791Vehicle::addSubscriptionFilterFieldOfVision(double openingAngle) {
2793 if (s != nullptr) {
2794 s->filterFieldOfVisionOpeningAngle = openingAngle;
2795 }
2796}
2797
2798
2799void
2800Vehicle::addSubscriptionFilterLateralDistance(double lateralDist, double downstreamDist, double upstreamDist) {
2802 if (s != nullptr) {
2803 s->filterLateralDist = lateralDist;
2804 }
2805 if (downstreamDist != INVALID_DOUBLE_VALUE) {
2806 addSubscriptionFilterDownstreamDistance(downstreamDist);
2807 }
2808 if (upstreamDist != INVALID_DOUBLE_VALUE) {
2809 addSubscriptionFilterUpstreamDistance(upstreamDist);
2810 }
2811}
2812
2813
2814void
2815Vehicle::storeShape(const std::string& id, PositionVector& shape) {
2816 shape.push_back(Helper::getVehicle(id)->getPosition());
2817}
2818
2819
2820std::shared_ptr<VariableWrapper>
2821Vehicle::makeWrapper() {
2822 return std::make_shared<Helper::SubscriptionWrapper>(handleVariable, mySubscriptionResults, myContextSubscriptionResults);
2823}
2824
2825
2826bool
2827Vehicle::handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper, tcpip::Storage* paramData) {
2828 switch (variable) {
2829 case TRACI_ID_LIST:
2830 return wrapper->wrapStringList(objID, variable, getIDList());
2831 case ID_COUNT:
2832 return wrapper->wrapInt(objID, variable, getIDCount());
2833 case VAR_POSITION:
2834 return wrapper->wrapPosition(objID, variable, getPosition(objID));
2835 case VAR_POSITION3D:
2836 return wrapper->wrapPosition(objID, variable, getPosition(objID, true));
2837 case VAR_ANGLE:
2838 return wrapper->wrapDouble(objID, variable, getAngle(objID));
2839 case VAR_SPEED:
2840 return wrapper->wrapDouble(objID, variable, getSpeed(objID));
2841 case VAR_SPEED_LAT:
2842 return wrapper->wrapDouble(objID, variable, getLateralSpeed(objID));
2843 case VAR_ROAD_ID:
2844 return wrapper->wrapString(objID, variable, getRoadID(objID));
2846 return wrapper->wrapDouble(objID, variable, getSpeedWithoutTraCI(objID));
2847 case VAR_SLOPE:
2848 return wrapper->wrapDouble(objID, variable, getSlope(objID));
2849 case VAR_LANE_ID:
2850 return wrapper->wrapString(objID, variable, getLaneID(objID));
2851 case VAR_LANE_INDEX:
2852 return wrapper->wrapInt(objID, variable, getLaneIndex(objID));
2853 case VAR_SEGMENT_ID:
2854 return wrapper->wrapString(objID, variable, getSegmentID(objID));
2855 case VAR_SEGMENT_INDEX:
2856 return wrapper->wrapInt(objID, variable, getSegmentIndex(objID));
2857 case VAR_TYPE:
2858 return wrapper->wrapString(objID, variable, getTypeID(objID));
2859 case VAR_ROUTE_ID:
2860 return wrapper->wrapString(objID, variable, getRouteID(objID));
2861 case VAR_DEPARTURE:
2862 return wrapper->wrapDouble(objID, variable, getDeparture(objID));
2863 case VAR_DEPART_DELAY:
2864 return wrapper->wrapDouble(objID, variable, getDepartDelay(objID));
2865 case VAR_ROUTE_INDEX:
2866 return wrapper->wrapInt(objID, variable, getRouteIndex(objID));
2867 case VAR_COLOR:
2868 return wrapper->wrapColor(objID, variable, getColor(objID));
2869 case VAR_LANEPOSITION:
2870 return wrapper->wrapDouble(objID, variable, getLanePosition(objID));
2872 return wrapper->wrapDouble(objID, variable, getLateralLanePosition(objID));
2873 case VAR_CO2EMISSION:
2874 return wrapper->wrapDouble(objID, variable, getCO2Emission(objID));
2875 case VAR_COEMISSION:
2876 return wrapper->wrapDouble(objID, variable, getCOEmission(objID));
2877 case VAR_HCEMISSION:
2878 return wrapper->wrapDouble(objID, variable, getHCEmission(objID));
2879 case VAR_PMXEMISSION:
2880 return wrapper->wrapDouble(objID, variable, getPMxEmission(objID));
2881 case VAR_NOXEMISSION:
2882 return wrapper->wrapDouble(objID, variable, getNOxEmission(objID));
2884 return wrapper->wrapDouble(objID, variable, getFuelConsumption(objID));
2885 case VAR_NOISEEMISSION:
2886 return wrapper->wrapDouble(objID, variable, getNoiseEmission(objID));
2888 return wrapper->wrapDouble(objID, variable, getElectricityConsumption(objID));
2889 case VAR_PERSON_NUMBER:
2890 return wrapper->wrapInt(objID, variable, getPersonNumber(objID));
2892 return wrapper->wrapInt(objID, variable, getPersonCapacity(objID));
2894 return wrapper->wrapDouble(objID, variable, getBoardingDuration(objID));
2896 return wrapper->wrapStringList(objID, variable, getPersonIDList(objID));
2897 case VAR_WAITING_TIME:
2898 return wrapper->wrapDouble(objID, variable, getWaitingTime(objID));
2900 return wrapper->wrapDouble(objID, variable, getAccumulatedWaitingTime(objID));
2901 case VAR_EDGE_TRAVELTIME: {
2902 StoHelp::readCompound(*paramData);
2903 const double time = StoHelp::readTypedDouble(*paramData);
2904 return wrapper->wrapDouble(objID, variable, getAdaptedTraveltime(objID, time, StoHelp::readTypedString(*paramData)));
2905 }
2906 case VAR_EDGE_EFFORT: {
2907 StoHelp::readCompound(*paramData);
2908 const double time = StoHelp::readTypedDouble(*paramData);
2909 return wrapper->wrapDouble(objID, variable, getEffort(objID, time, StoHelp::readTypedString(*paramData)));
2910 }
2911 case VAR_ROUTE_VALID:
2912 return wrapper->wrapInt(objID, variable, isRouteValid(objID));
2913 case VAR_EDGES:
2914 return wrapper->wrapStringList(objID, variable, getRoute(objID));
2915 case VAR_SIGNALS:
2916 return wrapper->wrapInt(objID, variable, getSignals(objID));
2917 case VAR_BEST_LANES:
2918 return wrapper->wrapBestLanesDataVector(objID, variable, getBestLanes(objID));
2919 case VAR_NEXT_LINKS:
2920 return wrapper->wrapConnectionVector(objID, variable, getNextLinks(objID));
2921 case VAR_STOPSTATE:
2922 return wrapper->wrapInt(objID, variable, getStopState(objID));
2923 case VAR_DISTANCE:
2924 return wrapper->wrapDouble(objID, variable, getDistance(objID));
2925 case VAR_ALLOWED_SPEED:
2926 return wrapper->wrapDouble(objID, variable, getAllowedSpeed(objID));
2927 case VAR_SPEED_FACTOR:
2928 return wrapper->wrapDouble(objID, variable, getSpeedFactor(objID));
2929 case VAR_SPEEDSETMODE:
2930 return wrapper->wrapInt(objID, variable, getSpeedMode(objID));
2932 return wrapper->wrapInt(objID, variable, getLaneChangeMode(objID));
2933 case VAR_ROUTING_MODE:
2934 return wrapper->wrapInt(objID, variable, getRoutingMode(objID));
2935 case VAR_LINE:
2936 return wrapper->wrapString(objID, variable, getLine(objID));
2937 case VAR_VIA:
2938 return wrapper->wrapStringList(objID, variable, getVia(objID));
2939 case VAR_ACCELERATION:
2940 return wrapper->wrapDouble(objID, variable, getAcceleration(objID));
2941 case VAR_LASTACTIONTIME:
2942 return wrapper->wrapDouble(objID, variable, getLastActionTime(objID));
2943 case VAR_STOP_DELAY:
2944 return wrapper->wrapDouble(objID, variable, getStopDelay(objID));
2945 case VAR_IMPATIENCE:
2946 return wrapper->wrapDouble(objID, variable, getImpatience(objID));
2948 return wrapper->wrapDouble(objID, variable, getStopArrivalDelay(objID));
2949 case VAR_TIMELOSS:
2950 return wrapper->wrapDouble(objID, variable, getTimeLoss(objID));
2951 case VAR_MINGAP_LAT:
2952 return wrapper->wrapDouble(objID, variable, getMinGapLat(objID));
2953 case VAR_LEADER:
2954 return wrapper->wrapStringDoublePair(objID, variable, getLeader(objID, StoHelp::readTypedDouble(*paramData)));
2955 case VAR_FOLLOWER:
2956 return wrapper->wrapStringDoublePair(objID, variable, getFollower(objID, StoHelp::readTypedDouble(*paramData)));
2957 case VAR_LOADED_LIST:
2958 return wrapper->wrapStringList(objID, variable, getLoadedIDList());
2960 return wrapper->wrapStringList(objID, variable, getTeleportingIDList());
2961 case VAR_FOLLOW_SPEED: {
2962 StoHelp::readCompound(*paramData);
2963 const double speed = StoHelp::readTypedDouble(*paramData);
2964 const double gap = StoHelp::readTypedDouble(*paramData);
2965 const double leaderSpeed = StoHelp::readTypedDouble(*paramData);
2966 const double leaderMaxDecel = StoHelp::readTypedDouble(*paramData);
2967 return wrapper->wrapDouble(objID, variable, getFollowSpeed(objID, speed, gap, leaderSpeed, leaderMaxDecel, StoHelp::readTypedString(*paramData)));
2968 }
2969 case VAR_SECURE_GAP: {
2970 StoHelp::readCompound(*paramData);
2971 const double speed = StoHelp::readTypedDouble(*paramData);
2972 const double leaderSpeed = StoHelp::readTypedDouble(*paramData);
2973 const double leaderMaxDecel = StoHelp::readTypedDouble(*paramData);
2974 return wrapper->wrapDouble(objID, variable, getSecureGap(objID, speed, leaderSpeed, leaderMaxDecel, StoHelp::readTypedString(*paramData)));
2975 }
2976 case VAR_STOP_SPEED: {
2977 StoHelp::readCompound(*paramData);
2978 const double speed = StoHelp::readTypedDouble(*paramData);
2979 return wrapper->wrapDouble(objID, variable, getStopSpeed(objID, speed, StoHelp::readTypedDouble(*paramData)));
2980 }
2981 case VAR_FOES:
2982 return wrapper->wrapJunctionFoeVector(objID, variable, getJunctionFoes(objID, StoHelp::readTypedDouble(*paramData)));
2983 case VAR_NEIGHBORS:
2984 return wrapper->wrapStringDoublePairList(objID, variable, getNeighbors(objID, StoHelp::readTypedByte(*paramData)));
2985 case CMD_CHANGELANE:
2986 return wrapper->wrapIntPair(objID, variable, getLaneChangeState(objID, StoHelp::readTypedInt(*paramData)));
2987 case VAR_STOP_PARAMETER: {
2988 const int count = StoHelp::readCompound(*paramData);
2989 const int nextStopIndex = StoHelp::readTypedInt(*paramData);
2990 const std::string param = StoHelp::readTypedString(*paramData);
2991 const bool customParam = count == 3 && StoHelp::readTypedByte(*paramData) != 0;
2992 return wrapper->wrapString(objID, variable, getStopParameter(objID, nextStopIndex, param, customParam));
2993 }
2994 case VAR_NEXT_TLS:
2995 return wrapper->wrapNextTLSDataVector(objID, variable, getNextTLS(objID));
2996 case VAR_NEXT_STOPS:
2997 return wrapper->wrapNextStopDataVector(objID, variable, getNextStops(objID));
2998 case VAR_NEXT_STOPS2:
2999 return wrapper->wrapNextStopDataVector(objID, variable, getStops(objID, StoHelp::readTypedInt(*paramData)));
3000 case DISTANCE_REQUEST: {
3001 TraCIRoadPosition roadPos;
3002 Position pos;
3003 if (Helper::readDistanceRequest(*paramData, roadPos, pos) == libsumo::POSITION_ROADMAP) {
3004 return wrapper->wrapDouble(objID, variable, getDrivingDistance(objID, roadPos.edgeID, roadPos.pos, roadPos.laneIndex));
3005 }
3006 return wrapper->wrapDouble(objID, variable, getDrivingDistance2D(objID, pos.x(), pos.y()));
3007 }
3008 case VAR_TAXI_FLEET:
3009 return wrapper->wrapStringList(objID, variable, getTaxiFleet(StoHelp::readTypedInt(*paramData)));
3010 case VAR_PARAMETER:
3011 return wrapper->wrapString(objID, variable, getParameter(objID, StoHelp::readTypedString(*paramData)));
3013 return wrapper->wrapStringPair(objID, variable, getParameterWithKey(objID, StoHelp::readTypedString(*paramData)));
3014 default:
3015 return VehicleType::handleVariableWithID(objID, getTypeID(objID), variable, wrapper, paramData);
3016 }
3017}
3018
3019
3020}
3021
3022
3023/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
@ GLO_VEHICLE
a vehicle
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
std::vector< MSEdge * > MSEdgeVector
Definition MSEdge.h:73
std::pair< const MSVehicle *, double > CLeaderDist
ConstMSEdgeVector::const_iterator MSRouteIterator
Definition MSRoute.h:57
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:288
#define WRITE_ERROR(msg)
Definition MsgHandler.h:296
#define WRITE_WARNING(msg)
Definition MsgHandler.h:287
#define TL(string)
Definition MsgHandler.h:305
#define TLF(string,...)
Definition MsgHandler.h:307
std::shared_ptr< const MSRoute > ConstMSRoutePtr
Definition Route.h:32
void checkTimeBounds(const double time)
check the valid SUMOTime range of double input and throw an error if out of bounds
Definition SUMOTime.cpp:173
SUMOTime DELTA_T
Definition SUMOTime.cpp:38
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:46
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:91
#define STEPS2TIME(x)
Definition SUMOTime.h:55
#define SPEED2DIST(x)
Definition SUMOTime.h:45
#define SUMOTime_MAX
Definition SUMOTime.h:34
#define SIMTIME
Definition SUMOTime.h:62
#define TIME2STEPS(x)
Definition SUMOTime.h:57
LatAlignmentDefinition
Possible ways to choose the lateral alignment, i.e., how vehicles align themselves within their lane.
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
SUMOVehicleShape getVehicleShapeID(const std::string &name)
Returns the class id of the shape class given by its name.
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
std::string getVehicleShapeName(SUMOVehicleShape id)
Returns the class name of the shape class given by its id.
StringBijection< SUMOVehicleClass > SumoVehicleClassStrings(sumoVehicleClassStringInitializer, SVC_CUSTOM2, false)
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
const long long int VEHPARS_ARRIVALSPEED_SET
const long long int VEHPARS_PERSON_NUMBER_SET
const long long int VEHPARS_DEPARTSPEED_SET
const int STOP_ARRIVAL_SET
const int STOP_DURATION_SET
const int STOP_POSLAT_SET
const int STOP_EXPECTED_SET
const long long int VEHPARS_FORCE_REROUTE
const int STOP_SPEED_SET
const int STOP_JUMP_UNTIL_SET
const int STOP_UNTIL_SET
const int STOP_LINE_SET
const int STOP_PARKING_SET
const int STOP_TRIP_ID_SET
const long long int VEHPARS_COLOR_SET
const int STOP_PERMITTED_SET
const int STOP_SPLIT_SET
const long long int VEHPARS_TO_TAZ_SET
const long long int VEHPARS_ARRIVALLANE_SET
const long long int VEHPARS_DEPARTLANE_SET
const int STOP_START_SET
const long long int VEHPARS_DEPARTPOS_SET
const int STOP_JOIN_SET
const long long int VEHPARS_ARRIVALPOS_SET
const int STOP_EXTENSION_SET
const long long int VEHPARS_FROM_TAZ_SET
const int STOP_ENDED_SET
const int STOP_TRIGGER_SET
const long long int VEHPARS_VTYPE_SET
const int STOP_JUMP_SET
const int STOP_ONDEMAND_SET
const int STOP_END_SET
const int STOP_STARTED_SET
const int STOP_EXPECTED_CONTAINERS_SET
const long long int VEHPARS_LINE_SET
@ GIVEN
The time is given.
@ NOW
The vehicle is discarded if emission fails (not fully implemented yet)
@ CONTAINER_TRIGGERED
The departure is container triggered.
@ TRIGGERED
The departure is person triggered.
@ LCA_UNKNOWN
The action has not been determined.
@ SUMO_ATTR_STARTPOS
@ SUMO_ATTR_PARKING
@ SUMO_ATTR_EXTENSION
@ SUMO_ATTR_LANE
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_STARTED
@ SUMO_ATTR_CONTAINER_STOP
@ SUMO_ATTR_PARKING_AREA
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_BUS_STOP
@ SUMO_ATTR_TRAIN_STOP
@ SUMO_ATTR_ENDPOS
@ SUMO_ATTR_SPLIT
@ SUMO_ATTR_ACTTYPE
@ SUMO_ATTR_POSITION_LAT
@ SUMO_ATTR_EXPECTED
@ SUMO_ATTR_LINE
@ SUMO_ATTR_CHARGING_STATION
@ SUMO_ATTR_ENDED
@ SUMO_ATTR_ONDEMAND
@ SUMO_ATTR_LCA_CONTRIGHT
@ SUMO_ATTR_INDEX
@ SUMO_ATTR_ARRIVAL
@ SUMO_ATTR_TRIP_ID
@ SUMO_ATTR_PERMITTED
@ SUMO_ATTR_JOIN
@ SUMO_ATTR_JUMP
@ SUMO_ATTR_EXPECTED_CONTAINERS
@ SUMO_ATTR_UNTIL
@ SUMO_ATTR_JUMP_UNTIL
@ SUMO_ATTR_TRIGGERED
@ SUMO_ATTR_DURATION
const double INVALID_DOUBLE
invalid double
Definition StdDefs.h:64
T MIN2(T a, T b)
Definition StdDefs.h:76
T MAX2(T a, T b)
Definition StdDefs.h:82
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition ToString.h:283
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM)
Definition TraCIDefs.h:77
#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS)
Definition TraCIDefs.h:124
double getParameter(const int index) const
Returns the nth parameter of this distribution.
static PositionVector makeRing(const double radius1, const double radius2, const Position &center, unsigned int nPoints)
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)
A vehicle from the mesoscopic point of view.
Definition MEVehicle.h:42
int getQueIndex() const
Returns the index of the que the vehicle is in.
Definition MEVehicle.h:233
SUMOTime getEventTime() const
Returns the (planned) time at which the vehicle leaves its current segment.
Definition MEVehicle.h:206
virtual double getSafetyFactor() const
return factor for modifying the safety constraints of the car-following model
virtual void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this laneChangeModel. Throw exception for unsupported key
void setExtraImpatience(double value)
Sets routing behavior.
The base class for microscopic and mesoscopic vehicles.
double getMaxSpeed() const
Returns the maximum speed (the minimum of desired and technical maximum speed)
double getImpatience() const
Returns this vehicles impatience.
void resetRoutePosition(int index, DepartLaneDefinition departLaneProcedure)
reset index of edge within route
bool replaceStop(int nextStopIndex, SUMOVehicleParameter::Stop stop, const std::string &info, bool teleport, std::string &errorMsg)
void setChosenSpeedFactor(const double factor)
Returns the precomputed factor by which the driver wants to be faster than the speed limit.
void setCarFollowModelParameter(const std::string &key, const std::string &value)
set individual carFollow model parameters (not type related)
void setRoutingMode(int value)
Sets routing behavior.
virtual double getStopDelay() const
Returns the estimated public transport stop (departure) delay in seconds.
bool rerouteBetweenStops(int nextStopIndex, const std::string &info, bool teleport, std::string &errorMsg)
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
double getChosenSpeedFactor() const
Returns the precomputed factor by which the driver wants to be faster than the speed limit.
virtual BaseInfluencer & getBaseInfluencer()=0
Returns the velocity/lane influencer.
virtual bool replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addRouteStops=true, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given one.
virtual double getTimeLossSeconds() const
Returns the time loss in seconds.
double getOdometer() const
Returns the distance that was already driven by this vehicle.
MSVehicleType & getSingularType()
Replaces the current vehicle type with a new one used by this vehicle only.
virtual void replaceVehicleType(MSVehicleType *type)
Replaces the current vehicle type by the one given.
const MSRouteIterator & getCurrentRouteEdge() const
Returns an iterator pointing to the current edge in this vehicles route.
bool hasValidRoute(std::string &msg, ConstMSRoutePtr route=0) const
Validates the current or given route.
virtual void onRemovalFromNet(const MSMoveReminder::Notification)
Called when the vehicle is removed from the network.
double getLength() const
Returns the vehicle's length.
bool isParking() const
Returns whether the vehicle is parking.
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
double getHarmonoise_NoiseEmissions() const
Returns noise emissions of the current state.
int getPersonNumber() const
Returns the number of persons.
void setJunctionModelParameter(const std::string &key, const std::string &value)
set individual junction model paramete (not type related)
bool hasDeparted() const
Returns whether this vehicle has already departed.
const std::list< MSStop > & getStops() const
SUMOTime getDeparture() const
Returns this vehicle's real departure time.
void setDeviceParameter(const std::string &deviceName, const std::string &key, const std::string &value)
try to set the given parameter from any of the vehicles devices, raise InvalidArgument if no device p...
virtual std::pair< const MSVehicle *const, double > getLeader(double dist=0, bool considerCrossingFoes=true) const
Returns the leader of the vehicle looking for a fixed distance.
bool hasStops() const
Returns whether the vehicle has to stop somewhere.
void addToOdometer(double value)
Manipulate the odometer.
const MSStop & getNextStop() const
std::string getPrefixedParameter(const std::string &key, std::string &error) const
retrieve parameters of devices, models and the vehicle itself
SUMOVehicleClass getVClass() const
Returns the vehicle's access class.
virtual double getStopArrivalDelay() const
Returns the estimated public transport stop arrival delay in seconds.
MSStop & getStop(int nextStopIndex)
virtual std::pair< const MSVehicle *const, double > getFollower(double dist=0) const
Returns the follower of the vehicle looking for a fixed distance.
bool insertStop(int nextStopIndex, SUMOVehicleParameter::Stop stop, const std::string &info, bool teleport, std::string &errorMsg)
std::vector< std::string > getPersonIDList() const
Returns the list of persons.
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle's internal edge travel times/efforts container.
const std::vector< SUMOVehicleParameter::Stop > & getPastStops() const
virtual bool addTraciStop(SUMOVehicleParameter::Stop stop, std::string &errorMsg)
const MSRoute & getRoute() const
Returns the current route.
int getRoutingMode() const
return routing mode (configures router choice but also handling of transient permission changes)
int getRoutePosition() const
return index of edge within route
double getEmissions() const
Returns emissions of the current state The value is always per 1s, so multiply by step length if nece...
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT() const
virtual bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
bool reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false, const bool silent=false, const MSEdge *sink=nullptr)
Performs a rerouting using the given router.
int getRNGIndex() const
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
void createDevice(const std::string &deviceName)
create device of the given type
bool isStopped() const
Returns whether the vehicle is at a stop.
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists, nullptr otherwise.
bool abortNextStop(int nextStopIndex=0)
deletes the next stop at the given index if it exists
bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true, std::string *msgReturn=nullptr)
Replaces the current route by the given edges.
double getEmergencyDecel() const
Get the vehicle type's maximal physically possible deceleration [m/s^2].
Definition MSCFModel.h:277
@ FUTURE
the return value is used for calculating future speeds
Definition MSCFModel.h:83
virtual double getSecureGap(const MSVehicle *const veh, const MSVehicle *const, const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
double getApparentDecel() const
Get the vehicle type's apparent deceleration [m/s^2] (the one regarded by its followers.
Definition MSCFModel.h:285
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
Definition MSCFModel.h:261
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
Definition MSCFModel.h:408
virtual double getImperfection() const
Get the driver's imperfection.
Definition MSCFModel.h:331
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
Definition MSCFModel.h:269
virtual double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0, const CalcReason usage=CalcReason::CURRENT) const =0
Computes the vehicle's follow speed (no dawdling)
double stopSpeed(const MSVehicle *const veh, const double speed, double gap, const CalcReason usage=CalcReason::CURRENT) const
Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
Definition MSCFModel.h:173
virtual double getHeadwayTime() const
Get the driver's desired headway [s].
Definition MSCFModel.h:339
A device which collects info on the vehicle trip (mainly on departure and arrival)
static const std::vector< MSDevice_Taxi * > & getFleet()
static MSDispatch * getDispatchAlgorithm()
A dispatch algorithm that services customers in reservation order and always sends the closest availa...
void interpretDispatch(MSDevice_Taxi *taxi, const std::vector< std::string > &reservationsIDs)
trigger taxi dispatch.
An algorithm that performs distpach for a taxi fleet.
Definition MSDispatch.h:112
A road/street connecting two junctions.
Definition MSEdge.h:77
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition MSEdge.cpp:1085
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition MSEdge.h:168
static void parseEdgesList(const std::string &desc, ConstMSEdgeVector &into, const std::string &rid)
Parses the given string assuming it contains a list of edge ids divided by spaces.
Definition MSEdge.cpp:1109
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING, bool ignoreTransientPermissions=false) const
Get the allowed lanes to reach the destination-edge.
Definition MSEdge.cpp:479
double getLength() const
return the length of the edge
Definition MSEdge.h:685
bool isInternal() const
return whether this edge is an internal edge
Definition MSEdge.h:268
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:1046
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the maximum speed the vehicle may use on this edge.
Definition MSEdge.cpp:1169
const MSEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself
Definition MSEdge.cpp:936
bool retrieveExistingTravelTime(const MSEdge *const e, const double t, double &value) const
Returns a travel time for an edge and time if stored.
bool knowsTravelTime(const MSEdge *const e) const
Returns the information whether any travel time is known for the given edge.
void addTravelTime(const MSEdge *const e, double begin, double end, double value)
Adds a travel time information for an edge and a time span.
void removeEffort(const MSEdge *const e)
Removes the effort information for an edge.
bool knowsEffort(const MSEdge *const e) const
Returns the information whether any effort is known for the given edge.
void addEffort(const MSEdge *const e, double begin, double end, double value)
Adds an effort information for an edge and a time span.
bool retrieveExistingEffort(const MSEdge *const e, const double t, double &value) const
Returns an effort for an edge and time if stored.
void removeTravelTime(const MSEdge *const e)
Removes the travel time information for an edge.
static bool gCheckRoutes
Definition MSGlobals.h:91
static double gLateralResolution
Definition MSGlobals.h:100
static bool gSemiImplicitEulerUpdate
Definition MSGlobals.h:53
void alreadyDeparted(SUMOVehicle *veh)
stops trying to emit the given vehicle (because it already departed)
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
virtual const MSJunctionLogic * getLogic() const
Definition MSJunction.h:141
virtual const MSLogicJunction::LinkBits & getResponseFor(int linkIndex) const
Returns the response for the given link.
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:2824
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
Definition MSLane.cpp:2806
static std::vector< MSLink * >::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
Definition MSLane.cpp:2668
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
Definition MSLane.cpp:1366
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
Definition MSLane.h:592
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
Definition MSLane.cpp:2439
void addLeaders(const MSVehicle *vehicle, double vehPos, MSLeaderDistanceInfo &result, bool oppositeDirection=false)
get leaders for ego on the given lane
Definition MSLane.cpp:4116
double getLength() const
Returns the lane's length.
Definition MSLane.h:606
bool isLinkEnd(std::vector< MSLink * >::const_iterator &i) const
Definition MSLane.h:853
int getIndex() const
Returns the lane's index.
Definition MSLane.h:642
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
Definition MSLane.cpp:4363
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition MSLane.cpp:2463
bool isInternal() const
Definition MSLane.cpp:2594
virtual const PositionVector & getShape(bool) const
Definition MSLane.h:294
MSEdge & getEdge() const
Returns the lane's edge.
Definition MSLane.h:764
MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle *ego, double backOffset, bool allSublanes, double searchDist=-1, MinorLinkMode mLinkMode=FOLLOW_ALWAYS) const
return the sublane followers with the largest missing rear gap among all predecessor lanes (within di...
Definition MSLane.cpp:3777
double getWidth() const
Returns the lane's width.
Definition MSLane.h:635
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
Definition MSLane.h:724
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition MSLane.h:560
saves leader/follower vehicles and their distances relative to an ego vehicle
void fixOppositeGaps(bool isFollower)
subtract vehicle length from all gaps if the leader vehicle is driving in the opposite direction
virtual int addLeader(const MSVehicle *veh, double gap, double latOffset=0, int sublane=-1)
int numSublanes() const
bool hasVehicles() const
Notification
Definition of a vehicle state.
@ NOTIFICATION_VAPORIZED_TRACI
The vehicle got removed via TraCI.
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
@ NOTIFICATION_TELEPORT_ARRIVED
The vehicle was teleported out of the net.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:186
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition MSNet.h:325
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition MSNet.h:436
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:383
const ConstMSEdgeVector & getEdges() const
Definition MSRoute.h:125
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition MSRoute.cpp:79
static bool dictionary(const std::string &id, ConstMSRoutePtr route)
Adds a route to the dictionary.
Definition MSRoute.cpp:109
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition MSRoute.cpp:73
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:311
const MSLane * lane
The lane to stop at (microsim only)
Definition MSStop.h:50
void initPars(const SUMOVehicleParameter::Stop &stopPar)
initialize attributes from the given stop parameters
Definition MSStop.cpp:112
int getStateFlagsOld() const
return flags as used by Vehicle::getStopState
Definition MSStop.cpp:128
bool reached
Information whether the stop has been reached.
Definition MSStop.h:75
MSRouteIterator edge
The edge in the route to stop at.
Definition MSStop.h:48
SUMOTime duration
The stopping duration.
Definition MSStop.h:67
const SUMOVehicleParameter::Stop pars
The stop parameter.
Definition MSStop.h:65
void setLaneChangeMode(int value)
Sets lane changing behavior.
void deactivateGapController()
Deactivates the gap control.
void setSpeedMode(int speedMode)
Sets speed-constraining behaviors.
void setLaneTimeLine(const std::vector< std::pair< SUMOTime, int > > &laneTimeLine)
Sets a new lane timeline.
void setSublaneChange(double latDist)
Sets a new sublane-change request.
void setSignals(int signals)
Definition MSVehicle.h:1583
void setSpeedTimeLine(const std::vector< std::pair< SUMOTime, double > > &speedTimeLine)
Sets a new velocity timeline.
void activateGapController(double originalTau, double newTimeHeadway, double newSpaceHeadway, double duration, double changeRate, double maxDecel, MSVehicle *refVeh=nullptr)
Activates the gap control with the given parameters,.
The class responsible for building and deletion of vehicles.
void removePending()
Removes a vehicle after it has ended.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, SumoRNG *rng=nullptr, bool readOnly=false)
Returns the named vehicle type or a sample from the named distribution.
std::map< std::string, SUMOVehicle * >::const_iterator constVehIt
Definition of the internal vehicles map iterator.
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, ConstMSRoutePtr route, MSVehicleType *type, const bool ignoreStopErrors, const VehicleDefinitionSource source=ROUTEFILE, bool addRouteStops=true)
Builds a vehicle, increases the number of built vehicles.
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false, bool wasKept=false)
Deletes the vehicle.
constVehIt loadedVehBegin() const
Returns the begin of the internal vehicle map.
constVehIt loadedVehEnd() const
Returns the end of the internal vehicle map.
Representation of a vehicle in the micro simulation.
Definition MSVehicle.h:77
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
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
SUMOTime getLastActionTime() const
Returns the time of the vehicle's last action point.
Definition MSVehicle.h:541
void setTentativeLaneAndPosition(MSLane *lane, double pos, double posLat=0)
set tentative lane and position during insertion to ensure that all cfmodels work (some of them requi...
void setPreviousSpeed(double prevSpeed, double prevAcceleration)
Sets the influenced previous speed.
SUMOTime getWaitingTime(const bool accumulated=false) const
Returns the SUMOTime waited (speed was lesser than 0.1m/s)
Definition MSVehicle.h:670
MSAbstractLaneChangeModel & getLaneChangeModel()
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
const std::vector< MSLane * > & getBestLanesContinuation() const
Returns the best sequence of lanes to continue the route starting at myLane.
void onRemovalFromNet(const MSMoveReminder::Notification reason)
Called when the vehicle is removed from the network.
bool resumeFromStopping()
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle's position relative to the given lane.
Definition MSVehicle.h:398
void resetActionOffset(const SUMOTime timeUntilNextAction=0)
Resets the action offset for the vehicle.
bool rerouteParkingArea(const std::string &parkingAreaID, std::string &errorMsg)
void switchOffSignal(int signal)
Switches the given signal off.
Definition MSVehicle.h:1170
@ VEH_SIGNAL_NONE
Everything is switched off.
Definition MSVehicle.h:1107
const MSLane * getLane() const
Returns the lane the vehicle is on.
Definition MSVehicle.h:581
MSLane * getMutableLane() const
Returns the lane the vehicle is on Non const version indicates that something volatile is going on.
Definition MSVehicle.h:589
Influencer & getInfluencer()
void setActionStepLength(double actionStepLength, bool resetActionOffset=true)
Sets the action steplength of the vehicle.
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
Definition MSVehicle.h:413
double getSpeed() const
Returns the vehicle's current speed.
Definition MSVehicle.h:490
void updateLaneBruttoSum()
Update the lane brutto occupancy after a change in minGap.
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
Definition MSVehicle.h:969
double getPositionOnLane() const
Get the vehicle's position along the lane.
Definition MSVehicle.h:374
double getAngle() const
Returns the vehicle's direction in radians.
Definition MSVehicle.h:735
bool hasInfluencer() const
whether the vehicle is individually influenced (via TraCI or special parameters)
Definition MSVehicle.h:1690
void setLateralPositionOnLane(double posLat)
Definition MSVehicle.h:417
void switchOnSignal(int signal)
Switches the given signal on.
Definition MSVehicle.h:1162
int getLaneIndex() const
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
void remove(MSVehicle *veh)
Remove a vehicle from this transfer object.
The car-following model and parameter.
void setHeight(const double &height)
Set a new value for this type's height.
void setMaxSpeedLat(const double &maxSpeedLat)
Set a new value for this type's maximum lateral speed.
double getMinGapLat() const
Get the minimum lateral gap that vehicles of this type maintain.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
void setEmissionClass(SUMOEmissionClass eclass)
Set a new value for this type's emission class.
double getMaxSpeed() const
Get vehicle's (technical) maximum speed [m/s].
int getPersonCapacity() const
Get this vehicle type's person capacity.
const std::string & getID() const
Returns the name of the vehicle type.
void setMinGapLat(const double &minGapLat)
Set a new value for this type's minimum lataral gap.
double getMinGap() const
Get the free space in front of vehicles of this class.
void setApparentDecel(double apparentDecel)
Set a new value for this type's apparent deceleration.
double getHeight() const
Get the height which vehicles of this class shall have when being drawn.
void setMaxSpeed(const double &maxSpeed)
Set a new value for this type's maximum speed.
const Distribution_Parameterized & getSpeedFactor() const
Returns this type's speed factor.
void setBoardingDuration(SUMOTime duration, bool isPerson=true)
Set a new value for this type's boardingDuration.
double getActionStepLengthSecs() const
Returns this type's default action step length in seconds.
void setLength(const double &length)
Set a new value for this type's length.
double getMaxSpeedLat() const
Get vehicle's maximum lateral speed [m/s].
void setVClass(SUMOVehicleClass vclass)
Set a new value for this type's vehicle class.
void setAccel(double accel)
Set a new value for this type's acceleration.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
void setWidth(const double &width)
Set a new value for this type's width.
void setLcContRight(const std::string &value)
Set lcContRight (which is the only lc-attribute not used within the laneChange model)
void setImperfection(double imperfection)
Set a new value for this type's imperfection.
void setPreferredLateralAlignment(const LatAlignmentDefinition &latAlignment, double latAlignmentOffset=0.0)
Set vehicle's preferred lateral alignment.
void setTau(double tau)
Set a new value for this type's headway.
double getLength() const
Get vehicle's length [m].
void setMass(double mass)
Set a new value for this type's mass.
double getMass() const
Get this vehicle type's mass.
void setMinGap(const double &minGap)
Set a new value for this type's minimum gap.
void setShape(SUMOVehicleShape shape)
Set a new value for this type's shape.
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:67
const std::string & getID() const
Returns the id.
Definition Named.h:74
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
static std::string getName(const SUMOEmissionClass c)
Checks whether the string describes a known vehicle class.
static SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc=SVC_IGNORING)
Checks whether the string describes a known vehicle class.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
Definition Position.h:273
void sub(double dx, double dy)
Subtracts the given position from this one.
Definition Position.h:149
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
double y() const
Returns the y-position.
Definition Position.h:57
A list of positions.
double rotationAtOffset(double pos) const
Returns the rotation 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 move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
assigns new values
Definition RGBColor.cpp:98
virtual double getSlope() const =0
Returns the slope of the road at object's position in degrees.
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual double getPreviousSpeed() const =0
Returns the object's previous speed.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
static double getDefaultDecel(const SUMOVehicleClass vc=SVC_IGNORING)
Returns the default deceleration for the given vehicle class This needs to be a function because the ...
static bool parseLatAlignment(const std::string &val, double &lao, LatAlignmentDefinition &lad)
Parses and validates a given latAlignment value.
Representation of a vehicle.
Definition SUMOVehicle.h:62
virtual int getRouteValidity(bool update=true, bool silent=false, std::string *msgReturn=nullptr)=0
computes validity attributes for the current route
virtual bool wasRemoteControlled(SUMOTime lookBack=DELTA_T) const =0
Returns the information whether the vehicle is fully controlled via TraCI.
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
virtual bool isOnRoad() const =0
Returns the information whether the vehicle is on a road (is simulated)
virtual bool isParking() const =0
Returns the information whether the vehicle is parked.
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.
SUMOTime extension
The maximum time extension for boarding / loading.
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
double posLat
the lateral offset when stopping
bool onDemand
whether the stop may be skipped
std::string chargingStation
(Optional) charging station if one is assigned to the stop
std::vector< std::string > getTriggers() const
write trigger attribute
std::set< std::string > permitted
IDs of persons or containers that may board/load at this stop.
SUMOTime jumpUntil
earlierst jump end if there shall be a jump from this stop to the next route edge
int parametersSet
Information for the output which parameter were set.
SUMOTime jump
transfer time if there shall be a jump from this stop to the next route edge
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)
SUMOTime ended
the time at which this stop was ended
double endPos
The stopping position end.
std::set< std::string > awaitedPersons
IDs of persons the vehicle has to wait for until departing.
std::set< std::string > awaitedContainers
IDs of containers the vehicle has to wait for until departing.
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
SUMOTime arrival
The (expected) time at which the vehicle reaches the stop.
SUMOTime duration
The stopping duration.
Structure representing possible vehicle parameter.
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
double departSpeed
(optional) The initial speed of the vehicle
std::string vtypeid
The vehicle's type id.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
static bool parseArrivalLane(const std::string &val, const std::string &element, const std::string &id, int &lane, ArrivalLaneDefinition &ald, std::string &error)
Validates a given arrivalLane value.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
long long int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
static bool parseDepartSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, DepartSpeedDefinition &dsd, std::string &error)
Validates a given departSpeed value.
static bool parseArrivalPos(const std::string &val, const std::string &element, const std::string &id, double &pos, ArrivalPosDefinition &apd, std::string &error)
Validates a given arrivalPos value.
int personNumber
The static number of persons in the vehicle when it departs (not including boarding persons)
static bool parseArrivalSpeed(const std::string &val, const std::string &element, const std::string &id, double &speed, ArrivalSpeedDefinition &asd, std::string &error)
Validates a given arrivalSpeed value.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
double departPos
(optional) The position the vehicle shall depart from
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
RGBColor color
The vehicle's color, TraCI may change this.
double arrivalPos
(optional) The position the vehicle shall arrive on
static bool parseDepartLane(const std::string &val, const std::string &element, const std::string &id, int &lane, DepartLaneDefinition &dld, std::string &error)
Validates a given departLane value.
std::string id
The vehicle's id.
static bool parseDepart(const std::string &val, const std::string &element, const std::string &id, SUMOTime &depart, DepartDefinition &dd, std::string &error, const std::string &attr="departure")
Validates a given depart value.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
std::string toTaz
The vehicle's destination zone (district)
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
static bool parseDepartPos(const std::string &val, const std::string &element, const std::string &id, double &pos, DepartPosDefinition &dpd, std::string &error)
Validates a given departPos value.
std::string fromTaz
The vehicle's origin zone (district)
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::string line
The vehicle's line (mainly for public transport)
static ParkingType parseParkingType(const std::string &value)
parses parking type value
static void parseStopTriggers(const std::vector< std::string > &triggers, bool expectTrigger, Stop &stop)
parses stop trigger values
static bool isInternalRouteID(const std::string &id)
Checks whether the route ID uses the syntax of internal routes.
static StringBijection< LinkState > LinkStates
link states
static int getIndexFromLane(const std::string laneID)
return lane index when given the lane ID
static StringBijection< LinkDirection > LinkDirections
link directions
const std::string & getString(const T key) const
get string
std::set< std::string > getSet()
return set of strings
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
static bool endsWith(const std::string &str, const std::string suffix)
Checks whether a given string ends with the suffix.
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter
C++ TraCI client API implementation.
static MSEdge * getEdge(const std::string &edgeID)
Definition Helper.cpp:409
static TraCIPosition makeTraCIPosition(const Position &position, const bool includeZ=false)
Definition Helper.cpp:393
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:1757
static TraCIPositionVector makeTraCIPositionVector(const PositionVector &positionVector)
helper functions
Definition Helper.cpp:353
static int readDistanceRequest(tcpip::Storage &data, TraCIRoadPosition &roadPos, Position &pos)
Definition Helper.cpp:1882
static MSBaseVehicle * getVehicle(const std::string &id)
Definition Helper.cpp:494
static TraCIColor makeTraCIColor(const RGBColor &color)
Definition Helper.cpp:376
static TraCINextStopData buildStopData(const SUMOVehicleParameter::Stop &stopPar)
Definition Helper.cpp:660
static void setRemoteControlled(MSVehicle *v, Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
Definition Helper.cpp:1400
static const MSVehicleType & getVehicleType(const std::string &vehicleID)
Definition Helper.cpp:529
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:1440
static std::pair< MSLane *, double > convertCartesianToRoadMap(const Position &pos, const SUMOVehicleClass vClass)
Definition Helper.cpp:436
static SUMOVehicleParameter::Stop buildStopParameters(const std::string &edgeOrStoppingPlaceID, double pos, int laneIndex, double startPos, int flags, double duration, double until)
Definition Helper.cpp:554
static Subscription * addSubscriptionFilter(SubscriptionFilterType filter)
Definition Helper.cpp:229
static const MSLane * getLaneChecking(const std::string &edgeID, int laneIndex, double pos)
Definition Helper.cpp:419
static int readTypedByte(tcpip::Storage &ret, const std::string &error="")
static int readCompound(tcpip::Storage &ret, int expectedSize=-1, const std::string &error="")
static int readTypedInt(tcpip::Storage &ret, const std::string &error="")
static std::string readTypedString(tcpip::Storage &ret, const std::string &error="")
static double readTypedDouble(tcpip::Storage &ret, const std::string &error="")
#define CALL_MESO_FUN(veh, fun, microResult)
#define CALL_MICRO_FUN(veh, fun, mesoResult)
#define DEBUG_COND
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int VAR_LASTACTIONTIME
TRACI_CONST int VAR_EDGES
TRACI_CONST int POSITION_ROADMAP
TRACI_CONST int VAR_NOXEMISSION
TRACI_CONST int VAR_LANECHANGE_MODE
TRACI_CONST int MOVE_AUTOMATIC
TRACI_CONST int LAST_STEP_PERSON_ID_LIST
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int VAR_IMPATIENCE
TRACI_CONST int VAR_SEGMENT_ID
TRACI_CONST int VAR_TYPE
TRACI_CONST int VAR_DEPARTURE
TRACI_CONST int VAR_ROUTING_MODE
TRACI_CONST int VAR_SECURE_GAP
TRACI_CONST int VAR_WAITING_TIME
TRACI_CONST int VAR_LINE
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
Definition TraCIDefs.h:379
TRACI_CONST int VAR_EDGE_TRAVELTIME
TRACI_CONST int VAR_ROAD_ID
TRACI_CONST int MOVE_NORMAL
TRACI_CONST int VAR_TIMELOSS
TRACI_CONST int VAR_SPEED_FACTOR
TRACI_CONST int VAR_FOLLOW_SPEED
TRACI_CONST int VAR_STOP_ARRIVALDELAY
TRACI_CONST int VAR_SPEED_LAT
TRACI_CONST int VAR_ANGLE
TRACI_CONST int VAR_NEXT_TLS
TRACI_CONST int VAR_EDGE_EFFORT
TRACI_CONST int VAR_BEST_LANES
TRACI_CONST int VAR_ALLOWED_SPEED
TRACI_CONST int VAR_LANE_INDEX
TRACI_CONST int VAR_PMXEMISSION
TRACI_CONST int VAR_SPEED_WITHOUT_TRACI
TRACI_CONST int VAR_BOARDING_DURATION
TRACI_CONST int MOVE_TELEPORT
TRACI_CONST int VAR_PERSON_NUMBER
TRACI_CONST int VAR_COEMISSION
TRACI_CONST int VAR_COLOR
TRACI_CONST int VAR_POSITION
TRACI_CONST int VAR_PERSON_CAPACITY
TRACI_CONST int VAR_STOP_PARAMETER
TRACI_CONST int VAR_LEADER
TRACI_CONST int VAR_CO2EMISSION
TRACI_CONST int VAR_TELEPORTING_LIST
TRACI_CONST int REMOVE_TELEPORT
TRACI_CONST int VAR_TAXI_FLEET
TRACI_CONST int VAR_ROUTE_VALID
TRACI_CONST int VAR_SPEEDSETMODE
TRACI_CONST int VAR_FUELCONSUMPTION
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition TraCIDefs.h:378
TRACI_CONST int VAR_SLOPE
TRACI_CONST int VAR_HCEMISSION
TRACI_CONST int ID_COUNT
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int VAR_LANEPOSITION
TRACI_CONST int REMOVE_PARKING
TRACI_CONST int VAR_LANE_ID
TRACI_CONST int VAR_STOP_SPEED
TRACI_CONST int VAR_NOISEEMISSION
TRACI_CONST int VAR_POSITION3D
TRACI_CONST int VAR_SPEED
TRACI_CONST int VAR_SIGNALS
TRACI_CONST int VAR_PARAMETER_WITH_KEY
TRACI_CONST int VAR_ACCUMULATED_WAITING_TIME
TRACI_CONST int VAR_MINGAP_LAT
TRACI_CONST int INVALID_INT_VALUE
TRACI_CONST int VAR_NEXT_LINKS
TRACI_CONST int VAR_ROUTE_INDEX
TRACI_CONST int VAR_NEXT_STOPS2
TRACI_CONST int VAR_ACCELERATION
TRACI_CONST int VAR_ROUTE_ID
TRACI_CONST int REMOVE_ARRIVED
TRACI_CONST int DISTANCE_REQUEST
@ SUBS_FILTER_LEAD_FOLLOW
@ SUBS_FILTER_UPSTREAM_DIST
@ SUBS_FILTER_VTYPE
@ SUBS_FILTER_LANES
@ SUBS_FILTER_NOOPPOSITE
@ SUBS_FILTER_DOWNSTREAM_DIST
@ SUBS_FILTER_LATERAL_DIST
@ SUBS_FILTER_TURN
@ SUBS_FILTER_VCLASS
@ SUBS_FILTER_FIELD_OF_VISION
TRACI_CONST int VAR_SEGMENT_INDEX
TRACI_CONST int ROUTING_MODE_DEFAULT
TRACI_CONST int VAR_LANEPOSITION_LAT
TRACI_CONST int CMD_CHANGELANE
TRACI_CONST int VAR_STOP_DELAY
TRACI_CONST int REMOVE_TELEPORT_ARRIVED
TRACI_CONST int VAR_NEIGHBORS
TRACI_CONST int REMOVE_VAPORIZED
TRACI_CONST int VAR_STOPSTATE
TRACI_CONST int VAR_FOLLOWER
TRACI_CONST int VAR_LOADED_LIST
TRACI_CONST int VAR_DEPART_DELAY
std::map< int, std::shared_ptr< libsumo::TraCIResult > > TraCIResults
{variable->value}
Definition TraCIDefs.h:376
TRACI_CONST int VAR_FOES
TRACI_CONST int VAR_DISTANCE
TRACI_CONST int ROUTING_MODE_AGGREGATED_CUSTOM
TRACI_CONST int VAR_ELECTRICITYCONSUMPTION
TRACI_CONST int VAR_VIA
TRACI_CONST int VAR_NEXT_STOPS
@ key
the parser read a key of a value in an object
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition json.hpp:21884
A structure representing the best lanes for continuing the current route starting at 'lane'.
Definition MSVehicle.h:857