A sparse MPC solver for walking motion generation.
ip_problem_param.cpp
Go to the documentation of this file.
1 
9 /****************************************
10  * INCLUDES
11  ****************************************/
12 
13 #include "ip_problem_param.h"
14 
15 #include <cmath> //cos,sin
16 
17 /****************************************
18  * FUNCTIONS
19  ****************************************/
20 
21 namespace IP
22 {
24  const int N_,
25  const double gain_position,
26  const double gain_velocity,
27  const double gain_acceleration,
28  const double gain_jerk)
29  {
30  N = N_;
31 
32  i2Q[0] = 1/(2*(gain_position/2));
33  i2Q[1] = 1/(2*(gain_velocity/2));
34  i2Q[2] = 1/(2*(gain_acceleration/2));
35 
36  i2P = 1/(2 * (gain_jerk/2));
37 
38  spar = new state_parameters[N];
39  }
40 
41 
42 
44  {
45  if (spar != NULL)
46  delete [] spar;
47  }
48 
49 
50 
58  const double* T_,
59  const double* h_,
60  const double h_initial_,
61  const double* angle)
62  {
63  h_initial = h_initial_;
64 
65  for (int i = 0; i < N; i++)
66  {
67  spar[i].cos = cos(angle[i]);
68  spar[i].sin = sin(angle[i]);
69 
70  if (i == 0)
71  {
72  spar[i].A6 = T_[i]*T_[i]/2 - (h_[0] - h_initial);
73  }
74  else
75  {
76  spar[i].A6 = T_[i]*T_[i]/2 - (h_[i] - h_[i-1]);
77  }
78 
79  spar[i].T = T_[i];
80  spar[i].h = h_[i];
81 
82  spar[i].B[2] = T_[i];
83  spar[i].B[1] = T_[i]*T_[i]/2;
84  spar[i].B[0] = spar[i].B[1]*T_[i]/3 - h_[i]*T_[i];
85 
86  spar[i].A3 = T_[i];
87  }
88  }
89 }
void set_state_parameters(const double *, const double *, const double, const double *)
Initializes quadratic problem.
problem_parameters(const int, const double, const double, const double, const double)
state_parameters * spar
double h_initial
Height of the CoM at initial state divided by the gravity, this initial state precede the first state...