Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
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/MSVehicle.h>
33#include "MSLane.h"
35#include "MSParkingArea.h"
36#include "MSGlobals.h"
37
38//#define DEBUG_RESERVATIONS
39//#define DEBUG_GET_LAST_FREE_POS
40//#define DEBUG_COND2(obj) (obj.getID() == "v.3")
41#define DEBUG_COND2(obj) (obj.isSelected())
42
43
44// ===========================================================================
45// method definitions
46// ===========================================================================
47MSParkingArea::MSParkingArea(const std::string& id, const std::vector<std::string>& lines,
48 const std::vector<std::string>& badges, MSLane& lane,
49 double begPos, double endPos, int capacity, double width, double length,
50 double angle, const std::string& name, bool onRoad,
51 const std::string& departPos, bool lefthand) :
52 MSStoppingPlace(id, SUMO_TAG_PARKING_AREA, lines, lane, begPos, endPos, name),
53 myRoadSideCapacity(capacity),
54 myCapacity(0),
55 myOnRoad(onRoad),
56 myWidth(width),
57 myLength(length),
58 myAngle(lefthand ? -angle : angle),
59 myAcceptedBadges(badges.begin(), badges.end()),
60 myEgressBlocked(false),
61 myReservationTime(-1),
62 myLastReservationTime(-1),
63 myReservations(0),
64 myLastReservations(0),
65 myReservationMaxLength(0),
66 myLastReservationMaxLength(0),
67 myMaxVehLength(0),
68 myNumAlternatives(0),
69 myLastStepOccupancy(0),
70 myDepartPos(-1),
71 myDepartPosDefinition(DepartPosDefinition::DEFAULT),
72 myUpdateEvent(nullptr) {
73 // initialize unspecified defaults
74 if (myWidth == 0) {
76 }
77
78 if (departPos != "") {
79 std::string error;
81 throw ProcessError(error);
82 }
84 // maybe allow other methods at a later time
85 throw ProcessError("Only a numerical departPos is supported for " + toString(myElement) + " '" + getID() + "'");
86 } else if (myDepartPos < 0 || myDepartPos > lane.getLength()) {
87 throw ProcessError("Invalid departPos for " + toString(myElement) + " '" + getID() + "'");
88 }
89 }
90
91 const double offset = (MSGlobals::gLefthand != lefthand) ? -1 : 1;
95 if (!myOnRoad) {
96 myShape.move2side((lane.getWidth() / 2. + myWidth / 2.) * offset);
97 }
98 setRoadsideCapacity(capacity);
99}
100
101
103
104
105void
106MSParkingArea::addLotEntry(double x, double y, double z, double width, double length, double angle, double slope) {
107 // create LotSpaceDefinition
108 LotSpaceDefinition lsd((int)mySpaceOccupancies.size(), nullptr, x, y, z, angle, slope, width, length);
109 // If we are modelling parking set the end position to the lot position relative to the lane
110 // rather than the end of the parking area - this results in vehicles stopping nearer the space
111 // and re-entering the lane nearer the space. (If we are not modelling parking the vehicle will usually
112 // enter the space and re-enter at the end of the parking area.)
114 const double offset = this->getLane().getShape().nearest_offset_to_point2D(lsd.position);
115 if (offset < getBeginLanePosition()) {
116 lsd.endPos = getBeginLanePosition() + POSITION_EPS;
117 } else {
118 if (this->getLane().getLength() > offset) {
119 lsd.endPos = offset;
120 } else {
121 lsd.endPos = this->getLane().getLength() - POSITION_EPS;
122 }
123 }
124 // Work out the angle of the lot relative to the lane (-90 adjusts for the way the bay is drawn )
125 double relativeAngle = fmod(lsd.rotation - 90., 360) - fmod(RAD2DEG(this->getLane().getShape().rotationAtOffset(lsd.endPos)), 360) + 0.5;
126 if (relativeAngle < 0.) {
127 relativeAngle += 360.;
128 }
129 lsd.manoeuverAngle = relativeAngle;
130
131 // if p2.y is -ve the lot is on LHS of lane relative to lane direction
132 // we need to know this because it inverts the complexity of the parking manoeuver
134 if (p2.y() < (0. + POSITION_EPS)) {
135 lsd.sideIsLHS = true;
136 } else {
137 lsd.sideIsLHS = false;
138 }
139 } else {
140 lsd.endPos = myEndPos;
141 lsd.manoeuverAngle = int(angle); // unused unless gModelParkingManoeuver is true
142 lsd.sideIsLHS = true;
143 }
144 mySpaceOccupancies.push_back(lsd);
145 myCapacity++;
147}
148
149int
151 assert(myLastFreeLot >= 0);
152 assert(myLastFreeLot < (int)mySpaceOccupancies.size());
153
155 if (lsd.sideIsLHS) {
156 return abs(int(lsd.manoeuverAngle)) % 180;
157 } else {
158 return abs(abs(int(lsd.manoeuverAngle)) % 180 - 180) % 180;
159 }
160}
161
162double
164 assert(myLastFreeLot >= 0);
165 assert(myLastFreeLot < (int)mySpaceOccupancies.size());
166
168 if (lsd.manoeuverAngle > 180.) {
169 return DEG2RAD(lsd.manoeuverAngle - 360.);
170 } else {
171 return DEG2RAD(lsd.manoeuverAngle);
172 }
173}
174
175
176double
177MSParkingArea::getLastFreePos(const SUMOVehicle& forVehicle, double brakePos) const {
178 if (myCapacity == (int)myEndPositions.size()) {
179 // keep enough space so that parking vehicles can leave
180#ifdef DEBUG_GET_LAST_FREE_POS
181 if (DEBUG_COND2(forVehicle)) {
182 std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " allOccupied\n";
183 }
184#endif
185 return myLastFreePos - forVehicle.getVehicleType().getMinGap() - POSITION_EPS;
186 } else {
187 const double minPos = MIN2(myEndPos, brakePos);
188 if (myLastFreePos >= minPos) {
189#ifdef DEBUG_GET_LAST_FREE_POS
190 if (DEBUG_COND2(forVehicle)) {
191 std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " brakePos=" << brakePos << " myEndPos=" << myEndPos << " using myLastFreePos=" << myLastFreePos << "\n";
192 }
193#endif
194 return myLastFreePos;
195 } else {
196 // find free pos after minPos
197 for (const auto& lsd : mySpaceOccupancies) {
198 if (lsd.vehicle == nullptr && lsd.endPos >= minPos) {
199#ifdef DEBUG_GET_LAST_FREE_POS
200 if (DEBUG_COND2(forVehicle)) {
201 std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " brakePos=" << brakePos << " myEndPos=" << myEndPos << " nextFreePos=" << lsd.endPos << "\n";
202 }
203#endif
204 return lsd.endPos;
205 }
206 }
207 // shouldn't happen. No good solution seems possible
208#ifdef DEBUG_GET_LAST_FREE_POS
209 if (DEBUG_COND2(forVehicle)) {
210 std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " brakePos=" << brakePos << " myEndPos=" << myEndPos << " noGoodFreePos blockedAt=" << brakePos << "\n";
211 }
212#endif
213 return brakePos;
214 }
215 }
216}
217
220 for (const auto& lsd : mySpaceOccupancies) {
221 if (lsd.vehicle == &forVehicle) {
222 return lsd.position;
223 }
224 }
225 return Position::INVALID;
226}
227
228
229double
232 return myDepartPos;
233 }
234 for (const auto& lsd : mySpaceOccupancies) {
235 if (lsd.vehicle == &forVehicle) {
236 return lsd.endPos;
237 }
238 }
239 return -1;
240}
241
242
243double
245 for (const auto& lsd : mySpaceOccupancies) {
246 if (lsd.vehicle == &forVehicle) {
247 return (lsd.rotation - 90.) * (double) M_PI / (double) 180.0;
248 }
249 }
250 return 0;
251}
252
253double
255 for (const auto& lsd : mySpaceOccupancies) {
256 if (lsd.vehicle == &forVehicle) {
257 return lsd.slope;
258 }
259 }
260 return 0;
261}
262
263double
264MSParkingArea::getGUIAngle(const SUMOVehicle& forVehicle) const {
265 for (const auto& lsd : mySpaceOccupancies) {
266 if (lsd.vehicle == &forVehicle) {
267 if (lsd.manoeuverAngle > 180.) {
268 return DEG2RAD(lsd.manoeuverAngle - 360.);
269 } else {
270 return DEG2RAD(lsd.manoeuverAngle);
271 }
272 }
273 }
274 return 0.;
275}
276
277int
279 for (const auto& lsd : mySpaceOccupancies) {
280 if (lsd.vehicle == &forVehicle) {
281 if (lsd.sideIsLHS) {
282 return abs(int(lsd.manoeuverAngle)) % 180;
283 } else {
284 return abs(abs(int(lsd.manoeuverAngle)) % 180 - 180) % 180;
285 }
286 }
287 }
288 return 0;
289}
290
291int
293 if (veh->getPositionOnLane() > myLastFreePos) {
294 // vehicle has gone past myLastFreePos and we need to find the actual lot
295 int closestLot = -1;
296 for (int i = 0; i < (int)mySpaceOccupancies.size(); i++) {
298 if (lsd.vehicle == nullptr) {
299 closestLot = i;
300 if (lsd.endPos >= veh->getPositionOnLane()) {
301 return i;
302 }
303 }
304 }
305 return closestLot;
306 }
307 if (myOnRoad && myLastFreePos - veh->getPositionOnLane() > POSITION_EPS) {
308 // for on-road parking we need to be precise
309 return -1;
310 }
311 return myLastFreeLot;
312}
313
314void
316 double beg = veh->getPositionOnLane() + veh->getVehicleType().getMinGap();
317 double end = veh->getPositionOnLane() - veh->getVehicleType().getLength();
318 if (myUpdateEvent == nullptr) {
321 }
322 int lotIndex = getLotIndex(veh);
323 if (lotIndex < 0) {
324 WRITE_WARNING("Unsuitable parking position for vehicle '" + veh->getID() + "' at parkingArea '" + getID() + "' time=" + time2string(SIMSTEP));
325 lotIndex = myLastFreeLot;
326 }
327#ifdef DEBUG_GET_LAST_FREE_POS
328 ((SUMOVehicleParameter&)veh->getParameter()).setParameter("lotIndex", toString(lotIndex));
329#endif
330 assert(myLastFreePos >= 0);
331 assert(lotIndex < (int)mySpaceOccupancies.size());
332 mySpaceOccupancies[lotIndex].vehicle = veh;
333 myEndPositions[veh] = std::pair<double, double>(beg, end);
336 // current search ends here
338}
339
340
341void
343 assert(myEndPositions.find(what) != myEndPositions.end());
344 if (myUpdateEvent == nullptr) {
347 }
348 for (auto& lsd : mySpaceOccupancies) {
349 if (lsd.vehicle == what) {
350 lsd.vehicle = nullptr;
351 break;
352 }
353 }
354 if (what->getLength() == myMaxVehLength) {
355 myMaxVehLength = 0;
356 for (auto item : myEndPositions) {
357 myMaxVehLength = MAX2(myMaxVehLength, item.first->getLength());
358 }
359 }
360 myEndPositions.erase(myEndPositions.find(what));
362}
363
364
368 myUpdateEvent = nullptr;
369 return 0;
370}
371
372
374 index(-1),
375 vehicle(nullptr),
376 rotation(0),
377 slope(0),
378 width(0),
379 length(0),
380 endPos(0),
381 manoeuverAngle(0),
382 sideIsLHS(false) {
383}
384
385
386MSParkingArea::LotSpaceDefinition::LotSpaceDefinition(int index_, SUMOVehicle* vehicle_, double x, double y, double z, double rotation_, double slope_, double width_, double length_) :
387 index(index_),
388 vehicle(vehicle_),
389 position(Position(x, y, z)),
390 rotation(rotation_),
391 slope(slope_),
392 width(width_),
393 length(length_),
394 endPos(0),
395 manoeuverAngle(0),
396 sideIsLHS(false) {
397}
398
399
400void
402 myLastFreeLot = -1;
404 myEgressBlocked = false;
405 for (auto& lsd : mySpaceOccupancies) {
406 if (lsd.vehicle == nullptr
407 || (getOccupancy() == getCapacity()
408 && lsd.vehicle->remainingStopDuration() <= 0
409 && !lsd.vehicle->isStoppedTriggered())) {
410 if (lsd.vehicle == nullptr) {
411 myLastFreeLot = lsd.index;
412 myLastFreePos = lsd.endPos;
413 } else {
414 // vehicle wants to exit the parking area
415 myLastFreeLot = lsd.index;
416 myLastFreePos = lsd.endPos - lsd.vehicle->getVehicleType().getLength() - POSITION_EPS;
417 myEgressBlocked = true;
418 }
419 break;
420 } else {
422 lsd.endPos - lsd.vehicle->getVehicleType().getLength() - NUMERICAL_EPS);
423 }
424 }
425}
426
427
428double
430 // do not perform reservation when far away
431 if (forVehicle.getLane() != &myLane || forVehicle.getPositionOnLane() < (myBegPos - myMaxVehLength - forVehicle.getVehicleType().getMinGap())) {
432 // for different lanes, do not consider reservations to avoid lane-order
433 // dependency in parallel simulation
434#ifdef DEBUG_RESERVATIONS
435 if (DEBUG_COND2(forVehicle)) {
436 std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID() << " other lane\n";
437 }
438#endif
439 if (myNumAlternatives > 0 && getOccupancy() == getCapacity()) {
440 // ensure that the vehicle reaches the rerouter lane
441 if (mySpaceOccupancies.size() > 0) {
442 assert(mySpaceOccupancies[0].vehicle != nullptr);
443 const double waitPos = (mySpaceOccupancies[0].endPos
444 - mySpaceOccupancies[0].vehicle->getLength()
445 - forVehicle.getVehicleType().getMinGap()
446 - NUMERICAL_EPS);
447 return MAX2(waitPos, MIN2(POSITION_EPS, myEndPos));
448 } else {
449 return MAX2(myBegPos, MIN2(POSITION_EPS, myEndPos));
450 }
451 } else {
452 // check if there is a reservation from the last time step
453 // (this could also be in myReserations, if myLane wasn't processed before the forVehicle-lane)
454 const SUMOTime last = t - DELTA_T;
455 if (DEBUG_COND2(forVehicle)) std::cout << SIMTIME << " last=" << time2string(last) << " lastRes=" << time2string(myLastReservationTime) << " resTime=" << toString(myReservationTime) << "\n";
456 if (myLastReservationTime == last || myReservationTime == last) {
458 if (myCapacity <= getOccupancy() + res) {
460#ifdef DEBUG_RESERVATIONS
461 if (DEBUG_COND2(forVehicle)) std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID()
462 << " lastRes=" << res << " resTime=" << myReservationTime << " reserved full, maxLen=" << maxLen << " endPos=" << mySpaceOccupancies[0].endPos << "\n";
463#endif
464 return (mySpaceOccupancies[0].endPos
465 - maxLen
466 - forVehicle.getVehicleType().getMinGap()
467 - NUMERICAL_EPS);
468 }
469 }
470 return getLastFreePos(forVehicle, brakePos);
471 }
472 }
473 if (t > myReservationTime) {
474#ifdef DEBUG_RESERVATIONS
475 if (DEBUG_COND2(forVehicle)) {
476 std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID() << " first reservation\n";
477 }
478#endif
483 myReservations = 1;
485 myReservedVehicles.clear();
486 myReservedVehicles.insert(&forVehicle);
487 for (const auto& lsd : mySpaceOccupancies) {
488 if (lsd.vehicle != nullptr) {
489 myReservationMaxLength = MAX2(myReservationMaxLength, lsd.vehicle->getVehicleType().getLength());
490 }
491 }
492 return getLastFreePos(forVehicle, brakePos);
493 } else {
495#ifdef DEBUG_RESERVATIONS
496 if (DEBUG_COND2(forVehicle)) {
497 std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID() << " res=" << myReservations << " enough space\n";
498 }
499#endif
502 myReservedVehicles.insert(&forVehicle);
503 return getLastFreePos(forVehicle, brakePos);
504 } else {
505 if (myCapacity == 0) {
506 return getLastFreePos(forVehicle, brakePos);
507 } else {
508#ifdef DEBUG_RESERVATIONS
509 if (DEBUG_COND2(forVehicle)) std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID()
510 << " res=" << myReservations << " resTime=" << myReservationTime << " reserved full, maxLen=" << myReservationMaxLength << " endPos=" << mySpaceOccupancies[0].endPos << "\n";
511#endif
512 return (mySpaceOccupancies[0].endPos
514 - forVehicle.getVehicleType().getMinGap()
515 - NUMERICAL_EPS);
516 }
517 }
518 }
519}
520
521
522double
524 return myWidth;
525}
526
527
528double
530 return myLength;
531}
532
533
534double
536 return myAngle;
537}
538
539
540int
542 return myCapacity;
543}
544
545
546bool
548 return myOnRoad;
549}
550
551
552int
554 return (int)myEndPositions.size() - (myEgressBlocked ? 1 : 0);
555}
556
557
558int
560 return (int)myEndPositions.size();
561}
562
563int
565 if (myReservedVehicles.count(forVehicle) != 0) {
566 return (int)myEndPositions.size();
567 } else {
568 return (int)myEndPositions.size() + myReservations;
569 }
570}
571
572int
576
577
578void
579MSParkingArea::accept(std::string badge) {
580 myAcceptedBadges.insert(badge);
581}
582
583
584void
585MSParkingArea::accept(std::vector<std::string> badges) {
586 myAcceptedBadges.insert(badges.begin(), badges.end());
587}
588
589
590void
591MSParkingArea::refuse(std::string badge) {
592 myAcceptedBadges.erase(badge);
593}
594
595
596bool
598 if (myAcceptedBadges.size() == 0) {
599 return true;
600 } else {
601 std::vector<std::string> vehicleBadges = veh->getParkingBadges();
602 for (auto badge : vehicleBadges) {
603 if (myAcceptedBadges.count(badge) != 0) {
604 return true;
605 }
606 }
607 return false;
608 }
609}
610
611
612void
616
617
618int
622
623
624void
627}
628
629
630std::vector<std::string>
632 std::vector<std::string> result(myAcceptedBadges.begin(), myAcceptedBadges.end());
633 return result;
634}
635
636
637void
638MSParkingArea::setAcceptedBadges(const std::vector<std::string>& badges) {
639 myAcceptedBadges.clear();
640 myAcceptedBadges.insert(badges.begin(), badges.end());
641}
642
643
644void
646 // reinit parking lot generation process
647 myRoadSideCapacity = capacity;
648
649 // Initialize space occupancies if there is a road-side capacity
650 // The overall number of lots is fixed and each lot accepts one vehicle regardless of size
652 if (myLength == 0) {
653 myLength = spaceDim;
654 }
655 mySpaceOccupancies.clear();
656 myCapacity = 0;
657 for (int i = 0; i < myRoadSideCapacity; ++i) {
658 // calculate pos, angle and slope of parking lot space
660 double spaceAngle = GeomHelper::calculateLotSpaceAngle(myShape, i, spaceDim, myAngle);
661 double spaceSlope = GeomHelper::calculateLotSpaceSlope(myShape, i, spaceDim);
662 // add lotEntry
663 addLotEntry(pos.x(), pos.y(), pos.z(), myWidth, myLength, spaceAngle, spaceSlope);
664 // update endPos
665 mySpaceOccupancies.back().endPos = MIN2(myEndPos, myBegPos + MAX2(POSITION_EPS, spaceDim * (i + 1)));
666 }
667}
668
669/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
@ DEFAULT
default cursor
#define DEG2RAD(x)
Definition GeomHelper.h:35
#define RAD2DEG(x)
Definition GeomHelper.h:36
#define DEBUG_COND2(obj)
Definition MESegment.cpp:53
#define WRITE_WARNING(msg)
Definition MsgHandler.h:287
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:61
#define SIMTIME
Definition SUMOTime.h:62
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:48
T MIN2(T a, T b)
Definition StdDefs.h:76
T MAX2(T a, T b)
Definition StdDefs.h:82
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
The base class for microscopic and mesoscopic vehicles.
const std::vector< std::string > & getParkingBadges() const
get the valid parking access rights (vehicle settings override vehicle type settings)
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
double getLength() const
Returns the lane's length.
Definition MSLane.h:606
double interpolateLanePosToGeometryPos(double lanePos) const
Definition MSLane.h:554
virtual const PositionVector & getShape(bool) const
Definition MSLane.h:294
double getWidth() const
Returns the lane's width.
Definition MSLane.h:635
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition MSNet.cpp:186
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
Definition MSNet.h:486
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 myReservations
number of reservations
int myCapacity
Stop area total capacity.
int getCapacity() const
Returns the area capacity.
void enter(SUMOVehicle *veh)
Called if a vehicle enters this stop.
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
SUMOTime myLastReservationTime
void setNumAlternatives(int alternatives)
set number alternatives
PositionVector myShape
The roadside shape of this parkingArea.
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 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
DepartPosDefinition myDepartPosDefinition
double myReservationMaxLength
reservation max length
int myNumAlternatives
the number of alternative parkingAreas that are assigned to parkingAreaRerouter
double myWidth
The default width of each parking space.
bool accepts(MSBaseVehicle *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)
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.
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)
Constructor.
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
double getGUIAngle(const SUMOVehicle &forVehicle) const
Return the GUI angle of the lot where the vehicle is parked.
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:319
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
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 double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
Definition SUMOVehicle.h:62
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.