KinematicInertialPoseObserver.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2019 CNRS-UM LIRMM, CNRS-AIST JRL
3  *
4  * This file is inspired by Stephane's Caron implementation as part of
5  * lipm_walking_controller <https://github.com/stephane-caron/lipm_walking_controller>
6  */
7 
8 #pragma once
9 
10 #include <mc_observers/Observer.h>
11 #include <mc_observers/api.h>
12 #include <mc_rbdyn/Robot.h>
13 
14 #include <SpaceVecAlg/SpaceVecAlg>
15 
16 namespace mc_observers
17 {
18 
39 {
41  KinematicInertialPoseObserver(const std::string & type, double dt) : Observer(type, dt) {}
42 
44  void configure(const mc_control::MCController & ctl, const mc_rtc::Configuration & config) override;
45 
47  void reset(const mc_control::MCController & ctl) override;
48 
67  bool run(const mc_control::MCController & ctl) override;
68 
70  void update(mc_control::MCController & ctl) override;
71 
73  const sva::PTransformd & posW() const { return pose_; }
74 
75 protected:
76  void addToLogger(const mc_control::MCController & ctl, mc_rtc::Logger &, const std::string & category) override;
77  void addToGUI(const mc_control::MCController &,
79  const std::vector<std::string> & category) override;
80 
91  void estimateOrientation(const mc_rbdyn::Robot & robot, const mc_rbdyn::Robot & realRobot);
92 
102  void estimatePosition(const mc_control::MCController & ctl);
103 
104 protected:
105  std::string robot_;
106  std::string realRobot_;
107  std::string imuSensor_;
109  std::string anchorFrameFunction_ = "";
110  sva::PTransformd X_0_anchorFrame_ =
111  sva::PTransformd::Identity();
112  sva::PTransformd X_0_anchorFrameReal_ =
113  sva::PTransformd::Identity();
114 
115  double maxAnchorFrameDiscontinuity_ =
116  0.01;
117  bool anchorFrameJumped_ = false;
118  bool firstIter_ = true;
120 private:
121  sva::PTransformd pose_ = sva::PTransformd::Identity();
122  bool showAnchorFrame_ = false;
123  bool showAnchorFrameReal_ = false;
124  bool showPose_ = false;
125  bool advancedGUI_ = false;
126 
127  bool logPose_ = true;
128  bool logAnchorFrame_ = true;
129 };
130 
131 } // namespace mc_observers
mc_rtc::Configuration
Simplify access to values hold within a JSON file.
Definition: Configuration.h:165
mc_observers::KinematicInertialPoseObserver::imuSensor_
std::string imuSensor_
Definition: KinematicInertialPoseObserver.h:107
mc_observers::KinematicInertialPoseObserver::robot_
std::string robot_
Definition: KinematicInertialPoseObserver.h:105
mc_rbdyn::Robot
Definition: Robot.h:62
mc_observers::KinematicInertialPoseObserver::realRobot_
std::string realRobot_
Definition: KinematicInertialPoseObserver.h:106
MC_OBSERVER_DLLAPI
#define MC_OBSERVER_DLLAPI
Definition: api.h:92
Observer.h
mc_observers::KinematicInertialPoseObserver
Definition: KinematicInertialPoseObserver.h:38
mc_rtc::Logger
Logs controller data to disk.
Definition: Logger.h:29
mc_observers::KinematicInertialPoseObserver::KinematicInertialPoseObserver
KinematicInertialPoseObserver(const std::string &type, double dt)
Definition: KinematicInertialPoseObserver.h:41
mc_observers::Observer
State observation API.
Definition: Observer.h:50
mc_rtc::gui::StateBuilder
Definition: StateBuilder.h:27
Robot.h
mc_observers
Definition: BodySensorObserver.h:13
mc_observers::KinematicInertialPoseObserver::posW
const sva::PTransformd & posW() const
Get floating-base pose in the world frame.
Definition: KinematicInertialPoseObserver.h:73
mc_control::MCController
MCController is the base class to implement all controllers. It assumes that at least two robots are ...
Definition: MCController.h:98
api.h