Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSParkingArea.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2015-2026 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
19// A area where vehicles can park next to the road
20/****************************************************************************/
21#pragma once
22#include <config.h>
23
24#include <vector>
25#include <algorithm>
26#include <map>
27#include <string>
29#include <utils/common/Named.h>
31#include "MSStoppingPlace.h"
32
33
34// ===========================================================================
35// class declarations
36// ===========================================================================
37class MSLane;
38class SUMOVehicle;
39class MSTransportable;
40class MSBaseVehicle;
41class Position;
42class Command;
43
44
45// ===========================================================================
46// class definitions
47// ===========================================================================
61public:
62
69
71 LotSpaceDefinition(int index, SUMOVehicle* vehicle, double x, double y, double z, double rotation, double slope, double width, double length);
72
74 const int index;
75
78
81
83 const double rotation;
84
86 const double slope;
87
89 const double width;
90
92 const double length;
93
95 double endPos;
96
99
102 };
103
118 MSParkingArea(const std::string& id,
119 const std::vector<std::string>& lines,
120 const std::vector<std::string>& badges, MSLane& lane,
121 double begPos, double endPos, int capacity,
122 double width, double length, double angle, const std::string& name,
123 bool onRoad,
124 const std::string& departPos,
125 bool lefthand, bool reservable);
126
128 virtual ~MSParkingArea();
129
131 friend class NLTriggerBuilder;
132
134 int getCapacity() const;
135
137 bool parkOnRoad() const;
138
140 bool mustAdvance(SUMOVehicleClass svc) const;
141
143 inline bool isReservable() const {
144 return myReservable;
145 }
146
148 int getLotIndex(const SUMOVehicle* veh) const;
149
156 int getOccupancy() const;
157
160
161 int getOccupancyIncludingReservations(const SUMOVehicle* forVehicle) const;
162
163 int getOccupancyIncludingRemoteReservations(const SUMOVehicle* forVehicle) const;
164
166 int getLastStepOccupancy() const;
167
169
171 void accept(std::string badge);
172
174 void accept(std::vector<std::string> badges);
175
177 void refuse(std::string badge);
178
180 bool accepts(SUMOVehicle* veh) const;
181
192 void enter(SUMOVehicle* veh, const bool parking);
193
203 void leaveFrom(SUMOVehicle* what);
204
207 void addSpaceReservation(const SUMOVehicle* veh);
208 void removeSpaceReservation(const SUMOVehicle* veh);
209
210 const std::set<const SUMOVehicle*>& getRemoteReservedVehicles() const {
212 }
214
222 SUMOTime updateOccupancy(SUMOTime currentTime);
223
225 double getLastFreePos(const SUMOVehicle& forVehicle, double brakePos = 0) const;
226
232 double getLastFreePosWithReservation(SUMOTime t, const SUMOVehicle& forVehicle, double brakePos);
233
235 Position getVehiclePosition(const SUMOVehicle& forVehicle) const;
236
238 double getInsertionPosition(const SUMOVehicle& forVehicle) const;
239
241 double getVehicleAngle(const SUMOVehicle& forVehicle) const;
242
244 double getVehicleSlope(const SUMOVehicle& forVehicle) const;
245
251 int getLastFreeLotAngle() const;
252
258 double getLastFreeLotGUIAngle() const;
259
261 int getManoeuverAngle(const SUMOVehicle& forVehicle) const;
262
264 double getGUIAngle(const SUMOVehicle& forVehicle) const;
265
277 virtual void addLotEntry(double x, double y, double z,
278 double width, double length,
279 double angle, double slope);
280
282 double getWidth() const;
283
285 double getLength() const;
286
288 double getAngle() const;
289
291 void notifyEgressBlocked();
292
294 int getNumAlternatives() const;
295
297 void setNumAlternatives(int alternatives);
298
300 std::vector<std::string> getAcceptedBadges() const;
301
303 void setAcceptedBadges(const std::vector<std::string>& badges);
304
306 const std::vector<LotSpaceDefinition>& getSpaceOccupancies() const;
307
309 const PositionVector& getShape() const;
310
311
312protected:
314 void setRoadsideCapacity(int capactity);
315
317 bool cannotChange(SUMOVehicleClass svc) const;
318
319protected:
320
321
328 void computeLastFreePos();
329
332
335
338
341
344
346 double myWidth;
347
349 double myLength;
350
352 double myAngle;
353
355 std::vector<LotSpaceDefinition> mySpaceOccupancies;
356
359
361 std::set<std::string> myAcceptedBadges;
362
365
369
373
377
379 std::set<const SUMOVehicle*> myReservedVehicles;
381 std::set<const SUMOVehicle*> myRemoteReservedVehicles;
383 std::set<const SUMOVehicle*> myLastRemoteReservedVehicles;
384
387
390
393
397
400
401private:
403 MSParkingArea(const MSParkingArea&) = delete;
404
407};
long long int SUMOTime
Definition GUI.h:36
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
DepartPosDefinition
Possible ways to choose the departure position.
Base (microsim) event class.
Definition Command.h:50
The base class for microscopic and mesoscopic vehicles.
Representation of a lane in the micro simulation.
Definition MSLane.h:84
A lane area vehicles can halt at.
void notifyEgressBlocked()
update state so that vehicles wishing to enter cooperate with exiting vehicles
int getOccupancyIncludingReservations(const SUMOVehicle *forVehicle) const
double getAngle() const
Returns the lot rectangle angle.
void leaveFrom(SUMOVehicle *what)
Called if a vehicle leaves this stop.
int getNumAlternatives() const
get number alternatives
void refuse(std::string badge)
Remove the access right for the given badge.
int getLastStepOccupancyIncludingRemoteReservations(const SUMOVehicle *forVehicle) const
int myReservations
number of reservations
int myCapacity
Stop area total capacity.
int getCapacity() const
Returns the area capacity.
MSParkingArea(const MSParkingArea &)=delete
Invalidated copy constructor.
int myLastStepOccupancy
Changes to the occupancy in the current time step.
MSParkingArea & operator=(const MSParkingArea &)=delete
Invalidated assignment operator.
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
bool isReservable() const
whether vehicles may reserve a slot for this parkingArea
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.
std::set< const SUMOVehicle * > myRemoteReservedVehicles
the set of vehicles that performed a remote reservation
double getLength() const
Returns the lot rectangle length.
virtual void addLotEntry(double x, double y, double z, double width, double length, double angle, double slope)
Add a lot entry to parking area.
SUMOTime myReservationTime
track parking reservations from the lane for the current time step
double getWidth() const
Returns the lot rectangle width.
double getVehicleSlope(const SUMOVehicle &forVehicle) const
Returns the slope of parked vehicle.
int myRoadSideCapacity
Stop area capacity configured via roadsideCapacity.
int getLotIndex(const SUMOVehicle *veh) const
compute lot for this vehicle
virtual ~MSParkingArea()
Destructor.
SUMOTime updateOccupancy(SUMOTime currentTime)
Called at the end of the time step.
std::set< const SUMOVehicle * > myReservedVehicles
the set of vehicles that performed a local reservation in this step
int getLastFreeLotAngle() const
Return the angle of myLastFreeLot - the next parking lot only expected to be called after we have est...
double myDepartPos
custom departPos
double myAngle
The default angle of each parking space.
bool parkOnRoad() const
whether vehicles park on the road
void addSpaceReservation(const SUMOVehicle *veh)
api for reserving spaces at this parkingArea
DepartPosDefinition myDepartPosDefinition
double myReservationMaxLength
reservation max length
int myNumAlternatives
the number of alternative parkingAreas that are assigned to parkingAreaRerouter
int getOccupancyIncludingRemoteReservations(const SUMOVehicle *forVehicle) const
void removeSpaceReservation(const SUMOVehicle *veh)
double myWidth
The default width of each parking space.
bool accepts(SUMOVehicle *veh) const
Return the parking accepts the vehicle (due to its given badges)
bool myReservable
Whether this parkingarea may receive reservations by vehicles that are on their way.
double myLength
The default length of each parking space.
void computeLastFreePos()
Computes the last free position on this stop.
const std::set< const SUMOVehicle * > & getRemoteReservedVehicles() const
bool mustAdvance(SUMOVehicleClass svc) const
whether parked vehicles must advance in a queue
int getOccupancyIncludingBlocked() const
Returns the area occupancy.
void setAcceptedBadges(const std::vector< std::string > &badges)
set the accepted badges
double getLastFreePosWithReservation(SUMOTime t, const SUMOVehicle &forVehicle, double brakePos)
Returns the last free position on this stop including reservations from the current lane and time ste...
double getLastFreeLotGUIAngle() const
Return the GUI angle of myLastFreeLot - the angle the GUI uses to rotate into the next parking lot as...
int getManoeuverAngle(const SUMOVehicle &forVehicle) const
Return the manoeuver angle of the lot where the vehicle is parked.
int getLastStepOccupancy() const
Returns the area occupancy at the end of the last simulation step.
void accept(std::string badge)
Add a badge to the accepted set.
int getOccupancy() const
Returns the area occupancy.
void setRoadsideCapacity(int capactity)
overwrite the capacity (caution: will delete ANY previous parking space definitions)
const std::vector< LotSpaceDefinition > & getSpaceOccupancies() const
get the parking lots (with occupancy)
double getVehicleAngle(const SUMOVehicle &forVehicle) const
Returns the angle of parked vehicle.
Command * myUpdateEvent
Event for updating the occupancy.
std::vector< LotSpaceDefinition > mySpaceOccupancies
All the spaces in this parking area.
double getInsertionPosition(const SUMOVehicle &forVehicle) const
Returns the insertion position of a parked vehicle.
void enter(SUMOVehicle *veh, const bool parking)
Called if a vehicle enters this stop.
double myLastReservationMaxLength
Position getVehiclePosition(const SUMOVehicle &forVehicle) const
Returns the position of parked vehicle.
std::set< std::string > myAcceptedBadges
The parking badges to grant access.
double myMaxVehLength
maximum length of all parked vehicles
std::set< const SUMOVehicle * > myLastRemoteReservedVehicles
a copy from the last step is needed to achieve thread/lane ordering independence
double getGUIAngle(const SUMOVehicle &forVehicle) const
Return the GUI angle of the lot where the vehicle is parked.
bool cannotChange(SUMOVehicleClass svc) const
whether overtaking on this lane is impossible for the given vehicle class
bool myEgressBlocked
whether a vehicle wants to exit but is blocked
A lane area vehicles can halt at.
double getLastFreePos() const
Builds trigger objects for microsim.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.
Representation of a vehicle.
Definition SUMOVehicle.h:63
Representation of a single lot space.
const double slope
The slope.
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.
const int index
the running index
const double width
The width.
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 double length
The length.
const SUMOVehicle * vehicle
The last parked vehicle or 0.