Laelaps  2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
laeThreadKin.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: Laelaps
4 //
5 // File: laeThreadKin.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 kinodynamics thread class interface.
13  *
14  * \author Robin Knight (robin.knight@roadnarrows.com)
15  *
16  * \par Copyright
17  * \h_copy 2015-2018. RoadNarrows LLC.\n
18  * http://www.roadnarrows.com\n
19  * All Rights Reserved
20  */
21 /*
22  * @EulaBegin@
23  *
24  * Unless otherwise stated explicitly, all materials contained are copyrighted
25  * and may not be used without RoadNarrows LLC's written consent,
26  * except as provided in these terms and conditions or in the copyright
27  * notice (documents and software) or other proprietary notice provided with
28  * the relevant materials.
29  *
30  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY
31  * MEMBERS/EMPLOYEES/CONTRACTORS OF ROADNARROWS OR DISTRIBUTORS OF THIS SOFTWARE
32  * BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR
33  * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
34  * DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN
35  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37  * THE AUTHORS AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
38  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
39  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
40  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
41  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
42  *
43  * @EulaEnd@
44  */
45 ////////////////////////////////////////////////////////////////////////////////
46 
47 #ifndef _LAE_THREAD_KIN_H
48 #define _LAE_THREAD_KIN_H
49 
50 #include <sys/types.h>
51 #include <sys/time.h>
52 #include <time.h>
53 #include <pthread.h>
54 
55 #include <string>
56 
57 #include "rnr/rnrconfig.h"
58 #include "rnr/log.h"
59 
60 #include "Laelaps/laelaps.h"
61 #include "Laelaps/laeUtils.h"
62 #include "Laelaps/laeTune.h"
63 
64 #include "Laelaps/laeKin.h"
65 
66 #include "Laelaps/laeThread.h"
67 
68 /*!
69  * \brief The \h_laelaps namespace encapsulates all \h_laelaps related
70  * constructs.
71  */
72 namespace laelaps
73 {
74 
75  //----------------------------------------------------------------------------
76  // LaeThreadKin Class
77  //----------------------------------------------------------------------------
78 
79  /*!
80  * Watchdog thread class.
81  */
82  class LaeThreadKin : public LaeThread
83  {
84  public:
85  static const double ThreadKinPrioDft; ///< default priority
86  static const double ThreadKinHzDft; ///< default run rate
87  static const long ThreadKinTHealthDft; ///< monitor health period
88 
89  /*!
90  * \brief Default constructor.
91  */
93 
94  /*!
95  * \brief Destructor.
96  */
97  virtual ~LaeThreadKin();
98 
99  /*!
100  * \brief Reload tunable paramaters.
101  *
102  * This function executes under the lock/unlock mutex.
103  */
104  int reload(const LaeTunes &tunes);
105 
106  /*!
107  * \brief Force calling thread to wait one full execution cycle.
108  *
109  * \par Context:
110  * Calling thread.
111  */
112  virtual void waitOneCycle();
113 
114  protected:
115  LaeKinematics &m_kin; ///< kinematics interface
116  bool m_bWaitOneCycle; ///< [not] waiting for one cycle
117  struct timespec m_tsSchedHealth; ///< working health scheduler time stamp
118 
119  /*!
120  * \brief Ready to Running state transition function.
121  *
122  * This function is called after entering the Running state but prior to
123  * any run execution.
124  *
125  * This function does not execute under the lock/unlock mutex.
126  *
127  * \par Context:
128  * This thread.
129  */
130  virtual void transToRunning();
131 
132  /*!
133  * \brief Execute watchdog task within scheduled cycle.
134  *
135  * This function executes under the lock/unlock mutex.
136  *
137  * \par Context:
138  * This thread.
139  */
140  virtual void exec();
141  };
142 
143 } // namespace laelaps
144 
145 
146 #endif // _LAE_THREAD_KIN_H
Laelaps thread base class interface.
Laelaps tuning data class.
Definition: laeTune.h:566
Laelaps kinematics class.
Definition: laeKin.h:119
virtual void exec()
Execute watchdog task within scheduled cycle.
static const double ThreadKinHzDft
default run rate
Definition: laeThreadKin.h:86
static const double ThreadKinPrioDft
default priority
Definition: laeThreadKin.h:85
bool m_bWaitOneCycle
[not] waiting for one cycle
Definition: laeThreadKin.h:116
The <b><i>Laelaps</i></b> namespace encapsulates all <b><i>Laelaps</i></b> related constructs...
Definition: laeAlarms.h:64
virtual ~LaeThreadKin()
Destructor.
virtual void transToRunning()
Ready to Running state transition function.
Laelaps common utilities.
LaeKinematics & m_kin
kinematics interface
Definition: laeThreadKin.h:115
The Laelaps kinematics and dynamics class interface.
Laelaps tuning.
LaeThreadKin(LaeKinematics &kin)
Default constructor.
struct timespec m_tsSchedHealth
working health scheduler time stamp
Definition: laeThreadKin.h:117
virtual void waitOneCycle()
Force calling thread to wait one full execution cycle.
static const long ThreadKinTHealthDft
monitor health period
Definition: laeThreadKin.h:87
int reload(const LaeTunes &tunes)
Reload tunable paramaters.
Top-level package include file.