A sparse MPC solver for walking motion generation.
walk_patterns.cpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @author Antonio Paolillo
4  * @author Dimitar Dimitrov
5  * @author Alexander Sherikov
6  */
7 
8 #include "oru_walk.h"
9 #include "oruw_log.h"
10 #include "oruw_timer.h"
11 
12 
13 /**
14  * @brief Initialize selected walk pattern
15  */
17 {
18  // support foot position and orientation
19  nao.init (
20  IGM_SUPPORT_LEFT,
21  0.0, 0.05, 0.0, // position
22  0.0, 0.0, 0.0); // orientation
23  // swing foot position
24  nao.getSwingFootPosture (nao.state_sensor, nao.right_foot_posture.data());
25 
26 
27  switch (wp.walk_pattern)
28  {
31  break;
34  break;
37  break;
38  default:
39  halt("Unknown walk pattern.\n", __FUNCTION__);
40  break;
41  }
42 }
43 
44 
45 /**
46  * @brief Initializes walk pattern
47  */
49 {
50  // each step is defined relatively to the previous step
51  const double step_x = wp.step_length; // relative X position
52  const double step_y = wmg.def_constraints.support_distance_y;// relative Y position
53 
54 
55  wmg.setFootstepParametersMS(0, 0, 0);
56  wmg.addFootstep(0.0, step_y/2, 0.0, FS_TYPE_SS_L);
57 
58  // Initial double support
59  wmg.setFootstepParametersMS(3*wp.ss_time_ms, 0, 0);
60  wmg.addFootstep(0.0, -step_y/2, 0.0, FS_TYPE_DS);
61 
62 
63  // all subsequent steps have normal feet size
64  wmg.setFootstepParametersMS(wp.ss_time_ms, 0, 0);
65  wmg.addFootstep(0.0 , -step_y/2, 0.0);
66  wmg.setFootstepParametersMS(wp.ss_time_ms, wp.ds_time_ms, wp.ds_number);
67  wmg.addFootstep(step_x, step_y, 0.0);
68 
69  for (int i = 0; i < wp.step_pairs_number; i++)
70  {
71  wmg.addFootstep(step_x, -step_y, 0.0);
72  wmg.addFootstep(step_x, step_y, 0.0);
73  }
74 
75  // here we give many reference points, since otherwise we
76  // would not have enough steps in preview window to reach
77  // the last footsteps
78  wmg.setFootstepParametersMS(5*wp.ss_time_ms, 0, 0);
79  wmg.addFootstep(0.0 , -step_y/2, 0.0, FS_TYPE_DS);
80  wmg.setFootstepParametersMS(0, 0, 0);
81  wmg.addFootstep(0.0 , -step_y/2, 0.0, FS_TYPE_SS_R);
82 }
83 
84 
85 
86 /**
87  * @brief Initializes walk pattern
88  */
90 {
91  // each step is defined relatively to the previous step
92  const double step_x = wp.step_length; // relative X position
93  const double step_y = wmg.def_constraints.support_distance_y;// relative Y position
94 
95 
96  wmg.setFootstepParametersMS (0, 0, 0);
97  wmg.addFootstep(0.0, step_y/2, 0.0, FS_TYPE_SS_L);
98 
99  // Initial double support
100  wmg.setFootstepParametersMS (3*wp.ss_time_ms, 0, 0);
101  wmg.addFootstep(0.0, -step_y/2, 0.0, FS_TYPE_DS);
102 
103  // each step is defined relatively to the previous step
104  const double shift = -0.01;
105 
106  // all subsequent steps have normal feet size
107  wmg.setFootstepParametersMS (wp.ss_time_ms, wp.ds_time_ms, wp.ds_number);
108  wmg.addFootstep(0.0 , -step_y/2, 0.0);
109  wmg.addFootstep(step_x, step_y + shift, 0.0);
110 
111  for (int i = 0; i < wp.step_pairs_number; i++)
112  {
113  wmg.addFootstep(step_x, -step_y + shift, 0.0);
114  wmg.addFootstep(step_x, step_y + shift, 0.0);
115  }
116 
117 
118  // here we give many reference points, since otherwise we
119  // would not have enough steps in preview window to reach
120  // the last footsteps
121  wmg.setFootstepParametersMS (6*wp.ss_time_ms, 0, 0);
122  wmg.addFootstep(0.0 , -step_y/2, 0.0, FS_TYPE_DS);
123  wmg.setFootstepParametersMS (0, 0, 0);
124  wmg.addFootstep(0.0 , -step_y/2, 0.0, FS_TYPE_SS_R);
125 }
126 
127 
128 
129 
130 /**
131  * @brief Initializes walk pattern
132  */
134 {
135  // each step is defined relatively to the previous step
136  const double step_x_ext = wp.step_length; // relative X position
137  const double step_y = wmg.def_constraints.support_distance_y;// relative Y position
138 
139  const double R_ext = 0.55;
140  const double R_int = R_ext - step_y;
141 
142  // relative angle
143  double a = asin (step_x_ext / R_ext);
144  double step_x_int = step_x_ext * R_int / R_ext;
145 
146 
147  wmg.setFootstepParametersMS (0, 0, 0);
148  wmg.addFootstep(0.0, step_y/2, 0.0, FS_TYPE_SS_L);
149 
150  // Initial double support
151  wmg.setFootstepParametersMS (3*wp.ss_time_ms, 0, 0);
152  wmg.addFootstep(0.0, -step_y/2, 0.0, FS_TYPE_DS);
153 
154 
155 
156  wmg.setFootstepParametersMS (wp.ss_time_ms, wp.ds_time_ms, wp.ds_number);
157  wmg.addFootstep(0.0 , -step_y/2, 0.0);
158  wmg.addFootstep(step_x_int, step_y, a);
159 
160  for (int i = 0; i < wp.step_pairs_number; i++)
161  {
162  wmg.addFootstep(step_x_ext, -step_y, a);
163  wmg.addFootstep(step_x_int, step_y, a);
164  }
165 
166  // here we give many reference points, since otherwise we
167  // would not have enough steps in preview window to reach
168  // the last footsteps
169  wmg.setFootstepParametersMS (6*wp.ss_time_ms, 0, 0);
170  wmg.addFootstep(0.0 , -step_y/2, 0.0, FS_TYPE_DS);
171  wmg.setFootstepParametersMS (0, 0, 0);
172  wmg.addFootstep(0.0 , -step_y/2, 0.0, FS_TYPE_SS_R);
173 }
nao_igm nao
Definition: oru_walk.h:134
void initWalkPattern(WMG &)
Initialize selected walk pattern.
void halt(const char *, const char *)
Log a message, remove stiffness and die.
Definition: walking.cpp:441
walkParameters wp
Definition: oru_walk.h:137
void initWalkPattern_Circular(WMG &)
Initializes walk pattern.
void initWalkPattern_Straight(WMG &)
Initializes walk pattern.
void initWalkPattern_Diagonal(WMG &)
Initializes walk pattern.