Eclipse SUMO - Simulation of Urban MObility
MSLaneChangerSublane.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2002-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 /****************************************************************************/
19 // Performs sub-lane changing of vehicles
20 /****************************************************************************/
21 #pragma once
22 #include <config.h>
23 
25 #include "MSLaneChanger.h"
26 
27 
28 // ===========================================================================
29 // class declarations
30 // ===========================================================================
31 
32 
33 // ===========================================================================
34 // class definitions
35 // ===========================================================================
41 public:
43  MSLaneChangerSublane(const std::vector<MSLane*>* lanes, bool allowChanging);
44 
47 
48 protected:
49 
51  virtual bool change();
52 
54  virtual void initChanger();
55 
57  virtual void updateChanger(bool vehHasChanged);
58 
69  int laneOffset,
70  LaneChangeAction alternatives,
71  const std::vector<MSVehicle::LaneQ>& preb,
72  double& latDist,
73  double& maneuverDist) const;
74 
75  /* @brief call lanechange model to check the merits of an opposite-direction
76  * change and update state accordingly */
78  MSVehicle* vehicle,
79  int laneOffset,
80  MSLane* targetLane,
81  const std::pair<MSVehicle* const, double>& leader,
82  const std::pair<MSVehicle* const, double>& neighLead,
83  const std::pair<MSVehicle* const, double>& neighFollow,
84  const std::vector<MSVehicle::LaneQ>& preb);
85 
86 
88  // (used to continue sublane changing in non-action steps).
89  bool continueChangeSublane(MSVehicle* vehicle, ChangerIt& from);
90 
92  bool startChangeSublane(MSVehicle* vehicle, ChangerIt& from, double latDist, double maneuverDist);
93 
95  bool checkChangeToNewLane(MSVehicle* vehicle, const int direction, ChangerIt from, ChangerIt to);
96 
98  MSLeaderDistanceInfo getLeaders(const ChangerIt& target, const MSVehicle* ego) const;
99 
101  void abortLCManeuver(MSVehicle* vehicle);
102 
105  StateAndDist checkChangeHelper(MSVehicle* vehicle, int laneOffset, LaneChangeAction alternatives);
106 
108  static std::pair<MSVehicle*, double> findClosestLeader(const MSLeaderDistanceInfo& leaders, const MSVehicle* vehicle);
109 
111  void outputLCStarted(MSVehicle* vehicle, ChangerIt& from, ChangerIt& to, int direction, double maneuverDist);
113  void outputLCEnded(MSVehicle* vehicle, ChangerIt& from, ChangerIt& to, int direction);
114 
115  void addOutsideLeaders(const MSVehicle* vehicle, MSLeaderDistanceInfo& leaders) const;
116 
119 
120 private:
123 
126 
129 };
LaneChangeAction
The state of a vehicle's lane-change behavior.
Performs lane changing of vehicles.
Definition: MSLaneChanger.h:45
Changer::iterator ChangerIt
the iterator moving over the ChangeElems
Performs lane changing of vehicles.
bool startChangeSublane(MSVehicle *vehicle, ChangerIt &from, double latDist, double maneuverDist)
change by the specified amount and return whether a new lane was entered
bool checkChangeToNewLane(MSVehicle *vehicle, const int direction, ChangerIt from, ChangerIt to)
check whether the given vehicle has entered the new lane 'to->lane' during a sublane LC-step
void outputLCStarted(MSVehicle *vehicle, ChangerIt &from, ChangerIt &to, int direction, double maneuverDist)
optional output for start of lane-change maneuvre
MSLaneChangerSublane(const MSLaneChangerSublane &)
Copy constructor.
void addOutsideLeaders(const MSVehicle *vehicle, MSLeaderDistanceInfo &leaders) const
MSLaneChangerSublane & operator=(const MSLaneChangerSublane &)
Assignment operator.
MSLeaderDistanceInfo getLeaders(const ChangerIt &target, const MSVehicle *ego) const
get leaders for ego on the given lane
StateAndDist checkChangeHelper(MSVehicle *vehicle, int laneOffset, LaneChangeAction alternatives)
helper function that calls checkChangeSublane and sets blocker information
static std::pair< MSVehicle *, double > findClosestLeader(const MSLeaderDistanceInfo &leaders, const MSVehicle *vehicle)
find the closest leader that prevents ego vehicle from passing on the current lane
bool myCheckedChangeOpposite
whether checkChangeOpposite was called for the current vehicle
virtual void initChanger()
Initialize the changer before looping over all vehicles.
bool checkChangeOpposite(MSVehicle *vehicle, int laneOffset, MSLane *targetLane, const std::pair< MSVehicle *const, double > &leader, const std::pair< MSVehicle *const, double > &neighLead, const std::pair< MSVehicle *const, double > &neighFollow, const std::vector< MSVehicle::LaneQ > &preb)
virtual void updateChanger(bool vehHasChanged)
void abortLCManeuver(MSVehicle *vehicle)
immediately stop lane-changing and register vehicle as unchanged
MSLaneChangerSublane()
Default constructor.
void outputLCEnded(MSVehicle *vehicle, ChangerIt &from, ChangerIt &to, int direction)
optional output for end of lane-change maneuvre
MSAbstractLaneChangeModel::StateAndDist StateAndDist
int checkChangeSublane(int laneOffset, LaneChangeAction alternatives, const std::vector< MSVehicle::LaneQ > &preb, double &latDist, double &maneuverDist) const
check whether sub-lane changing in the given direction is desirable and possible
bool continueChangeSublane(MSVehicle *vehicle, ChangerIt &from)
Continue a sublane-lane change maneuver and return whether the midpoint was passed in this step.
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
saves leader/follower vehicles and their distances relative to an ego vehicle
Definition: MSLeaderInfo.h:144
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77