EncoderObserver.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2019 CNRS-UM LIRMM, CNRS-AIST JRL
3  */
4 
5 #pragma once
6 
8 #include <mc_observers/api.h>
9 #include <mc_rbdyn/Robot.h>
10 
11 namespace mc_observers
12 {
34 {
35  EncoderObserver(const std::string & type, double dt) : Observer(type, dt) {}
36 
38  void configure(const mc_control::MCController & ctl, const mc_rtc::Configuration & config) override;
39 
44  void reset(const mc_control::MCController & ctl) override;
45 
51  bool run(const mc_control::MCController & ctl) override;
52 
58  void update(mc_control::MCController & ctl) override;
59 
60 protected:
61  void addToLogger(const mc_control::MCController &, mc_rtc::Logger &, const std::string &) override;
62 
63 protected:
65  enum class PosUpdate
66  {
67  Control,
68  EncoderValues,
69  None
70  };
72  enum class VelUpdate
73  {
74  Control,
75  EncoderVelocities,
76  EncoderFiniteDifferences,
77  None
78  };
79 
80  PosUpdate posUpdate_ = PosUpdate::EncoderValues;
81  VelUpdate velUpdate_ = VelUpdate::EncoderFiniteDifferences;
82  bool computeFK_ = true;
83  bool computeFV_ = true;
84 
85  bool initialized_ = false;
86 
87  std::string robot_ = "";
88  std::string updateRobot_ = "";
89 
90  std::vector<double> prevEncoders_;
91  std::vector<double> encodersVelocity_;
92 
93  bool logPosition_ = false;
94  bool logVelocity_ = true;
95 };
96 
97 } // namespace mc_observers
#define MC_OBSERVER_DLLAPI
Definition: api.h:92
Definition: BodySensorObserver.h:14
MCController is the base class to implement all controllers. It assumes that at least two robots are ...
Definition: MCController.h:99
Definition: EncoderObserver.h:34
EncoderObserver(const std::string &type, double dt)
Definition: EncoderObserver.h:35
void addToLogger(const mc_control::MCController &, mc_rtc::Logger &, const std::string &) override
Add observer from logger.
PosUpdate
Definition: EncoderObserver.h:66
void reset(const mc_control::MCController &ctl) override
std::vector< double > prevEncoders_
Previous encoder values (for VelUpdate::EncoderFiniteDifferences)
Definition: EncoderObserver.h:90
std::vector< double > encodersVelocity_
Estimated encoder velocity.
Definition: EncoderObserver.h:91
void configure(const mc_control::MCController &ctl, const mc_rtc::Configuration &config) override
VelUpdate
Definition: EncoderObserver.h:73
bool run(const mc_control::MCController &ctl) override
Computes encoder velocity if necessary:
void update(mc_control::MCController &ctl) override
State observation API.
Definition: Observer.h:51
Simplify access to values hold within a JSON file.
Definition: Configuration.h:166
Logs controller data to disk.
Definition: Logger.h:30