Laelaps  2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
laeBatt.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: Laelaps
4 //
5 // File: laeBatt.h
6 //
7 /*! \file
8  *
9  * $LastChangedDate: 2016-01-21 16:50:25 -0700 (Thu, 21 Jan 2016) $
10  * $Rev: 4268 $
11  *
12  * \brief Laelaps battery management and energy monitoring class interface.
13  *
14  * A class instance runs under the control of the WatchDog thread.
15  *
16  * \author Robin Knight (robin.knight@roadnarrows.com)
17  *
18  * \par Copyright
19  * \h_copy 2015-2017. RoadNarrows LLC.\n
20  * http://www.roadnarrows.com\n
21  * All Rights Reserved
22  */
23 /*
24  * @EulaBegin@
25  *
26  * Unless otherwise stated explicitly, all materials contained are copyrighted
27  * and may not be used without RoadNarrows LLC's written consent,
28  * except as provided in these terms and conditions or in the copyright
29  * notice (documents and software) or other proprietary notice provided with
30  * the relevant materials.
31  *
32  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY
33  * MEMBERS/EMPLOYEES/CONTRACTORS OF ROADNARROWS OR DISTRIBUTORS OF THIS SOFTWARE
34  * BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR
35  * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
36  * DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN
37  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38  *
39  * THE AUTHORS AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
40  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
41  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
42  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
43  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
44  *
45  * @EulaEnd@
46  */
47 ////////////////////////////////////////////////////////////////////////////////
48 
49 #ifndef _LAE_BATT_H
50 #define _LAE_BATT_H
51 
52 #include "rnr/rnrconfig.h"
53 
54 #include "Laelaps/laelaps.h"
55 
56 /*!
57  * \brief The \h_laelaps namespace encapsulates all \h_laelaps related
58  * constructs.
59  */
60 namespace laelaps
61 {
62  /*!
63  * \brief Battery Management and System Energy Monitoring (BMSEM) Class.
64  */
65  class LaeBattery
66  {
67  public:
68  /*!
69  * \brief Default constructor.
70  */
71  LaeBattery();
72 
73  /*!
74  * \brief Destructor.
75  */
76  virtual ~LaeBattery();
77 
78  /*!
79  * \brief Get the most recently updated battery charging state.
80  *
81  * \return The batteries are [not] being charged.
82  */
84  {
85  return m_bIsCharging;
86  }
87 
88  /*!
89  * \brief Get the most recently sensed battery voltage.
90  *
91  * The battery voltage is the (weighted) average of all voltage sensors
92  * from all batteries.
93  *
94  * \return The sensed battery average voltage (V).
95  */
97  {
98  return m_fBatteryVoltage;
99  }
100 
101  /*!
102  * \brief Get the most recently estimated battery state of charge.
103  *
104  * \return State of Charge (0.0% - 100.0%).
105  */
107  {
108  return m_fBatterySoC;
109  }
110 
111  /*!
112  * \brief Get most recently sensed current pulled by all motors.
113  *
114  * \param Motor current (amps).
115  */
117  {
118  return m_fMotorAmps;
119  }
120 
121  /*!
122  * \brief Get most recently calculated power used by all motors.
123  *
124  * \return Motor power (watts).
125  */
126  double getMotorPowerElec(const double fMotorWatts)
127  {
128  return m_fMotorWatts;
129  }
130 
131  /*!
132  * \brief Get most recently estimated total current pulled by the robot.
133  *
134  * \return System total current (amps).
135  */
137  {
138  return m_fTotalAmps;
139  }
140 
141  /*!
142  * \brief Get most recently estimated power consumed by robot.
143  *
144  * \return System total power (watts).
145  */
146  double getTotalPower()
147  {
148  return m_fTotalWatts;
149  }
150 
151  /*!
152  * \brief Calculate the present energy state of the robot motors.
153  *
154  * \note The motor controllers have battery voltage sensors, so the
155  * battery voltage is determined here also.
156  */
157  virtual void calcMotorEnergyState();
158 
159  /*!
160  * \brief Calculate the present energy state of all logic curcuitry.
161  *
162  * Logic circuitry includes odroid, motor controllers, battery chargers,
163  * IMU, watchdog sub-processor, sensors, and supporting hardware.
164  */
165  virtual void calcLogicEnergyState();
166 
167  /*!
168  * \brief Estimate batteries State of Charge given the present energy state.
169  *
170  * \return SoC [0.0% - 100.0%]
171  */
172  virtual double estimateBatteryStateOfCharge();
173 
174  /*!
175  * \brief Update the energy state for all of the robot's subsystems.
176  */
177  virtual void update();
178 
179  protected:
180  bool m_bIsCharging; ///< the battery is [not] being charged
181  double m_fBatteryVoltage; ///< sensed battery output voltage (V)
182  double m_fBatterySoC; ///< battery state of charge (0% - 100%)
183  double m_fMotorAmps; ///< sensed current for all motors (A)
184  double m_fMotorWatts; ///< sensed power for all motors (watts)
185  double m_fLogicAmps; ///< current consumed by logic circuitry (A)
186  double m_fLogicWatts; ///< power consumed by logic circuitry (watts)
187  double m_fTotalAmps; ///< total system current draw (A)
188  double m_fTotalWatts; ///< total system power used (watts)
189  }; // LaeBattery
190 
191 } // namespace laelaps
192 
193 
194 #endif // _LAE_BATT_H
double m_fTotalWatts
total system power used (watts)
Definition: laeBatt.h:188
double m_fBatteryVoltage
sensed battery output voltage (V)
Definition: laeBatt.h:181
virtual double estimateBatteryStateOfCharge()
Estimate batteries State of Charge given the present energy state.
Definition: laeBatt.cxx:326
double m_fMotorAmps
sensed current for all motors (A)
Definition: laeBatt.h:183
double m_fLogicAmps
current consumed by logic circuitry (A)
Definition: laeBatt.h:185
double getTotalCurrent()
Get most recently estimated total current pulled by the robot.
Definition: laeBatt.h:136
bool getChargingState()
Get the most recently updated battery charging state.
Definition: laeBatt.h:83
double m_fMotorWatts
sensed power for all motors (watts)
Definition: laeBatt.h:184
double getTotalPower()
Get most recently estimated power consumed by robot.
Definition: laeBatt.h:146
virtual void calcMotorEnergyState()
Calculate the present energy state of the robot motors.
Definition: laeBatt.cxx:266
virtual ~LaeBattery()
Destructor.
Definition: laeBatt.cxx:262
double getMotorPowerElec(const double fMotorWatts)
Get most recently calculated power used by all motors.
Definition: laeBatt.h:126
The <b><i>Laelaps</i></b> namespace encapsulates all <b><i>Laelaps</i></b> related constructs...
Definition: laeAlarms.h:64
double m_fLogicWatts
power consumed by logic circuitry (watts)
Definition: laeBatt.h:186
double getBatteryStateOfCharge()
Get the most recently estimated battery state of charge.
Definition: laeBatt.h:106
double getBatteryVoltage()
Get the most recently sensed battery voltage.
Definition: laeBatt.h:96
double getMotorCurrent()
Get most recently sensed current pulled by all motors.
Definition: laeBatt.h:116
double m_fBatterySoC
battery state of charge (0% - 100%)
Definition: laeBatt.h:182
Battery Management and System Energy Monitoring (BMSEM) Class.
Definition: laeBatt.h:65
double m_fTotalAmps
total system current draw (A)
Definition: laeBatt.h:187
LaeBattery()
Default constructor.
Definition: laeBatt.cxx:250
bool m_bIsCharging
the battery is [not] being charged
Definition: laeBatt.h:180
virtual void update()
Update the energy state for all of the robot&#39;s subsystems.
Definition: laeBatt.cxx:373
virtual void calcLogicEnergyState()
Calculate the present energy state of all logic curcuitry.
Definition: laeBatt.cxx:317
Top-level package include file.