mc_rtc  2.15.2
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 {
35 {
36  EncoderObserver(const std::string & type, double dt) : Observer(type, dt) {}
37 
39  void configure(const mc_control::MCController & ctl, const mc_rtc::Configuration & config) override;
40 
45  void reset(const mc_control::MCController & ctl) override;
46 
52  bool run(const mc_control::MCController & ctl) override;
53 
59  void update(mc_control::MCController & ctl) override;
60 
61 protected:
62  void addToLogger(const mc_control::MCController &, mc_rtc::Logger &, const std::string &) override;
63 
64 protected:
66  enum class PosUpdate
67  {
68  Control,
69  EncoderValues,
70  None
71  };
73  enum class VelUpdate
74  {
75  Control,
76  EncoderVelocities,
77  EncoderFiniteDifferences,
78  None
79  };
81  enum class TorqueUpdate
82  {
83  Control,
84  JointTorques,
85  None
86  };
87 
88  PosUpdate posUpdate_ = PosUpdate::EncoderValues;
89  VelUpdate velUpdate_ = VelUpdate::EncoderFiniteDifferences;
90  TorqueUpdate torqueUpdate_ = TorqueUpdate::JointTorques;
91  bool computeFK_ = true;
92  bool computeFV_ = true;
93 
94  bool initialized_ = false;
95 
96  std::string robot_ = "";
97  std::string updateRobot_ = "";
98 
99  std::vector<double> prevEncoders_;
100  std::vector<double> encodersVelocity_;
101 
102  bool logPosition_ = false;
103  bool logVelocity_ = true;
104  bool logTorque_ = false;
105 };
106 
107 } // 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:35
EncoderObserver(const std::string &type, double dt)
Definition: EncoderObserver.h:36
void addToLogger(const mc_control::MCController &, mc_rtc::Logger &, const std::string &) override
Add observer from logger.
PosUpdate
Definition: EncoderObserver.h:67
void reset(const mc_control::MCController &ctl) override
std::vector< double > prevEncoders_
Previous encoder values (for VelUpdate::EncoderFiniteDifferences)
Definition: EncoderObserver.h:99
std::vector< double > encodersVelocity_
Estimated encoder velocity.
Definition: EncoderObserver.h:100
void configure(const mc_control::MCController &ctl, const mc_rtc::Configuration &config) override
VelUpdate
Definition: EncoderObserver.h:74
TorqueUpdate
Definition: EncoderObserver.h:82
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