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