FloatingBaseObserver.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2019, CNRS-UM LIRMM
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #pragma once
29 
30 #include <mc_rbdyn/Robot.h>
31 
32 #include <SpaceVecAlg/SpaceVecAlg>
33 
34 namespace lipm_walking
35 {
36 
44 {
45  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
46 
52  FloatingBaseObserver(const mc_rbdyn::Robot & controlRobot);
53 
65  sva::PTransformd getAnchorFrame(const mc_rbdyn::Robot & robot);
66 
72  void reset(const sva::PTransformd & X_0_fb);
73 
79  void run(const mc_rbdyn::Robot & realRobot);
80 
86  void updateRobot(mc_rbdyn::Robot & robot);
87 
93  const Eigen::Quaterniond & imuOrientation()
94  {
95  return controlRobot_.bodySensor().orientation();
96  }
97 
103  void leftFootRatio(double ratio)
104  {
105  leftFootRatio_ = ratio;
106  }
107 
108 private:
114  void estimateOrientation(const mc_rbdyn::Robot & realRobot);
115 
116  /* Update floating-base position.
117  *
118  * \param realRobot Measurements robot model.
119  *
120  * The new position is chosen so that the origin of the real anchor frame
121  * coincides with the control anchor frame.
122  *
123  */
124  void estimatePosition(const mc_rbdyn::Robot & realRobot);
125 
126 private:
127  Eigen::Matrix3d orientation_;
128  Eigen::Vector3d position_;
129  const mc_rbdyn::Robot & controlRobot_;
130  double leftFootRatio_;
131 };
132 
133 } // namespace lipm_walking
EIGEN_MAKE_ALIGNED_OPERATOR_NEW FloatingBaseObserver(const mc_rbdyn::Robot &controlRobot)
Initialize floating base observer.
void reset(const sva::PTransformd &X_0_fb)
Reset floating base estimate.
Kinematics-only floating-base observer.
void run(const mc_rbdyn::Robot &realRobot)
Update floating-base transform of real robot.
void updateRobot(mc_rbdyn::Robot &robot)
Write observed floating-base transform to the robot&#39;s configuration.
sva::PTransformd getAnchorFrame(const mc_rbdyn::Robot &robot)
Get anchor frame of a robot for a given contact state.
const Eigen::Quaterniond & imuOrientation()
Get the orientation of the IMU with respect to the inertial frame.
Main controller namespace.
Definition: build.dox:1
void leftFootRatio(double ratio)
Set fraction of total weight sustained by the left foot.