Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSParkingArea.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2015-2026 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
20// A area where vehicles can park next to the road
21/****************************************************************************/
22#include <config.h>
23
24#include <cassert>
27#include <utils/geom/Position.h>
30#include <microsim/MSNet.h>
31#include <microsim/MSEdge.h>
32#include <microsim/MSVehicle.h>
34#include "MSLane.h"
36#include "MSParkingArea.h"
37#include "MSGlobals.h"
39
40//#define DEBUG_RESERVATIONS
41//#define DEBUG_GET_LAST_FREE_POS
42//#define DEBUG_COND2(obj) (obj.getID() == "v.3")
43#define DEBUG_COND2(obj) (obj.isSelected())
44
45
46// ===========================================================================
47// method definitions
48// ===========================================================================
49MSParkingArea::MSParkingArea(const std::string& id, const std::vector<std::string>& lines,
50 const std::vector<std::string>& badges, MSLane& lane,
51 double begPos, double endPos, int capacity, double width, double length,
52 double angle, const std::string& name, bool onRoad,
53 const std::string& departPos, bool lefthand, bool reservable) :
54 MSStoppingPlace(id, SUMO_TAG_PARKING_AREA, lines, lane, begPos, endPos, name),
55 myRoadSideCapacity(capacity),
56 myCapacity(0),
57 myOnRoad(onRoad),
58 myReservable(reservable),
59 myWidth(width),
60 myLength(length),
61 myAngle(lefthand ? -angle : angle),
62 myAcceptedBadges(badges.begin(), badges.end()),
63 myEgressBlocked(false),
64 myReservationTime(-1),
65 myLastReservationTime(-1),
66 myReservations(0),
67 myLastReservations(0),
68 myReservationMaxLength(0),
69 myLastReservationMaxLength(0),
70 myMaxVehLength(0),
71 myNumAlternatives(0),
72 myLastStepOccupancy(0),
73 myDepartPos(-1),
74 myDepartPosDefinition(DepartPosDefinition::DEFAULT),
75 myUpdateEvent(nullptr) {
76 // initialize unspecified defaults
77 if (myWidth == 0) {
79 }
80
81 if (departPos != "") {
82 std::string error;
84 throw ProcessError(error);
85 }
87 // maybe allow other methods at a later time
88 throw ProcessError(TLF("Only a numerical departPos is supported for % '%'", toString(myElement), getID()));
89 } else if (myDepartPos < 0 || myDepartPos > lane.getLength()) {
90 throw ProcessError(TLF("Invalid departPos for % '%'", toString(myElement), getID()));
91 }
92 }
93
94 const double offset = (MSGlobals::gLefthand != lefthand) ? -1 : 1;
98 if (!myOnRoad) {
99 myShape.move2side((lane.getWidth() / 2. + myWidth / 2.) * offset);
100 }
101 setRoadsideCapacity(capacity);
102}
103
104
106
107
108void
109MSParkingArea::addLotEntry(double x, double y, double z, double width, double length, double angle, double slope) {
110 // create LotSpaceDefinition
111 LotSpaceDefinition lsd((int)mySpaceOccupancies.size(), nullptr, x, y, z, angle, slope, width, length);
112 // If we are modelling parking set the end position to the lot position relative to the lane
113 // rather than the end of the parking area - this results in vehicles stopping nearer the space
114 // and re-entering the lane nearer the space. (If we are not modelling parking the vehicle will usually
115 // enter the space and re-enter at the end of the parking area.)
117 const double offset = this->getLane().getShape().nearest_offset_to_point2D(lsd.position);
118 if (offset < getBeginLanePosition()) {
119 lsd.endPos = getBeginLanePosition() + POSITION_EPS;
120 } else {
121 if (this->getLane().getLength() > offset) {
122 lsd.endPos = offset;
123 } else {
124 lsd.endPos = this->getLane().getLength() - POSITION_EPS;
125 }
126 }
127 // Work out the angle of the lot relative to the lane (-90 adjusts for the way the bay is drawn )
128 double relativeAngle = fmod(lsd.rotation - 90., 360) - fmod(RAD2DEG(this->getLane().getShape().rotationAtOffset(lsd.endPos)), 360) + 0.5;
129 if (relativeAngle < 0.) {
130 relativeAngle += 360.;
131 }
132 lsd.manoeuverAngle = relativeAngle;
133
134 // if p2.y is -ve the lot is on LHS of lane relative to lane direction
135 // we need to know this because it inverts the complexity of the parking manoeuver
137 if (p2.y() < (0. + POSITION_EPS)) {
138 lsd.sideIsLHS = true;
139 } else {
140 lsd.sideIsLHS = false;
141 }
142 } else {
143 lsd.endPos = myEndPos;
144 lsd.manoeuverAngle = int(angle); // unused unless gModelParkingManoeuver is true
145 lsd.sideIsLHS = true;
146 }
147 mySpaceOccupancies.push_back(lsd);
148 myCapacity++;
150}
151
152int
154 assert(myLastFreeLot >= 0);
155 assert(myLastFreeLot < (int)mySpaceOccupancies.size());
156
158 if (lsd.sideIsLHS) {
159 return abs(int(lsd.manoeuverAngle)) % 180;
160 } else {
161 return abs(abs(int(lsd.manoeuverAngle)) % 180 - 180) % 180;
162 }
163}
164
165double
167 assert(myLastFreeLot >= 0);
168 assert(myLastFreeLot < (int)mySpaceOccupancies.size());
169
171 if (lsd.manoeuverAngle > 180.) {
172 return DEG2RAD(lsd.manoeuverAngle - 360.);
173 } else {
174 return DEG2RAD(lsd.manoeuverAngle);
175 }
176}
177
178
179double
180MSParkingArea::getLastFreePos(const SUMOVehicle& forVehicle, double brakePos) const {
181 if (myCapacity == (int)myEndPositions.size()) {
182 // keep enough space so that parking vehicles can leave
183#ifdef DEBUG_GET_LAST_FREE_POS
184 if (DEBUG_COND2(forVehicle)) {
185 std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " allOccupied\n";
186 }
187#endif
188 return myLastFreePos - forVehicle.getVehicleType().getMinGap() - POSITION_EPS;
189 } else if (mustAdvance(forVehicle.getVClass())) {
190 // vehicles cannot overtake so we must fill from the downstream end
191 int skipN = SIMSTEP == myReservationTime ? myReservations - 1 : 0;
192 //std::cout << SIMTIME << " v=" << forVehicle.getID() << " t=" << SIMTIME << " resTime=" << STEPS2TIME(myReservationTime) << " myR=" << myReservations << " skip=" << skipN << " rV=" << toString(myReservedVehicles) << "\n";
193 for (auto it_lsd = mySpaceOccupancies.rbegin(); it_lsd != mySpaceOccupancies.rend(); it_lsd++) {
194 if (it_lsd->vehicle == nullptr) {
195 if (skipN > 0) {
196 // skip reservations
197 skipN--;
198 continue;
199 }
200#ifdef DEBUG_GET_LAST_FREE_POS
201 if (DEBUG_COND2(forVehicle)) {
202 std::cout << SIMTIME << " getLastFreePos (onRoad-upstream) veh=" << forVehicle.getID() << " brakePos=" << brakePos << " myEndPos=" << myEndPos << " nextFreePos=" << it_lsd->endPos << "\n";
203 }
204#endif
205 return it_lsd->endPos;
206 }
207 }
208 // should not happen
209 return brakePos;
210 } else {
211 const double minPos = MIN2(myEndPos, brakePos);
212 if (myLastFreePos >= minPos) {
213#ifdef DEBUG_GET_LAST_FREE_POS
214 if (DEBUG_COND2(forVehicle)) {
215 std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " brakePos=" << brakePos << " myEndPos=" << myEndPos << " using myLastFreePos=" << myLastFreePos << "\n";
216 }
217#endif
218 return myLastFreePos;
219 } else {
220 // find free pos after minPos
221 for (const auto& lsd : mySpaceOccupancies) {
222 if (lsd.vehicle == nullptr && lsd.endPos >= minPos) {
223#ifdef DEBUG_GET_LAST_FREE_POS
224 if (DEBUG_COND2(forVehicle)) {
225 std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " brakePos=" << brakePos << " myEndPos=" << myEndPos << " nextFreePos=" << lsd.endPos << "\n";
226 }
227#endif
228 return lsd.endPos;
229 }
230 }
231 // shouldn't happen. No good solution seems possible
232#ifdef DEBUG_GET_LAST_FREE_POS
233 if (DEBUG_COND2(forVehicle)) {
234 std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " brakePos=" << brakePos << " myEndPos=" << myEndPos << " noGoodFreePos blockedAt=" << brakePos << "\n";
235 }
236#endif
237 return brakePos;
238 }
239 }
240}
241
242bool
246
247bool
249 const MSLane* left = myLane.getParallelLane(1, false);
250 const MSLane* right = myLane.getParallelLane(-1, false);
251 return ((left == nullptr || !left->allowsVehicleClass(svc) || !myLane.allowsChangingLeft(svc))
252 && (right == nullptr || !right->allowsVehicleClass(svc) || !myLane.allowsChangingRight(svc)));
253}
254
255
258 for (const auto& lsd : mySpaceOccupancies) {
259 if (lsd.vehicle == &forVehicle) {
260 return lsd.position;
261 }
262 }
263 return Position::INVALID;
264}
265
266
267double
270 return myDepartPos;
271 }
272 for (const auto& lsd : mySpaceOccupancies) {
273 if (lsd.vehicle == &forVehicle) {
274 return lsd.endPos;
275 }
276 }
277 return -1;
278}
279
280
281double
283 for (const auto& lsd : mySpaceOccupancies) {
284 if (lsd.vehicle == &forVehicle) {
285 return (lsd.rotation - 90.) * (double) M_PI / (double) 180.0;
286 }
287 }
288 return 0;
289}
290
291double
293 for (const auto& lsd : mySpaceOccupancies) {
294 if (lsd.vehicle == &forVehicle) {
295 return lsd.slope;
296 }
297 }
298 return 0;
299}
300
301double
302MSParkingArea::getGUIAngle(const SUMOVehicle& forVehicle) const {
303 for (const auto& lsd : mySpaceOccupancies) {
304 if (lsd.vehicle == &forVehicle) {
305 if (lsd.manoeuverAngle > 180.) {
306 return DEG2RAD(lsd.manoeuverAngle - 360.);
307 } else {
308 return DEG2RAD(lsd.manoeuverAngle);
309 }
310 }
311 }
312 return 0.;
313}
314
315int
317 for (const auto& lsd : mySpaceOccupancies) {
318 if (lsd.vehicle == &forVehicle) {
319 if (lsd.sideIsLHS) {
320 return abs(int(lsd.manoeuverAngle)) % 180;
321 } else {
322 return abs(abs(int(lsd.manoeuverAngle)) % 180 - 180) % 180;
323 }
324 }
325 }
326 return 0;
327}
328
329int
331 if (veh->getPositionOnLane() > myLastFreePos) {
332 // vehicle has gone past myLastFreePos and we need to find the actual lot
333 int closestLot = -1;
334 for (int i = 0; i < (int)mySpaceOccupancies.size(); i++) {
336 if (lsd.vehicle == nullptr) {
337 closestLot = i;
338 if (lsd.endPos >= veh->getPositionOnLane()) {
339 return i;
340 }
341 }
342 }
343 return closestLot;
344 }
345 if (myOnRoad && myLastFreePos - veh->getPositionOnLane() > POSITION_EPS) {
346 // for on-road parking we need to be precise
347 return -1;
348 }
349 return myLastFreeLot;
350}
351
352void
353MSParkingArea::enter(SUMOVehicle* veh, const bool /* parking */) {
355 double beg = veh->getPositionOnLane() + veh->getVehicleType().getMinGap();
356 double end = veh->getPositionOnLane() - veh->getVehicleType().getLength();
357 if (myUpdateEvent == nullptr) {
360 }
361 int lotIndex = getLotIndex(veh);
362 if (lotIndex < 0) {
363 WRITE_WARNING("Unsuitable parking position for vehicle '" + veh->getID() + "' at parkingArea '" + getID() + "' time=" + time2string(SIMSTEP));
364 lotIndex = myLastFreeLot;
365 }
366#ifdef DEBUG_GET_LAST_FREE_POS
367 ((SUMOVehicleParameter&)veh->getParameter()).setParameter("lotIndex", toString(lotIndex));
368#endif
369 assert(myLastFreePos >= 0);
370 assert(lotIndex < (int)mySpaceOccupancies.size());
371 mySpaceOccupancies[lotIndex].vehicle = veh;
372 myEndPositions[veh] = std::pair<double, double>(beg, end);
375 // current search ends here
377}
378
379
380void
388
389void
397
398void
400 assert(myEndPositions.find(what) != myEndPositions.end());
401 if (myUpdateEvent == nullptr) {
404 }
405 for (auto& lsd : mySpaceOccupancies) {
406 if (lsd.vehicle == what) {
407 lsd.vehicle = nullptr;
408 break;
409 }
410 }
411 if (what->getLength() == myMaxVehLength) {
412 myMaxVehLength = 0;
413 for (auto item : myEndPositions) {
414 myMaxVehLength = MAX2(myMaxVehLength, item.first->getLength());
415 }
416 }
417 myEndPositions.erase(myEndPositions.find(what));
419}
420
421
429
430
432 index(-1),
433 vehicle(nullptr),
434 rotation(0),
435 slope(0),
436 width(0),
437 length(0),
438 endPos(0),
439 manoeuverAngle(0),
440 sideIsLHS(false) {
441}
442
443
444MSParkingArea::LotSpaceDefinition::LotSpaceDefinition(int index_, SUMOVehicle* vehicle_, double x, double y, double z, double rotation_, double slope_, double width_, double length_) :
445 index(index_),
446 vehicle(vehicle_),
447 position(Position(x, y, z)),
448 rotation(rotation_),
449 slope(slope_),
450 width(width_),
451 length(length_),
452 endPos(0),
453 manoeuverAngle(0),
454 sideIsLHS(false) {
455}
456
457
458void
460 myLastFreeLot = -1;
462 myEgressBlocked = false;
463 for (auto& lsd : mySpaceOccupancies) {
464 if (lsd.vehicle == nullptr
465 || (getOccupancy() == getCapacity()
466 && lsd.vehicle->remainingStopDuration() <= 0
467 && !lsd.vehicle->isStoppedTriggered())) {
468 if (lsd.vehicle == nullptr) {
469 myLastFreeLot = lsd.index;
470 myLastFreePos = lsd.endPos;
471 } else {
472 // vehicle wants to exit the parking area
473 myLastFreeLot = lsd.index;
474 myLastFreePos = lsd.endPos - lsd.vehicle->getVehicleType().getLength() - POSITION_EPS;
475 myEgressBlocked = true;
476 }
477 break;
478 } else {
480 lsd.endPos - lsd.vehicle->getVehicleType().getLength() - NUMERICAL_EPS);
481 }
482 }
483}
484
485
486double
488 // do not perform reservation when far away
489 if (forVehicle.getLane() != &myLane || forVehicle.getPositionOnLane() < (myBegPos - myMaxVehLength - forVehicle.getVehicleType().getMinGap())) {
490 // for different lanes, do not consider reservations to avoid lane-order
491 // dependency in parallel simulation
492#ifdef DEBUG_RESERVATIONS
493 if (DEBUG_COND2(forVehicle)) {
494 std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID() << " other lane\n";
495 }
496#endif
497 if (myNumAlternatives > 0 && getOccupancy() == getCapacity()) {
498 // ensure that the vehicle reaches the rerouter lane
499 if (mySpaceOccupancies.size() > 0) {
500 assert(mySpaceOccupancies[0].vehicle != nullptr);
501 const double waitPos = (mySpaceOccupancies[0].endPos
502 - mySpaceOccupancies[0].vehicle->getLength()
503 - forVehicle.getVehicleType().getMinGap()
504 - NUMERICAL_EPS);
505 return MAX2(waitPos, MIN2(POSITION_EPS, myEndPos));
506 } else {
507 return MAX2(myBegPos, MIN2(POSITION_EPS, myEndPos));
508 }
509 } else {
510 // check if there is a reservation from the last time step
511 // (this could also be in myReserations, if myLane wasn't processed before the forVehicle-lane)
512 const SUMOTime last = t - DELTA_T;
513#ifdef DEBUG_RESERVATIONS
514 if (DEBUG_COND2(forVehicle)) {
515 std::cout << SIMTIME << " last=" << time2string(last) << " lastRes=" << time2string(myLastReservationTime) << " resTime=" << toString(myReservationTime) << "\n";
516 }
517#endif
518 if (myLastReservationTime == last || myReservationTime == last) {
520 if (myCapacity <= getOccupancy() + res) {
522#ifdef DEBUG_RESERVATIONS
523 if (DEBUG_COND2(forVehicle)) std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID()
524 << " lastRes=" << res << " resTime=" << myReservationTime << " reserved full, maxLen=" << maxLen << " endPos=" << mySpaceOccupancies[0].endPos << "\n";
525#endif
526 return (mySpaceOccupancies[0].endPos
527 - maxLen
528 - forVehicle.getVehicleType().getMinGap()
529 - NUMERICAL_EPS);
530 }
531 }
532 return getLastFreePos(forVehicle, brakePos);
533 }
534 }
535 if (t > myReservationTime) {
536#ifdef DEBUG_RESERVATIONS
537 if (DEBUG_COND2(forVehicle)) {
538 std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID() << " first reservation\n";
539 }
540#endif
545 myReservations = 1;
547 myReservedVehicles.clear();
548 myReservedVehicles.insert(&forVehicle);
549 for (const auto& lsd : mySpaceOccupancies) {
550 if (lsd.vehicle != nullptr) {
551 myReservationMaxLength = MAX2(myReservationMaxLength, lsd.vehicle->getVehicleType().getLength());
552 }
553 }
554 return getLastFreePos(forVehicle, brakePos);
555 } else {
557#ifdef DEBUG_RESERVATIONS
558 if (DEBUG_COND2(forVehicle)) {
559 std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID() << " res=" << myReservations << " enough space\n";
560 }
561#endif
564 myReservedVehicles.insert(&forVehicle);
565 return getLastFreePos(forVehicle, brakePos);
566 } else {
567 if (myCapacity == 0) {
568 return getLastFreePos(forVehicle, brakePos);
569 } else {
570#ifdef DEBUG_RESERVATIONS
571 if (DEBUG_COND2(forVehicle)) std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID()
572 << " res=" << myReservations << " resTime=" << myReservationTime << " reserved full, maxLen=" << myReservationMaxLength << " endPos=" << mySpaceOccupancies[0].endPos << "\n";
573#endif
574 return (mySpaceOccupancies[0].endPos
576 - forVehicle.getVehicleType().getMinGap()
577 - NUMERICAL_EPS);
578 }
579 }
580 }
581}
582
583
584double
586 return myWidth;
587}
588
589
590double
592 return myLength;
593}
594
595
596double
598 return myAngle;
599}
600
601
602int
604 return myCapacity;
605}
606
607
608bool
610 return myOnRoad;
611}
612
613
614int
616 return (int)myEndPositions.size() - (myEgressBlocked ? 1 : 0);
617}
618
619
620int
622 return (int)myEndPositions.size();
623}
624
625int
627 const bool reservedLocal = myReservedVehicles.count(forVehicle) != 0;
628 const bool reservedRemote = myRemoteReservedVehicles.count(forVehicle) != 0;
629 return ((int)myEndPositions.size()
630 + (reservedLocal ? 0 : myReservations)
631 + (reservedRemote ? 0 : myRemoteReservedVehicles.size()));
632}
633
634
635int
637 const bool reservedRemote = myRemoteReservedVehicles.count(forVehicle) != 0;
638 return getOccupancy() + (int)myRemoteReservedVehicles.size() - (reservedRemote ? 1 : 0);
639}
640
641
642int
646
647
648int
650 const bool reservedRemote = myLastRemoteReservedVehicles.count(forVehicle) != 0;
651 return myLastStepOccupancy - (int)myLastRemoteReservedVehicles.size() + (reservedRemote ? 1 : 0);
652}
653
654
655void
656MSParkingArea::accept(std::string badge) {
657 myAcceptedBadges.insert(badge);
658}
659
660
661void
662MSParkingArea::accept(std::vector<std::string> badges) {
663 myAcceptedBadges.insert(badges.begin(), badges.end());
664}
665
666
667void
668MSParkingArea::refuse(std::string badge) {
669 myAcceptedBadges.erase(badge);
670}
671
672
673bool
675 if (myAcceptedBadges.size() == 0) {
676 return true;
677 } else {
678 std::vector<std::string> vehicleBadges = veh->getParkingBadges();
679 for (auto badge : vehicleBadges) {
680 if (myAcceptedBadges.count(badge) != 0) {
681 return true;
682 }
683 }
684 return false;
685 }
686}
687
688
689void
693
694
695int
699
700
701void
704}
705
706
707std::vector<std::string>
709 std::vector<std::string> result(myAcceptedBadges.begin(), myAcceptedBadges.end());
710 return result;
711}
712
713
714void
715MSParkingArea::setAcceptedBadges(const std::vector<std::string>& badges) {
716 myAcceptedBadges.clear();
717 myAcceptedBadges.insert(badges.begin(), badges.end());
718}
719
720
721const std::vector<MSParkingArea::LotSpaceDefinition>&
725
726
727const PositionVector&
729 return myShape;
730}
731
732
733void
735 // reinit parking lot generation process
736 myRoadSideCapacity = capacity;
737
738 // Initialize space occupancies if there is a road-side capacity
739 // The overall number of lots is fixed and each lot accepts one vehicle regardless of size
741 const double spaceOffset = myRoadSideCapacity > 0 ? (myEndPos - myBegPos) / myRoadSideCapacity : 7.5;
742 if (myLength == 0) {
743 myLength = spaceDim;
744 }
745 mySpaceOccupancies.clear();
746 myCapacity = 0;
747 for (int i = 0; i < myRoadSideCapacity; ++i) {
748 // calculate pos, angle and slope of parking lot space
750 double spaceAngle = GeomHelper::calculateLotSpaceAngle(myShape, i, spaceDim, myAngle);
751 double spaceSlope = GeomHelper::calculateLotSpaceSlope(myShape, i, spaceDim);
752 // add lotEntry
753 addLotEntry(pos.x(), pos.y(), pos.z(), myWidth, myLength, spaceAngle, spaceSlope);
754 // update endPos
755 mySpaceOccupancies.back().endPos = MIN2(myEndPos, myBegPos + MAX2(POSITION_EPS, spaceOffset * (i + 1)));
756 }
757 // recompute after modifying the last endPos
759}
760
761/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define DEG2RAD(x)
Definition GeomHelper.h:35
#define RAD2DEG(x)
Definition GeomHelper.h:36
#define DEBUG_COND2(obj)
Definition MESegment.cpp:54
#define WRITE_WARNING(msg)
Definition MsgHandler.h:286
#define TLF(string,...)
Definition MsgHandler.h:306
SUMOTime DELTA_T
Definition SUMOTime.cpp:38
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:91
#define SIMSTEP
Definition SUMOTime.h:64
#define SIMTIME
Definition SUMOTime.h:65
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
DepartPosDefinition
Possible ways to choose the departure position.
@ GIVEN
The position is given.
@ SUMO_TAG_PARKING_AREA
A parking area.
const double SUMO_const_laneWidth
Definition StdDefs.h:52
T MIN2(T a, T b)
Definition StdDefs.h:80
T MAX2(T a, T b)
Definition StdDefs.h:86
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
static const Position calculateLotSpacePosition(const PositionVector &shape, const int index, const double spaceDim, const double angle, const double width, const double length)
calculate lotSpace position
static double calculateLotSpaceAngle(const PositionVector &shape, const int index, const double spaceDim, const double angle)
calculate lotSpace angle
static double calculateLotSpaceSlope(const PositionVector &shape, const int index, const double spaceDim)
calculate lotSpace slope
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
static bool gModelParkingManoeuver
whether parking simulation includes manoeuver time and any associated lane blocking
Definition MSGlobals.h:162
static bool gLefthand
Whether lefthand-drive is being simulated.
Definition MSGlobals.h:174
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:2862
bool allowsChangingRight(SUMOVehicleClass vclass) const
Returns whether the given vehicle class may change left from this lane.
Definition MSLane.h:953
double getLength() const
Returns the lane's length.
Definition MSLane.h:617
bool allowsChangingLeft(SUMOVehicleClass vclass) const
Returns whether the given vehicle class may change left from this lane.
Definition MSLane.h:948
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition MSLane.h:941
double interpolateLanePosToGeometryPos(double lanePos) const
Definition MSLane.h:555
virtual const PositionVector & getShape(bool) const
Definition MSLane.h:294
double getWidth() const
Returns the lane's width.
Definition MSLane.h:646
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:187
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
Definition MSNet.h:495
void notifyEgressBlocked()
update state so that vehicles wishing to enter cooperate with exiting vehicles
int getOccupancyIncludingReservations(const SUMOVehicle *forVehicle) const
double getAngle() const
Returns the lot rectangle angle.
void leaveFrom(SUMOVehicle *what)
Called if a vehicle leaves this stop.
int getNumAlternatives() const
get number alternatives
void refuse(std::string badge)
Remove the access right for the given badge.
int getLastStepOccupancyIncludingRemoteReservations(const SUMOVehicle *forVehicle) const
int myReservations
number of reservations
int myCapacity
Stop area total capacity.
int getCapacity() const
Returns the area capacity.
int myLastStepOccupancy
Changes to the occupancy in the current time step.
bool myOnRoad
Whether vehicles stay on the road.
int myLastFreeLot
Last free lot number (-1 no free lot)
std::vector< std::string > getAcceptedBadges() const
get the accepted badges
const PositionVector & getShape() const
get the parking shape
MSParkingArea(const std::string &id, const std::vector< std::string > &lines, const std::vector< std::string > &badges, MSLane &lane, double begPos, double endPos, int capacity, double width, double length, double angle, const std::string &name, bool onRoad, const std::string &departPos, bool lefthand, bool reservable)
Constructor.
SUMOTime myLastReservationTime
void setNumAlternatives(int alternatives)
set number alternatives
PositionVector myShape
The roadside shape of this parkingArea.
std::set< const SUMOVehicle * > myRemoteReservedVehicles
the set of vehicles that performed a remote reservation
double getLength() const
Returns the lot rectangle length.
virtual void addLotEntry(double x, double y, double z, double width, double length, double angle, double slope)
Add a lot entry to parking area.
SUMOTime myReservationTime
track parking reservations from the lane for the current time step
double getWidth() const
Returns the lot rectangle width.
double getVehicleSlope(const SUMOVehicle &forVehicle) const
Returns the slope of parked vehicle.
int myRoadSideCapacity
Stop area capacity configured via roadsideCapacity.
int getLotIndex(const SUMOVehicle *veh) const
compute lot for this vehicle
virtual ~MSParkingArea()
Destructor.
SUMOTime updateOccupancy(SUMOTime currentTime)
Called at the end of the time step.
std::set< const SUMOVehicle * > myReservedVehicles
the set of vehicles that performed a local reservation in this step
int getLastFreeLotAngle() const
Return the angle of myLastFreeLot - the next parking lot only expected to be called after we have est...
double myDepartPos
custom departPos
double myAngle
The default angle of each parking space.
bool parkOnRoad() const
whether vehicles park on the road
void addSpaceReservation(const SUMOVehicle *veh)
api for reserving spaces at this parkingArea
DepartPosDefinition myDepartPosDefinition
double myReservationMaxLength
reservation max length
int myNumAlternatives
the number of alternative parkingAreas that are assigned to parkingAreaRerouter
int getOccupancyIncludingRemoteReservations(const SUMOVehicle *forVehicle) const
void removeSpaceReservation(const SUMOVehicle *veh)
double myWidth
The default width of each parking space.
bool accepts(SUMOVehicle *veh) const
Return the parking accepts the vehicle (due to its given badges)
double myLength
The default length of each parking space.
void computeLastFreePos()
Computes the last free position on this stop.
bool mustAdvance(SUMOVehicleClass svc) const
whether parked vehicles must advance in a queue
int getOccupancyIncludingBlocked() const
Returns the area occupancy.
void setAcceptedBadges(const std::vector< std::string > &badges)
set the accepted badges
double getLastFreePosWithReservation(SUMOTime t, const SUMOVehicle &forVehicle, double brakePos)
Returns the last free position on this stop including reservations from the current lane and time ste...
double getLastFreeLotGUIAngle() const
Return the GUI angle of myLastFreeLot - the angle the GUI uses to rotate into the next parking lot as...
int getManoeuverAngle(const SUMOVehicle &forVehicle) const
Return the manoeuver angle of the lot where the vehicle is parked.
int getLastStepOccupancy() const
Returns the area occupancy at the end of the last simulation step.
void accept(std::string badge)
Add a badge to the accepted set.
int getOccupancy() const
Returns the area occupancy.
void setRoadsideCapacity(int capactity)
overwrite the capacity (caution: will delete ANY previous parking space definitions)
const std::vector< LotSpaceDefinition > & getSpaceOccupancies() const
get the parking lots (with occupancy)
double getVehicleAngle(const SUMOVehicle &forVehicle) const
Returns the angle of parked vehicle.
Command * myUpdateEvent
Event for updating the occupancy.
std::vector< LotSpaceDefinition > mySpaceOccupancies
All the spaces in this parking area.
double getInsertionPosition(const SUMOVehicle &forVehicle) const
Returns the insertion position of a parked vehicle.
void enter(SUMOVehicle *veh, const bool parking)
Called if a vehicle enters this stop.
double myLastReservationMaxLength
Position getVehiclePosition(const SUMOVehicle &forVehicle) const
Returns the position of parked vehicle.
std::set< std::string > myAcceptedBadges
The parking badges to grant access.
double myMaxVehLength
maximum length of all parked vehicles
std::set< const SUMOVehicle * > myLastRemoteReservedVehicles
a copy from the last step is needed to achieve thread/lane ordering independence
double getGUIAngle(const SUMOVehicle &forVehicle) const
Return the GUI angle of the lot where the vehicle is parked.
bool cannotChange(SUMOVehicleClass svc) const
whether overtaking on this lane is impossible for the given vehicle class
bool myEgressBlocked
whether a vehicle wants to exit but is blocked
A lane area vehicles can halt at.
const SumoXMLTag myElement
the type of stopping place
const double myBegPos
The begin position this bus stop is located at.
double getBeginLanePosition() const
Returns the begin position of this stop.
const MSLane & myLane
The lane this bus stop is located at.
std::map< const SUMOVehicle *, std::pair< double, double >, ComparatorNumericalIdLess > myEndPositions
A map from objects (vehicles) to the areas they acquire after entering the stop.
const double myEndPos
The end position this bus stop is located at.
const MSLane & getLane() const
Returns the lane this stop is located at.
double myLastFreePos
The last free position at this stop (variable)
double getLastFreePos() const
double getMinGap() const
Get the free space in front of vehicles of this class.
double getLength() const
Get vehicle's length [m].
const std::string & getID() const
Returns the id.
Definition Named.h:74
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition Position.h:323
double x() const
Returns the x-position.
Definition Position.h:52
double z() const
Returns the z-position.
Definition Position.h:62
double y() const
Returns the y-position.
Definition Position.h:57
A list of positions.
double nearest_offset_to_point2D(const Position &p, bool perpendicular=true) const
return the nearest offest to point 2D
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
PositionVector getSubpart(double beginOffset, double endOffset) const
get subpart of a position vector
Position transformToVectorCoordinates(const Position &p, bool extend=false) const
return position p within the length-wise coordinate system defined by this position vector....
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
Definition SUMOVehicle.h:63
virtual const std::vector< std::string > & getParkingBadges() const =0
virtual double getLength() const =0
Returns the vehicles's length.
virtual void setNumberParkingReroutes(int value)=0
Structure representing possible vehicle parameter.
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.
A wrapper for a Command function.
#define M_PI
Definition odrSpiral.cpp:45
Representation of a single lot space.
const Position position
The position of the vehicle when parking in this space.
bool sideIsLHS
Whether the lot is on the LHS of the lane relative to the lane direction.
double manoeuverAngle
The angle between lane and lot through which a vehicle must manoeuver to enter the lot.
const double rotation
The rotation.
double endPos
The position along the lane that the vehicle needs to reach for entering this lot.
LotSpaceDefinition()
default constructor
const SUMOVehicle * vehicle
The last parked vehicle or 0.