Laelaps  2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
laeDb.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: Laelaps
4 //
5 // File: laeDb.h
6 //
7 /*! \file
8  *
9  * $LastChangedDate: 2015-12-28 10:06:00 -0700 (Mon, 28 Dec 2015) $
10  * $Rev: 4247 $
11  *
12  * \brief Laelaps real-time "database".
13  *
14  * The Laelaps library use a single instance of this DB to export library global
15  * data. No concurrency control is exercised. For each DB datam, there should
16  * only be one writer (producer) and that the writes are atomic enough. Multiple
17  * readers can access the data.
18  *
19  * A more robust, fullier featured database may be developed at some future
20  * date, if needed.
21  *
22  * \author Robin Knight (robin.knight@roadnarrows.com)
23  *
24  * \par Copyright
25  * \h_copy 2015-2017. RoadNarrows LLC.\n
26  * http://www.roadnarrows.com\n
27  * All Rights Reserved
28  */
29 /*
30  * @EulaBegin@
31  *
32  * Unless otherwise stated explicitly, all materials contained are copyrighted
33  * and may not be used without RoadNarrows LLC's written consent,
34  * except as provided in these terms and conditions or in the copyright
35  * notice (documents and software) or other proprietary notice provided with
36  * the relevant materials.
37  *
38  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY
39  * MEMBERS/EMPLOYEES/CONTRACTORS OF ROADNARROWS OR DISTRIBUTORS OF THIS SOFTWARE
40  * BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR
41  * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
42  * DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN
43  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44  *
45  * THE AUTHORS AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
46  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
47  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
48  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
49  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
50  *
51  * @EulaEnd@
52  */
53 ////////////////////////////////////////////////////////////////////////////////
54 
55 #ifndef _LAE_DB_H
56 #define _LAE_DB_H
57 
58 #include "rnr/rnrconfig.h"
59 
60 #include "Laelaps/laelaps.h"
61 #include "Laelaps/laeSysDev.h"
62 #include "Laelaps/laeMotor.h"
63 #include "Laelaps/laeImu.h"
64 #include "Laelaps/laeAlarms.h"
65 
66 /*!
67  * \brief The \h_laelaps namespace encapsulates all \h_laelaps related
68  * constructs.
69  */
70 namespace laelaps
71 {
72 #define RTDB_SIG_LEN 32 ///< database signature length (bytes)
73 
74  /*!
75  * \brief Product data.
76  */
77  struct LaeDbProduct
78  {
79  int m_eProdId; ///< base product id
80  uint_t m_uProdHwVer; ///< product hardware version number
82  ///< motor controllers firmware versions
83  uint_t m_uImuFwVer; ///< IMU sub-processor firmware version
84  uint_t m_uWatchDogFwVer; ///< watchdog sub-processor firmware version
85  uint_t m_uToFMuxFwVer; ///< ToF Mux sub-processor firmware version
86  uint_t m_uAccFwVer; ///< accessory sub-processor firmware version
87  }; // LaeDbProduct
88 
89  /*!
90  * \brief Robot configuration parameters.
91  */
92  struct LaeDbConfig
93  {
94  double m_fKinThreadHz; ///< kinodynamics thread exec rate (hertz)
95  double m_fImuThreadHz; ///< IMU thread exec rate (Hertz)
96  double m_fRangeThreadHz; ///< range group thread exec rate (Hertz)
97  double m_fWatchDogThreadHz; ///< watchdog thread exec rate (Hertz)
98  double m_fWatchDogTimeout; ///< watchdog timeout (seconds)
99  double m_fVelocityDerate; ///< velocity derate (percent)
100  }; // LaeDbConfig
101 
102  /*!
103  * \brief Robot top-level status.
104  */
106  {
107  bool m_bIsConnected; ///< critical hardware [not] connected
108  LaeRobotMode m_eRobotMode; ///< robot operating mode
109  bool m_bIsEStopped; ///< robot is [not] emergency stopped
110  bool m_bAlarmState; ///< robot is [not] alarmed
111  bool m_bAreMotorsPowered;///< robot motors are [not] driven
112  bool m_bInMotion; ///< 1+ motors are [not] moving
113  double m_fTempAvg; ///< average interior temperature
114  };
115 
116  /*!
117  * \brief Enabled subsytems.
118  */
119  struct LaeDbEnable
120  {
121  bool m_bMotorCtlr; ///< motor controller [not] enabled
122  bool m_bAuxPortBatt; ///< battery auxilliary port [not] enabled
123  bool m_bAuxPort5v; ///< 5 volt auxilliary port [not] enabled
124  bool m_bRange; ///< Range sensors [not] enabled
125  bool m_bImu; ///< IMU sensor [not] enabled
126  bool m_bFCam; ///< Front camera [not] enabled
127  };
128 
129  /*!
130  * \brief Motor controller data.
131  */
133  {
134  u32_t m_uStatus; ///< status bits
135  double m_fTemperature; ///< sensed temperature (C)
136  double m_fBatteryVoltage; ///< sensed battery voltage (V)
137  double m_fMotorCurrent[LaeNumMotorsPerCtlr]; ///< motor currents (A)
138  }; // LaeDbMotorCtlr
139 
140  /*!
141  * \brief Range sensor data.
142  */
143  struct LaeDbRange
144  {
145  double m_fRange; ///< range (m)
146  double m_fAmbientLight; ///< ambient light (lux)
147  };
148 
149  /*!
150  * \brief IMU sensor data.
151  */
152  struct LaeDbImu
153  {
154  double m_accel[sensor::imu::NumOfAxes]; ///< accelerometer data (m/s^2)
155  double m_gyro[sensor::imu::NumOfAxes]; ///< gyroscope data (radians/s)
156  double m_rpy[sensor::imu::NumOfAxes]; ///< vehicle roll,pitch,yaw (rads)
157  };
158 
159  /*!
160  * \brief Powertrain kinodynamics data.
161  */
163  {
164  s64_t m_nEncoder; ///< motor encoder position (quad pulses)
165  int m_nSpeed; ///< raw speed (qpps)
166  double m_fPosition; ///< wheel angular position (radians)
167  double m_fVelocity; ///< wheel angular velocity (radians/second)
168  double m_fPe; ///< motor input electrical power (W)
169  double m_fTorque; ///< wheel torque (N-m)
170  };
171 
172  /*!
173  * \brief Robot platform kinodynamics data.
174  */
176  {
177  double m_x; ///< robot absolute x position (meters)
178  double m_y; ///< robot absolute y position (meters)
179  double m_theta; ///< robot orientation (radians)
180  double m_fOdometer; ///< robot odometer (meters)
181  double m_fVelocity; ///< robot velocity (meters/second)
182  };
183 
184  /*!
185  * \brief Kinodynamics data.
186  */
187  struct LaeDbKin
188  {
190  ///< powertrain kinodynamics
191  LaeDbKinRobot m_robot; ///< robot kinodynmics
192  };
193 
194  /*!
195  * \brief Energy monitoring data.
196  */
197  struct LaeDbEnergy
198  {
199  bool m_bBatteryIsCharging; ///< batteries are [not] being charged
200  double m_fJackVoltage; ///< sensed power supply jack voltage
201  double m_fBatteryVoltage; ///< sensed battery subsystem voltage (V)
202  double m_fBatterySoC; ///< estimated battery state of charge (%)
203  double m_fTotalCurrent; ///< estimated total system current draw (A)
204  double m_fTotalPower; ///< estimated total system power (watts)
205  }; // LaeDbEnergy
206 
207  /*!
208  * \brief System and subsystem alarms and warnings data tree.
209  */
210  struct LaeDbAlarms
211  {
212  LaeAlarmInfo m_system; ///< system alarm summary state
213  LaeAlarmInfo m_battery; ///< battery subsystem alarm state
215  ///< motor contollers subsytem state
216  LaeAlarmInfo m_motor[LaeMotorsNumOf]; ///< motors subsytem state
217  LaeAlarmInfo m_sensors; ///< sensor alarms
218  }; // LaeDbAlarms
219 
220  /*!
221  * \brief Simple real-time database structure.
222  */
223  struct LaeDb
224  {
225  char m_signature[RTDB_SIG_LEN]; ///< database signature
226  u32_t m_uDbVer; ///< database version
227  LaeDbProduct m_product; ///< product data
228  LaeDbConfig m_config; ///< configuration data
229  LaeDbRobotStatus m_robotstatus; ///< robot status data
230  LaeDbEnable m_enable; ///< key gpio state data
232  ///< motor controller and motor data
234  ///< range sensors
235  LaeDbImu m_imu; ///< imu
236  LaeDbKin m_kin; ///< kinodynamics
237  LaeDbEnergy m_energy; ///< battery and energy data
238  LaeDbAlarms m_alarms; ///< alarm state data
239  }; // LaeDb
240 
241  /*!
242  * \brief The real-time database.
243  */
244  extern LaeDb RtDb;
245 
246 } // namespace laelaps
247 
248 
249 #endif // _LAE_DB_H
Powertrain kinodynamics data.
Definition: laeDb.h:162
LaeAlarmInfo m_sensors
sensor alarms
Definition: laeDb.h:217
double m_fPe
motor input electrical power (W)
Definition: laeDb.h:168
int m_eProdId
base product id
Definition: laeDb.h:79
int m_nSpeed
raw speed (qpps)
Definition: laeDb.h:165
LaeDbProduct m_product
product data
Definition: laeDb.h:227
Alarm information state structure.
Definition: laeAlarms.h:157
LaeDbKin m_kin
kinodynamics
Definition: laeDb.h:236
double m_fBatteryVoltage
sensed battery subsystem voltage (V)
Definition: laeDb.h:201
uint_t m_uProdHwVer
product hardware version number
Definition: laeDb.h:80
LaeRobotMode
<b><i>Laelaps</i></b> mode of operation.
Definition: laelaps.h:327
double m_fBatteryVoltage
sensed battery voltage (V)
Definition: laeDb.h:136
LaeDbRobotStatus m_robotstatus
robot status data
Definition: laeDb.h:229
static const int LaeMotorsNumOf
number of motors
Definition: laeMotor.h:107
uint_t m_uMotorCtlrFwVer[LaeNumMotorCtlrs]
motor controllers firmware versions
Definition: laeDb.h:81
System and subsystem alarms and warnings data tree.
Definition: laeDb.h:210
double m_fWatchDogThreadHz
watchdog thread exec rate (Hertz)
Definition: laeDb.h:97
double m_fVelocity
robot velocity (meters/second)
Definition: laeDb.h:181
double m_fBatterySoC
estimated battery state of charge (%)
Definition: laeDb.h:202
Range sensor data.
Definition: laeDb.h:143
double m_fKinThreadHz
kinodynamics thread exec rate (hertz)
Definition: laeDb.h:94
LaeDbKinRobot m_robot
robot kinodynmics
Definition: laeDb.h:191
uint_t m_uAccFwVer
accessory sub-processor firmware version
Definition: laeDb.h:86
double m_fVelocityDerate
velocity derate (percent)
Definition: laeDb.h:99
bool m_bBatteryIsCharging
batteries are [not] being charged
Definition: laeDb.h:199
#define RTDB_SIG_LEN
database signature length (bytes)
Definition: laeDb.h:72
LaeAlarmInfo m_battery
battery subsystem alarm state
Definition: laeDb.h:213
Robot configuration parameters.
Definition: laeDb.h:92
Robot platform kinodynamics data.
Definition: laeDb.h:175
double m_fOdometer
robot odometer (meters)
Definition: laeDb.h:180
const int ToFSensorMaxNumOf
maximum number of ToF sensors
Definition: laeSysDev.h:244
LaeDb RtDb
The real-time database.
Definition: laeDb.h:244
uint_t m_uImuFwVer
IMU sub-processor firmware version.
Definition: laeDb.h:83
double m_fTotalPower
estimated total system power (watts)
Definition: laeDb.h:204
double m_fVelocity
wheel angular velocity (radians/second)
Definition: laeDb.h:167
LaeAlarmInfo m_system
system alarm summary state
Definition: laeDb.h:212
bool m_bAuxPortBatt
battery auxilliary port [not] enabled
Definition: laeDb.h:122
u32_t m_uDbVer
database version
Definition: laeDb.h:226
LaeRobotMode m_eRobotMode
robot operating mode
Definition: laeDb.h:108
double m_fImuThreadHz
IMU thread exec rate (Hertz)
Definition: laeDb.h:95
double m_fWatchDogTimeout
watchdog timeout (seconds)
Definition: laeDb.h:98
Product data.
Definition: laeDb.h:77
bool m_bIsConnected
critical hardware [not] connected
Definition: laeDb.h:107
s64_t m_nEncoder
motor encoder position (quad pulses)
Definition: laeDb.h:164
bool m_bImu
IMU sensor [not] enabled.
Definition: laeDb.h:125
double m_y
robot absolute y position (meters)
Definition: laeDb.h:178
double m_fTotalCurrent
estimated total system current draw (A)
Definition: laeDb.h:203
double m_theta
robot orientation (radians)
Definition: laeDb.h:179
uint_t m_uToFMuxFwVer
ToF Mux sub-processor firmware version.
Definition: laeDb.h:85
LaeDbEnable m_enable
key gpio state data
Definition: laeDb.h:230
The <b><i>Laelaps</i></b> namespace encapsulates all <b><i>Laelaps</i></b> related constructs...
Definition: laeAlarms.h:64
bool m_bFCam
Front camera [not] enabled.
Definition: laeDb.h:126
bool m_bInMotion
1+ motors are [not] moving
Definition: laeDb.h:112
LaeDbEnergy m_energy
battery and energy data
Definition: laeDb.h:237
double m_fJackVoltage
sensed power supply jack voltage
Definition: laeDb.h:200
Laelaps built-in Inertial Measurement Unit class interface.
double m_x
robot absolute x position (meters)
Definition: laeDb.h:177
double m_fPosition
wheel angular position (radians)
Definition: laeDb.h:166
uint_t m_uWatchDogFwVer
watchdog sub-processor firmware version
Definition: laeDb.h:84
double m_fTemperature
sensed temperature (C)
Definition: laeDb.h:135
bool m_bRange
Range sensors [not] enabled.
Definition: laeDb.h:124
LaeDbImu m_imu
imu
Definition: laeDb.h:235
double m_fTorque
wheel torque (N-m)
Definition: laeDb.h:169
bool m_bIsEStopped
robot is [not] emergency stopped
Definition: laeDb.h:109
u32_t m_uStatus
status bits
Definition: laeDb.h:134
Laelaps system devices.
bool m_bMotorCtlr
motor controller [not] enabled
Definition: laeDb.h:121
Enabled subsytems.
Definition: laeDb.h:119
Robot top-level status.
Definition: laeDb.h:105
Laelaps motors, encoder, and controllers hardware abstraction interfaces.
Laelaps alarm monitoring class interface.
static const int LaeNumMotorCtlrs
number of motor controllers
Definition: laeMotor.h:115
Energy monitoring data.
Definition: laeDb.h:197
LaeDbAlarms m_alarms
alarm state data
Definition: laeDb.h:238
bool m_bAuxPort5v
5 volt auxilliary port [not] enabled
Definition: laeDb.h:123
double m_fTempAvg
average interior temperature
Definition: laeDb.h:113
bool m_bAlarmState
robot is [not] alarmed
Definition: laeDb.h:110
LaeDbConfig m_config
configuration data
Definition: laeDb.h:228
Simple real-time database structure.
Definition: laeDb.h:223
bool m_bAreMotorsPowered
robot motors are [not] driven
Definition: laeDb.h:111
double m_fRange
range (m)
Definition: laeDb.h:145
Kinodynamics data.
Definition: laeDb.h:187
Motor controller data.
Definition: laeDb.h:132
double m_fRangeThreadHz
range group thread exec rate (Hertz)
Definition: laeDb.h:96
static const int LaeNumMotorsPerCtlr
number of motors/controller
Definition: laeMotor.h:130
IMU sensor data.
Definition: laeDb.h:152
Top-level package include file.
double m_fAmbientLight
ambient light (lux)
Definition: laeDb.h:146