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-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"
38
39//#define DEBUG_RESERVATIONS
40//#define DEBUG_GET_LAST_FREE_POS
41//#define DEBUG_COND2(obj) (obj.getID() == "v.3")
42#define DEBUG_COND2(obj) (obj.isSelected())
43
44
45// ===========================================================================
46// method definitions
47// ===========================================================================
48MSParkingArea::MSParkingArea(const std::string& id, const std::vector<std::string>& lines,
49 const std::vector<std::string>& badges, MSLane& lane,
50 double begPos, double endPos, int capacity, double width, double length,
51 double angle, const std::string& name, bool onRoad,
52 const std::string& departPos, bool lefthand) :
53 MSStoppingPlace(id, SUMO_TAG_PARKING_AREA, lines, lane, begPos, endPos, name),
54 myRoadSideCapacity(capacity),
55 myCapacity(0),
56 myOnRoad(onRoad),
57 myWidth(width),
58 myLength(length),
59 myAngle(lefthand ? -angle : angle),
60 myAcceptedBadges(badges.begin(), badges.end()),
61 myEgressBlocked(false),
62 myReservationTime(-1),
63 myLastReservationTime(-1),
64 myReservations(0),
65 myLastReservations(0),
66 myReservationMaxLength(0),
67 myLastReservationMaxLength(0),
68 myMaxVehLength(0),
69 myNumAlternatives(0),
70 myLastStepOccupancy(0),
71 myDepartPos(-1),
72 myDepartPosDefinition(DepartPosDefinition::DEFAULT),
73 myUpdateEvent(nullptr) {
74 // initialize unspecified defaults
75 if (myWidth == 0) {
77 }
78
79 if (departPos != "") {
80 std::string error;
82 throw ProcessError(error);
83 }
85 // maybe allow other methods at a later time
86 throw ProcessError(TLF("Only a numerical departPos is supported for % '%'", toString(myElement), getID()));
87 } else if (myDepartPos < 0 || myDepartPos > lane.getLength()) {
88 throw ProcessError(TLF("Invalid departPos for % '%'", toString(myElement), getID()));
89 }
90 }
91
92 const double offset = (MSGlobals::gLefthand != lefthand) ? -1 : 1;
96 if (!myOnRoad) {
97 myShape.move2side((lane.getWidth() / 2. + myWidth / 2.) * offset);
98 }
99 setRoadsideCapacity(capacity);
100}
101
102
104
105
106void
107MSParkingArea::addLotEntry(double x, double y, double z, double width, double length, double angle, double slope) {
108 // create LotSpaceDefinition
109 LotSpaceDefinition lsd((int)mySpaceOccupancies.size(), nullptr, x, y, z, angle, slope, width, length);
110 // If we are modelling parking set the end position to the lot position relative to the lane
111 // rather than the end of the parking area - this results in vehicles stopping nearer the space
112 // and re-entering the lane nearer the space. (If we are not modelling parking the vehicle will usually
113 // enter the space and re-enter at the end of the parking area.)
115 const double offset = this->getLane().getShape().nearest_offset_to_point2D(lsd.position);
116 if (offset < getBeginLanePosition()) {
117 lsd.endPos = getBeginLanePosition() + POSITION_EPS;
118 } else {
119 if (this->getLane().getLength() > offset) {
120 lsd.endPos = offset;
121 } else {
122 lsd.endPos = this->getLane().getLength() - POSITION_EPS;
123 }
124 }
125 // Work out the angle of the lot relative to the lane (-90 adjusts for the way the bay is drawn )
126 double relativeAngle = fmod(lsd.rotation - 90., 360) - fmod(RAD2DEG(this->getLane().getShape().rotationAtOffset(lsd.endPos)), 360) + 0.5;
127 if (relativeAngle < 0.) {
128 relativeAngle += 360.;
129 }
130 lsd.manoeuverAngle = relativeAngle;
131
132 // if p2.y is -ve the lot is on LHS of lane relative to lane direction
133 // we need to know this because it inverts the complexity of the parking manoeuver
135 if (p2.y() < (0. + POSITION_EPS)) {
136 lsd.sideIsLHS = true;
137 } else {
138 lsd.sideIsLHS = false;
139 }
140 } else {
141 lsd.endPos = myEndPos;
142 lsd.manoeuverAngle = int(angle); // unused unless gModelParkingManoeuver is true
143 lsd.sideIsLHS = true;
144 }
145 mySpaceOccupancies.push_back(lsd);
146 myCapacity++;
148}
149
150int
152 assert(myLastFreeLot >= 0);
153 assert(myLastFreeLot < (int)mySpaceOccupancies.size());
154
156 if (lsd.sideIsLHS) {
157 return abs(int(lsd.manoeuverAngle)) % 180;
158 } else {
159 return abs(abs(int(lsd.manoeuverAngle)) % 180 - 180) % 180;
160 }
161}
162
163double
165 assert(myLastFreeLot >= 0);
166 assert(myLastFreeLot < (int)mySpaceOccupancies.size());
167
169 if (lsd.manoeuverAngle > 180.) {
170 return DEG2RAD(lsd.manoeuverAngle - 360.);
171 } else {
172 return DEG2RAD(lsd.manoeuverAngle);
173 }
174}
175
176
177double
178MSParkingArea::getLastFreePos(const SUMOVehicle& forVehicle, double brakePos) const {
179 if (myCapacity == (int)myEndPositions.size()) {
180 // keep enough space so that parking vehicles can leave
181#ifdef DEBUG_GET_LAST_FREE_POS
182 if (DEBUG_COND2(forVehicle)) {
183 std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " allOccupied\n";
184 }
185#endif
186 return myLastFreePos - forVehicle.getVehicleType().getMinGap() - POSITION_EPS;
187 } else {
188 const double minPos = MIN2(myEndPos, brakePos);
189 if (myLastFreePos >= minPos) {
190#ifdef DEBUG_GET_LAST_FREE_POS
191 if (DEBUG_COND2(forVehicle)) {
192 std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " brakePos=" << brakePos << " myEndPos=" << myEndPos << " using myLastFreePos=" << myLastFreePos << "\n";
193 }
194#endif
195 return myLastFreePos;
196 } else {
197 // find free pos after minPos
198 for (const auto& lsd : mySpaceOccupancies) {
199 if (lsd.vehicle == nullptr && lsd.endPos >= minPos) {
200#ifdef DEBUG_GET_LAST_FREE_POS
201 if (DEBUG_COND2(forVehicle)) {
202 std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " brakePos=" << brakePos << " myEndPos=" << myEndPos << " nextFreePos=" << lsd.endPos << "\n";
203 }
204#endif
205 return lsd.endPos;
206 }
207 }
208 // shouldn't happen. No good solution seems possible
209#ifdef DEBUG_GET_LAST_FREE_POS
210 if (DEBUG_COND2(forVehicle)) {
211 std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " brakePos=" << brakePos << " myEndPos=" << myEndPos << " noGoodFreePos blockedAt=" << brakePos << "\n";
212 }
213#endif
214 return brakePos;
215 }
216 }
217}
218
221 for (const auto& lsd : mySpaceOccupancies) {
222 if (lsd.vehicle == &forVehicle) {
223 return lsd.position;
224 }
225 }
226 return Position::INVALID;
227}
228
229
230double
233 return myDepartPos;
234 }
235 for (const auto& lsd : mySpaceOccupancies) {
236 if (lsd.vehicle == &forVehicle) {
237 return lsd.endPos;
238 }
239 }
240 return -1;
241}
242
243
244double
246 for (const auto& lsd : mySpaceOccupancies) {
247 if (lsd.vehicle == &forVehicle) {
248 return (lsd.rotation - 90.) * (double) M_PI / (double) 180.0;
249 }
250 }
251 return 0;
252}
253
254double
256 for (const auto& lsd : mySpaceOccupancies) {
257 if (lsd.vehicle == &forVehicle) {
258 return lsd.slope;
259 }
260 }
261 return 0;
262}
263
264double
265MSParkingArea::getGUIAngle(const SUMOVehicle& forVehicle) const {
266 for (const auto& lsd : mySpaceOccupancies) {
267 if (lsd.vehicle == &forVehicle) {
268 if (lsd.manoeuverAngle > 180.) {
269 return DEG2RAD(lsd.manoeuverAngle - 360.);
270 } else {
271 return DEG2RAD(lsd.manoeuverAngle);
272 }
273 }
274 }
275 return 0.;
276}
277
278int
280 for (const auto& lsd : mySpaceOccupancies) {
281 if (lsd.vehicle == &forVehicle) {
282 if (lsd.sideIsLHS) {
283 return abs(int(lsd.manoeuverAngle)) % 180;
284 } else {
285 return abs(abs(int(lsd.manoeuverAngle)) % 180 - 180) % 180;
286 }
287 }
288 }
289 return 0;
290}
291
292int
294 if (veh->getPositionOnLane() > myLastFreePos) {
295 // vehicle has gone past myLastFreePos and we need to find the actual lot
296 int closestLot = -1;
297 for (int i = 0; i < (int)mySpaceOccupancies.size(); i++) {
299 if (lsd.vehicle == nullptr) {
300 closestLot = i;
301 if (lsd.endPos >= veh->getPositionOnLane()) {
302 return i;
303 }
304 }
305 }
306 return closestLot;
307 }
308 if (myOnRoad && myLastFreePos - veh->getPositionOnLane() > POSITION_EPS) {
309 // for on-road parking we need to be precise
310 return -1;
311 }
312 return myLastFreeLot;
313}
314
315void
317 double beg = veh->getPositionOnLane() + veh->getVehicleType().getMinGap();
318 double end = veh->getPositionOnLane() - veh->getVehicleType().getLength();
319 if (myUpdateEvent == nullptr) {
322 }
323 int lotIndex = getLotIndex(veh);
324 if (lotIndex < 0) {
325 WRITE_WARNING("Unsuitable parking position for vehicle '" + veh->getID() + "' at parkingArea '" + getID() + "' time=" + time2string(SIMSTEP));
326 lotIndex = myLastFreeLot;
327 }
328#ifdef DEBUG_GET_LAST_FREE_POS
329 ((SUMOVehicleParameter&)veh->getParameter()).setParameter("lotIndex", toString(lotIndex));
330#endif
331 assert(myLastFreePos >= 0);
332 assert(lotIndex < (int)mySpaceOccupancies.size());
333 mySpaceOccupancies[lotIndex].vehicle = veh;
334 myEndPositions[veh] = std::pair<double, double>(beg, end);
337 // current search ends here
339}
340
341
342void
344 assert(myEndPositions.find(what) != myEndPositions.end());
345 if (myUpdateEvent == nullptr) {
348 }
349 for (auto& lsd : mySpaceOccupancies) {
350 if (lsd.vehicle == what) {
351 lsd.vehicle = nullptr;
352 break;
353 }
354 }
355 if (what->getLength() == myMaxVehLength) {
356 myMaxVehLength = 0;
357 for (auto item : myEndPositions) {
358 myMaxVehLength = MAX2(myMaxVehLength, item.first->getLength());
359 }
360 }
361 myEndPositions.erase(myEndPositions.find(what));
363}
364
365
369 myUpdateEvent = nullptr;
370 return 0;
371}
372
373
375 index(-1),
376 vehicle(nullptr),
377 rotation(0),
378 slope(0),
379 width(0),
380 length(0),
381 endPos(0),
382 manoeuverAngle(0),
383 sideIsLHS(false) {
384}
385
386
387MSParkingArea::LotSpaceDefinition::LotSpaceDefinition(int index_, SUMOVehicle* vehicle_, double x, double y, double z, double rotation_, double slope_, double width_, double length_) :
388 index(index_),
389 vehicle(vehicle_),
390 position(Position(x, y, z)),
391 rotation(rotation_),
392 slope(slope_),
393 width(width_),
394 length(length_),
395 endPos(0),
396 manoeuverAngle(0),
397 sideIsLHS(false) {
398}
399
400
401void
403 myLastFreeLot = -1;
405 myEgressBlocked = false;
406 for (auto& lsd : mySpaceOccupancies) {
407 if (lsd.vehicle == nullptr
408 || (getOccupancy() == getCapacity()
409 && lsd.vehicle->remainingStopDuration() <= 0
410 && !lsd.vehicle->isStoppedTriggered())) {
411 if (lsd.vehicle == nullptr) {
412 myLastFreeLot = lsd.index;
413 myLastFreePos = lsd.endPos;
414 } else {
415 // vehicle wants to exit the parking area
416 myLastFreeLot = lsd.index;
417 myLastFreePos = lsd.endPos - lsd.vehicle->getVehicleType().getLength() - POSITION_EPS;
418 myEgressBlocked = true;
419 }
420 break;
421 } else {
423 lsd.endPos - lsd.vehicle->getVehicleType().getLength() - NUMERICAL_EPS);
424 }
425 }
426}
427
428
429double
431 // do not perform reservation when far away
432 if (forVehicle.getLane() != &myLane || forVehicle.getPositionOnLane() < (myBegPos - myMaxVehLength - forVehicle.getVehicleType().getMinGap())) {
433 // for different lanes, do not consider reservations to avoid lane-order
434 // dependency in parallel simulation
435#ifdef DEBUG_RESERVATIONS
436 if (DEBUG_COND2(forVehicle)) {
437 std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID() << " other lane\n";
438 }
439#endif
440 if (myNumAlternatives > 0 && getOccupancy() == getCapacity()) {
441 // ensure that the vehicle reaches the rerouter lane
442 if (mySpaceOccupancies.size() > 0) {
443 assert(mySpaceOccupancies[0].vehicle != nullptr);
444 const double waitPos = (mySpaceOccupancies[0].endPos
445 - mySpaceOccupancies[0].vehicle->getLength()
446 - forVehicle.getVehicleType().getMinGap()
447 - NUMERICAL_EPS);
448 return MAX2(waitPos, MIN2(POSITION_EPS, myEndPos));
449 } else {
450 return MAX2(myBegPos, MIN2(POSITION_EPS, myEndPos));
451 }
452 } else {
453 // check if there is a reservation from the last time step
454 // (this could also be in myReserations, if myLane wasn't processed before the forVehicle-lane)
455 const SUMOTime last = t - DELTA_T;
456 if (DEBUG_COND2(forVehicle)) std::cout << SIMTIME << " last=" << time2string(last) << " lastRes=" << time2string(myLastReservationTime) << " resTime=" << toString(myReservationTime) << "\n";
457 if (myLastReservationTime == last || myReservationTime == last) {
459 if (myCapacity <= getOccupancy() + res) {
461#ifdef DEBUG_RESERVATIONS
462 if (DEBUG_COND2(forVehicle)) std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID()
463 << " lastRes=" << res << " resTime=" << myReservationTime << " reserved full, maxLen=" << maxLen << " endPos=" << mySpaceOccupancies[0].endPos << "\n";
464#endif
465 return (mySpaceOccupancies[0].endPos
466 - maxLen
467 - forVehicle.getVehicleType().getMinGap()
468 - NUMERICAL_EPS);
469 }
470 }
471 return getLastFreePos(forVehicle, brakePos);
472 }
473 }
474 if (t > myReservationTime) {
475#ifdef DEBUG_RESERVATIONS
476 if (DEBUG_COND2(forVehicle)) {
477 std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID() << " first reservation\n";
478 }
479#endif
484 myReservations = 1;
486 myReservedVehicles.clear();
487 myReservedVehicles.insert(&forVehicle);
488 for (const auto& lsd : mySpaceOccupancies) {
489 if (lsd.vehicle != nullptr) {
490 myReservationMaxLength = MAX2(myReservationMaxLength, lsd.vehicle->getVehicleType().getLength());
491 }
492 }
493 return getLastFreePos(forVehicle, brakePos);
494 } else {
496#ifdef DEBUG_RESERVATIONS
497 if (DEBUG_COND2(forVehicle)) {
498 std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID() << " res=" << myReservations << " enough space\n";
499 }
500#endif
503 myReservedVehicles.insert(&forVehicle);
504 return getLastFreePos(forVehicle, brakePos);
505 } else {
506 if (myCapacity == 0) {
507 return getLastFreePos(forVehicle, brakePos);
508 } else {
509#ifdef DEBUG_RESERVATIONS
510 if (DEBUG_COND2(forVehicle)) std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID()
511 << " res=" << myReservations << " resTime=" << myReservationTime << " reserved full, maxLen=" << myReservationMaxLength << " endPos=" << mySpaceOccupancies[0].endPos << "\n";
512#endif
513 return (mySpaceOccupancies[0].endPos
515 - forVehicle.getVehicleType().getMinGap()
516 - NUMERICAL_EPS);
517 }
518 }
519 }
520}
521
522
523double
525 return myWidth;
526}
527
528
529double
531 return myLength;
532}
533
534
535double
537 return myAngle;
538}
539
540
541int
543 return myCapacity;
544}
545
546
547bool
549 return myOnRoad;
550}
551
552
553int
555 return (int)myEndPositions.size() - (myEgressBlocked ? 1 : 0);
556}
557
558
559int
561 return (int)myEndPositions.size();
562}
563
564int
566 if (myReservedVehicles.count(forVehicle) != 0) {
567 return (int)myEndPositions.size();
568 } else {
569 return (int)myEndPositions.size() + myReservations;
570 }
571}
572
573int
577
578
579void
580MSParkingArea::accept(std::string badge) {
581 myAcceptedBadges.insert(badge);
582}
583
584
585void
586MSParkingArea::accept(std::vector<std::string> badges) {
587 myAcceptedBadges.insert(badges.begin(), badges.end());
588}
589
590
591void
592MSParkingArea::refuse(std::string badge) {
593 myAcceptedBadges.erase(badge);
594}
595
596
597bool
599 if (myAcceptedBadges.size() == 0) {
600 return true;
601 } else {
602 std::vector<std::string> vehicleBadges = veh->getParkingBadges();
603 for (auto badge : vehicleBadges) {
604 if (myAcceptedBadges.count(badge) != 0) {
605 return true;
606 }
607 }
608 return false;
609 }
610}
611
612
613void
617
618
619int
623
624
625void
628}
629
630
631std::vector<std::string>
633 std::vector<std::string> result(myAcceptedBadges.begin(), myAcceptedBadges.end());
634 return result;
635}
636
637
638void
639MSParkingArea::setAcceptedBadges(const std::vector<std::string>& badges) {
640 myAcceptedBadges.clear();
641 myAcceptedBadges.insert(badges.begin(), badges.end());
642}
643
644
645const std::vector<MSParkingArea::LotSpaceDefinition>&
649
650
651const PositionVector&
653 return myShape;
654}
655
656
657void
659 // reinit parking lot generation process
660 myRoadSideCapacity = capacity;
661
662 // Initialize space occupancies if there is a road-side capacity
663 // The overall number of lots is fixed and each lot accepts one vehicle regardless of size
665 if (myLength == 0) {
666 myLength = spaceDim;
667 }
668 mySpaceOccupancies.clear();
669 myCapacity = 0;
670 for (int i = 0; i < myRoadSideCapacity; ++i) {
671 // calculate pos, angle and slope of parking lot space
673 double spaceAngle = GeomHelper::calculateLotSpaceAngle(myShape, i, spaceDim, myAngle);
674 double spaceSlope = GeomHelper::calculateLotSpaceSlope(myShape, i, spaceDim);
675 // add lotEntry
676 addLotEntry(pos.x(), pos.y(), pos.z(), myWidth, myLength, spaceAngle, spaceSlope);
677 // update endPos
678 mySpaceOccupancies.back().endPos = MIN2(myEndPos, myBegPos + MAX2(POSITION_EPS, spaceDim * (i + 1)));
679 }
680}
681
682/****************************************************************************/
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:54
#define WRITE_WARNING(msg)
Definition MsgHandler.h:287
#define TLF(string,...)
Definition MsgHandler.h:307
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: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
double getLength() const
Returns the lane's length.
Definition MSLane.h:611
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:640
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:487
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
const PositionVector & getShape() const
get the parking shape
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(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.
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: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 double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
Definition SUMOVehicle.h:62
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.