43#define DEBUG_COND2(obj) (obj.isSelected())
50 const std::vector<std::string>& badges,
MSLane& lane,
51 double begPos,
double endPos,
int capacity,
double width,
double length,
52 double angle,
const std::string& name,
bool onRoad,
53 const std::string& departPos,
bool lefthand,
bool reservable) :
55 myRoadSideCapacity(capacity),
58 myReservable(reservable),
61 myAngle(lefthand ? -angle : angle),
62 myAcceptedBadges(badges.begin(), badges.end()),
63 myEgressBlocked(false),
64 myReservationTime(-1),
65 myLastReservationTime(-1),
67 myLastReservations(0),
68 myReservationMaxLength(0),
69 myLastReservationMaxLength(0),
72 myLastStepOccupancy(0),
75 myUpdateEvent(nullptr) {
81 if (departPos !=
"") {
89 }
else if (myDepartPos < 0 || myDepartPos > lane.
getLength()) {
129 if (relativeAngle < 0.) {
130 relativeAngle += 360.;
137 if (p2.
y() < (0. + POSITION_EPS)) {
183#ifdef DEBUG_GET_LAST_FREE_POS
185 std::cout <<
SIMTIME <<
" getLastFreePos veh=" << forVehicle.
getID() <<
" allOccupied\n";
194 if (it_lsd->vehicle ==
nullptr) {
200#ifdef DEBUG_GET_LAST_FREE_POS
202 std::cout <<
SIMTIME <<
" getLastFreePos (onRoad-upstream) veh=" << forVehicle.
getID() <<
" brakePos=" << brakePos <<
" myEndPos=" <<
myEndPos <<
" nextFreePos=" << it_lsd->endPos <<
"\n";
205 return it_lsd->endPos;
213#ifdef DEBUG_GET_LAST_FREE_POS
215 std::cout <<
SIMTIME <<
" getLastFreePos veh=" << forVehicle.
getID() <<
" brakePos=" << brakePos <<
" myEndPos=" <<
myEndPos <<
" using myLastFreePos=" <<
myLastFreePos <<
"\n";
222 if (lsd.vehicle ==
nullptr && lsd.endPos >= minPos) {
223#ifdef DEBUG_GET_LAST_FREE_POS
225 std::cout <<
SIMTIME <<
" getLastFreePos veh=" << forVehicle.
getID() <<
" brakePos=" << brakePos <<
" myEndPos=" <<
myEndPos <<
" nextFreePos=" << lsd.endPos <<
"\n";
232#ifdef DEBUG_GET_LAST_FREE_POS
234 std::cout <<
SIMTIME <<
" getLastFreePos veh=" << forVehicle.
getID() <<
" brakePos=" << brakePos <<
" myEndPos=" <<
myEndPos <<
" noGoodFreePos blockedAt=" << brakePos <<
"\n";
255 if (lsd.vehicle == &forVehicle) {
269 if (lsd.vehicle == &forVehicle) {
280 if (lsd.vehicle == &forVehicle) {
281 return (lsd.rotation - 90.) * (double)
M_PI / (
double) 180.0;
290 if (lsd.vehicle == &forVehicle) {
300 if (lsd.vehicle == &forVehicle) {
301 if (lsd.manoeuverAngle > 180.) {
302 return DEG2RAD(lsd.manoeuverAngle - 360.);
304 return DEG2RAD(lsd.manoeuverAngle);
314 if (lsd.vehicle == &forVehicle) {
316 return abs(
int(lsd.manoeuverAngle)) % 180;
318 return abs(abs(
int(lsd.manoeuverAngle)) % 180 - 180) % 180;
362#ifdef DEBUG_GET_LAST_FREE_POS
402 if (lsd.vehicle == what) {
403 lsd.vehicle =
nullptr;
460 if (lsd.vehicle ==
nullptr
462 && lsd.vehicle->remainingStopDuration() <= 0
463 && !lsd.vehicle->isStoppedTriggered())) {
464 if (lsd.vehicle ==
nullptr) {
470 myLastFreePos = lsd.endPos - lsd.vehicle->getVehicleType().getLength() - POSITION_EPS;
476 lsd.endPos - lsd.vehicle->getVehicleType().getLength() - NUMERICAL_EPS);
488#ifdef DEBUG_RESERVATIONS
490 std::cout <<
SIMTIME <<
" pa=" <<
getID() <<
" freePosRes veh=" << forVehicle.
getID() <<
" other lane\n";
516#ifdef DEBUG_RESERVATIONS
530#ifdef DEBUG_RESERVATIONS
532 std::cout <<
SIMTIME <<
" pa=" <<
getID() <<
" freePosRes veh=" << forVehicle.
getID() <<
" first reservation\n";
544 if (lsd.vehicle !=
nullptr) {
551#ifdef DEBUG_RESERVATIONS
564#ifdef DEBUG_RESERVATIONS
673 for (
auto badge : vehicleBadges) {
701std::vector<std::string>
715const std::vector<MSParkingArea::LotSpaceDefinition>&
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
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
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
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
static bool gLefthand
Whether lefthand-drive is being simulated.
Representation of a lane in the micro simulation.
MSLane * getParallelLane(int offset, bool includeOpposite=true) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
bool allowsChangingRight(SUMOVehicleClass vclass) const
Returns whether the given vehicle class may change left from this lane.
double getLength() const
Returns the lane's length.
bool allowsChangingLeft(SUMOVehicleClass vclass) const
Returns whether the given vehicle class may change left from this lane.
bool allowsVehicleClass(SUMOVehicleClass vclass) const
double interpolateLanePosToGeometryPos(double lanePos) const
virtual const PositionVector & getShape(bool) const
double getWidth() const
Returns the lane's width.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
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.
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
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, bool reservable)
Constructor.
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)
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.
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.
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.
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.
static const Position INVALID
used to indicate that a position is valid
double x() const
Returns the x-position.
double z() const
Returns the z-position.
double y() const
Returns the y-position.
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 SUMOVehicleClass getVClass() const =0
Returns the object's access class.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
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.
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.