Gazebo Common

API Reference

5.7.0
gz/common/Battery.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef GZ_COMMON_BATTERY_HH_
18 #define GZ_COMMON_BATTERY_HH_
19 
20 #include <functional>
21 #include <map>
22 #include <memory>
23 #include <string>
24 
25 #include <gz/common/Export.hh>
26 
27 #include <gz/utils/ImplPtr.hh>
28 
29 namespace gz
30 {
31  namespace common
32  {
43  class GZ_COMMON_VISIBLE Battery
44  {
48 
50  public: explicit Battery();
51 
55  public: Battery(const std::string &_name, const double _voltage);
56 
59  public: Battery(const Battery &_battery);
60 
64  public: Battery &operator=(const Battery &_battery);
65 
68  public: Battery(Battery &&_battery);
69 
73  public: Battery &operator=(Battery &&_battery);
74 
76  public: virtual ~Battery() = default;
77 
82  public: bool operator==(const Battery &_battery) const;
83 
88  public: bool operator!=(const Battery &_battery) const;
89 
91  public: virtual void Init();
92 
96  public: virtual void ResetVoltage();
97 
100  public: double InitVoltage() const;
101 
104  public: virtual void SetInitVoltage(const double _voltage);
105 
108  public: std::string Name() const;
109 
112  public: void SetName(const std::string &_name) const;
113 
116  public: uint32_t AddConsumer();
117 
122  public: bool RemoveConsumer(const uint32_t _consumerId);
123 
128  public: bool SetPowerLoad(const uint32_t _consumerId,
129  const double _powerLoad);
130 
135  public: bool PowerLoad(const uint32_t _consumerId,
136  double &_powerLoad) const;
137 
140  public: const PowerLoad_M &PowerLoads() const;
141 
144  public: double Voltage() const;
145 
153  public: void SetUpdateFunc(
154  std::function<double (Battery *)> _updateFunc);
155 
159  public: void ResetUpdateFunc();
160 
164  public: void Update();
165 
167  protected: void InitConsumers();
168 
172  private: double UpdateDefault(Battery *_battery);
173 
175  GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
176  };
177 
181  }
182 }
183 #endif
0"> 140  public: const PowerLoad_M &PowerLoads() const;
141 
144  public: double Voltage() const;
145 
153  public: void SetUpdateFunc(
154  std::function<double (Battery *)> _updateFunc);
155 
159  public: void ResetUpdateFunc();
160 
164  public: void Update();
165 
167  protected: void InitConsumers();
168 
172  private: double UpdateDefault(Battery *_battery);
173 
175  GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
176  };
177 
180  typedef std::shared_ptr<Battery> BatteryPtr;
181  }
182 }
183 #endif