biped_gait_generator.cc
Go to the documentation of this file.
1 /******************************************************************************
2 Copyright (c) 2018, Alexander W. Winkler. All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6 
7 * Redistributions of source code must retain the above copyright notice, this
8  list of conditions and the following disclaimer.
9 
10 * Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation
12  and/or other materials provided with the distribution.
13 
14 * Neither the name of the copyright holder nor the names of its
15  contributors may be used to endorse or promote products derived from
16  this software without specific prior written permission.
17 
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 ******************************************************************************/
29 
31 
32 #include <cassert>
33 #include <iostream>
34 
36 
37 namespace towr {
38 
40 {
41  ContactState init(2, false);
42  I_ = b_ = P_ = B_ = init;
43 
44  P_.at(L) = true;
45  b_.at(R) = true;
46  B_ = { true, true };
47 
48  SetGaits({Stand});
49 }
50 
51 void
53 {
54  switch (combo) {
55  case C0: SetGaits({Stand, Walk1, Walk1, Walk1, Walk1, Stand}); break;
56  case C1: SetGaits({Stand, Run1, Run1, Run1, Run1, Stand}); break;
57  case C2: SetGaits({Stand, Hop1, Hop1, Hop1, Stand}); break;
58  case C3: SetGaits({Stand, Hop1, Hop2, Hop2, Stand}); break;
59  case C4: SetGaits({Stand, Hop5, Hop5, Hop5, Stand}); break;
60  default: assert(false); std::cout << "Gait not defined\n"; break;
61  }
62 }
63 
66 {
67  switch (gait) {
68  case Stand: return GetStrideStand();
69  case Flight: return GetStrideFlight();
70  case Walk1: return GetStrideWalk();
71  case Walk2: return GetStrideWalk();
72  case Run1: return GetStrideRun();
73  case Run3: return GetStrideRun();
74  case Hop1: return GetStrideHop();
75  case Hop2: return GetStrideLeftHop();
76  case Hop3: return GetStrideRightHop();
77  case Hop5: return GetStrideGallopHop();
78  default: assert(false); // gait not implemented
79  }
80 }
81 
84 {
85  auto times =
86  {
87  0.2,
88  };
89  auto contacts =
90  {
91  B_,
92  };
93 
94  return std::make_pair(times, contacts);
95 }
96 
99 {
100  auto times =
101  {
102  0.5,
103  };
104  auto contacts =
105  {
106  I_,
107  };
108 
109  return std::make_pair(times, contacts);
110 }
111 
114 {
115  double step = 0.3;
116  double stance = 0.05;
117  auto times =
118  {
119  step, stance,
120  step, stance,
121  };
122  auto phase_contacts =
123  {
124  b_, B_, // swing left foot
125  P_, B_, // swing right foot
126  };
127 
128  return std::make_pair(times, phase_contacts);
129 }
130 
133 {
134  double flight = 0.4;
135  double pushoff = 0.15;
136  double landing = 0.15;
137  auto times =
138  {
139  pushoff, flight,
140  landing+pushoff, flight, landing,
141  };
142  auto phase_contacts =
143  {
144  b_, I_, // swing left foot
145  P_, I_, b_, // swing right foot
146  };
147 
148  return std::make_pair(times, phase_contacts);
149 }
150 
153 {
154  double push = 0.15;
155  double flight = 0.5;
156  double land = 0.15;
157  auto times =
158  {
159  push, flight, land
160  };
161  auto phase_contacts =
162  {
163  B_, I_, B_,
164  };
165 
166  return std::make_pair(times, phase_contacts);
167 }
168 
171 {
172  double push = 0.2;
173  double flight = 0.3;
174  double land = 0.2;
175 
176  auto times =
177  {
178  push, flight,
179  land, land,
180  };
181  auto phase_contacts =
182  {
183  P_, I_,
184  b_, B_,
185  };
186 
187  return std::make_pair(times, phase_contacts);
188 }
189 
192 {
193  double push = 0.15;
194  double flight = 0.4;
195  double land = 0.15;
196 
197  auto times =
198  {
199  push, flight, land,
200  };
201  auto phase_contacts =
202  {
203  b_, I_, b_
204  };
205 
206  return std::make_pair(times, phase_contacts);
207 }
208 
211 {
212  double push = 0.2;
213  double flight = 0.2;
214  double land = 0.2;
215 
216  auto times =
217  {
218  push, flight, land
219  };
220  auto phase_contacts =
221  {
222  P_, I_, P_
223  };
224 
225  return std::make_pair(times, phase_contacts);
226 }
227 
228 } /* namespace towr */
Gaits
Predefined strides, each with a different gait diagram.
Combos
Predefined combinations of different strides.
std::pair< VecTimes, std::vector< ContactState > > GaitInfo
void SetGaits(const std::vector< Gaits > &gaits)
Sets the times_ and contacts_ variables according to the gaits.
void SetCombo(Combos combo) override
Sets a specific sequence of gaits.
std::vector< bool > ContactState
GaitInfo GetGait(Gaits gait) const override


towr
Author(s): Alexander W. Winkler
autogenerated on Mon Feb 28 2022 23:54:22