Go to the documentation of this file.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/parameters.h>
00031 #include <towr/variables/cartesian_dimensions.h>
00032
00033 #include <algorithm>
00034 #include <numeric>
00035 #include <math.h>
00036 #include <cassert>
00037
00038 namespace towr {
00039
00040 Parameters::Parameters ()
00041 {
00042
00043 duration_base_polynomial_ = 0.1;
00044 force_polynomials_per_stance_phase_ = 3;
00045 ee_polynomials_per_swing_phase_ = 2;
00046
00047
00048 force_limit_in_normal_direction_ = 1000;
00049 dt_constraint_range_of_motion_ = 0.08;
00050 dt_constraint_dynamic_ = 0.1;
00051 dt_constraint_base_motion_ = duration_base_polynomial_/4.;
00052 bound_phase_duration_ = std::make_pair(0.2, 1.0);
00053
00054
00055 constraints_.push_back(Terrain);
00056 constraints_.push_back(Dynamic);
00057 constraints_.push_back(BaseAcc);
00058 constraints_.push_back(EndeffectorRom);
00059 constraints_.push_back(Force);
00060 constraints_.push_back(Swing);
00061
00062
00063
00064
00065
00066 bounds_final_lin_pos_ = {X,Y};
00067 bounds_final_lin_vel_ = {X,Y,Z};
00068 bounds_final_ang_pos_ = {X,Y,Z};
00069 bounds_final_ang_vel_ = {X,Y,Z};
00070
00071
00072
00073 }
00074
00075 void
00076
00077 Parameters::OptimizePhaseDurations ()
00078 {
00079 constraints_.push_back(TotalTime);
00080 }
00081
00082 Parameters::VecTimes
00083 Parameters::GetBasePolyDurations () const
00084 {
00085 std::vector<double> base_spline_timings_;
00086 double dt = duration_base_polynomial_;
00087 double t_left = GetTotalTime ();
00088
00089 double eps = 1e-10;
00090 while (t_left > eps) {
00091 double duration = t_left>dt? dt : t_left;
00092 base_spline_timings_.push_back(duration);
00093
00094 t_left -= dt;
00095 }
00096
00097 return base_spline_timings_;
00098 }
00099
00100 int
00101 Parameters::GetPhaseCount(EEID ee) const
00102 {
00103 return ee_phase_durations_.at(ee).size();
00104 }
00105
00106 int
00107 Parameters::GetEECount() const
00108 {
00109 return ee_in_contact_at_start_.size();
00110 }
00111
00112 double
00113 Parameters::GetTotalTime () const
00114 {
00115 std::vector<double> T_feet;
00116
00117 for (const auto& v : ee_phase_durations_)
00118 T_feet.push_back(std::accumulate(v.begin(), v.end(), 0.0));
00119
00120
00121 double T = T_feet.empty()? 0.0 : T_feet.front();
00122 for (double Tf : T_feet)
00123 assert(fabs(Tf - T) < 1e-6);
00124
00125 return T;
00126 }
00127
00128 bool
00129 Parameters::IsOptimizeTimings () const
00130 {
00131
00132 ConstraintName c = TotalTime;
00133 auto v = constraints_;
00134 return std::find(v.begin(), v.end(), c) != v.end();
00135 }
00136
00137 }