- 3.0.2 core module.
Observer.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 #include "EventHandler.h"
9 
12 
13 namespace ct {
14 namespace core {
15 
16 template <size_t STATE_DIM, typename SCALAR>
17 class Integrator;
18 
20 
26 template <size_t STATE_DIM, typename SCALAR = double>
27 class Observer
28 {
29 public:
30  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
31 
32  friend class Integrator<STATE_DIM, SCALAR>;
33 
34  typedef std::vector<std::shared_ptr<EventHandler<STATE_DIM, SCALAR>>,
35  Eigen::aligned_allocator<std::shared_ptr<EventHandler<STATE_DIM, SCALAR>>>>
37 
39 
42  Observer(const EventHandlerPtrVector& eventHandlers);
43 
45  void reset();
46 
47  void observe(const StateVector<STATE_DIM, SCALAR>& x, const SCALAR& t);
48 
49  void log(const StateVector<STATE_DIM, SCALAR>& x, const SCALAR& t);
50 
51  void observeInternal(const StateVector<STATE_DIM, SCALAR>& x, const SCALAR& t);
52 
53 private:
55  std::function<void(const StateVector<STATE_DIM, SCALAR>& x, const SCALAR& t)> observeWrap;
56  std::function<void(const StateVector<STATE_DIM, SCALAR>& x, const SCALAR& t)> observeWrapWithLogging;
57 
60 
61 
62  EventHandlerPtrVector eventHandlers_;
63 };
64 }
65 }
void observeInternal(const StateVector< STATE_DIM, SCALAR > &x, const SCALAR &t)
Definition: Observer-impl.h:51
void observe(const StateVector< STATE_DIM, SCALAR > &x, const SCALAR &t)
Definition: Observer-impl.h:34
An discrete array (vector) of a particular data type.
Definition: DiscreteArray.h:22
Observer(const EventHandlerPtrVector &eventHandlers)
default constructor
Definition: Observer-impl.h:12
Observer for Integrator.
Definition: Observer.h:27
clear all close all load ct GNMSLog0 mat reformat t
CppAD::AD< CppAD::cg::CG< double > > SCALAR
Definition: StateVector.h:12
Standard Integrator.
Definition: Integrator.h:62
ct::core::StateVector< state_dim > x
An array in time.
Definition: TimeArray.h:22
void log(const StateVector< STATE_DIM, SCALAR > &x, const SCALAR &t)
Definition: Observer-impl.h:44
std::vector< std::shared_ptr< EventHandler< STATE_DIM, SCALAR > >, Eigen::aligned_allocator< std::shared_ptr< EventHandler< STATE_DIM, SCALAR > > > > EventHandlerPtrVector
Definition: Observer.h:36
void reset()
reset the observer
Definition: Observer-impl.h:24