humoto
point_mass_model_6z.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Alexander Sherikov
4  @author Don Joven Agravante
5  @author Jan Michalczyk
6  @copyright 2014-2017 INRIA, 2014-2015 CNRS. Licensed under the Apache
7  License, Version 2.0. (see @ref LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
8  @brief
9 */
10 
11 #pragma once
12 
13 namespace humoto
14 {
15  namespace walking
16  {
17  /**
18  * @brief Point Mass Model with piece-wise constant CoP velocity
19  *
20  * This class generates matrices of the following systems:
21  *
22  * 1) controlled by position of the CoP
23  * c(k+1) = A c(k) + B z(k+1)
24  * zdot(k) = D c(k) + E z(k+1)
25  *
26  * 2) controlled by velocity of the CoP
27  * c(k+1) = Adz c(k) + Bdz dz(k+1)
28  * z(k) = Ddz c(k)
29  *
30  * @todo It can be faster if A,B are computed directly as derived in
31  * documentation.
32  */
34  {
35  private:
36  /**
37  * @brief Create A matrix of unrefined model
38  */
39  static etools::Matrix3 getAdz3(const double T, const double omega)
40  {
41  double Tw = T*omega;
42 
43  etools::Matrix3 A3;
44 
45  double ch = cosh(Tw);
46  double sh = sinh(Tw);
47 
48  A3 << 1., sh/omega, (ch - 1)/(omega*omega),
49  0., ch , sh/omega,
50  0., omega*sh, ch;
51 
52  return(A3);
53  }
54 
55 
56  /**
57  * @brief Create B matrix of unrefined model
58  */
59  static etools::Vector3 getBdz3(const double T, const double omega)
60  {
61  double Tw = T*omega;
62 
63  etools::Vector3 B3;
64 
65  double ch = cosh(Tw);
66  double sh = sinh(Tw);
67 
68  B3 << -sh/omega + T,
69  -ch + 1,
70  -omega*sh;
71 
72  return(B3);
73  }
74 
75 
76  /**
77  * @brief Create D matrix of unrefined model
78  */
79  static etools::Matrix1x3 getDdz3(const double omega)
80  {
82 
83  D3 << 1., 0., -1./(omega*omega);
84 
85  return(D3);
86  }
87 
88 
89  public:
90  /// Number of state variables
91  const std::size_t Ns_;
92 
93  /// Number of control variables
94  const int Nu_;
95 
96 
97  public:
98  /**
99  * @brief Constructor
100  */
101  PointMassModel6z() : Ns_(6), Nu_(2)
102  {
103  }
104 
105 
106  static double getOmega(const double com_height)
107  {
108  return(std::sqrt(humoto::g_gravitational_acceleration / com_height));
109  }
110 
111 
112  /**
113  * @brief Converts given cstate vector to CoM state.
114  *
115  * @return CoM state
116  */
118  const etools::Vector6 &cstate,
119  const double com_height)
120  {
122 
123  com_state.position_ << cstate(0), cstate(3), com_height;
124  com_state.velocity_ << cstate(1), cstate(4), 0.0;
125  com_state.acceleration_ << cstate(2), cstate(5), 0.0;
126 
127  return (com_state);
128  }
129 
130 
131  /**
132  * @brief Get cstate
133  */
134  static etools::Vector6 convertCoMState(const humoto::rigidbody::PointMassState &com_state)
135  {
136  etools::Vector6 cstate;
137  cstate << com_state.position_.x(),
138  com_state.velocity_.x(),
139  com_state.acceleration_.x(),
140  com_state.position_.y(),
141  com_state.velocity_.y(),
142  com_state.acceleration_.y();
143  return(cstate);
144  }
145 
146 
148  const double Ts,
149  const double T,
150  const double com_height,
151  const etools::Vector6 & cstate,
152  const etools::Vector2 & control)
153  {
155 
156 
157  etools::Matrix6 A = getA6(Ts, getOmega(com_height), T);
158  etools::Matrix6x2 B = getB6(Ts, getOmega(com_height), T);
159 
160  com_state = convertCoMState(A * cstate + B * control, com_height);
161 
162  return (com_state);
163  }
164 
165 
166  /**
167  * @brief Create A matrix of final model
168  */
169  static etools::Matrix3 getA3(const double T, const double omega, const double Tsample)
170  {
171  etools::Matrix3 A3 = getAdz3(T, omega);
172  etools::Vector3 B3 = getBdz3(T, omega);
173  etools::Matrix1x3 D3 = getDdz3(omega);
174 
175  A3 = A3 - B3*D3/Tsample;
176  return A3;
177  }
178 
179 
180  /**
181  * @brief Create A matrix of final model
182  */
183  static etools::Matrix3 getA3(const double T, const double omega)
184  {
185  return getA3(T, omega, T);
186  }
187 
188 
189  /**
190  * @brief Create A matrix of final model
191  */
192  static etools::Matrix6 getA6(const double T, const double omega, const double Tsample)
193  {
194  etools::Matrix3 A3 = getA3(T, omega, Tsample);
195 
196  etools::Matrix6 out;
197  out << A3, Eigen::Matrix3d::Zero(),
198  Eigen::Matrix3d::Zero(), A3;
199  return out;
200  }
201 
202 
203  /**
204  * @brief Create A matrix of final model
205  */
206  static etools::Matrix6 getA6(const double T, const double omega)
207  {
208  return ( getA6(T, omega, T) );
209  }
210 
211 
212  /**
213  * @brief Create B matrix of final model
214  */
215  static etools::Vector3 getB3(const double T, const double omega, const double Tsample)
216  {
217  etools::Vector3 B3 = getBdz3(T, omega);
218  B3 = B3/Tsample;
219 
220  return B3;
221  }
222 
223 
224  /**
225  * @brief Create A matrix of final model
226  */
227  static etools::Vector3 getB3(const double T, const double omega)
228  {
229  return getB3(T, omega, T);
230  }
231 
232 
233  /**
234  * @brief Create B matrix of final model
235  */
236  static etools::Matrix6x2 getB6(const double T, const double omega, const double Tsample)
237  {
238  etools::Vector3 B3 = getB3(T, omega, Tsample);
239 
240  etools::Matrix6x2 out;
241  out << B3, Eigen::Vector3d::Zero(),
242  Eigen::Vector3d::Zero(), B3;
243 
244  return out;
245  }
246 
247 
248  /**
249  * @brief Create B matrix of final model
250  */
251  static etools::Matrix6x2 getB6(const double T, const double omega)
252  {
253  return ( getB6(T, omega, T) );
254  }
255 
256 
257  /**
258  * @brief Create D matrix of final model
259  */
260  static etools::Matrix1x3 getD3(const double T, const double omega)
261  {
262  etools::Matrix1x3 D3 = getDdz3(omega);
263 
264  D3 = -D3/T;
265  return (D3);
266  }
267 
268 
269  /**
270  * @brief Create D matrix of final model
271  */
272  static etools::Matrix2x6 getD6(const double T, const double omega)
273  {
274  etools::Matrix1x3 D3 = getD3(T, omega);
275 
276  etools::Matrix2x6 out(2,6);
277  out << D3, etools::Matrix1x3::Zero(),
278  etools::Matrix1x3::Zero(), D3;
279  return out;
280  }
281 
282 
283  /**
284  * @brief Create E matrix of final model
285  */
286  static double getE3(const double T)
287  {
288  return (1./T);
289  }
290 
291 
292  /**
293  * @brief Create E matrix of final model
294  */
295  static etools::Matrix2 getE6(const double T, const double omega)
296  {
297  return (getE3(T) * Eigen::Matrix2d::Identity());
298  }
299 
300 
301  /**
302  * @brief Create Ddz6 matrix
303  */
304  static etools::Matrix2x6 getDdz6(const double com_height)
305  {
306  etools::Matrix2x6 out;
307  double hg = com_height / humoto::g_gravitational_acceleration;
308  out << 1., 0., -hg, 0., 0., 0.,
309  0., 0., 0., 1., 0., -hg;
310  return out;
311  }
312 
313 
314  /**
315  * @brief Create ksi matrix
316  *
317  * @note Used to generate matrix for terminal constraint
318  */
319  static etools::Matrix2x6 getDcpv6(const double omega)
320  {
321  etools::Matrix2x6 out;
322  out << 0., 1., 1./omega, 0., 0., 0.,
323  0., 0., 0., 0., 1., 1./omega;
324  return out;
325  }
326  };
327  }
328 }
static double getE3(const double T)
Create E matrix of final model.
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix2x6
Definition: eigentools.h:98
static etools::Matrix6x2 getB6(const double T, const double omega)
Create B matrix of final model.
#define HUMOTO_LOCAL
Definition: export_import.h:26
static etools::Matrix6x2 getB6(const double T, const double omega, const double Tsample)
Create B matrix of final model.
const int Nu_
Number of control variables.
static etools::Matrix6 getA6(const double T, const double omega, const double Tsample)
Create A matrix of final model.
const std::size_t Ns_
Number of state variables.
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix6
Definition: eigentools.h:80
static etools::Matrix3 getAdz3(const double T, const double omega)
Create A matrix of unrefined model.
static double getOmega(const double com_height)
static etools::Matrix3 getA3(const double T, const double omega)
Create A matrix of final model.
Point Mass Model with piece-wise constant CoP velocity.
static humoto::rigidbody::PointMassState convertCoMState(const etools::Vector6 &cstate, const double com_height)
Converts given cstate vector to CoM state.
static etools::Matrix2 getE6(const double T, const double omega)
Create E matrix of final model.
static humoto::rigidbody::PointMassState evaluate(const double Ts, const double T, const double com_height, const etools::Vector6 &cstate, const etools::Vector2 &control)
static etools::Vector6 convertCoMState(const humoto::rigidbody::PointMassState &com_state)
Get cstate.
static etools::Matrix1x3 getD3(const double T, const double omega)
Create D matrix of final model.
static etools::Matrix2x6 getD6(const double T, const double omega)
Create D matrix of final model.
The root namespace of HuMoTo.
Definition: config.h:12
Class that groups together parmeters related to a robot foot.
static etools::Vector3 getB3(const double T, const double omega, const double Tsample)
Create B matrix of final model.
static etools::Vector3 getB3(const double T, const double omega)
Create A matrix of final model.
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix1x3
Definition: eigentools.h:87
const double g_gravitational_acceleration
Gravitational acceleration.
Definition: constants.h:21
static etools::Matrix3 getA3(const double T, const double omega, const double Tsample)
Create A matrix of final model.
static etools::Vector3 getBdz3(const double T, const double omega)
Create B matrix of unrefined model.
static etools::Matrix1x3 getDdz3(const double omega)
Create D matrix of unrefined model.
static etools::Matrix2x6 getDcpv6(const double omega)
Create ksi matrix.
static etools::Matrix2x6 getDdz6(const double com_height)
Create Ddz6 matrix.
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix6x2
Definition: eigentools.h:127
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix2
Definition: eigentools.h:76
EIGENTOOLS_CONSTANT_SIZE_MATRIX Matrix3
Definition: eigentools.h:77
static etools::Matrix6 getA6(const double T, const double omega)
Create A matrix of final model.