00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <towr/initialization/biped_gait_generator.h>
00031
00032 #include <cassert>
00033 #include <iostream>
00034
00035 #include <towr/models/endeffector_mappings.h>
00036
00037 namespace towr {
00038
00039 BipedGaitGenerator::BipedGaitGenerator ()
00040 {
00041 ContactState init(2, false);
00042 I_ = b_ = P_ = B_ = init;
00043
00044 P_.at(L) = true;
00045 b_.at(R) = true;
00046 B_ = { true, true };
00047
00048 SetGaits({Stand});
00049 }
00050
00051 void
00052 BipedGaitGenerator::SetCombo (Combos combo)
00053 {
00054 switch (combo) {
00055 case C0: SetGaits({Stand, Walk1, Walk1, Walk1, Walk1, Stand}); break;
00056 case C1: SetGaits({Stand, Run1, Run1, Run1, Run1, Stand}); break;
00057 case C2: SetGaits({Stand, Hop1, Hop1, Hop1, Stand}); break;
00058 case C3: SetGaits({Stand, Hop1, Hop2, Hop2, Stand}); break;
00059 case C4: SetGaits({Stand, Hop5, Hop5, Hop5, Stand}); break;
00060 default: assert(false); std::cout << "Gait not defined\n"; break;
00061 }
00062 }
00063
00064 BipedGaitGenerator::GaitInfo
00065 BipedGaitGenerator::GetGait (Gaits gait) const
00066 {
00067 switch (gait) {
00068 case Stand: return GetStrideStand();
00069 case Flight: return GetStrideFlight();
00070 case Walk1: return GetStrideWalk();
00071 case Walk2: return GetStrideWalk();
00072 case Run1: return GetStrideRun();
00073 case Run3: return GetStrideRun();
00074 case Hop1: return GetStrideHop();
00075 case Hop2: return GetStrideLeftHop();
00076 case Hop3: return GetStrideRightHop();
00077 case Hop5: return GetStrideGallopHop();
00078 default: assert(false);
00079 }
00080 }
00081
00082 BipedGaitGenerator::GaitInfo
00083 BipedGaitGenerator::GetStrideStand () const
00084 {
00085 auto times =
00086 {
00087 0.2,
00088 };
00089 auto contacts =
00090 {
00091 B_,
00092 };
00093
00094 return std::make_pair(times, contacts);
00095 }
00096
00097 BipedGaitGenerator::GaitInfo
00098 BipedGaitGenerator::GetStrideFlight () const
00099 {
00100 auto times =
00101 {
00102 0.5,
00103 };
00104 auto contacts =
00105 {
00106 I_,
00107 };
00108
00109 return std::make_pair(times, contacts);
00110 }
00111
00112 BipedGaitGenerator::GaitInfo
00113 BipedGaitGenerator::GetStrideWalk () const
00114 {
00115 double step = 0.3;
00116 double stance = 0.05;
00117 auto times =
00118 {
00119 step, stance,
00120 step, stance,
00121 };
00122 auto phase_contacts =
00123 {
00124 b_, B_,
00125 P_, B_,
00126 };
00127
00128 return std::make_pair(times, phase_contacts);
00129 }
00130
00131 BipedGaitGenerator::GaitInfo
00132 BipedGaitGenerator::GetStrideRun () const
00133 {
00134 double flight = 0.4;
00135 double pushoff = 0.15;
00136 double landing = 0.15;
00137 auto times =
00138 {
00139 pushoff, flight,
00140 landing+pushoff, flight, landing,
00141 };
00142 auto phase_contacts =
00143 {
00144 b_, I_,
00145 P_, I_, b_,
00146 };
00147
00148 return std::make_pair(times, phase_contacts);
00149 }
00150
00151 BipedGaitGenerator::GaitInfo
00152 BipedGaitGenerator::GetStrideHop () const
00153 {
00154 double push = 0.15;
00155 double flight = 0.5;
00156 double land = 0.15;
00157 auto times =
00158 {
00159 push, flight, land
00160 };
00161 auto phase_contacts =
00162 {
00163 B_, I_, B_,
00164 };
00165
00166 return std::make_pair(times, phase_contacts);
00167 }
00168
00169 BipedGaitGenerator::GaitInfo
00170 BipedGaitGenerator::GetStrideGallopHop () const
00171 {
00172 double push = 0.2;
00173 double flight = 0.3;
00174 double land = 0.2;
00175
00176 auto times =
00177 {
00178 push, flight,
00179 land, land,
00180 };
00181 auto phase_contacts =
00182 {
00183 P_, I_,
00184 b_, B_,
00185 };
00186
00187 return std::make_pair(times, phase_contacts);
00188 }
00189
00190 BipedGaitGenerator::GaitInfo
00191 BipedGaitGenerator::GetStrideLeftHop () const
00192 {
00193 double push = 0.15;
00194 double flight = 0.4;
00195 double land = 0.15;
00196
00197 auto times =
00198 {
00199 push, flight, land,
00200 };
00201 auto phase_contacts =
00202 {
00203 b_, I_, b_
00204 };
00205
00206 return std::make_pair(times, phase_contacts);
00207 }
00208
00209 BipedGaitGenerator::GaitInfo
00210 BipedGaitGenerator::GetStrideRightHop () const
00211 {
00212 double push = 0.2;
00213 double flight = 0.2;
00214 double land = 0.2;
00215
00216 auto times =
00217 {
00218 push, flight, land
00219 };
00220 auto phase_contacts =
00221 {
00222 P_, I_, P_
00223 };
00224
00225 return std::make_pair(times, phase_contacts);
00226 }
00227
00228 }