Laelaps  2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
laelaps::LaeThreadKin Class Reference

#include <laeThreadKin.h>

Inheritance diagram for laelaps::LaeThreadKin:
laelaps::LaeThread

Public Member Functions

 LaeThreadKin (LaeKinematics &kin)
 Default constructor.
 
virtual ~LaeThreadKin ()
 Destructor.
 
int reload (const LaeTunes &tunes)
 Reload tunable paramaters. More...
 
virtual void waitOneCycle ()
 Force calling thread to wait one full execution cycle. More...
 
- Public Member Functions inherited from laelaps::LaeThread
 LaeThread (const std::string &strThreadName)
 Default constructor.
 
virtual ~LaeThread ()
 Destructor.
 
virtual int createThread (int nPriority)
 Create the thread. More...
 
virtual int runThread (const double fHz)
 Run the thread. More...
 
virtual int terminateThread ()
 Terminate the thread. More...
 
virtual void setHz (const double fHz)
 Calculate thread new full cycle run rate. More...
 
std::string getThreadName () const
 Get assigned thread name. More...
 
int getThreadPriority () const
 Get thread system scheduling priority. More...
 
double getThreadHz () const
 Get thread run full cycle rate. More...
 

Static Public Attributes

static const double ThreadKinPrioDft = 99
 default priority
 
static const double ThreadKinHzDft = 30.0
 default run rate
 
static const long ThreadKinTHealthDft = 5
 monitor health period
 
- Static Public Attributes inherited from laelaps::LaeThread
static const int ThreadPriorityMin = 1
 minimum scheduling priority
 
static const int ThreadPriorityMax = 99
 maximum scheduling priority
 
static const double ThreadMinHz = 0.001
 minimum thread Hertz More...
 

Protected Member Functions

virtual void transToRunning ()
 Ready to Running state transition function. More...
 
virtual void exec ()
 Execute watchdog task within scheduled cycle. More...
 
- Protected Member Functions inherited from laelaps::LaeThread
void lock ()
 Lock the I2C bus. More...
 
void unlock ()
 Unlock the I2C bus. More...
 
void changeState (ThreadState eNewState)
 Change the thread state. More...
 
void timedWait (const struct timespec &tsTimeout)
 Timed wait until state change or time out. More...
 
virtual void readyBlock ()
 Block indefinitely while in the ready state. More...
 
virtual void schedBlock ()
 Block the thread until the next subcycle task is to be run. More...
 
virtual void transToReady ()
 Uninitialized to Ready state transition function. More...
 
virtual void transToExit ()
 Any to Exit state transition function. More...
 

Protected Attributes

LaeKinematicsm_kin
 kinematics interface
 
bool m_bWaitOneCycle
 [not] waiting for one cycle
 
struct timespec m_tsSchedHealth
 working health scheduler time stamp
 
- Protected Attributes inherited from laelaps::LaeThread
std::string m_strThreadName
 thread identifying name
 
ThreadState m_eState
 thread state
 
pthread_mutex_t m_mutexSync
 synchonization mutex
 
pthread_cond_t m_condSync
 synchonization condition
 
pthread_t m_thread
 pthread identifier
 
int m_nPriority
 thread OS scheduling priority
 
double m_fHz
 thread cycle run rate (Hertz)
 
double m_fTExec
 task execution cycle period (seconds)
 
struct timespec m_tsExecPeriod
 task execution period (converted)
 
struct timespec m_tsJitter
 allowable scheduling jitter
 
struct timespec m_tsSched
 working scheduler time stamp
 
struct timespec m_tsExecLast
 start of last execution time stamp
 
struct timespec m_tsExecThis
 start of this execution time stamp
 
int m_nSlipErrCnt
 slipped error count leaky bucket
 

Additional Inherited Members

- Public Types inherited from laelaps::LaeThread
enum  ThreadState {
  ThreadStateUninit,
  ThreadStateReady,
  ThreadStateStart,
  ThreadStateRunning,
  ThreadStateExit
}
 Kinematics thread states. More...
 
- Static Protected Member Functions inherited from laelaps::LaeThread
static void * thread (void *pArg)
 The thread. More...
 

Detailed Description

Watchdog thread class.

Definition at line 82 of file laeThreadKin.h.

Member Function Documentation

void LaeThreadKin::exec ( )
protectedvirtual

Execute watchdog task within scheduled cycle.

This function executes under the lock/unlock mutex.

Context:
This thread.

Reimplemented from laelaps::LaeThread.

Definition at line 124 of file laeThreadKin.cxx.

References laelaps::LaeKinematics::exec(), m_bWaitOneCycle, laelaps::LaeThread::m_condSync, m_kin, laelaps::LaeThread::m_tsExecThis, m_tsSchedHealth, laelaps::LaeKinematics::monitorHealth(), and ThreadKinTHealthDft.

125 {
126  m_kin.exec();
127 
128  // time to monitor health
130  {
134  }
135 
136  // caller blocked waiting one execution cycle - signal to unblock
137  if( m_bWaitOneCycle )
138  {
139  m_bWaitOneCycle = false;
140  pthread_cond_signal(&m_condSync);
141  }
142 }
virtual void exec()
Execute kinematics task(s).
Definition: laeKin.cxx:1600
bool m_bWaitOneCycle
[not] waiting for one cycle
Definition: laeThreadKin.h:116
struct timespec m_tsExecThis
start of this execution time stamp
Definition: laeThread.h:210
LaeKinematics & m_kin
kinematics interface
Definition: laeThreadKin.h:115
struct timespec m_tsSchedHealth
working health scheduler time stamp
Definition: laeThreadKin.h:117
pthread_cond_t m_condSync
synchonization condition
Definition: laeThread.h:199
static const long ThreadKinTHealthDft
monitor health period
Definition: laeThreadKin.h:87
virtual int monitorHealth()
Monitor kinematics health.
Definition: laeKin.cxx:1551
int LaeThreadKin::reload ( const LaeTunes tunes)

Reload tunable paramaters.

This function executes under the lock/unlock mutex.

Definition at line 87 of file laeThreadKin.cxx.

References laelaps::LaeTunes::getKinematicsHz(), laelaps::LaeThread::lock(), laelaps::LaeThread::m_fHz, m_kin, laelaps::LaeKinematics::reload(), laelaps::LaeThread::setHz(), and laelaps::LaeThread::unlock().

Referenced by laelaps::LaeRobot::reload().

88 {
89  double fHz;
90  int rc;
91 
92  lock();
93 
94  fHz = tunes.getKinematicsHz();
95 
96  if( fHz != m_fHz )
97  {
98  setHz(fHz);
99  }
100 
101  rc = m_kin.reload(tunes);
102 
103  unlock();
104 
105  return rc;
106 }
void unlock()
Unlock the I2C bus.
Definition: laeThread.h:235
double getKinematicsHz() const
Get kinematics thread cycle rate tune parameter (hertz).
Definition: laeTune.cxx:324
void lock()
Lock the I2C bus.
Definition: laeThread.h:221
LaeKinematics & m_kin
kinematics interface
Definition: laeThreadKin.h:115
virtual void setHz(const double fHz)
Calculate thread new full cycle run rate.
Definition: laeThread.cxx:214
double m_fHz
thread cycle run rate (Hertz)
Definition: laeThread.h:204
virtual int reload(const LaeTunes &tunes)
Reload configuration tuning parameters.
Definition: laeKin.cxx:897
void LaeThreadKin::transToRunning ( )
protectedvirtual

Ready to Running state transition function.

This function is called after entering the Running state but prior to any run execution.

This function does not execute under the lock/unlock mutex.

Context:
This thread.

Reimplemented from laelaps::LaeThread.

Definition at line 119 of file laeThreadKin.cxx.

References laelaps::LaeThread::m_tsExecThis, and m_tsSchedHealth.

120 {
122 }
struct timespec m_tsExecThis
start of this execution time stamp
Definition: laeThread.h:210
struct timespec m_tsSchedHealth
working health scheduler time stamp
Definition: laeThreadKin.h:117
void LaeThreadKin::waitOneCycle ( )
virtual

Force calling thread to wait one full execution cycle.

Context:
Calling thread.

Definition at line 108 of file laeThreadKin.cxx.

References laelaps::LaeThread::lock(), m_bWaitOneCycle, laelaps::LaeThread::m_condSync, laelaps::LaeThread::m_mutexSync, and laelaps::LaeThread::unlock().

109 {
110  lock();
111 
112  m_bWaitOneCycle = true;
113 
114  pthread_cond_wait(&m_condSync, &m_mutexSync);
115 
116  unlock();
117 }
void unlock()
Unlock the I2C bus.
Definition: laeThread.h:235
pthread_mutex_t m_mutexSync
synchonization mutex
Definition: laeThread.h:198
void lock()
Lock the I2C bus.
Definition: laeThread.h:221
bool m_bWaitOneCycle
[not] waiting for one cycle
Definition: laeThreadKin.h:116
pthread_cond_t m_condSync
synchonization condition
Definition: laeThread.h:199

The documentation for this class was generated from the following files: