Eclipse SUMO - Simulation of Urban MObility
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-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
19 // A area where vehicles can park next to the road
20 /****************************************************************************/
21 #include <config.h>
22 
23 #include <cassert>
26 #include <utils/geom/Position.h>
27 #include <utils/geom/GeomHelper.h>
29 #include <microsim/MSNet.h>
30 #include <microsim/MSVehicle.h>
31 #include <microsim/MSVehicleType.h>
32 #include "MSLane.h"
34 #include "MSParkingArea.h"
35 #include "MSGlobals.h"
36 
37 //#define DEBUG_RESERVATIONS
38 //#define DEBUG_GET_LAST_FREE_POS
39 //#define DEBUG_COND2(obj) (obj.getID() == "v.3")
40 #define DEBUG_COND2(obj) (obj.isSelected())
41 
42 
43 // ===========================================================================
44 // method definitions
45 // ===========================================================================
46 MSParkingArea::MSParkingArea(const std::string& id, const std::vector<std::string>& lines,
47  const std::vector<std::string>& badges, MSLane& lane,
48  double begPos, double endPos, int capacity, double width, double length,
49  double angle, const std::string& name, bool onRoad,
50  const std::string& departPos, bool lefthand) :
51  MSStoppingPlace(id, SUMO_TAG_PARKING_AREA, lines, lane, begPos, endPos, name),
52  myRoadSideCapacity(capacity),
53  myCapacity(0),
54  myOnRoad(onRoad),
55  myWidth(width),
56  myLength(length),
57  myAngle(lefthand ? -angle : angle),
58  myAcceptedBadges(badges.begin(), badges.end()),
59  myEgressBlocked(false),
60  myReservationTime(-1),
61  myReservations(0),
62  myReservationMaxLength(0),
63  myNumAlternatives(0),
64  myLastStepOccupancy(0),
65  myDepartPos(-1),
66  myDepartPosDefinition(DepartPosDefinition::DEFAULT),
67  myUpdateEvent(nullptr) {
68  // initialize unspecified defaults
69  if (myWidth == 0) {
71  }
72  const double spaceDim = capacity > 0 ? myLane.interpolateLanePosToGeometryPos((myEndPos - myBegPos) / capacity) : 7.5;
73  if (myLength == 0) {
74  myLength = spaceDim;
75  }
76  if (departPos != "") {
77  std::string error;
79  throw ProcessError(error);
80  }
82  // maybe allow other methods at a later time
83  throw ProcessError("Only a numerical departPos is supported for " + toString(myElement) + " '" + getID() + "'");
84  } else if (myDepartPos < 0 || myDepartPos > lane.getLength()) {
85  throw ProcessError("Invalid departPos for " + toString(myElement) + " '" + getID() + "'");
86  }
87  }
88 
89  const double offset = (MSGlobals::gLefthand != lefthand) ? -1 : 1;
90  myShape = lane.getShape().getSubpart(
92  lane.interpolateLanePosToGeometryPos(endPos));
93  if (!myOnRoad) {
94  myShape.move2side((lane.getWidth() / 2. + myWidth / 2.) * offset);
95  }
96  // Initialize space occupancies if there is a road-side capacity
97  // The overall number of lots is fixed and each lot accepts one vehicle regardless of size
98  for (int i = 0; i < capacity; ++i) {
99  // calculate pos, angle and slope of parking lot space
101  double spaceAngle = GeomHelper::calculateLotSpaceAngle(myShape, i, spaceDim, myAngle);
102  double spaceSlope = GeomHelper::calculateLotSpaceSlope(myShape, i, spaceDim);
103  // add lotEntry
104  addLotEntry(pos.x(), pos.y(), pos.z(), myWidth, myLength, spaceAngle, spaceSlope);
105  // update endPos
106  mySpaceOccupancies.back().endPos = MIN2(myEndPos, myBegPos + MAX2(POSITION_EPS, spaceDim * (i + 1)));
107  }
109 }
110 
111 
113 
114 
115 void
116 MSParkingArea::addLotEntry(double x, double y, double z, double width, double length, double angle, double slope) {
117  // create LotSpaceDefinition
118  LotSpaceDefinition lsd((int)mySpaceOccupancies.size(), nullptr, x, y, z, angle, slope, width, length);
119  // If we are modelling parking set the end position to the lot position relative to the lane
120  // rather than the end of the parking area - this results in vehicles stopping nearer the space
121  // and re-entering the lane nearer the space. (If we are not modelling parking the vehicle will usually
122  // enter the space and re-enter at the end of the parking area.)
124  const double offset = this->getLane().getShape().nearest_offset_to_point2D(lsd.position);
125  if (offset < getBeginLanePosition()) {
126  lsd.endPos = getBeginLanePosition() + POSITION_EPS;
127  } else {
128  if (this->getLane().getLength() > offset) {
129  lsd.endPos = offset;
130  } else {
131  lsd.endPos = this->getLane().getLength() - POSITION_EPS;
132  }
133  }
134  // Work out the angle of the lot relative to the lane (-90 adjusts for the way the bay is drawn )
135  double relativeAngle = fmod(lsd.rotation - 90., 360) - fmod(RAD2DEG(this->getLane().getShape().rotationAtOffset(lsd.endPos)), 360) + 0.5;
136  if (relativeAngle < 0.) {
137  relativeAngle += 360.;
138  }
139  lsd.manoeuverAngle = relativeAngle;
140 
141  // if p2.y is -ve the lot is on LHS of lane relative to lane direction
142  // we need to know this because it inverts the complexity of the parking manoeuver
144  if (p2.y() < (0. + POSITION_EPS)) {
145  lsd.sideIsLHS = true;
146  } else {
147  lsd.sideIsLHS = false;
148  }
149  } else {
150  lsd.endPos = myEndPos;
151  lsd.manoeuverAngle = int(angle); // unused unless gModelParkingManoeuver is true
152  lsd.sideIsLHS = true;
153  }
154  mySpaceOccupancies.push_back(lsd);
155  myCapacity++;
157 }
158 
159 int
161  assert(myLastFreeLot >= 0);
162  assert(myLastFreeLot < (int)mySpaceOccupancies.size());
163 
165  if (lsd.sideIsLHS) {
166  return abs(int(lsd.manoeuverAngle)) % 180;
167  } else {
168  return abs(abs(int(lsd.manoeuverAngle)) % 180 - 180) % 180;
169  }
170 }
171 
172 double
174  assert(myLastFreeLot >= 0);
175  assert(myLastFreeLot < (int)mySpaceOccupancies.size());
176 
178  if (lsd.manoeuverAngle > 180.) {
179  return DEG2RAD(lsd.manoeuverAngle - 360.);
180  } else {
181  return DEG2RAD(lsd.manoeuverAngle);
182  }
183 }
184 
185 
186 double
187 MSParkingArea::getLastFreePos(const SUMOVehicle& forVehicle, double brakePos) const {
188  if (myCapacity == (int)myEndPositions.size()) {
189  // keep enough space so that parking vehicles can leave
190 #ifdef DEBUG_GET_LAST_FREE_POS
191  if (DEBUG_COND2(forVehicle)) {
192  std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " allOccupied\n";
193  }
194 #endif
195  return myLastFreePos - forVehicle.getVehicleType().getMinGap() - POSITION_EPS;
196  } else {
197  const double minPos = MIN2(myEndPos, brakePos);
198  if (myLastFreePos >= 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 << " using myLastFreePos=" << myLastFreePos << "\n";
202  }
203 #endif
204  return myLastFreePos;
205  } else {
206  // find free pos after minPos
207  for (const auto& lsd : mySpaceOccupancies) {
208  if (lsd.vehicle == nullptr && lsd.endPos >= minPos) {
209 #ifdef DEBUG_GET_LAST_FREE_POS
210  if (DEBUG_COND2(forVehicle)) {
211  std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " brakePos=" << brakePos << " myEndPos=" << myEndPos << " nextFreePos=" << lsd.endPos << "\n";
212  }
213 #endif
214  return lsd.endPos;
215  }
216  }
217  // shouldn't happen. No good solution seems possible
218 #ifdef DEBUG_GET_LAST_FREE_POS
219  if (DEBUG_COND2(forVehicle)) {
220  std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " brakePos=" << brakePos << " myEndPos=" << myEndPos << " noGoodFreePos blockedAt=" << brakePos << "\n";
221  }
222 #endif
223  return brakePos;
224  }
225  }
226 }
227 
228 Position
230  for (const auto& lsd : mySpaceOccupancies) {
231  if (lsd.vehicle == &forVehicle) {
232  return lsd.position;
233  }
234  }
235  return Position::INVALID;
236 }
237 
238 
239 double
242  return myDepartPos;
243  }
244  for (const auto& lsd : mySpaceOccupancies) {
245  if (lsd.vehicle == &forVehicle) {
246  return lsd.endPos;
247  }
248  }
249  return -1;
250 }
251 
252 
253 double
254 MSParkingArea::getVehicleAngle(const SUMOVehicle& forVehicle) const {
255  for (const auto& lsd : mySpaceOccupancies) {
256  if (lsd.vehicle == &forVehicle) {
257  return (lsd.rotation - 90.) * (double) M_PI / (double) 180.0;
258  }
259  }
260  return 0;
261 }
262 
263 double
264 MSParkingArea::getVehicleSlope(const SUMOVehicle& forVehicle) const {
265  for (const auto& lsd : mySpaceOccupancies) {
266  if (lsd.vehicle == &forVehicle) {
267  return lsd.slope;
268  }
269  }
270  return 0;
271 }
272 
273 double
274 MSParkingArea::getGUIAngle(const SUMOVehicle& forVehicle) const {
275  for (const auto& lsd : mySpaceOccupancies) {
276  if (lsd.vehicle == &forVehicle) {
277  if (lsd.manoeuverAngle > 180.) {
278  return DEG2RAD(lsd.manoeuverAngle - 360.);
279  } else {
280  return DEG2RAD(lsd.manoeuverAngle);
281  }
282  }
283  }
284  return 0.;
285 }
286 
287 int
289  for (const auto& lsd : mySpaceOccupancies) {
290  if (lsd.vehicle == &forVehicle) {
291  if (lsd.sideIsLHS) {
292  return abs(int(lsd.manoeuverAngle)) % 180;
293  } else {
294  return abs(abs(int(lsd.manoeuverAngle)) % 180 - 180) % 180;
295  }
296  }
297  }
298  return 0;
299 }
300 
301 int
303  if (veh->getPositionOnLane() > myLastFreePos) {
304  // vehicle has gone past myLastFreePos and we need to find the actual lot
305  int closestLot = -1;
306  for (int i = 0; i < (int)mySpaceOccupancies.size(); i++) {
307  const LotSpaceDefinition lsd = mySpaceOccupancies[i];
308  if (lsd.vehicle == nullptr) {
309  closestLot = i;
310  if (lsd.endPos >= veh->getPositionOnLane()) {
311  return i;
312  }
313  }
314  }
315  return closestLot;
316  }
317  if (myOnRoad && myLastFreePos - veh->getPositionOnLane() > POSITION_EPS) {
318  // for on-road parking we need to be precise
319  return -1;
320  }
321  return myLastFreeLot;
322 }
323 
324 void
326  double beg = veh->getPositionOnLane() + veh->getVehicleType().getMinGap();
327  double end = veh->getPositionOnLane() - veh->getVehicleType().getLength();
328  if (myUpdateEvent == nullptr) {
331  }
332  int lotIndex = getLotIndex(veh);
333  if (lotIndex < 0) {
334  WRITE_WARNING("Unsuitable parking position for vehicle '" + veh->getID() + "' at parkingArea '" + getID() + "' time=" + time2string(SIMSTEP));
335  lotIndex = myLastFreeLot;
336  }
337 #ifdef DEBUG_GET_LAST_FREE_POS
338  ((SUMOVehicleParameter&)veh->getParameter()).setParameter("lotIndex", toString(lotIndex));
339 #endif
340  assert(myLastFreePos >= 0);
341  assert(lotIndex < (int)mySpaceOccupancies.size());
342  mySpaceOccupancies[lotIndex].vehicle = veh;
343  myEndPositions[veh] = std::pair<double, double>(beg, end);
345  // current search ends here
346  veh->setNumberParkingReroutes(0);
347 }
348 
349 
350 void
352  assert(myEndPositions.find(what) != myEndPositions.end());
353  if (myUpdateEvent == nullptr) {
356  }
357  for (auto& lsd : mySpaceOccupancies) {
358  if (lsd.vehicle == what) {
359  lsd.vehicle = nullptr;
360  break;
361  }
362  }
363  myEndPositions.erase(myEndPositions.find(what));
365 }
366 
367 
368 SUMOTime
371  myUpdateEvent = nullptr;
372  return 0;
373 }
374 
375 
377  index(-1),
378  vehicle(nullptr),
379  rotation(0),
380  slope(0),
381  width(0),
382  length(0),
383  endPos(0),
384  manoeuverAngle(0),
385  sideIsLHS(false) {
386 }
387 
388 
389 MSParkingArea::LotSpaceDefinition::LotSpaceDefinition(int index_, SUMOVehicle* vehicle_, double x, double y, double z, double rotation_, double slope_, double width_, double length_) :
390  index(index_),
391  vehicle(vehicle_),
392  position(Position(x, y, z)),
393  rotation(rotation_),
394  slope(slope_),
395  width(width_),
396  length(length_),
397  endPos(0),
398  manoeuverAngle(0),
399  sideIsLHS(false) {
400 }
401 
402 
403 void
405  myLastFreeLot = -1;
407  myEgressBlocked = false;
408  for (auto& lsd : mySpaceOccupancies) {
409  if (lsd.vehicle == nullptr
410  || (getOccupancy() == getCapacity()
411  && lsd.vehicle->remainingStopDuration() <= 0
412  && !lsd.vehicle->isStoppedTriggered())) {
413  if (lsd.vehicle == nullptr) {
414  myLastFreeLot = lsd.index;
415  myLastFreePos = lsd.endPos;
416  } else {
417  // vehicle wants to exit the parking area
418  myLastFreeLot = lsd.index;
419  myLastFreePos = lsd.endPos - lsd.vehicle->getVehicleType().getLength() - POSITION_EPS;
420  myEgressBlocked = true;
421  }
422  break;
423  } else {
425  lsd.endPos - lsd.vehicle->getVehicleType().getLength() - NUMERICAL_EPS);
426  }
427  }
428 }
429 
430 
431 double
432 MSParkingArea::getLastFreePosWithReservation(SUMOTime t, const SUMOVehicle& forVehicle, double brakePos) {
433  if (forVehicle.getLane() != &myLane) {
434  // for different lanes, do not consider reservations to avoid lane-order
435  // dependency in parallel simulation
436 #ifdef DEBUG_RESERVATIONS
437  if (DEBUG_COND2(forVehicle)) {
438  std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID() << " other lane\n";
439  }
440 #endif
441  if (myNumAlternatives > 0 && getOccupancy() == getCapacity()) {
442  // ensure that the vehicle reaches the rerouter lane
443  return MAX2(myBegPos, MIN2(POSITION_EPS, myEndPos));
444  } else {
445  return getLastFreePos(forVehicle, brakePos);
446  }
447  }
448  if (t > myReservationTime) {
449 #ifdef DEBUG_RESERVATIONS
450  if (DEBUG_COND2(forVehicle)) {
451  std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID() << " first reservation\n";
452  }
453 #endif
454  myReservationTime = t;
455  myReservations = 1;
457  for (const auto& lsd : mySpaceOccupancies) {
458  if (lsd.vehicle != nullptr) {
459  myReservationMaxLength = MAX2(myReservationMaxLength, lsd.vehicle->getVehicleType().getLength());
460  }
461  }
462  return getLastFreePos(forVehicle, brakePos);
463  } else {
465 #ifdef DEBUG_RESERVATIONS
466  if (DEBUG_COND2(forVehicle)) {
467  std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID() << " res=" << myReservations << " enough space\n";
468  }
469 #endif
470  myReservations++;
472  return getLastFreePos(forVehicle, brakePos);
473  } else {
474  if (myCapacity == 0) {
475  return getLastFreePos(forVehicle, brakePos);
476  } else {
477 #ifdef DEBUG_RESERVATIONS
478  if (DEBUG_COND2(forVehicle)) std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID()
479  << " res=" << myReservations << " resTime=" << myReservationTime << " reserved full, maxLen=" << myReservationMaxLength << " endPos=" << mySpaceOccupancies[0].endPos << "\n";
480 #endif
481  return (mySpaceOccupancies[0].endPos
483  - forVehicle.getVehicleType().getMinGap()
484  - NUMERICAL_EPS);
485  }
486  }
487  }
488 }
489 
490 
491 double
493  return myWidth;
494 }
495 
496 
497 double
499  return myLength;
500 }
501 
502 
503 double
505  return myAngle;
506 }
507 
508 
509 int
511  return myCapacity;
512 }
513 
514 
515 bool
517  return myOnRoad;
518 }
519 
520 
521 int
523  return (int)myEndPositions.size() - (myEgressBlocked ? 1 : 0);
524 }
525 
526 
527 int
529  return (int)myEndPositions.size();
530 }
531 
532 
533 int
535  return myLastStepOccupancy;
536 }
537 
538 
539 void
540 MSParkingArea::accept(std::string badge) {
541  myAcceptedBadges.insert(badge);
542 }
543 
544 
545 void
546 MSParkingArea::accept(std::vector<std::string> badges) {
547  myAcceptedBadges.insert(badges.begin(), badges.end());
548 }
549 
550 
551 void
552 MSParkingArea::refuse(std::string badge) {
553  myAcceptedBadges.erase(badge);
554 }
555 
556 
557 bool
559  if (myAcceptedBadges.size() == 0) {
560  return true;
561  } else {
562  std::vector<std::string> vehicleBadges = veh->getParkingBadges();
563  for (auto badge : vehicleBadges) {
564  if (myAcceptedBadges.count(badge) != 0) {
565  return true;
566  }
567  }
568  return false;
569  }
570 }
571 
572 
573 void
576 }
577 
578 
579 int
581  return myNumAlternatives;
582 }
583 
584 
585 void
587  myNumAlternatives = MAX2(myNumAlternatives, alternatives);
588 }
589 
590 /****************************************************************************/
long long int SUMOTime
Definition: GUI.h:35
@ DEFAULT
default cursor
#define DEG2RAD(x)
Definition: GeomHelper.h:35
#define RAD2DEG(x)
Definition: GeomHelper.h:36
#define DEBUG_COND2(obj)
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:295
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition: SUMOTime.cpp:69
#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
Definition: GeomHelper.cpp:280
static double calculateLotSpaceAngle(const PositionVector &shape, const int index, const double spaceDim, const double angle)
calculate lotSpace angle
Definition: GeomHelper.cpp:319
static double calculateLotSpaceSlope(const PositionVector &shape, const int index, const double spaceDim)
calculate lotSpace slope
Definition: GeomHelper.cpp:329
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:55
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:157
static bool gLefthand
Whether lefthand-drive is being simulated.
Definition: MSGlobals.h:169
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
double getLength() const
Returns the lane's length.
Definition: MSLane.h:598
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:546
double getWidth() const
Returns the lane's width.
Definition: MSLane.h:627
virtual const PositionVector & getShape(bool) const
Definition: MSLane.h:294
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:182
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
Definition: MSNet.h:481
void notifyEgressBlocked()
update state so that vehicles wishing to enter cooperate with exiting vehicles
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)
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 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.
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.
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.
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.
Position getVehiclePosition(const SUMOVehicle &forVehicle) const
Returns the position of parked vehicle.
std::set< std::string > myAcceptedBadges
The parking badges to grant access.
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:317
double x() const
Returns the x-position.
Definition: Position.h:55
double z() const
Returns the z-position.
Definition: Position.h:65
double y() const
Returns the y-position.
Definition: Position.h:60
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 SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual const MSLane * getLane() const =0
Returns the lane the object is currently at.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
Definition: SUMOVehicle.h:60
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.