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 /****************************************************************************/
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>
28 #include <utils/geom/GeomHelper.h>
30 #include <microsim/MSNet.h>
31 #include <microsim/MSVehicle.h>
32 #include <microsim/MSVehicleType.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 // ===========================================================================
47 MSParkingArea::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  myReservations(0),
63  myReservationMaxLength(0),
64  myNumAlternatives(0),
65  myLastStepOccupancy(0),
66  myDepartPos(-1),
67  myDepartPosDefinition(DepartPosDefinition::DEFAULT),
68  myUpdateEvent(nullptr) {
69  // initialize unspecified defaults
70  if (myWidth == 0) {
72  }
73 
74  if (departPos != "") {
75  std::string error;
77  throw ProcessError(error);
78  }
80  // maybe allow other methods at a later time
81  throw ProcessError("Only a numerical departPos is supported for " + toString(myElement) + " '" + getID() + "'");
82  } else if (myDepartPos < 0 || myDepartPos > lane.getLength()) {
83  throw ProcessError("Invalid departPos for " + toString(myElement) + " '" + getID() + "'");
84  }
85  }
86 
87  const double offset = (MSGlobals::gLefthand != lefthand) ? -1 : 1;
88  myShape = lane.getShape().getSubpart(
90  lane.interpolateLanePosToGeometryPos(endPos));
91  if (!myOnRoad) {
92  myShape.move2side((lane.getWidth() / 2. + myWidth / 2.) * offset);
93  }
94  setRoadsideCapacity(capacity);
95 }
96 
97 
99 
100 
101 void
102 MSParkingArea::addLotEntry(double x, double y, double z, double width, double length, double angle, double slope) {
103  // create LotSpaceDefinition
104  LotSpaceDefinition lsd((int)mySpaceOccupancies.size(), nullptr, x, y, z, angle, slope, width, length);
105  // If we are modelling parking set the end position to the lot position relative to the lane
106  // rather than the end of the parking area - this results in vehicles stopping nearer the space
107  // and re-entering the lane nearer the space. (If we are not modelling parking the vehicle will usually
108  // enter the space and re-enter at the end of the parking area.)
110  const double offset = this->getLane().getShape().nearest_offset_to_point2D(lsd.position);
111  if (offset < getBeginLanePosition()) {
112  lsd.endPos = getBeginLanePosition() + POSITION_EPS;
113  } else {
114  if (this->getLane().getLength() > offset) {
115  lsd.endPos = offset;
116  } else {
117  lsd.endPos = this->getLane().getLength() - POSITION_EPS;
118  }
119  }
120  // Work out the angle of the lot relative to the lane (-90 adjusts for the way the bay is drawn )
121  double relativeAngle = fmod(lsd.rotation - 90., 360) - fmod(RAD2DEG(this->getLane().getShape().rotationAtOffset(lsd.endPos)), 360) + 0.5;
122  if (relativeAngle < 0.) {
123  relativeAngle += 360.;
124  }
125  lsd.manoeuverAngle = relativeAngle;
126 
127  // if p2.y is -ve the lot is on LHS of lane relative to lane direction
128  // we need to know this because it inverts the complexity of the parking manoeuver
130  if (p2.y() < (0. + POSITION_EPS)) {
131  lsd.sideIsLHS = true;
132  } else {
133  lsd.sideIsLHS = false;
134  }
135  } else {
136  lsd.endPos = myEndPos;
137  lsd.manoeuverAngle = int(angle); // unused unless gModelParkingManoeuver is true
138  lsd.sideIsLHS = true;
139  }
140  mySpaceOccupancies.push_back(lsd);
141  myCapacity++;
143 }
144 
145 int
147  assert(myLastFreeLot >= 0);
148  assert(myLastFreeLot < (int)mySpaceOccupancies.size());
149 
151  if (lsd.sideIsLHS) {
152  return abs(int(lsd.manoeuverAngle)) % 180;
153  } else {
154  return abs(abs(int(lsd.manoeuverAngle)) % 180 - 180) % 180;
155  }
156 }
157 
158 double
160  assert(myLastFreeLot >= 0);
161  assert(myLastFreeLot < (int)mySpaceOccupancies.size());
162 
164  if (lsd.manoeuverAngle > 180.) {
165  return DEG2RAD(lsd.manoeuverAngle - 360.);
166  } else {
167  return DEG2RAD(lsd.manoeuverAngle);
168  }
169 }
170 
171 
172 double
173 MSParkingArea::getLastFreePos(const SUMOVehicle& forVehicle, double brakePos) const {
174  if (myCapacity == (int)myEndPositions.size()) {
175  // keep enough space so that parking vehicles can leave
176 #ifdef DEBUG_GET_LAST_FREE_POS
177  if (DEBUG_COND2(forVehicle)) {
178  std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " allOccupied\n";
179  }
180 #endif
181  return myLastFreePos - forVehicle.getVehicleType().getMinGap() - POSITION_EPS;
182  } else {
183  const double minPos = MIN2(myEndPos, brakePos);
184  if (myLastFreePos >= minPos) {
185 #ifdef DEBUG_GET_LAST_FREE_POS
186  if (DEBUG_COND2(forVehicle)) {
187  std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " brakePos=" << brakePos << " myEndPos=" << myEndPos << " using myLastFreePos=" << myLastFreePos << "\n";
188  }
189 #endif
190  return myLastFreePos;
191  } else {
192  // find free pos after minPos
193  for (const auto& lsd : mySpaceOccupancies) {
194  if (lsd.vehicle == nullptr && lsd.endPos >= minPos) {
195 #ifdef DEBUG_GET_LAST_FREE_POS
196  if (DEBUG_COND2(forVehicle)) {
197  std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " brakePos=" << brakePos << " myEndPos=" << myEndPos << " nextFreePos=" << lsd.endPos << "\n";
198  }
199 #endif
200  return lsd.endPos;
201  }
202  }
203  // shouldn't happen. No good solution seems possible
204 #ifdef DEBUG_GET_LAST_FREE_POS
205  if (DEBUG_COND2(forVehicle)) {
206  std::cout << SIMTIME << " getLastFreePos veh=" << forVehicle.getID() << " brakePos=" << brakePos << " myEndPos=" << myEndPos << " noGoodFreePos blockedAt=" << brakePos << "\n";
207  }
208 #endif
209  return brakePos;
210  }
211  }
212 }
213 
214 Position
216  for (const auto& lsd : mySpaceOccupancies) {
217  if (lsd.vehicle == &forVehicle) {
218  return lsd.position;
219  }
220  }
221  return Position::INVALID;
222 }
223 
224 
225 double
228  return myDepartPos;
229  }
230  for (const auto& lsd : mySpaceOccupancies) {
231  if (lsd.vehicle == &forVehicle) {
232  return lsd.endPos;
233  }
234  }
235  return -1;
236 }
237 
238 
239 double
240 MSParkingArea::getVehicleAngle(const SUMOVehicle& forVehicle) const {
241  for (const auto& lsd : mySpaceOccupancies) {
242  if (lsd.vehicle == &forVehicle) {
243  return (lsd.rotation - 90.) * (double) M_PI / (double) 180.0;
244  }
245  }
246  return 0;
247 }
248 
249 double
250 MSParkingArea::getVehicleSlope(const SUMOVehicle& forVehicle) const {
251  for (const auto& lsd : mySpaceOccupancies) {
252  if (lsd.vehicle == &forVehicle) {
253  return lsd.slope;
254  }
255  }
256  return 0;
257 }
258 
259 double
260 MSParkingArea::getGUIAngle(const SUMOVehicle& forVehicle) const {
261  for (const auto& lsd : mySpaceOccupancies) {
262  if (lsd.vehicle == &forVehicle) {
263  if (lsd.manoeuverAngle > 180.) {
264  return DEG2RAD(lsd.manoeuverAngle - 360.);
265  } else {
266  return DEG2RAD(lsd.manoeuverAngle);
267  }
268  }
269  }
270  return 0.;
271 }
272 
273 int
275  for (const auto& lsd : mySpaceOccupancies) {
276  if (lsd.vehicle == &forVehicle) {
277  if (lsd.sideIsLHS) {
278  return abs(int(lsd.manoeuverAngle)) % 180;
279  } else {
280  return abs(abs(int(lsd.manoeuverAngle)) % 180 - 180) % 180;
281  }
282  }
283  }
284  return 0;
285 }
286 
287 int
289  if (veh->getPositionOnLane() > myLastFreePos) {
290  // vehicle has gone past myLastFreePos and we need to find the actual lot
291  int closestLot = -1;
292  for (int i = 0; i < (int)mySpaceOccupancies.size(); i++) {
293  const LotSpaceDefinition lsd = mySpaceOccupancies[i];
294  if (lsd.vehicle == nullptr) {
295  closestLot = i;
296  if (lsd.endPos >= veh->getPositionOnLane()) {
297  return i;
298  }
299  }
300  }
301  return closestLot;
302  }
303  if (myOnRoad && myLastFreePos - veh->getPositionOnLane() > POSITION_EPS) {
304  // for on-road parking we need to be precise
305  return -1;
306  }
307  return myLastFreeLot;
308 }
309 
310 void
312  double beg = veh->getPositionOnLane() + veh->getVehicleType().getMinGap();
313  double end = veh->getPositionOnLane() - veh->getVehicleType().getLength();
314  if (myUpdateEvent == nullptr) {
317  }
318  int lotIndex = getLotIndex(veh);
319  if (lotIndex < 0) {
320  WRITE_WARNING("Unsuitable parking position for vehicle '" + veh->getID() + "' at parkingArea '" + getID() + "' time=" + time2string(SIMSTEP));
321  lotIndex = myLastFreeLot;
322  }
323 #ifdef DEBUG_GET_LAST_FREE_POS
324  ((SUMOVehicleParameter&)veh->getParameter()).setParameter("lotIndex", toString(lotIndex));
325 #endif
326  assert(myLastFreePos >= 0);
327  assert(lotIndex < (int)mySpaceOccupancies.size());
328  mySpaceOccupancies[lotIndex].vehicle = veh;
329  myEndPositions[veh] = std::pair<double, double>(beg, end);
331  // current search ends here
332  veh->setNumberParkingReroutes(0);
333 }
334 
335 
336 void
338  assert(myEndPositions.find(what) != myEndPositions.end());
339  if (myUpdateEvent == nullptr) {
342  }
343  for (auto& lsd : mySpaceOccupancies) {
344  if (lsd.vehicle == what) {
345  lsd.vehicle = nullptr;
346  break;
347  }
348  }
349  myEndPositions.erase(myEndPositions.find(what));
351 }
352 
353 
354 SUMOTime
357  myUpdateEvent = nullptr;
358  return 0;
359 }
360 
361 
363  index(-1),
364  vehicle(nullptr),
365  rotation(0),
366  slope(0),
367  width(0),
368  length(0),
369  endPos(0),
370  manoeuverAngle(0),
371  sideIsLHS(false) {
372 }
373 
374 
375 MSParkingArea::LotSpaceDefinition::LotSpaceDefinition(int index_, SUMOVehicle* vehicle_, double x, double y, double z, double rotation_, double slope_, double width_, double length_) :
376  index(index_),
377  vehicle(vehicle_),
378  position(Position(x, y, z)),
379  rotation(rotation_),
380  slope(slope_),
381  width(width_),
382  length(length_),
383  endPos(0),
384  manoeuverAngle(0),
385  sideIsLHS(false) {
386 }
387 
388 
389 void
391  myLastFreeLot = -1;
393  myEgressBlocked = false;
394  for (auto& lsd : mySpaceOccupancies) {
395  if (lsd.vehicle == nullptr
396  || (getOccupancy() == getCapacity()
397  && lsd.vehicle->remainingStopDuration() <= 0
398  && !lsd.vehicle->isStoppedTriggered())) {
399  if (lsd.vehicle == nullptr) {
400  myLastFreeLot = lsd.index;
401  myLastFreePos = lsd.endPos;
402  } else {
403  // vehicle wants to exit the parking area
404  myLastFreeLot = lsd.index;
405  myLastFreePos = lsd.endPos - lsd.vehicle->getVehicleType().getLength() - POSITION_EPS;
406  myEgressBlocked = true;
407  }
408  break;
409  } else {
411  lsd.endPos - lsd.vehicle->getVehicleType().getLength() - NUMERICAL_EPS);
412  }
413  }
414 }
415 
416 
417 double
418 MSParkingArea::getLastFreePosWithReservation(SUMOTime t, const SUMOVehicle& forVehicle, double brakePos) {
419  if (forVehicle.getLane() != &myLane) {
420  // for different lanes, do not consider reservations to avoid lane-order
421  // dependency in parallel simulation
422 #ifdef DEBUG_RESERVATIONS
423  if (DEBUG_COND2(forVehicle)) {
424  std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID() << " other lane\n";
425  }
426 #endif
427  if (myNumAlternatives > 0 && getOccupancy() == getCapacity()) {
428  // ensure that the vehicle reaches the rerouter lane
429  return MAX2(myBegPos, MIN2(POSITION_EPS, myEndPos));
430  } else {
431  return getLastFreePos(forVehicle, brakePos);
432  }
433  }
434  if (t > myReservationTime) {
435 #ifdef DEBUG_RESERVATIONS
436  if (DEBUG_COND2(forVehicle)) {
437  std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID() << " first reservation\n";
438  }
439 #endif
440  myReservationTime = t;
441  myReservations = 1;
443  for (const auto& lsd : mySpaceOccupancies) {
444  if (lsd.vehicle != nullptr) {
445  myReservationMaxLength = MAX2(myReservationMaxLength, lsd.vehicle->getVehicleType().getLength());
446  }
447  }
448  return getLastFreePos(forVehicle, brakePos);
449  } else {
451 #ifdef DEBUG_RESERVATIONS
452  if (DEBUG_COND2(forVehicle)) {
453  std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID() << " res=" << myReservations << " enough space\n";
454  }
455 #endif
456  myReservations++;
458  return getLastFreePos(forVehicle, brakePos);
459  } else {
460  if (myCapacity == 0) {
461  return getLastFreePos(forVehicle, brakePos);
462  } else {
463 #ifdef DEBUG_RESERVATIONS
464  if (DEBUG_COND2(forVehicle)) std::cout << SIMTIME << " pa=" << getID() << " freePosRes veh=" << forVehicle.getID()
465  << " res=" << myReservations << " resTime=" << myReservationTime << " reserved full, maxLen=" << myReservationMaxLength << " endPos=" << mySpaceOccupancies[0].endPos << "\n";
466 #endif
467  return (mySpaceOccupancies[0].endPos
469  - forVehicle.getVehicleType().getMinGap()
470  - NUMERICAL_EPS);
471  }
472  }
473  }
474 }
475 
476 
477 double
479  return myWidth;
480 }
481 
482 
483 double
485  return myLength;
486 }
487 
488 
489 double
491  return myAngle;
492 }
493 
494 
495 int
497  return myCapacity;
498 }
499 
500 
501 bool
503  return myOnRoad;
504 }
505 
506 
507 int
509  return (int)myEndPositions.size() - (myEgressBlocked ? 1 : 0);
510 }
511 
512 
513 int
515  return (int)myEndPositions.size();
516 }
517 
518 
519 int
521  return myLastStepOccupancy;
522 }
523 
524 
525 void
526 MSParkingArea::accept(std::string badge) {
527  myAcceptedBadges.insert(badge);
528 }
529 
530 
531 void
532 MSParkingArea::accept(std::vector<std::string> badges) {
533  myAcceptedBadges.insert(badges.begin(), badges.end());
534 }
535 
536 
537 void
538 MSParkingArea::refuse(std::string badge) {
539  myAcceptedBadges.erase(badge);
540 }
541 
542 
543 bool
545  if (myAcceptedBadges.size() == 0) {
546  return true;
547  } else {
548  std::vector<std::string> vehicleBadges = veh->getParkingBadges();
549  for (auto badge : vehicleBadges) {
550  if (myAcceptedBadges.count(badge) != 0) {
551  return true;
552  }
553  }
554  return false;
555  }
556 }
557 
558 
559 void
562 }
563 
564 
565 int
567  return myNumAlternatives;
568 }
569 
570 
571 void
573  myNumAlternatives = MAX2(myNumAlternatives, alternatives);
574 }
575 
576 
577 void
579  // reinit parking lot generation process
580  myRoadSideCapacity = capacity;
581 
582  // Initialize space occupancies if there is a road-side capacity
583  // The overall number of lots is fixed and each lot accepts one vehicle regardless of size
585  if (myLength == 0) {
586  myLength = spaceDim;
587  }
588  mySpaceOccupancies.clear();
589  myCapacity = 0;
590  for (int i = 0; i < myRoadSideCapacity; ++i) {
591  // calculate pos, angle and slope of parking lot space
593  double spaceAngle = GeomHelper::calculateLotSpaceAngle(myShape, i, spaceDim, myAngle);
594  double spaceSlope = GeomHelper::calculateLotSpaceSlope(myShape, i, spaceDim);
595  // add lotEntry
596  addLotEntry(pos.x(), pos.y(), pos.z(), myWidth, myLength, spaceAngle, spaceSlope);
597  // update endPos
598  mySpaceOccupancies.back().endPos = MIN2(myEndPos, myBegPos + MAX2(POSITION_EPS, spaceDim * (i + 1)));
599  }
600 }
601 
602 /****************************************************************************/
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:57
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:159
static bool gLefthand
Whether lefthand-drive is being simulated.
Definition: MSGlobals.h:171
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:184
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 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.
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.
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.
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:322
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:62
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.