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 (myOnRoad && cannotChange(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 myEndPos;
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
242
243bool
245 const MSLane* left = myLane.getParallelLane(1, false);
246 const MSLane* right = myLane.getParallelLane(-1, false);
247 return ((left == nullptr || !left->allowsVehicleClass(svc) || !myLane.allowsChangingLeft(svc))
248 && (right == nullptr || !right->allowsVehicleClass(svc) || !myLane.allowsChangingRight(svc)));
249}
250
251
254 for (const auto& lsd : mySpaceOccupancies) {
255 if (lsd.vehicle == &forVehicle) {
256 return lsd.position;
257 }
258 }
259 return Position::INVALID;
260}
261
262
263double
266 return myDepartPos;
267 }
268 for (const auto& lsd : mySpaceOccupancies) {
269 if (lsd.vehicle == &forVehicle) {
270 return lsd.endPos;
271 }
272 }
273 return -1;
274}
275
276
277double
279 for (const auto& lsd : mySpaceOccupancies) {
280 if (lsd.vehicle == &forVehicle) {
281 return (lsd.rotation - 90.) * (double) M_PI / (double) 180.0;
282 }
283 }
284 return 0;
285}
286
287double
289 for (const auto& lsd : mySpaceOccupancies) {
290 if (lsd.vehicle == &forVehicle) {
291 return lsd.slope;
292 }
293 }
294 return 0;
295}
296
297double
298MSParkingArea::getGUIAngle(const SUMOVehicle& forVehicle) const {
299 for (const auto& lsd : mySpaceOccupancies) {
300 if (lsd.vehicle == &forVehicle) {
301 if (lsd.manoeuverAngle > 180.) {
302 return DEG2RAD(lsd.manoeuverAngle - 360.);
303 } else {
304 return DEG2RAD(lsd.manoeuverAngle);
305 }
306 }
307 }
308 return 0.;
309}
310
311int
313 for (const auto& lsd : mySpaceOccupancies) {
314 if (lsd.vehicle == &forVehicle) {
315 if (lsd.sideIsLHS) {
316 return abs(int(lsd.manoeuverAngle)) % 180;
317 } else {
318 return abs(abs(int(lsd.manoeuverAngle)) % 180 - 180) % 180;
319 }
320 }
321 }
322 return 0;
323}
324
325int
327 if (veh->getPositionOnLane() > myLastFreePos) {
328 // vehicle has gone past myLastFreePos and we need to find the actual lot
329 int closestLot = -1;
330 for (int i = 0; i < (int)mySpaceOccupancies.size(); i++) {
332 if (lsd.vehicle == nullptr) {
333 closestLot = i;
334 if (lsd.endPos >= veh->getPositionOnLane()) {
335 return i;
336 }
337 }
338 }
339 return closestLot;
340 }
341 if (myOnRoad && myLastFreePos - veh->getPositionOnLane() > POSITION_EPS) {
342 // for on-road parking we need to be precise
343 return -1;
344 }
345 return myLastFreeLot;
346}
347
348void
349MSParkingArea::enter(SUMOVehicle* veh, const bool /* parking */) {
351 double beg = veh->getPositionOnLane() + veh->getVehicleType().getMinGap();
352 double end = veh->getPositionOnLane() - veh->getVehicleType().getLength();
353 if (myUpdateEvent == nullptr) {
356 }
357 int lotIndex = getLotIndex(veh);
358 if (lotIndex < 0) {
359 WRITE_WARNING("Unsuitable parking position for vehicle '" + veh->getID() + "' at parkingArea '" + getID() + "' time=" + time2string(SIMSTEP));
360 lotIndex = myLastFreeLot;
361 }
362#ifdef DEBUG_GET_LAST_FREE_POS
363 ((SUMOVehicleParameter&)veh->getParameter()).setParameter("lotIndex", toString(lotIndex));
364#endif
365 assert(myLastFreePos >= 0);
366 assert(lotIndex < (int)mySpaceOccupancies.size());
367 mySpaceOccupancies[lotIndex].vehicle = veh;
368 myEndPositions[veh] = std::pair<double, double>(beg, end);
371 // current search ends here
373}
374
375
376void
384
385void
393
394void
396 assert(myEndPositions.find(what) != myEndPositions.end());
397 if (myUpdateEvent == nullptr) {
400 }
401 for (auto& lsd : mySpaceOccupancies) {
402 if (lsd.vehicle == what) {
403 lsd.vehicle = nullptr;
404 break;
405 }
406 }
407 if (what->getLength() == myMaxVehLength) {
408 myMaxVehLength = 0;
409 for (auto item : myEndPositions) {
410 myMaxVehLength = MAX2(myMaxVehLength, item.first->getLength());
411 }
412 }
413 myEndPositions.erase(myEndPositions.find(what));
415}
416
417
425
426
428 index(-1),
429 vehicle(nullptr),
430 rotation(0),
431 slope(0),
432 width(0),
433 length(0),
434 endPos(0),
435 manoeuverAngle(0),
436 sideIsLHS(false) {
437}
438
439
440MSParkingArea::LotSpaceDefinition::LotSpaceDefinition(int index_, SUMOVehicle* vehicle_, double x, double y, double z, double rotation_, double slope_, double width_, double length_) :
441 index(index_),
442 vehicle(vehicle_),
443 position(Position(x, y, z)),
444 rotation(rotation_),
445 slope(slope_),
446 width(width_),
447 length(length_),
448 endPos(0),
449 manoeuverAngle(0),
450 sideIsLHS(false) {
451}
452
453
454void
456 myLastFreeLot = -1;
458 myEgressBlocked = false;
459 for (auto& lsd : mySpaceOccupancies) {
460 if (lsd.vehicle == nullptr
461 || (getOccupancy() == getCapacity()
462 && lsd.vehicle->remainingStopDuration() <= 0
463 && !lsd.vehicle->isStoppedTriggered())) {
464 if (lsd.vehicle == nullptr) {
465 myLastFreeLot = lsd.index;
466 myLastFreePos = lsd.endPos;
467 } else {
468 // vehicle wants to exit the parking area
469 myLastFreeLot = lsd.index;
470 myLastFreePos = lsd.endPos - lsd.vehicle->getVehicleType().getLength() - POSITION_EPS;
471 myEgressBlocked = true;
472 }
473 break;
474 } else {
476 lsd.endPos - lsd.vehicle->getVehicleType().getLength() - NUMERICAL_EPS);
477 }
478 }
479}
480
481
482double
484 // do not perform reservation when far away
485 if (forVehicle.getLane() != &myLane || forVehicle.getPositionOnLane() < (myBegPos - myMaxVehLength - forVehicle.getVehicleType().getMinGap())) {
486 // for different lanes, do not consider reservations to avoid lane-order
487 // dependency in parallel simulation
488#ifdef DEBUG_RESERVATIONS
489 if (DEBUG_COND2(forVehicle)) {
490 std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID() << " other lane\n";
491 }
492#endif
493 if (myNumAlternatives > 0 && getOccupancy() == getCapacity()) {
494 // ensure that the vehicle reaches the rerouter lane
495 if (mySpaceOccupancies.size() > 0) {
496 assert(mySpaceOccupancies[0].vehicle != nullptr);
497 const double waitPos = (mySpaceOccupancies[0].endPos
498 - mySpaceOccupancies[0].vehicle->getLength()
499 - forVehicle.getVehicleType().getMinGap()
500 - NUMERICAL_EPS);
501 return MAX2(waitPos, MIN2(POSITION_EPS, myEndPos));
502 } else {
503 return MAX2(myBegPos, MIN2(POSITION_EPS, myEndPos));
504 }
505 } else {
506 // check if there is a reservation from the last time step
507 // (this could also be in myReserations, if myLane wasn't processed before the forVehicle-lane)
508 const SUMOTime last = t - DELTA_T;
509 if (DEBUG_COND2(forVehicle)) {
510 std::cout << SIMTIME << " last=" << time2string(last) << " lastRes=" << time2string(myLastReservationTime) << " resTime=" << toString(myReservationTime) << "\n";
511 }
512 if (myLastReservationTime == last || myReservationTime == last) {
514 if (myCapacity <= getOccupancy() + res) {
516#ifdef DEBUG_RESERVATIONS
517 if (DEBUG_COND2(forVehicle)) std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID()
518 << " lastRes=" << res << " resTime=" << myReservationTime << " reserved full, maxLen=" << maxLen << " endPos=" << mySpaceOccupancies[0].endPos << "\n";
519#endif
520 return (mySpaceOccupancies[0].endPos
521 - maxLen
522 - forVehicle.getVehicleType().getMinGap()
523 - NUMERICAL_EPS);
524 }
525 }
526 return getLastFreePos(forVehicle, brakePos);
527 }
528 }
529 if (t > myReservationTime) {
530#ifdef DEBUG_RESERVATIONS
531 if (DEBUG_COND2(forVehicle)) {
532 std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID() << " first reservation\n";
533 }
534#endif
539 myReservations = 1;
541 myReservedVehicles.clear();
542 myReservedVehicles.insert(&forVehicle);
543 for (const auto& lsd : mySpaceOccupancies) {
544 if (lsd.vehicle != nullptr) {
545 myReservationMaxLength = MAX2(myReservationMaxLength, lsd.vehicle->getVehicleType().getLength());
546 }
547 }
548 return getLastFreePos(forVehicle, brakePos);
549 } else {
551#ifdef DEBUG_RESERVATIONS
552 if (DEBUG_COND2(forVehicle)) {
553 std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID() << " res=" << myReservations << " enough space\n";
554 }
555#endif
558 myReservedVehicles.insert(&forVehicle);
559 return getLastFreePos(forVehicle, brakePos);
560 } else {
561 if (myCapacity == 0) {
562 return getLastFreePos(forVehicle, brakePos);
563 } else {
564#ifdef DEBUG_RESERVATIONS
565 if (DEBUG_COND2(forVehicle)) std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID()
566 << " res=" << myReservations << " resTime=" << myReservationTime << " reserved full, maxLen=" << myReservationMaxLength << " endPos=" << mySpaceOccupancies[0].endPos << "\n";
567#endif
568 return (mySpaceOccupancies[0].endPos
570 - forVehicle.getVehicleType().getMinGap()
571 - NUMERICAL_EPS);
572 }
573 }
574 }
575}
576
577
578double
580 return myWidth;
581}
582
583
584double
586 return myLength;
587}
588
589
590double
592 return myAngle;
593}
594
595
596int
598 return myCapacity;
599}
600
601
602bool
604 return myOnRoad;
605}
606
607
608int
610 return (int)myEndPositions.size() - (myEgressBlocked ? 1 : 0);
611}
612
613
614int
616 return (int)myEndPositions.size();
617}
618
619int
621 const bool reservedLocal = myReservedVehicles.count(forVehicle) != 0;
622 const bool reservedRemote = myRemoteReservedVehicles.count(forVehicle) != 0;
623 return ((int)myEndPositions.size()
624 + (reservedLocal ? 0 : myReservations)
625 + (reservedRemote ? 0 : myRemoteReservedVehicles.size()));
626}
627
628
629int
631 const bool reservedRemote = myRemoteReservedVehicles.count(forVehicle) != 0;
632 return getOccupancy() + (int)myRemoteReservedVehicles.size() - (reservedRemote ? 1 : 0);
633}
634
635
636int
640
641
642int
644 const bool reservedRemote = myLastRemoteReservedVehicles.count(forVehicle) != 0;
645 return myLastStepOccupancy - (int)myLastRemoteReservedVehicles.size() + (reservedRemote ? 1 : 0);
646}
647
648
649void
650MSParkingArea::accept(std::string badge) {
651 myAcceptedBadges.insert(badge);
652}
653
654
655void
656MSParkingArea::accept(std::vector<std::string> badges) {
657 myAcceptedBadges.insert(badges.begin(), badges.end());
658}
659
660
661void
662MSParkingArea::refuse(std::string badge) {
663 myAcceptedBadges.erase(badge);
664}
665
666
667bool
669 if (myAcceptedBadges.size() == 0) {
670 return true;
671 } else {
672 std::vector<std::string> vehicleBadges = veh->getParkingBadges();
673 for (auto badge : vehicleBadges) {
674 if (myAcceptedBadges.count(badge) != 0) {
675 return true;
676 }
677 }
678 return false;
679 }
680}
681
682
683void
687
688
689int
693
694
695void
698}
699
700
701std::vector<std::string>
703 std::vector<std::string> result(myAcceptedBadges.begin(), myAcceptedBadges.end());
704 return result;
705}
706
707
708void
709MSParkingArea::setAcceptedBadges(const std::vector<std::string>& badges) {
710 myAcceptedBadges.clear();
711 myAcceptedBadges.insert(badges.begin(), badges.end());
712}
713
714
715const std::vector<MSParkingArea::LotSpaceDefinition>&
719
720
721const PositionVector&
723 return myShape;
724}
725
726
727void
729 // reinit parking lot generation process
730 myRoadSideCapacity = capacity;
731
732 // Initialize space occupancies if there is a road-side capacity
733 // The overall number of lots is fixed and each lot accepts one vehicle regardless of size
735 if (myLength == 0) {
736 myLength = spaceDim;
737 }
738 mySpaceOccupancies.clear();
739 myCapacity = 0;
740 for (int i = 0; i < myRoadSideCapacity; ++i) {
741 // calculate pos, angle and slope of parking lot space
743 double spaceAngle = GeomHelper::calculateLotSpaceAngle(myShape, i, spaceDim, myAngle);
744 double spaceSlope = GeomHelper::calculateLotSpaceSlope(myShape, i, spaceDim);
745 // add lotEntry
746 addLotEntry(pos.x(), pos.y(), pos.z(), myWidth, myLength, spaceAngle, spaceSlope);
747 // update endPos
748 mySpaceOccupancies.back().endPos = MIN2(myEndPos, myBegPos + MAX2(POSITION_EPS, spaceDim * (i + 1)));
749 }
750 // recompute after modifying the last endPos
752}
753
754/****************************************************************************/
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:2864
bool allowsChangingRight(SUMOVehicleClass vclass) const
Returns whether the given vehicle class may change left from this lane.
Definition MSLane.h:948
double getLength() const
Returns the lane's length.
Definition MSLane.h:612
bool allowsChangingLeft(SUMOVehicleClass vclass) const
Returns whether the given vehicle class may change left from this lane.
Definition MSLane.h:943
bool allowsVehicleClass(SUMOVehicleClass vclass) const
Definition MSLane.h:936
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:641
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.
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.