Main MRPT website > C++ reference for MRPT 1.9.9
system/CRateTimer.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/system/CTicTac.h>
12 
13 namespace mrpt
14 {
15 namespace system
16 {
17 /** A class for calling sleep() in a loop, such that the amount of sleep time
18  * will be computed
19  * to make the loop run at the desired rate (in Hz).
20  * \note [New in MRPT 1.5.0]
21  * \ingroup mrpt_system_grp
22  */
24 {
25  public:
26  /** Ctor: specifies the desired rate (Hz) */
27  CRateTimer(const double rate_hz = 1.0);
28  /** Dtor */
29  virtual ~CRateTimer();
30 
31  /** Changes the object loop rate (Hz) */
32  void setRate(const double rate_hz);
33  /** Sleeps for some time, such as the return of this method is 1/rate
34  * (seconds)
35  * after the return of the previous call.
36  * \return false if the rate could not be achieved ("we are already late"),
37  * true if all went right. */
38  bool sleep();
39 
40  private:
41  double m_rate_hz;
43 }; // End of class def.
44 
45 } // End of namespace
46 } // End of namespace
mrpt::system::CTicTac
A high-performance stopwatch, with typical resolution of nanoseconds.
Definition: system/CTicTac.h:19
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::system::CRateTimer::m_tictac
mrpt::system::CTicTac m_tictac
Definition: system/CRateTimer.h:42
mrpt::system::CRateTimer::sleep
bool sleep()
Sleeps for some time, such as the return of this method is 1/rate (seconds) after the return of the p...
Definition: CRateTimer.cpp:26
mrpt::system::CRateTimer
A class for calling sleep() in a loop, such that the amount of sleep time will be computed to make th...
Definition: system/CRateTimer.h:23
mrpt::system::CRateTimer::CRateTimer
CRateTimer(const double rate_hz=1.0)
Ctor: specifies the desired rate (Hz)
Definition: CRateTimer.cpp:19
mrpt::system::CRateTimer::setRate
void setRate(const double rate_hz)
Changes the object loop rate (Hz)
Definition: CRateTimer.cpp:21
CTicTac.h
mrpt::system::CRateTimer::~CRateTimer
virtual ~CRateTimer()
Dtor.
Definition: CRateTimer.cpp:20
mrpt::system::CRateTimer::m_rate_hz
double m_rate_hz
Definition: system/CRateTimer.h:41



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST