1 /****************************************************************************/ 2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 3 // Copyright (C) 2002-2019 German Aerospace Center (DLR) and others. 4 // This program and the accompanying materials 5 // are made available under the terms of the Eclipse Public License v2.0 6 // which accompanies this distribution, and is available at 7 // http://www.eclipse.org/legal/epl-v20.html 8 // SPDX-License-Identifier: EPL-2.0 9 /****************************************************************************/ 10 /// @file MSLaneChangerSublane.h 11 /// @author Jakob Erdmann 12 /// @author Leonhard Luecken 13 /// @date Oct 2015 14 /// @version $Id$ 15 /// 16 // Performs sub-lane changing of vehicles 17 /****************************************************************************/ 18 #ifndef MSLaneChangerSublane_h 19 #define MSLaneChangerSublane_h 20 21 22 // =========================================================================== 23 // included modules 24 // =========================================================================== 25 #include <config.h> 26 27 #include <microsim/lcmodels/MSAbstractLaneChangeModel.h> 28 #include "MSLaneChanger.h" 29 30 31 // =========================================================================== 32 // class declarations 33 // =========================================================================== 34 35 36 // =========================================================================== 37 // class definitions 38 // =========================================================================== 39 /** 40 * @class MSLaneChangerSublane 41 * @brief Performs lane changing of vehicles 42 */ 43 class MSLaneChangerSublane : public MSLaneChanger { 44 public: 45 /// Constructor 46 MSLaneChangerSublane(const std::vector<MSLane*>* lanes, bool allowChanging); 47 48 /// Destructor. 49 ~MSLaneChangerSublane(); 50 51 protected: 52 53 /** Find a new candidate and try to change it. */ 54 virtual bool change(); 55 56 /// @brief Initialize the changer before looping over all vehicles. 57 virtual void initChanger(); 58 59 /** After the possible change, update the changer. */ 60 virtual void updateChanger(bool vehHasChanged); 61 62 /** @brief check whether sub-lane changing in the given direction is desirable 63 * and possible 64 * @param[in] laneOffset The direction in which changing should be checked 65 * @param[in] leaders The candidate vehicle's leaders 66 * @param[in] preb The bestLanse of the candidaet vehicle 67 * @param[out] latDist The distance by which the vehicle changes laterally 68 * @param[out] maneuverDist The lateral distance for the complete envisioned maneuver 69 * (used for maneuver continuation in non-actionsteps). 70 */ 71 int checkChangeSublane( 72 int laneOffset, 73 LaneChangeAction alternatives, 74 const std::vector<MSVehicle::LaneQ>& preb, 75 double& latDist, 76 double& maneuverDist) const; 77 78 /// @brief Continue a sublane-lane change maneuver and return whether the midpoint was passed in this step 79 // (used to continue sublane changing in non-action steps). 80 bool continueChangeSublane(MSVehicle* vehicle, ChangerIt& from); 81 82 /// @brief change by the specified amount and return whether a new lane was entered 83 bool startChangeSublane(MSVehicle* vehicle, ChangerIt& from, double latDist); 84 85 /// @brief check whether the given vehicle has entered the new lane 'to->lane' during a sublane LC-step 86 bool checkChangeToNewLane(MSVehicle* vehicle, const int direction, ChangerIt from, ChangerIt to); 87 88 /// @brief get leaders for ego on the given lane 89 MSLeaderDistanceInfo getLeaders(const ChangerIt& target, const MSVehicle* ego) const; 90 91 /// @brief immediately stop lane-changing and register vehicle as unchanged 92 void abortLCManeuver(MSVehicle* vehicle); 93 94 typedef MSAbstractLaneChangeModel::StateAndDist StateAndDist; 95 /// @brief helper function that calls checkChangeSublane and sets blocker information 96 StateAndDist checkChangeHelper(MSVehicle* vehicle, int laneOffset, LaneChangeAction alternatives); 97 98 /// @brief optional output for start of lane-change maneuvre 99 void outputLCStarted(MSVehicle* vehicle, ChangerIt& from, ChangerIt& to, int direction); 100 /// @brief optional output for end of lane-change maneuvre 101 void outputLCEnded(MSVehicle* vehicle, ChangerIt& from, ChangerIt& to, int direction); 102 103 private: 104 /// Default constructor. 105 MSLaneChangerSublane(); 106 107 /// Copy constructor. 108 MSLaneChangerSublane(const MSLaneChangerSublane&); 109 110 /// Assignment operator. 111 MSLaneChangerSublane& operator=(const MSLaneChangerSublane&); 112 }; 113 114 115 #endif 116 117 /****************************************************************************/ 118 119