41#define DEBUG_COND2(obj) (obj.isSelected())
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) :
53 myRoadSideCapacity(capacity),
58 myAngle(lefthand ? -angle : angle),
59 myAcceptedBadges(badges.begin(), badges.end()),
60 myEgressBlocked(false),
61 myReservationTime(-1),
63 myReservationMaxLength(0),
65 myLastStepOccupancy(0),
68 myUpdateEvent(nullptr) {
74 if (departPos !=
"") {
82 }
else if (myDepartPos < 0 || myDepartPos > lane.
getLength()) {
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.;
130 if (p2.
y() < (0. + POSITION_EPS)) {
176#ifdef DEBUG_GET_LAST_FREE_POS
178 std::cout <<
SIMTIME <<
" getLastFreePos veh=" << forVehicle.
getID() <<
" allOccupied\n";
185#ifdef DEBUG_GET_LAST_FREE_POS
187 std::cout <<
SIMTIME <<
" getLastFreePos veh=" << forVehicle.
getID() <<
" brakePos=" << brakePos <<
" myEndPos=" <<
myEndPos <<
" using myLastFreePos=" <<
myLastFreePos <<
"\n";
194 if (lsd.vehicle ==
nullptr && lsd.endPos >= minPos) {
195#ifdef DEBUG_GET_LAST_FREE_POS
197 std::cout <<
SIMTIME <<
" getLastFreePos veh=" << forVehicle.
getID() <<
" brakePos=" << brakePos <<
" myEndPos=" <<
myEndPos <<
" nextFreePos=" << lsd.endPos <<
"\n";
204#ifdef DEBUG_GET_LAST_FREE_POS
206 std::cout <<
SIMTIME <<
" getLastFreePos veh=" << forVehicle.
getID() <<
" brakePos=" << brakePos <<
" myEndPos=" <<
myEndPos <<
" noGoodFreePos blockedAt=" << brakePos <<
"\n";
217 if (lsd.vehicle == &forVehicle) {
231 if (lsd.vehicle == &forVehicle) {
242 if (lsd.vehicle == &forVehicle) {
243 return (lsd.rotation - 90.) * (double)
M_PI / (
double) 180.0;
252 if (lsd.vehicle == &forVehicle) {
262 if (lsd.vehicle == &forVehicle) {
263 if (lsd.manoeuverAngle > 180.) {
264 return DEG2RAD(lsd.manoeuverAngle - 360.);
266 return DEG2RAD(lsd.manoeuverAngle);
276 if (lsd.vehicle == &forVehicle) {
278 return abs(
int(lsd.manoeuverAngle)) % 180;
280 return abs(abs(
int(lsd.manoeuverAngle)) % 180 - 180) % 180;
323#ifdef DEBUG_GET_LAST_FREE_POS
344 if (lsd.vehicle == what) {
345 lsd.vehicle =
nullptr;
395 if (lsd.vehicle ==
nullptr
397 && lsd.vehicle->remainingStopDuration() <= 0
398 && !lsd.vehicle->isStoppedTriggered())) {
399 if (lsd.vehicle ==
nullptr) {
405 myLastFreePos = lsd.endPos - lsd.vehicle->getVehicleType().getLength() - POSITION_EPS;
411 lsd.endPos - lsd.vehicle->getVehicleType().getLength() - NUMERICAL_EPS);
422#ifdef DEBUG_RESERVATIONS
424 std::cout <<
SIMTIME <<
" pa=" <<
getID() <<
" freePosRes veh=" << forVehicle.
getID() <<
" other lane\n";
435#ifdef DEBUG_RESERVATIONS
437 std::cout <<
SIMTIME <<
" pa=" <<
getID() <<
" freePosRes veh=" << forVehicle.
getID() <<
" first reservation\n";
444 if (lsd.vehicle !=
nullptr) {
451#ifdef DEBUG_RESERVATIONS
463#ifdef DEBUG_RESERVATIONS
549 for (
auto badge : vehicleBadges) {
577std::vector<std::string>
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
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
The base class for microscopic and mesoscopic vehicles.
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
static bool gLefthand
Whether lefthand-drive is being simulated.
Representation of a lane in the micro simulation.
double getLength() const
Returns the lane's length.
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
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
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.
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)
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.
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 double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
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.