Cheetah Software  1.0
StateEstimatorContainer< T > Class Template Reference

#include <StateEstimatorContainer.h>

+ Inheritance diagram for StateEstimatorContainer< T >:
+ Collaboration diagram for StateEstimatorContainer< T >:

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW StateEstimatorContainer (CheaterState< double > *cheaterState, VectorNavData *vectorNavData, LegControllerData< T > *legControllerData, StateEstimate< T > *stateEstimate, RobotControlParameters *parameters)
 
void run (CheetahVisualization *visualization=nullptr)
 
const StateEstimate< T > & getResult ()
 
void setContactPhase (Vec4< T > &phase)
 
template<typename EstimatorToAdd >
void addEstimator ()
 
template<typename EstimatorToRemove >
void removeEstimator ()
 
void removeAllEstimators ()
 
 ~StateEstimatorContainer ()
 

Private Attributes

StateEstimatorData< T > _data
 
std::vector< GenericEstimator< T > * > _estimators
 
Vec4< T > _phase
 

Detailed Description

template<typename T>
class StateEstimatorContainer< T >

Main State Estimator Class Contains all GenericEstimators

Definition at line 89 of file StateEstimatorContainer.h.

Constructor & Destructor Documentation

template<typename T>
EIGEN_MAKE_ALIGNED_OPERATOR_NEW StateEstimatorContainer< T >::StateEstimatorContainer ( CheaterState< double > *  cheaterState,
VectorNavData vectorNavData,
LegControllerData< T > *  legControllerData,
StateEstimate< T > *  stateEstimate,
RobotControlParameters parameters 
)
inline

Construct a new state estimator container

Definition at line 96 of file StateEstimatorContainer.h.

100  {
101  _data.cheaterState = cheaterState;
102  _data.vectorNavData = vectorNavData;
103  _data.legControllerData = legControllerData;
104  _data.result = stateEstimate;
105  _phase = Vec4<T>::Zero();
106  _data.contactPhase = &_phase;
107  _data.parameters = parameters;
108  }
StateEstimatorData< T > _data
typename Eigen::Matrix< T, 4, 1 > Vec4
Definition: cppTypes.h:30
template<typename T>
StateEstimatorContainer< T >::~StateEstimatorContainer ( )
inline

Definition at line 177 of file StateEstimatorContainer.h.

177  {
178  for (auto estimator : _estimators) {
179  delete estimator;
180  }
181  }
std::vector< GenericEstimator< T > * > _estimators

Member Function Documentation

template<typename T>
template<typename EstimatorToAdd >
void StateEstimatorContainer< T >::addEstimator ( )
inline

Add an estimator of the given type

Template Parameters
EstimatorToAdd

Definition at line 139 of file StateEstimatorContainer.h.

139  {
140  auto* estimator = new EstimatorToAdd();
141  estimator->setData(_data);
142  estimator->setup();
143  _estimators.push_back(estimator);
144  }
std::vector< GenericEstimator< T > * > _estimators
StateEstimatorData< T > _data

+ Here is the caller graph for this function:

template<typename T>
const StateEstimate<T>& StateEstimatorContainer< T >::getResult ( )
inline

Get the result

Definition at line 127 of file StateEstimatorContainer.h.

127 { return *_data.result; }
StateEstimatorData< T > _data
template<typename T>
void StateEstimatorContainer< T >::removeAllEstimators ( )
inline

Remove all estimators

Definition at line 170 of file StateEstimatorContainer.h.

170  {
171  for (auto estimator : _estimators) {
172  delete estimator;
173  }
174  _estimators.clear();
175  }
std::vector< GenericEstimator< T > * > _estimators

+ Here is the caller graph for this function:

template<typename T>
template<typename EstimatorToRemove >
void StateEstimatorContainer< T >::removeEstimator ( )
inline

Remove all estimators of a given type

Template Parameters
EstimatorToRemove

Definition at line 151 of file StateEstimatorContainer.h.

151  {
152  int nRemoved = 0;
153  _estimators.erase(
154  std::remove_if(_estimators.begin(), _estimators.end(),
155  [&nRemoved](GenericEstimator<T>* e) {
156  if (dynamic_cast<EstimatorToRemove*>(e)) {
157  delete e;
158  nRemoved++;
159  return true;
160  } else {
161  return false;
162  }
163  }),
164  _estimators.end());
165  }
std::vector< GenericEstimator< T > * > _estimators
template<typename T>
void StateEstimatorContainer< T >::run ( CheetahVisualization visualization = nullptr)
inline

Run all estimators

Definition at line 113 of file StateEstimatorContainer.h.

113  {
114  for (auto estimator : _estimators) {
115  estimator->run();
116  }
117  if (visualization) {
118  visualization->quat = _data.result->orientation.template cast<float>();
119  visualization->p = _data.result->position.template cast<float>();
120  // todo contact!
121  }
122  }
std::vector< GenericEstimator< T > * > _estimators
StateEstimatorData< T > _data

+ Here is the caller graph for this function:

template<typename T>
void StateEstimatorContainer< T >::setContactPhase ( Vec4< T > &  phase)
inline

Set the contact phase

Definition at line 132 of file StateEstimatorContainer.h.

132 { *_data.contactPhase = phase; }
StateEstimatorData< T > _data

+ Here is the caller graph for this function:

Member Data Documentation

template<typename T>
StateEstimatorData<T> StateEstimatorContainer< T >::_data
private

Definition at line 184 of file StateEstimatorContainer.h.

template<typename T>
std::vector<GenericEstimator<T>*> StateEstimatorContainer< T >::_estimators
private

Definition at line 185 of file StateEstimatorContainer.h.

template<typename T>
Vec4<T> StateEstimatorContainer< T >::_phase
private

Definition at line 186 of file StateEstimatorContainer.h.


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