Gazebo Common

API Reference

6.1.0
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 <cstdint>
21#include <functional>
22#include <map>
23#include <memory>
24#include <string>
25
26#include <gz/common/Export.hh>
27
28#include <gz/utils/ImplPtr.hh>
29
30namespace gz
31{
32 namespace common
33 {
44 class GZ_COMMON_VISIBLE Battery
45 {
49
51 public: explicit Battery();
52
56 public: Battery(const std::string &_name, const double _voltage);
57
60 public: Battery(const Battery &_battery);
61
65 public: Battery &operator=(const Battery &_battery);
66
69 public: Battery(Battery &&_battery);
70
74 public: Battery &operator=(Battery &&_battery);
75
77 public: virtual ~Battery() = default;
78
83 public: bool operator==(const Battery &_battery) const;
84
89 public: bool operator!=(const Battery &_battery) const;
90
92 public: virtual void Init();
93
97 public: virtual void ResetVoltage();
98
101 public: double InitVoltage() const;
102
105 public: virtual void SetInitVoltage(const double _voltage);
106
109 public: std::string Name() const;
110
113 public: void SetName(const std::string &_name) const;
114
117 public: uint32_t AddConsumer();
118
123 public: bool RemoveConsumer(const uint32_t _consumerId);
124
129 public: bool SetPowerLoad(const uint32_t _consumerId,
130 const double _powerLoad);
131
136 public: bool PowerLoad(const uint32_t _consumerId,
137 double &_powerLoad) const;
138
141 public: const PowerLoad_M &PowerLoads() const;
142
145 public: double Voltage() const;
146
154 public: void SetUpdateFunc(
155 std::function<double (Battery *)> _updateFunc);
156
160 public: void ResetUpdateFunc();
161
165 public: void Update();
166
168 protected: void InitConsumers();
169
173 private: double UpdateDefault(Battery *_battery);
174
176 GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
177 };
178
182 }
183}
184#endif