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_Friction.h
15 : /// @author Daniel Krajzewicz
16 : /// @author Jakob Erdmann
17 : /// @date 11.06.2013
18 : ///
19 : // A device which stands as an implementation example and which outputs movereminder calls
20 : /****************************************************************************/
21 : #pragma once
22 : #include <config.h>
23 :
24 : #include "MSVehicleDevice.h"
25 :
26 :
27 : // ===========================================================================
28 : // class declarations
29 : // ===========================================================================
30 : class SUMOTrafficObject;
31 :
32 :
33 : // ===========================================================================
34 : // class definitions
35 : // ===========================================================================
36 : /**
37 : * @class MSDevice_Friction
38 : * @brief A device which collects info on current friction Coefficient on the road
39 : *
40 : * Each device collects friction -> insert Measurment modell if applicapble
41 : *
42 : * @see MSDevice
43 : */
44 : class MSDevice_Friction : public MSVehicleDevice {
45 : public:
46 : /** @brief Inserts MSDevice_Friction-options
47 : * @param[filled] oc The options container to add the options to
48 : */
49 : static void insertOptions(OptionsCont& oc);
50 :
51 : /** @brief Build devices for the given vehicle, if needed
52 : *
53 : * The options are read and evaluated whether a example-device shall be built
54 : * for the given vehicle.
55 : *
56 : * The built device is stored in the given vector.
57 : *
58 : * @param[in] v The vehicle for which a device may be built
59 : * @param[filled] into The vector to store the built device in
60 : */
61 : static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
62 :
63 : public:
64 : /// @brief Destructor.
65 : ~MSDevice_Friction();
66 :
67 : /// @name Methods called on vehicle movement / state change, overwriting MSDevice
68 : /// @{
69 :
70 : /** @brief Checks for waiting steps when the vehicle moves
71 : *
72 : * @param[in] veh Vehicle that asks this reminder.
73 : * @param[in] oldPos Position before move.
74 : * @param[in] newPos Position after move with newSpeed.
75 : * @param[in] newSpeed speed update.
76 : *
77 : * @return True (always).
78 : */
79 : bool notifyMove(SUMOTrafficObject& veh, double oldPos,
80 : double newPos, double newSpeed);
81 : /// @}
82 :
83 : /// @brief return the name for this type of device
84 0 : const std::string deviceName() const {
85 0 : return "friction";
86 : }
87 :
88 : /// @brief try to retrieve the given parameter from this device. Throw exception for unsupported key
89 : std::string getParameter(const std::string& key) const;
90 :
91 : /// @brief try to set the given parameter for this device. Throw exception for unsupported key
92 : void setParameter(const std::string& key, const std::string& value);
93 :
94 : inline double getMeasuredFriction() {
95 3556 : return myMeasuredFrictionCoefficient;
96 : }
97 :
98 : private:
99 : /** @brief Constructor
100 : *
101 : * @param[in] holder The vehicle that holds this device
102 : * @param[in] id The ID of the device
103 : */
104 : MSDevice_Friction(SUMOVehicle& holder, const std::string& id,
105 : double stdDev, double offset);
106 :
107 : private:
108 : // private state members of the Friction device
109 :
110 : /// @brief a value which is initialised based on a commandline/configuration option
111 : double myMeasuredFrictionCoefficient;
112 :
113 : /// @brief realValue from Road (without measurement model)
114 : double myRawFriction;
115 :
116 : /// @brief a value which is initialised based on a vehicle parameter
117 : double myStdDeviation;
118 :
119 : /// @brief a value which is initialised based on a vType parameter
120 : double myOffset;
121 :
122 : private:
123 : /// @brief Invalidated copy constructor.
124 : MSDevice_Friction(const MSDevice_Friction&);
125 :
126 : /// @brief Invalidated assignment operator.
127 : MSDevice_Friction& operator=(const MSDevice_Friction&);
128 :
129 : };
|