- 3.0.2 core module.
ExternallyDrivenTimer.h
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4 **********************************************************************************************************************/
5 
6 #pragma once
7 
8 namespace ct {
9 namespace core {
10 namespace tpl {
11 
13 
16 template <typename SCALAR = double>
18 {
19 public:
23 
27  inline void start(const SCALAR& time) { start_time = time; }
29 
32  inline void stop(const SCALAR& time) { stop_time = time; }
34 
37  SCALAR getElapsedTime() const { return stop_time - start_time; }
39 
42  void reset()
43  {
44  start_time = (SCALAR)0.0;
45  stop_time = (SCALAR)0.0;
46  }
47 
48 private:
49  SCALAR start_time;
50  SCALAR stop_time;
51 };
52 }
53 
55 }
56 }
ExternallyDrivenTimer()
Default constructor.
Definition: ExternallyDrivenTimer.h:21
void start(const SCALAR &time)
Trigger start.
Definition: ExternallyDrivenTimer.h:27
SCALAR getElapsedTime() const
Get the elapsed time between calls to start() and stop()
Definition: ExternallyDrivenTimer.h:37
CppAD::AD< CppAD::cg::CG< double > > SCALAR
void reset()
Resets the clock.
Definition: ExternallyDrivenTimer.h:42
void stop(const SCALAR &time)
Trigger stop.
Definition: ExternallyDrivenTimer.h:32
A timer ("stop watch") to record elapsed time based on external time stamps.
Definition: ExternallyDrivenTimer.h:17