parameters.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/parameters.h>
00031 
00032 #include <algorithm>
00033 
00034 namespace towr {
00035 
00036 Parameters::Parameters ()
00037 {
00038   t_total_ = 3.0; // [s]
00039 
00040   duration_base_polynomial_ = 0.2;
00041 
00042   // 2 also works quite well. Remember that in between the nodes, forces
00043   // could still be violating unilateral and friction constraints by
00044   // polynomial interpolation
00045   force_polynomials_per_stance_phase_ = 3; // this makes it a lot bigger
00046   ee_polynomials_per_swing_phase_ = 2; // should always be 2 if i want to use swing constraint!
00047 
00048 
00049   dt_constraint_range_of_motion_ = 0.1;
00050   dt_constraint_dynamic_ = 0.2;
00051   dt_constraint_base_motion_ = duration_base_polynomial_/4.;
00052 
00053 
00054   min_phase_duration_ = 0.1;
00055   double max_time = 2.0; // this helps convergence
00056   max_phase_duration_ = max_time>t_total_?  t_total_ : max_time;
00057 //  max_phase_duration_ = GetTotalTime()/contact_timings_.size();
00058 
00059 
00060   force_limit_in_norm_ = 1000; // [N] this affects convergence when optimizing gait
00061 
00062   constraints_ = {
00063       BaseAcc,
00064       EndeffectorRom,
00065       Dynamic,
00066       Terrain,
00067       Force,
00068 //      TotalTime, // Attention: this causes segfault in SNOPT
00069       Swing, // remove this at some point -> hacky
00070 //      BaseRom, //  CAREFUL: restricts the base to be in a specific range->very limiting
00071   };
00072 
00073   costs_ = {
00074 //    {ForcesCostID, 1.0},
00075   };
00076 }
00077 
00078 bool
00079 Parameters::OptimizeTimings () const
00080 {
00081   ConstraintName c = TotalTime;
00082   auto v = constraints_; // shorthand
00083   return std::find(v.begin(), v.end(), c) != v.end();
00084 }
00085 
00086 Parameters::VecTimes
00087 Parameters::GetBasePolyDurations () const
00088 {
00089   std::vector<double> base_spline_timings_;
00090   double dt = duration_base_polynomial_;
00091   double t_left = t_total_;
00092 
00093   double eps = 1e-10; // since repeated subtraction causes inaccuracies
00094   while (t_left > eps) {
00095     double duration = t_left>dt?  dt : t_left;
00096     base_spline_timings_.push_back(duration);
00097 
00098     t_left -= dt;
00099   }
00100 
00101   return base_spline_timings_;
00102 }
00103 
00104 int
00105 Parameters::GetPhaseCount(EEID ee) const
00106 {
00107   return ee_phase_durations_.at(ee).size();
00108 }
00109 
00110 int
00111 Parameters::GetEECount() const
00112 {
00113   return ee_in_contact_at_start_.size();
00114 }
00115 
00116 } // namespace towr
00117 


towr_core
Author(s): Alexander W. Winkler
autogenerated on Mon Apr 9 2018 03:12:44