95 struct VehPosition :
public std::binary_function < const MSVehicle*, double, bool > {
108 bool downstream =
true) :
114 myDownstream(downstream),
115 myDirection(downstream ? 1 : -1) {
119 return (myI1 == other.
myI1 120 && myI2 == other.
myI2 126 return !(*
this == other);
138 bool nextIsMyVehicles()
const;
183 MSLane(
const std::string&
id,
double maxSpeed,
double length,
MSEdge*
const edge,
209 void addNeigh(
const std::string&
id);
276 bool recheckNextLanes,
280 bool checkFailure(
MSVehicle* aVehicle,
double& speed,
double& dist,
const double nspeed,
const bool patchSpeed,
const std::string errorMsg)
const;
634 return (
int)
myDict.size();
641 static void insertIDs(std::vector<std::string>& into);
648 template<
class RTREE>
649 static void fill(RTREE& into);
661 const MSLane& succLinkSource,
662 const std::vector<MSLane*>& conts);
667 bool isLinkEnd(MSLinkCont::const_iterator& i)
const;
740 bool allSublanes,
double searchDist = -1,
bool ignoreMinorLinks =
false)
const;
757 std::pair<MSVehicle* const, double>
getLeader(
const MSVehicle* veh,
const double vehPos,
const std::vector<MSLane*>& bestLaneConts,
double dist = -1,
bool checkTmpVehicles =
false)
const;
782 double speed,
const MSVehicle& veh,
const std::vector<MSLane*>& bestLaneConts)
const;
978 std::pair<MSVehicle* const, double>
getFollower(
const MSVehicle* ego,
double egoPos,
double dist,
bool ignoreMinorLinks)
const;
1066 const MSLane::VehCont::iterator& at,
1071 SUMOTime timestep,
const std::string& stage);
1075 std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
1076 std::set<const MSVehicle*>& toTeleport)
const;
1080 double gap,
double latGap,
1081 std::set<const MSVehicle*, SUMOVehicle::ComparatorIdLess>& toRemove,
1082 std::set<const MSVehicle*>& toTeleport)
const;
void detectPedestrianJunctionCollision(const MSVehicle *collider, const PositionVector &colliderBoundary, const MSLane *foeLane, SUMOTime timestep, const std::string &stage)
detect whether a vehicle collids with pedestrians on the junction
int getRightmostSublane() const
int getNumericalID() const
Returns this lane's numerical id.
void loadState(std::vector< std::string > &vehIDs, MSVehicleControl &vc)
Loads the state of this segment with the given parameters.
SVCPermissions myPermissions
The vClass permissions for this lane.
VehCont myVehicles
The lane's vehicles. This container holds all vehicles that have their front (longitudinally) and the...
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
saves leader/follower vehicles and their distances relative to an ego vehicle
MSEdge & getEdge() const
Returns the lane's edge.
int getPartialVehicleNumber() const
Returns the number of vehicles partially on this lane (for which this lane is not responsible) ...
virtual double getChosenSpeedFactor() const =0
double getHarmonoise_NoiseEmissions() const
Returns the sum of last step noise emissions.
std::pair< MSVehicle *const, double > getLeaderOnConsecutive(double dist, double seen, double speed, const MSVehicle &veh, const std::vector< MSLane * > &bestLaneConts) const
Returns the immediate leader and the distance to him.
double getWidth() const
Returns the lane's width.
Representation of a vehicle in the micro simulation.
bool isLinkEnd(MSLinkCont::const_iterator &i) const
MSVehicle * getLastAnyVehicle() const
returns the last vehicle that is fully or partially on this lane
static MSLinkCont::const_iterator succLinkSec(const SUMOVehicle &veh, int nRouteSuccs, const MSLane &succLinkSource, const std::vector< MSLane * > &conts)
void resetPermissions(long transientID)
int getVehicleNumber() const
Returns the number of vehicles on this lane (for which this lane is responsible)
MSLane(const std::string &id, double maxSpeed, double length, MSEdge *const edge, int numericalID, const PositionVector &shape, double width, SVCPermissions permissions, int index, bool isRampAccel)
Constructor.
double getCenterOnEdge() const
static void insertIDs(std::vector< std::string > &into)
Adds the ids of all stored lanes into the given vector.
const MSEdge * getNextNormal() const
Returns the lane's follower if it is an internal lane, the edge of the lane otherwise.
std::pair< MSVehicle *const, double > getLeader(const MSVehicle *veh, const double vehPos, const std::vector< MSLane * > &bestLaneConts, double dist=-1, bool checkTmpVehicles=false) const
Returns the immediate leader of veh and the distance to veh starting on this lane.
Sorts lanes (IncomingLaneInfos) by their priority or, if this doesn't apply, wrt. the angle differenc...
virtual void removeParking(MSVehicle *veh)
remove parking vehicle. This must be syncrhonized when running with GUI
MSVehicle * getFirstAnyVehicle() const
returns the first vehicle that is fully or partially on this lane
virtual void releaseVehicles() const
Allows to use the container for microsimulation again.
MSLink * getLinkTo(const MSLane *) const
returns the link to the given lane or 0, if it is not connected
static bool teleportOnCollision()
static const long CHANGE_PERMISSIONS_GUI
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
int myI2
index for myPartialVehicles
std::pair< MSVehicle *const, double > getOppositeLeader(const MSVehicle *ego, double dist, bool oppositeDir) const
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
double getCOEmissions() const
Returns the sum of last step CO emissions.
void getLeadersOnConsecutive(double dist, double seen, double speed, const MSVehicle *ego, const std::vector< MSLane * > &bestLaneConts, MSLeaderDistanceInfo &result) const
Returns the immediate leaders and the distance to them (as getLeaderOnConsecutive but for the sublane...
bool isInsertionSuccess(MSVehicle *vehicle, double speed, double pos, double posLat, bool recheckNextLanes, MSMoveReminder::Notification notification)
Tries to insert the given vehicle with the given state (speed and pos)
const MSLeaderInfo & getLastVehicleInformation(const MSVehicle *ego, double latOffset, double minPos=0, bool allowCached=true) const
Returns the last vehicles on the lane.
MSLane * getOpposite() const
return the opposite direction lane for lane changing or 0
static void fill(RTREE &into)
Fills the given RTree with lane instances.
void setMaxSpeed(double val)
Sets a new maximum speed for the lane (used by TraCI and MSCalibrator)
virtual double getMaxSpeed() const =0
Returns the vehicle's maximum speed.
double getPMxEmissions() const
Returns the sum of last step PMx emissions.
double getNettoOccupancy() const
Returns the netto (excluding minGaps) occupancy of this lane during the last step (including minGaps)...
std::vector< IncomingLaneInfo > myIncomingLanes
All direct predecessor lanes.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
int myI2End
end index for myPartialVehicles
void addLink(MSLink *link)
Delayed initialization.
MSLane * myCanonicalPredecessorLane
Similar to LogicalPredecessorLane,.
int myIndex
The lane index.
virtual bool integrateNewVehicle(SUMOTime t)
Insert buffered vehicle into the real lane.
SUMOTime myLeaderInfoTime
time step for which myLeaderInfo was last updated
MSVehicle * getFirstFullVehicle() const
returns the first vehicle for which this lane is responsible or 0
static SUMOTime myCollisionStopTime
Notification
Definition of a vehicle state.
virtual MSVehicle * removeVehicle(MSVehicle *remVehicle, MSMoveReminder::Notification notification, bool notify=true)
double interpolateLanePosToGeometryPos(double lanePos) const
bool isAccelLane() const
return whether this lane is an acceleration lane
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
double myBruttoVehicleLengthSum
The current length of all vehicles on this lane, including their minGaps.
const MSEdge *const myEdge
std::pair< MSVehicle *const, double > getCriticalLeader(double dist, double seen, double speed, const MSVehicle &veh) const
Returns the most dangerous leader and the distance to him.
void addIncomingLane(MSLane *lane, MSLink *viaLink)
std::pair< MSVehicle *const, double > getFollower(const MSVehicle *ego, double egoPos, double dist, bool ignoreMinorLinks) const
Find follower vehicle for the given ego vehicle (which may be on the opposite direction lane) ...
double getLength() const
Returns the lane's length.
static void initCollisionOptions(const OptionsCont &oc)
Realises dumping the complete network state.
virtual void addMoveReminder(MSMoveReminder *rem)
Add a move-reminder to move-reminder container.
void leftByLaneChange(MSVehicle *v)
std::map< long, SVCPermissions > myPermissionChanges
void addNeigh(const std::string &id)
Adds a neighbor to this lane.
bool operator()(const IncomingLaneInfo &ili) const
virtual double setPartialOccupation(MSVehicle *v)
Sets the information about a vehicle lapping into this lane.
VehCont myPartialVehicles
The lane's partial vehicles. This container holds all vehicles that are partially on this lane but wh...
static bool myCheckJunctionCollisions
int myI1End
end index for myVehicles
double getNOxEmissions() const
Returns the sum of last step NOx emissions.
int myDirection
index delta
PositionVector myShape
The shape of the lane.
std::set< const MSVehicle * > myParkingVehicles
const std::set< const MSVehicle * > & getParkingVehicles() const
retrieve the parking vehicles (see GUIParkingArea)
bool myDownstream
iteration direction
virtual const VehCont & getVehiclesSecure() const
Returns the vehicles container; locks it for microsimulation.
Performs lane changing of vehicles.
std::vector< std::string > myNeighs
double getOppositePos(double pos) const
return the corresponding position on the opposite lane
static CollisionAction myCollisionAction
the action to take on collisions
virtual SUMOVehicleClass getVClass() const =0
Returns the vehicle's access class.
std::map< std::string, MSLane * > DictType
definition of the static dictionary type
static CollisionAction getCollisionAction()
double basePos(const MSVehicle &veh) const
departure position where the vehicle fits fully onto the lane (if possible)
virtual void detectCollisions(SUMOTime timestep, const std::string &stage)
Check if vehicles are too close.
static DictType myDict
Static dictionary to associate string-ids with objects.
Sorts lanes (their origin link) by the priority of their noninternal target edges or...
void addApproachingLane(MSLane *lane, bool warnMultiCon)
Performs lane changing of vehicles.
A road/street connecting two junctions.
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
double getBruttoVehLenSum() const
Returns the sum of lengths of vehicles, including their minGaps, which were on the lane during the la...
MSLane * getCanonicalSuccessorLane() const
double myLength
Lane length [m].
double getFuelConsumption() const
Returns the sum of last step fuel consumption.
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
VehCont myTmpVehicles
Container for lane-changing vehicles. After completion of lane-change- process, the containers will b...
Allows to store the object; used as context while traveling the rtree in TraCI.
bool allowsVehicleClass(SUMOVehicleClass vclass) const
MSLink * getEntryLink() const
Returns the entry link if this is an internal lane, else 0.
static int dictSize()
Returns the number of stored lanes.
Export the queueing length in front of a junction (very experimental!)
virtual void resetPartialOccupation(MSVehicle *v)
Removes the information about a vehicle lapping into this lane.
LinkState getIncomingLinkState() const
get the state of the link from the logical predecessor to this lane
const bool myIsRampAccel
whether this lane is an acceleration lane
const MSEdge *const myEdge
Representation of a vehicle.
void add(const MSLane *const l) const
Adds the given object to the container.
friend class AnyVehicleIterator
void setLength(double val)
Sets a new length for the lane (used by TraCI only)
Sorts vehicles by their position (descending)
double myRightSideOnEdge
the combined width of all lanes with lower index on myEdge
A point in 2D or 3D with translation and scaling methods.
bool lastInsertion(MSVehicle &veh, double mspeed, double posLat, bool patchSpeed)
inserts vehicle as close as possible to the last vehicle on this lane (or at the end of the lane if t...
SVCPermissions myOriginalPermissions
The original vClass permissions for this lane (before temporary modifications)
void enteredByLaneChange(MSVehicle *v)
double getElectricityConsumption() const
Returns the sum of last step electricity consumption.
const MSLeaderInfo & getFirstVehicleInformation(const MSVehicle *ego, double latOffset, bool onlyFrontOnLane, double maxPos=std::numeric_limits< double >::max(), bool allowCached=true) const
analogue to getLastVehicleInformation but in the upstream direction
MSLane * getParallelLane(int offset) const
Returns the lane with the given offset parallel to this one or 0 if it does not exist.
const MSLane * getFirstInternalInConnection(double &offset) const
Returns 0 if the lane is not internal. Otherwise the first part of the connection (sequence of intern...
MSLeaderDistanceInfo getFollowersOnConsecutive(const MSVehicle *ego, double backOffset, bool allSublanes, double searchDist=-1, bool ignoreMinorLinks=false) const
return the sublane followers with the largest missing rear gap among all predecessor lanes (within di...
const std::map< SUMOVehicleClass, double > * myRestrictions
The vClass speed restrictions for this lane.
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
Sorts edges by their angle relative to the given edge (straight comes first)
void forceVehicleInsertion(MSVehicle *veh, double pos, MSMoveReminder::Notification notification, double posLat=0)
Inserts the given vehicle at the given position.
int getVehicleNumberWithPartials() const
Returns the number of vehicles on this lane (including partial occupators)
int myRightmostSublane
the index of the rightmost sublane of this lane on myEdge
MSLane * myLogicalPredecessorLane
Something on a lane to be noticed about vehicle movement.
bool empty() const
Returns true if there is not a single vehicle on the lane.
SVCPermissions getPermissions() const
Returns the vehicle class permissions for this lane.
virtual void swapAfterLaneChange(SUMOTime t)
moves myTmpVehicles int myVehicles after a lane change procedure
int getIndex() const
Returns the lane's index.
An upper class for objects with additional parameters.
std::map< MSEdge *, std::vector< MSLane * > > myApproachingLanes
All direct internal and direct (disregarding internal predecessors) non-internal predecessor lanes of...
std::vector< MSVehicle * > VehCont
Container for vehicles.
Base class for objects which have an id.
int myNumericalID
Unique numerical ID (set on reading by netload)
std::vector< MSMoveReminder * > myMoveReminders
This lane's move reminder.
void handleCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, double gap, double latGap, std::set< const MSVehicle *, SUMOVehicle::ComparatorIdLess > &toRemove, std::set< const MSVehicle * > &toTeleport) const
take action upon collision
const MSLane *const myLane
void initRestrictions()
initialized vClass-specific speed limits
MSLane * getCanonicalPredecessorLane() const
bool operator()(const MSVehicle *cmp, double pos) const
compares vehicle position to the detector position
double getMeanSpeed() const
Returns the mean speed on this lane.
void sortPartialVehicles()
sorts myPartialVehicles
void setPermissions(SVCPermissions permissions, long transientID)
Sets the permissions to the given value. If a transientID is given, the permissions are recored as te...
bool freeInsertion(MSVehicle &veh, double speed, double posLat, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Tries to insert the given vehicle on any place.
std::vector< const MSLane * > getOutgoingLanes() const
get the list of outgoing lanes
double safeInsertionSpeed(const MSVehicle *veh, const MSLeaderInfo &leaders, double speed)
return the maximum safe speed for insertion behind leaders (a negative value indicates that safe inse...
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
double getLengthGeometryFactor() const
return shape.length() / myLength
The vehicle has departed (was inserted into the network)
int myI1
index for myVehicles
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
static void clear()
Clears the dictionary.
MSEdge *const myEdge
The lane's edge, for routing only.
const MSVehicle * operator->()
const MSLane * myLane
the lane that is being iterated
MSVehicle * getPartialBehind(const MSVehicle *ego) const
bool checkFailure(MSVehicle *aVehicle, double &speed, double &dist, const double nspeed, const bool patchSpeed, const std::string errorMsg) const
A storage for options typed value containers)
MSLeaderInfo getPartialBeyond() const
get all vehicles that are inlaping from consecutve edges
double getMaximumBrakeDist() const
compute maximum braking distance on this lane
bool isApproachedFrom(MSEdge *const edge)
std::pair< MSVehicle *const, double > getOppositeFollower(const MSVehicle *ego) const
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane's maximum speed, given a vehicle's speed limit adaptation.
AnyVehicleIterator anyVehiclesEnd() const
end iterator for iterating over all vehicles touching this lane in downstream direction ...
MSLane & operator=(const MSLane &)
invalidated assignment operator
void saveState(OutputDevice &out)
Saves the state of this lane into the given stream.
MSLeaderInfo myLeaderInfo
leaders on all sublanes as seen by approaching vehicles (cached)
const PositionVector & getShape() const
Returns this lane's shape.
const MSLane *const myLane
double getRightSideOnEdge() const
void visit(const TraCIServerAPI_Lane::StoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
MSLane * myCanonicalSuccessorLane
Main successor lane,.
Static storage of an output device and its base (abstract) implementation.
virtual bool isSelected() const
whether this lane is selected in the GUI
double myNettoVehicleLengthSum
The current length of all vehicles on this lane, excluding their minGaps.
MSLeaderInfo myFollowerInfo
followers on all sublanes as seen by vehicles on consecutive lanes (cached)
virtual ~MSLane()
Destructor.
double getHCEmissions() const
Returns the sum of last step HC emissions.
void addParking(MSVehicle *veh)
add parking vehicle. This should only used during state loading
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
double getCO2Emissions() const
Returns the sum of last step CO2 emissions.
The class responsible for building and deletion of vehicles.
double getMissingRearGap(const MSVehicle *leader, double backOffset, double leaderSpeed) const
return by how much further the leader must be inserted to avoid rear end collisions ...
const double myLengthGeometryFactor
precomputed myShape.length / myLength
double interpolateGeometryPosToLanePos(double geometryPos) const
MSLeaderInfo myLeaderInfoTmp
VehCont myVehBuffer
Buffer for vehicles that moved from their previous lane onto this one. Integrated after all vehicles ...
double getDepartPosLat(const MSVehicle &veh)
static const long CHANGE_PERMISSIONS_PERMANENT
AnyVehicleIterator(const MSLane *lane, int i1, int i2, const int i1End, const int i2End, bool downstream=true)
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
virtual bool executeMovements(SUMOTime t, std::vector< MSLane * > &lanesWithVehiclesToIntegrate)
Executes planned vehicle movements with regards to right-of-way.
SUMOTime myFollowerInfoTime
time step for which myFollowerInfo was last updated
MSVehicle * getLastFullVehicle() const
returns the last vehicle for which this lane is responsible or 0
const std::vector< MSMoveReminder * > & getMoveReminders() const
Return the list of this lane's move reminders.
double myMaxSpeed
Lane-wide speedlimit [m/s].
AnyVehicleIterator anyVehiclesBegin() const
begin iterator for iterating over all vehicles touching this lane in downstream direction ...
double getWaitingSeconds() const
Returns the overall waiting time on this lane.
Representation of a lane in the micro simulation.
AnyVehicleIterator anyVehiclesUpstreamEnd() const
end iterator for iterating over all vehicles touching this lane in upstream direction ...
int getCrossingIndex() const
return the index of the link to the next crossing if this is walkingArea, else -1 ...
const double myWidth
Lane width [m].
void setRightSideOnEdge(double value, int rightmostSublane)
virtual void incorporateVehicle(MSVehicle *veh, double pos, double speed, double posLat, const MSLane::VehCont::iterator &at, MSMoveReminder::Notification notification=MSMoveReminder::NOTIFICATION_DEPARTED)
Inserts the vehicle into this lane, and informs it about entering the network.
virtual bool appropriate(const MSVehicle *veh)
virtual void planMovements(const SUMOTime t)
Compute safe velocities for all vehicles based on positions and speeds from the last time step...
bool detectCollisionBetween(SUMOTime timestep, const std::string &stage, MSVehicle *collider, MSVehicle *victim, std::set< const MSVehicle *, SUMOVehicle::ComparatorIdLess > &toRemove, std::set< const MSVehicle * > &toTeleport) const
detect whether there is a collision between the two vehicles
vehicle_position_sorter(const MSLane *lane)
Constructor.
AnyVehicleIterator anyVehiclesUpstreamBegin() const
begin iterator for iterating over all vehicles touching this lane in upstream direction ...
vehicle_natural_position_sorter(const MSLane *lane)
Constructor.
double getDepartSpeed(const MSVehicle &veh, bool &patchSpeed)