Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2013-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 MSDevice_DriverState.h
15 : /// @author Leonhard Luecken
16 : /// @author Daniel Krajzewicz
17 : /// @author Jakob Erdmann
18 : /// @date 15.06.2018
19 : ///
20 : /// The Driver State Device mainly provides a configuration and interaction interface for the vehicle's driver state.
21 : /// @see microsim/MSDriverState.h
22 : ///
23 : /****************************************************************************/
24 : #pragma once
25 : #include <config.h>
26 :
27 : #include "MSVehicleDevice.h"
28 : #include <utils/common/SUMOTime.h>
29 : #include <utils/common/WrappingCommand.h>
30 :
31 :
32 : // ===========================================================================
33 : // class declarations
34 : // ===========================================================================
35 : class SUMOVehicle;
36 : class MSVehicle;
37 : class MSSimpleDriverState;
38 :
39 :
40 : // ===========================================================================
41 : // class definitions
42 : // ===========================================================================
43 : /**
44 : * @class MSDevice_DriverState
45 : *
46 : * @brief The ToC Device controls transition of control between automated and manual driving.
47 : * @todo: Provide logging facilities
48 : * @todo: allow manual and automated type to refer to vTypeDistributions
49 : *
50 : * @see MSDevice
51 : */
52 : class MSDevice_DriverState : public MSVehicleDevice {
53 : public:
54 : /** @brief Inserts MSDevice_DriverState-options
55 : * @param[filled] oc The options container to add the options to
56 : */
57 : static void insertOptions(OptionsCont& oc);
58 :
59 :
60 : /** @brief Build devices for the given vehicle, if needed
61 : *
62 : * The options are read and evaluated whether a ToC-device shall be built
63 : * for the given vehicle.
64 : *
65 : * The built device is stored in the given vector.
66 : *
67 : * @param[in] v The vehicle for which a device may be built
68 : * @param[filled] into The vector to store the built device in
69 : */
70 : static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
71 :
72 : /// update internal state
73 : void update();
74 :
75 : /// return internal state
76 : inline std::shared_ptr<MSSimpleDriverState> getDriverState() const {
77 : return myDriverState;
78 : }
79 :
80 : public:
81 : /// @brief Destructor.
82 388 : ~MSDevice_DriverState() {};
83 :
84 : /// @brief return the name for this type of device
85 316 : const std::string deviceName() const {
86 316 : return "driverstate";
87 : }
88 :
89 : /// @brief try to retrieve the given parameter from this device. Throw exception for unsupported key
90 : std::string getParameter(const std::string& key) const;
91 :
92 : /// @brief try to set the given parameter for this device. Throw exception for unsupported key
93 : void setParameter(const std::string& key, const std::string& value);
94 :
95 :
96 : private:
97 : /** @brief Constructor
98 : *
99 : * @param[in] holder The vehicle that holds this device
100 : * @param[in] id The ID of the device
101 : */
102 : MSDevice_DriverState(SUMOVehicle& holder, const std::string& id,
103 : double minAwareness,
104 : double initialAwareness,
105 : double errorTimeScaleCoefficient,
106 : double errorNoiseIntensityCoefficient,
107 : double speedDifferenceErrorCoefficient,
108 : double speedDifferenceChangePerceptionThreshold,
109 : double headwayChangePerceptionThreshold,
110 : double headwayErrorCoefficient,
111 : double freeSpeedErrorCoefficient,
112 : double maximalReactionTime);
113 :
114 : /// @brief Initialises the driver state parameters
115 : void initDriverState();
116 :
117 : private:
118 : /// @brief The holder vehicle casted to MSVehicle*
119 : MSVehicle* myHolderMS;
120 :
121 : /// @name Temporary to hold driverstate parameters until initialization.
122 : /// @note Invalid after call to initDriverState().
123 : /// @{
124 : double myMinAwareness;
125 : double myInitialAwareness;
126 : double myErrorTimeScaleCoefficient;
127 : double myErrorNoiseIntensityCoefficient;
128 : double mySpeedDifferenceErrorCoefficient;
129 : double mySpeedDifferenceChangePerceptionThreshold;
130 : double myHeadwayChangePerceptionThreshold;
131 : double myHeadwayErrorCoefficient;
132 : double myFreeSpeedErrorCoefficient;
133 : double myMaximalReactionTime;
134 : /// @}
135 :
136 : /// @brief The driver state of the holder.
137 : std::shared_ptr<MSSimpleDriverState> myDriverState;
138 :
139 : private:
140 : /// @brief Invalidated copy constructor.
141 : MSDevice_DriverState(const MSDevice_DriverState&);
142 :
143 : /// @brief Invalidated assignment operator.
144 : MSDevice_DriverState& operator=(const MSDevice_DriverState&);
145 :
146 : };
|