Laelaps  2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
laePlatform.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: Laelaps
4 //
5 // Library: liblaelaps
6 //
7 // File: laePlatform.h
8 //
9 /*! \file
10  *
11  * $LastChangedDate: 2016-02-15 12:16:48 -0700 (Mon, 15 Feb 2016) $
12  * $Rev: 4319 $
13  *
14  * \brief Laelaps robotic platform control and dynamics state interface.
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_PLATFORM_H
50 #define _LAE_PLATFORM_H
51 
52 #include <string>
53 #include <vector>
54 
55 #include "rnr/rnrconfig.h"
56 
57 #include "Laelaps/RoboClaw.h"
58 
59 #include "Laelaps/laelaps.h"
60 #include "Laelaps/laeTune.h"
61 #include "Laelaps/laeMotor.h"
62 #include "Laelaps/laeUtils.h"
63 #include "Laelaps/laeTraj.h"
64 #include "Laelaps/laePowertrain.h"
65 
66 namespace laelaps
67 {
68  // ---------------------------------------------------------------------------
69  // Class LaeMotorCtlrState
70  // ---------------------------------------------------------------------------
71 
72  /*!
73  * \brief Robot base motor controller board state.
74  */
76  {
77  public:
78  std::string m_strName; ///< motor controller name
79  double m_fMainVolts; ///< average sensed battery voltage (V)
80  double m_fBoardTemp; ///< average sensed interior tempature (C)
81  uint_t m_uStatus; ///< board status
82 
83  /*!
84  * \brief Default constructor.
85  */
87  {
88  clear();
89  }
90 
91  /*!
92  * \brief Copy constructor.
93  */
95 
96  /*!
97  * \brief Destructor.
98  */
100  {
101  }
102 
103  /*!
104  * \brief Assignment operator.
105  *
106  * \param rhs Right hand side object.
107  *
108  * \return Returns copy of this.
109  */
111 
112  /*!
113  * \brief Clear data sans name.
114  */
115  void clear();
116 
117  }; // class LaeMotorCtlrState
118 
119 
120  // ---------------------------------------------------------------------------
121  // Class LaePlatform
122  // ---------------------------------------------------------------------------
123 
124  /*!
125  * \brief Robot platform control and state data class.
126  */
128  {
129  public:
130  /*!
131  * \brief Working indices and sizes.
132  */
133  enum Idx
134  {
135  IdxPrev = 0, ///< index of previous history
136  IdxCur = 1, ///< index of current state
137  HistSize = 2 ///< size of history
138  };
139 
140  std::string m_strName; ///< robot platform name
141 
142  // dimensions
143  Dim m_dimRobot; ///< total dimensions of robot (TODO)
144  Dim m_dimBody; ///< dimensions of robot body
145  double m_fWheelbase; ///< wheelbase (m)
146  double m_fWheeltrack; ///< wheeltrack (m)
147 
148  // dynamics
149  double m_fPosLast[LaeMotorsNumOf];
150  ///< last sensed wheel positions (radians)
151  LaePose m_pose[HistSize]; ///< robot pose (meters, meters, radians)
152  double m_fOdometer; ///< robot odometer (meters)
153  double m_fVelocity; ///< robot velocity (meters/second)
154 
155  // power
156  double m_fAmpsMotors; ///< total draw from all motors (A)
157  double m_fVoltsAvg; ///< average sensed battery voltage (V)
158  double m_fTempAvg; ///< average sensed interior tempature (C)
159 
160  // motor controllers
161  LaeMotorCtlrState m_ctlr[LaeNumMotorCtlrs]; ///< motor controllers' state
162 
163  /*!
164  * \brief Default constructor.
165  */
166  LaePlatform();
167 
168  /*!
169  * \brief Copy constructor.
170  */
171  LaePlatform(const LaePlatform &src);
172 
173  /*!
174  * \brief Destructor.
175  */
177  {
178  }
179 
180  /*!
181  * \brief Assignment operator.
182  *
183  * \param rhs Right hand side object.
184  *
185  * \return Returns copy of this.
186  */
187  LaePlatform operator=(const LaePlatform &rhs);
188 
189  /*!
190  * \brief Clear data sans name.
191  */
192  void clear();
193 
194  /*!
195  * \brief Get robot platform name.
196  *
197  * \return String.
198  */
199  std::string getPlatformName() const
200  {
201  return m_strName;
202  }
203 
204  /*!
205  * \brief Configure robot platform from product description.
206  *
207  * \param desc Laelaps robot base product description data.
208  *
209  * \copydoc doc_return_std
210  */
211  virtual int configure(const LaeDescBase &desc);
212 
213  /*!
214  * \brief Configure platform.
215  *
216  * \param tunes Laelaps tuning parameters.
217  *
218  * \copydoc doc_return_std
219  */
220  virtual int configure(const LaeTunes &tunes);
221 
222  /*!
223  * \brief Reload tuning parameters and re-configure.
224  *
225  * \param tunes Laelaps tuning parameters.
226  *
227  * \copydoc doc_return_std
228  */
229  virtual int reload(const LaeTunes &tunes);
230 
231  /*!
232  * \brief Reset odometry to zero.
233  *
234  * All related positioning data are reset to 0.
235  *
236  * \copydoc doc_return_std
237  */
238  virtual int resetOdometer();
239 
240  /*!
241  * \brief Update robot platform state dynamics.
242  *
243  * \param mapPowertrains Powertrain kinodynamics.
244  *
245  * \copydoc doc_return_std
246  */
247  virtual int updateStateDynamics(const LaeMapPowertrain &mapPowertrains);
248 
249  /*!
250  * \brief Update robot platform motor controller health state.
251  *
252  * \param nCtlr Motor controller id.
253  * \param fVolts Motor input voltage (V).
254  * \param fTemp Motor controller board voltage (V).
255  * \param uCtlrStatus Motor controller status bits.
256  *
257  * \copydoc doc_return_std
258  */
259  virtual int updateCtlrHealth(int nCtlr,
260  double fVolts,
261  double fTemp,
262  uint_t uStatus);
263 
264  /*!
265  * \brief Update robot platform health state.
266  *
267  * \param mapPowertrains Powertrain kinodynamics.
268  *
269  * \copydoc doc_return_std
270  */
271  virtual int updateHealth(const LaeMapPowertrain &mapPowertrains);
272 
273  /*!
274  * \brief Clear pose history.
275  */
276  virtual void clearPoses();
277 
278  /*!
279  * \brief Push a new pose on the pose history.
280  *
281  * The history is aged first.
282  *
283  * \param pose New pose.
284  */
285  virtual void pushNewPose(const LaePose &pose);
286 
287  }; // class LaePlatform
288 
289 } // namespace laelaps
290 
291 
292 #endif // _LAE_PLATFORM_H
double m_fWheeltrack
wheeltrack (m)
Definition: laePlatform.h:146
double m_fVelocity
robot velocity (meters/second)
Definition: laePlatform.h:153
double m_fAmpsMotors
total draw from all motors (A)
Definition: laePlatform.h:156
std::string m_strName
robot platform name
Definition: laePlatform.h:140
std::string m_strName
motor controller name
Definition: laePlatform.h:78
Laelaps tuning data class.
Definition: laeTune.h:566
Trajectory classes interfaces.
static const int LaeMotorsNumOf
number of motors
Definition: laeMotor.h:107
Object width x height x length dimensions class.
Definition: laeUtils.h:524
RoboClaw motor controller class interface.
double m_fBoardTemp
average sensed interior tempature (C)
Definition: laePlatform.h:80
LaeMotorCtlrState()
Default constructor.
Definition: laePlatform.h:86
Dim m_dimBody
dimensions of robot body
Definition: laePlatform.h:144
The <b><i>Laelaps</i></b> namespace encapsulates all <b><i>Laelaps</i></b> related constructs...
Definition: laeAlarms.h:64
Dim m_dimRobot
total dimensions of robot (TODO)
Definition: laePlatform.h:143
LaeMotorCtlrState operator=(const LaeMotorCtlrState &rhs)
Assignment operator.
Definition: laePlatform.cxx:90
Laelaps common utilities.
Laelaps powertrain class interfaces.
std::map< std::string, LaePowertrain > LaeMapPowertrain
Map of powertrain kinodynamics.
Laelaps tuning.
Robot base motor controller board state.
Definition: laePlatform.h:75
~LaeMotorCtlrState()
Destructor.
Definition: laePlatform.h:99
double m_fMainVolts
average sensed battery voltage (V)
Definition: laePlatform.h:79
double m_fVoltsAvg
average sensed battery voltage (V)
Definition: laePlatform.h:157
~LaePlatform()
Destructor.
Definition: laePlatform.h:176
uint_t m_uStatus
board status
Definition: laePlatform.h:81
std::string getPlatformName() const
Get robot platform name.
Definition: laePlatform.h:199
Robotic base platform description.
Definition: laeDesc.h:113
Laelaps motors, encoder, and controllers hardware abstraction interfaces.
void clear()
Clear data sans name.
Definition: laePlatform.cxx:75
double m_fWheelbase
wheelbase (m)
Definition: laePlatform.h:145
static const int LaeNumMotorCtlrs
number of motor controllers
Definition: laeMotor.h:115
Laelaps 2D pose class.
Definition: laeTraj.h:170
Idx
Working indices and sizes.
Definition: laePlatform.h:133
double m_fTempAvg
average sensed interior tempature (C)
Definition: laePlatform.h:158
double m_fOdometer
robot odometer (meters)
Definition: laePlatform.h:152
Top-level package include file.
Robot platform control and state data class.
Definition: laePlatform.h:127