Pendulum.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_tasks/CoMTask.h>
31 
32 #include <lipm_walking/Contact.h>
33 
34 namespace lipm_walking
35 {
36 
40 struct Pendulum
41 {
42  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
43 
53  Pendulum(const Eigen::Vector3d & com = Eigen::Vector3d::Zero(),
54  const Eigen::Vector3d & comd = Eigen::Vector3d::Zero(),
55  const Eigen::Vector3d & comdd = Eigen::Vector3d::Zero());
56 
65  void completeIPM(const Contact & plane);
66 
74  void integrateCoMJerk(const Eigen::Vector3d & comddd, double dt);
75 
85  void integrateIPM(Eigen::Vector3d zmp, double lambda, double dt);
86 
96  void reset(const Eigen::Vector3d & com,
97  const Eigen::Vector3d & comd = Eigen::Vector3d::Zero(),
98  const Eigen::Vector3d & comdd = Eigen::Vector3d::Zero());
99 
107  void resetCoMHeight(double height, const Contact & contact);
108 
112  const Eigen::Vector3d & com() const
113  {
114  return com_;
115  }
116 
120  const Eigen::Vector3d & comd() const
121  {
122  return comd_;
123  }
124 
128  const Eigen::Vector3d & comdd() const
129  {
130  return comdd_;
131  }
132 
136  Eigen::Vector3d dcm() const
137  {
138  return com_ + comd_ / omega_;
139  }
140 
144  double omega() const
145  {
146  return omega_;
147  }
148 
155  const Eigen::Vector3d & zmp() const
156  {
157  return zmp_;
158  }
159 
163  const Eigen::Vector3d & zmpd() const
164  {
165  return zmpd_;
166  }
167 
168 protected:
169  Eigen::Vector3d com_;
170  Eigen::Vector3d comd_;
171  Eigen::Vector3d comdd_;
172  Eigen::Vector3d comddd_;
173  Eigen::Vector3d zmp_;
174  Eigen::Vector3d zmpd_;
175  double omega_;
176 };
177 
178 } // namespace lipm_walking
void reset(const Eigen::Vector3d &com, const Eigen::Vector3d &comd=Eigen::Vector3d::Zero(), const Eigen::Vector3d &comdd=Eigen::Vector3d::Zero())
Reset to a new state from CoM position and its derivatives.
Definition: Pendulum.cpp:39
double omega() const
Natural frequency.
Definition: Pendulum.h:144
const Eigen::Vector3d & comdd() const
CoM acceleration in the world frame.
Definition: Pendulum.h:128
State of the inverted pendulum model.
Definition: Pendulum.h:40
Eigen::Vector3d zmpd_
Velocity of the zero-tilting moment point.
Definition: Pendulum.h:174
Eigen::Vector3d comdd_
Acceleration of the center of mass.
Definition: Pendulum.h:171
void completeIPM(const Contact &plane)
Complete inverted pendulum inputs (ZMP and natural frequency) from contact plane. ...
Definition: Pendulum.cpp:88
const Eigen::Vector3d & comd() const
CoM velocity in the world frame.
Definition: Pendulum.h:120
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Pendulum(const Eigen::Vector3d &com=Eigen::Vector3d::Zero(), const Eigen::Vector3d &comd=Eigen::Vector3d::Zero(), const Eigen::Vector3d &comdd=Eigen::Vector3d::Zero())
Initialize state from CoM position and its derivatives.
Definition: Pendulum.cpp:34
Eigen::Vector3d zmp_
Position of the zero-tilting moment point.
Definition: Pendulum.h:173
void integrateCoMJerk(const Eigen::Vector3d &comddd, double dt)
Integrate constant CoM jerk for a given duration.
Definition: Pendulum.cpp:71
Eigen::Vector3d com_
Position of the center of mass.
Definition: Pendulum.h:169
void resetCoMHeight(double height, const Contact &contact)
Reset CoM height above a given contact plane.
Definition: Pendulum.cpp:79
Eigen::Vector3d dcm() const
Divergent component of motion.
Definition: Pendulum.h:136
const Eigen::Vector3d & zmp() const
Zero-tilting moment point.
Definition: Pendulum.h:155
const Eigen::Vector3d & zmpd() const
Velocity of the zero-tilting moment point.
Definition: Pendulum.h:163
void integrateIPM(Eigen::Vector3d zmp, double lambda, double dt)
Integrate in floating-base inverted pendulum mode with constant inputs.
Definition: Pendulum.cpp:52
Eigen::Vector3d comd_
Velocity of the center of mass.
Definition: Pendulum.h:170
Main controller namespace.
Definition: build.dox:1
Eigen::Vector3d comddd_
Jerk of the center of mass.
Definition: Pendulum.h:172
const Eigen::Vector3d & com() const
CoM position in the world frame.
Definition: Pendulum.h:112
Contacts wrap foot frames with extra info from the footstep plan.
Definition: Contact.h:58
double omega_
Natural frequency in [Hz].
Definition: Pendulum.h:175