Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-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 : /****************************************************************************/
14 : /// @file MSCFModel_W99.h
15 : /// @author Jakob Erdmann
16 : /// @date June 2019
17 : ///
18 : // The psycho-physical model of Wiedemann (10-Parameter version from 1999)
19 : // code adapted from https://github.com/glgh/w99-demo
20 : // (MIT License, Copyright (c) 2016 glgh)
21 : /****************************************************************************/
22 : #pragma once
23 : #include <config.h>
24 :
25 : #include "MSCFModel.h"
26 : #include <microsim/MSLane.h>
27 : #include <microsim/MSVehicle.h>
28 : #include <microsim/MSVehicleType.h>
29 : #include <utils/xml/SUMOXMLDefinitions.h>
30 :
31 :
32 : // ===========================================================================
33 : // class definitions
34 : // ===========================================================================
35 : /** @class MSCFModel_W99
36 : * @brief The W99 Model car-following model
37 : * @see MSCFModel
38 : */
39 : // XXX: which W99 is this? There are several versions... Below it is stated that it is modified it with Krauss vsafe... (Leo)
40 : class MSCFModel_W99 : public MSCFModel {
41 : public:
42 :
43 : /** @brief Constructor
44 : * @param[in] vtype the type for which this model is built and also the parameter object to configure this model
45 : */
46 : MSCFModel_W99(const MSVehicleType* vtype);
47 :
48 :
49 : /// @brief Destructor
50 : ~MSCFModel_W99();
51 :
52 :
53 : /// @name Implementations of the MSCFModel interface
54 : /// @{
55 :
56 :
57 : /** @brief Computes the vehicle's safe speed (no dawdling)
58 : * @param[in] veh The vehicle (EGO)
59 : * @param[in] speed The vehicle's speed
60 : * @param[in] gap2pred The (net) distance to the LEADER
61 : * @param[in] predSpeed The speed of LEADER
62 : * @return EGO's safe speed
63 : * @see MSCFModel::ffeV
64 : */
65 : double followSpeed(const MSVehicle* const veh, double speed, double gap2pred, double predSpeed,
66 : double predMaxDecel, const MSVehicle* const pred = 0, const CalcReason usage = CalcReason::CURRENT) const;
67 :
68 :
69 : /** @brief Computes the vehicle's safe speed for approaching a non-moving obstacle (no dawdling)
70 : * @param[in] veh The vehicle (EGO)
71 : * @param[in] gap The (net) distance to the obstacle
72 : * @return EGO's safe speed for approaching a non-moving obstacle
73 : * @see MSCFModel::ffeS
74 : * @todo generic Interface, models can call for the values they need
75 : */
76 : double stopSpeed(const MSVehicle* const veh, const double speed, double gap, double decel, const CalcReason usage = CalcReason::CURRENT) const;
77 :
78 :
79 : /** @brief Returns the maximum gap at which an interaction between both vehicles occurs
80 : *
81 : * "interaction" means that the LEADER influences EGO's speed.
82 : * @param[in] veh The EGO vehicle
83 : * @param[in] vL LEADER's speed
84 : * @return The interaction gap
85 : * @todo evaluate signature
86 : * @see MSCFModel::interactionGap
87 : */
88 : double interactionGap(const MSVehicle* const, double vL) const;
89 :
90 : /** @brief Returns the model's name
91 : * @return The model's name
92 : * @see MSCFModel::getModelName
93 : */
94 0 : int getModelID() const {
95 0 : return SUMO_TAG_CF_W99;
96 : }
97 :
98 :
99 : /** @brief Duplicates the car-following model
100 : * @param[in] vtype The vehicle type this model belongs to (1:1)
101 : * @return A duplicate of this car-following model
102 : */
103 : MSCFModel* duplicate(const MSVehicleType* vtype) const;
104 :
105 :
106 : /// @}
107 :
108 : /*
109 : enum Status {
110 : DECEL1,
111 : DECEL2,
112 : FOLLOW,
113 : FREE_FLOW,
114 : }
115 :
116 : private:
117 : class VehicleVariables : public MSCFModel::VehicleVariables {
118 : public:
119 : VehicleVariables() : lastStatus(FREE_FLOW) {}
120 : /// @brief state variable for remembering the previous state
121 : Status lastStatus;
122 : };
123 : */
124 :
125 :
126 : private:
127 : /// @name model parameter
128 : /// @{
129 :
130 : //const double myCC0; // StandStill Distance - (using minGap)
131 : const double myCC1; // Spacing Time - s
132 : const double myCC2; // Following Variation ("max drift") - m
133 : const double myCC3; // Threshold for Entering 'Following' - s
134 : const double myCC4; // Negative 'Following' Threshold - m/s
135 : const double myCC5; // Positive 'Following' Threshold - m/s
136 : const double myCC6; // Speed Dependency of Oscillation - 10^-4 rad/s
137 : const double myCC7; // Oscillation Acceleration - m/s^2
138 : const double myCC8; // Standstill Acceleration - m/s^2
139 : const double myCC9; // Acceleration at 80km/h - m/s^2
140 : /// @}
141 :
142 :
143 : void computeThresholds(double speed, double predSpeed, double leaderAccel, double rndVal,
144 : double& sdxc, double& sdxo, double& sdxv) const;
145 :
146 : private:
147 : /// @brief Invalidated assignment operator
148 : MSCFModel_W99& operator=(const MSCFModel_W99& s);
149 : };
|