monoped_gait_generator.cc
Go to the documentation of this file.
00001 /******************************************************************************
00002 Copyright (c) 2018, Alexander W. Winkler. All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 
00010 * Redistributions in binary form must reproduce the above copyright notice,
00011   this list of conditions and the following disclaimer in the documentation
00012   and/or other materials provided with the distribution.
00013 
00014 * Neither the name of the copyright holder nor the names of its
00015   contributors may be used to endorse or promote products derived from
00016   this software without specific prior written permission.
00017 
00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00021 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00022 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00023 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00024 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00025 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00026 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00027 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00028 ******************************************************************************/
00029 
00030 #include <towr/initialization/monoped_gait_generator.h>
00031 
00032 #include <cassert>
00033 #include <iostream>
00034 
00035 namespace towr {
00036 
00037 void
00038 MonopedGaitGenerator::SetCombo (Combos combo)
00039 {
00040   switch (combo) {
00041     case C0: SetGaits({Stand, Hop1, Hop1, Hop1, Hop1, Stand});       break;
00042     case C1: SetGaits({Stand, Hop1, Hop1, Hop1, Stand});             break;
00043     case C2: SetGaits({Stand, Hop1, Hop1, Hop1, Hop1, Stand});       break;
00044     case C3: SetGaits({Stand, Hop2, Hop2, Hop2, Stand});             break;
00045     case C4: SetGaits({Stand, Hop2, Hop2, Hop2, Hop2, Hop2, Stand}); break;
00046     default: assert(false); std::cout << "Gait not defined\n";       break;
00047   }
00048 }
00049 
00050 MonopedGaitGenerator::GaitInfo
00051 MonopedGaitGenerator::GetGait (Gaits gait) const
00052 {
00053   switch (gait) {
00054     case Stand:   return GetStrideStand();
00055     case Flight:  return GetStrideFlight();
00056     case Hop1:    return GetStrideHop();
00057     case Hop2:    return GetStrideHopLong();
00058     default: assert(false); // gait not implemented
00059   }
00060 }
00061 
00062 MonopedGaitGenerator::GaitInfo
00063 MonopedGaitGenerator::GetStrideStand () const
00064 {
00065   auto times =
00066   {
00067       0.5,
00068   };
00069   auto contacts =
00070   {
00071       o_,
00072   };
00073 
00074   return std::make_pair(times, contacts);
00075 }
00076 
00077 MonopedGaitGenerator::GaitInfo
00078 MonopedGaitGenerator::GetStrideFlight () const
00079 {
00080   auto times =
00081   {
00082       0.5,
00083   };
00084   auto contacts =
00085   {
00086       x_,
00087   };
00088 
00089   return std::make_pair(times, contacts);
00090 }
00091 
00092 MonopedGaitGenerator::GaitInfo
00093 MonopedGaitGenerator::GetStrideHop () const
00094 {
00095   auto times =
00096   {
00097       0.3, 0.3,
00098   };
00099   auto contacts =
00100   {
00101       o_, x_,
00102   };
00103 
00104   return std::make_pair(times, contacts);
00105 }
00106 
00107 MonopedGaitGenerator::GaitInfo
00108 MonopedGaitGenerator::GetStrideHopLong () const
00109 {
00110   auto times =
00111   {
00112       0.2, 0.3,
00113   };
00114   auto contacts =
00115   {
00116       o_, x_,
00117   };
00118 
00119   return std::make_pair(times, contacts);
00120 }
00121 
00122 } /* namespace towr */


towr
Author(s): Alexander W. Winkler
autogenerated on Mon Apr 15 2019 02:42:32