00001
00002
00003 #include "GaitGenerator.h"
00019 using namespace rats;
00020 #include <cstdio>
00021 #include <coil/stringutil.h>
00022
00023 #define eps_eq(a,b,epsilon) (std::fabs((a)-(b)) < (epsilon))
00024 #ifndef rad2deg
00025 #define rad2deg(rad) (rad * 180 / M_PI)
00026 #endif
00027 #ifndef deg2rad
00028 #define deg2rad(deg) (deg * M_PI / 180)
00029 #endif
00030
00031
00032
00033 template<class T> class ValueDifferenceChecker
00034 {
00035 T prev_value;
00036 double diff_thre, max_value_diff;
00037 bool is_small_diff, is_initialized;
00038 double calcDiff (T& value) const { return 0; };
00039 public:
00040 ValueDifferenceChecker (double _diff_thre) : diff_thre (_diff_thre), max_value_diff(0), is_small_diff(true), is_initialized(false)
00041 {
00042 };
00043 ~ValueDifferenceChecker () {};
00044 void checkValueDiff (T& value)
00045 {
00046
00047 if (!is_initialized) {
00048 prev_value = value;
00049 is_initialized = true;
00050 }
00051
00052 double diff = calcDiff(value);
00053 if (diff > max_value_diff) max_value_diff = diff;
00054 is_small_diff = (diff < diff_thre) && is_small_diff;
00055 prev_value = value;
00056 };
00057 double getMaxValue () const { return max_value_diff; };
00058 double getDiffThre () const { return diff_thre; };
00059 bool isSmallDiff () const { return is_small_diff; };
00060 };
00061
00062 template<> double ValueDifferenceChecker<hrp::Vector3>::calcDiff (hrp::Vector3& value) const
00063 {
00064 return (value - prev_value).norm();
00065 };
00066
00067 template<> double ValueDifferenceChecker< std::vector<hrp::Vector3> >::calcDiff (std::vector<hrp::Vector3>& value) const
00068 {
00069 double tmp = 0;
00070 for (size_t i = 0; i < value.size(); i++) {
00071 tmp += (value[i] - prev_value[i]).norm();
00072 }
00073 return tmp;
00074 };
00075
00076
00077
00078 class ValueErrorChecker
00079 {
00080 double error_thre, max_value_error;
00081 bool is_small_error;
00082 public:
00083 ValueErrorChecker (double _thre) : error_thre (_thre), max_value_error(0), is_small_error(true)
00084 {
00085 };
00086 ~ValueErrorChecker () {};
00087 void checkValueError (const hrp::Vector3& p0, const hrp::Vector3& p1, std::vector<size_t> neglect_index = std::vector<size_t>())
00088 {
00089 hrp::Vector3 errorv(p0-p1);
00090 for (size_t i = 0; i < neglect_index.size(); i++) errorv(neglect_index[i]) = 0.0;
00091 double error = errorv.norm();
00092 if (error > max_value_error) max_value_error = error;
00093 is_small_error = (error < error_thre) && is_small_error;
00094 };
00095 double getMaxValue () const { return max_value_error; };
00096 double getErrorThre () const { return error_thre; };
00097 bool isSmallError () const { return is_small_error; };
00098 };
00099
00100 class testGaitGenerator
00101 {
00102 protected:
00103 double dt;
00104 std::vector<hrp::Vector3> leg_pos;
00105 std::vector<std::string> all_limbs;
00106 hrp::Vector3 cog;
00107 gait_generator* gg;
00108 bool use_gnuplot, use_graph_append;
00109
00110 hrp::Vector3 prev_rfoot_pos, prev_lfoot_pos, prev_rfoot_rpy, prev_lfoot_rpy;
00111 hrp::Vector3 min_rfoot_pos, min_lfoot_pos, max_rfoot_pos, max_lfoot_pos;
00112 hrp::Vector3 prev_refzmp;
00113 coordinates prev_ssmc;
00114 std::vector<bool> prev_contact_states;
00115 std::vector<double> prev_swing_support_time;
00116 double min_toe_heel_dif_angle, max_toe_heel_dif_angle, min_zmp_offset_x, max_zmp_offset_x;
00117
00118 bool is_contact_states_swing_support_time_validity;
00119
00120 ValueDifferenceChecker< hrp::Vector3 > refzmp_diff_checker, cartzmp_diff_checker, cog_diff_checker, ssmcpos_diff_checker, ssmcrot_diff_checker, ssmcposvel_diff_checker, ssmcrotvel_diff_checker;
00121 ValueDifferenceChecker< std::vector<hrp::Vector3> > footpos_diff_checker, footrot_diff_checker, footposvel_diff_checker, footrotvel_diff_checker, zmpoffset_diff_checker;
00122
00123 ValueErrorChecker zmp_error_checker, cogzmp_error_checker;
00124
00125 std::vector<double> step_time_list, min_toe_heel_dif_angle_list, max_toe_heel_dif_angle_list, min_zmp_offset_x_list, max_zmp_offset_x_list;
00126 bool is_step_time_valid, is_toe_heel_dif_angle_valid, is_toe_heel_zmp_offset_x_valid;
00127
00128 std::string test_doc_string;
00129 std::string fname_cogzmp;
00130 FILE* fp_cogzmp;
00131 std::string fname_fpos;
00132 FILE* fp_fpos;
00133 std::string fname_frot;
00134 FILE* fp_frot;
00135 std::string fname_zoff;
00136 FILE* fp_zoff;
00137 std::string fname_fposvel;
00138 FILE* fp_fposvel;
00139 std::string fname_frotvel;
00140 FILE* fp_frotvel;
00141 std::string fname_thpos;
00142 FILE* fp_thpos;
00143 std::string fname_sstime;
00144 FILE* fp_sstime;
00145 std::string fname_ssmc;
00146 FILE* fp_ssmc;
00147 std::string fname_ssmcvel;
00148 FILE* fp_ssmcvel;
00149 private:
00151
00153
00154
00155 void plot_and_save (FILE* gp, const std::string graph_fname, const std::string plot_str)
00156 {
00157 fprintf(gp, "%s\n unset multiplot\n", plot_str.c_str());
00158 fprintf(gp, "set terminal postscript eps color\nset output '/tmp/%s.eps'\n", graph_fname.c_str());
00159 fprintf(gp, "%s\n unset multiplot\n", plot_str.c_str());
00160 fflush(gp);
00161 };
00162
00163
00164
00165 void proc_one_walking_motion (size_t i)
00166 {
00167
00168
00169
00170
00171
00172
00173
00174 fprintf(fp_cogzmp, "%f ", i * dt);
00175 for (size_t ii = 0; ii < 3; ii++) {
00176 fprintf(fp_cogzmp, "%f ", gg->get_refzmp()(ii));
00177 }
00178 hrp::Vector3 czmp = gg->get_cart_zmp();
00179 for (size_t ii = 0; ii < 3; ii++) {
00180 fprintf(fp_cogzmp, "%f ", czmp(ii));
00181 }
00182 for (size_t ii = 0; ii < 3; ii++) {
00183 double cogpos;
00184 if (ii==2) {
00185 coordinates tmpc;
00186 gg->get_swing_support_mid_coords(tmpc);
00187 cogpos = tmpc.pos(2)+gg->get_cog()(2);
00188 } else {
00189 cogpos = gg->get_cog()(ii);
00190 }
00191 fprintf(fp_cogzmp, "%f ", cogpos);
00192 }
00193 fprintf(fp_cogzmp, "\n");
00194 fflush(fp_cogzmp);
00195
00196
00197 fprintf(fp_fpos, "%f ", i * dt);
00198 std::vector<std::string> tmp_string_vector = boost::assign::list_of("rleg");
00199 hrp::Vector3 rfoot_pos = (gg->get_support_leg_names() == tmp_string_vector) ? gg->get_support_leg_steps().front().worldcoords.pos : gg->get_swing_leg_steps().front().worldcoords.pos;
00200 for (size_t ii = 0; ii < 3; ii++) {
00201 fprintf(fp_fpos, "%f ", rfoot_pos(ii));
00202 min_rfoot_pos(ii) = std::min(min_rfoot_pos(ii), rfoot_pos(ii));
00203 max_rfoot_pos(ii) = std::max(max_rfoot_pos(ii), rfoot_pos(ii));
00204 }
00205 tmp_string_vector = boost::assign::list_of("lleg");
00206 hrp::Vector3 lfoot_pos = (gg->get_support_leg_names() == tmp_string_vector) ? gg->get_support_leg_steps().front().worldcoords.pos : gg->get_swing_leg_steps().front().worldcoords.pos;
00207 for (size_t ii = 0; ii < 3; ii++) {
00208 fprintf(fp_fpos, "%f ", lfoot_pos(ii));
00209 min_lfoot_pos(ii) = std::min(min_lfoot_pos(ii), lfoot_pos(ii));
00210 max_lfoot_pos(ii) = std::max(max_lfoot_pos(ii), lfoot_pos(ii));
00211 }
00212 fprintf(fp_fpos, "\n");
00213 fflush(fp_fpos);
00214
00215
00216 fprintf(fp_frot, "%f ", i * dt);
00217 tmp_string_vector = boost::assign::list_of("rleg");
00218 hrp::Matrix33 rfoot_rot = (gg->get_support_leg_names() == tmp_string_vector) ? gg->get_support_leg_steps().front().worldcoords.rot : gg->get_swing_leg_steps().front().worldcoords.rot;
00219 hrp::Vector3 rfoot_rpy = hrp::rpyFromRot(rfoot_rot);
00220 for (size_t ii = 0; ii < 3; ii++) {
00221 fprintf(fp_frot, "%f ", rad2deg(rfoot_rpy(ii)));
00222 }
00223 tmp_string_vector = boost::assign::list_of("lleg");
00224 hrp::Matrix33 lfoot_rot = (gg->get_support_leg_names() == tmp_string_vector) ? gg->get_support_leg_steps().front().worldcoords.rot : gg->get_swing_leg_steps().front().worldcoords.rot;
00225 hrp::Vector3 lfoot_rpy = hrp::rpyFromRot(lfoot_rot);
00226 for (size_t ii = 0; ii < 3; ii++) {
00227 fprintf(fp_frot, "%f ", rad2deg(lfoot_rpy(ii)));
00228 }
00229 fprintf(fp_frot, "\n");
00230 fflush(fp_frot);
00231
00232
00233 fprintf(fp_zoff, "%f ", i * dt);
00234 tmp_string_vector = boost::assign::list_of("rleg");
00235 hrp::Vector3 rfoot_zmp_offset = (gg->get_support_leg_names() == tmp_string_vector) ? gg->get_support_foot_zmp_offsets().front() : gg->get_swing_foot_zmp_offsets().front();
00236 for (size_t ii = 0; ii < 3; ii++) {
00237 fprintf(fp_zoff, "%f ", rfoot_zmp_offset(ii));
00238 }
00239 tmp_string_vector = boost::assign::list_of("lleg");
00240 hrp::Vector3 lfoot_zmp_offset = (gg->get_support_leg_names() == tmp_string_vector) ? gg->get_support_foot_zmp_offsets().front() : gg->get_swing_foot_zmp_offsets().front();
00241 for (size_t ii = 0; ii < 3; ii++) {
00242 fprintf(fp_zoff, "%f ", lfoot_zmp_offset(ii));
00243 }
00244 fprintf(fp_zoff, "\n");
00245 fflush(fp_zoff);
00246 double tmpzoff;
00247 if (gg->get_support_leg_names()[0] == "lleg") tmpzoff = rfoot_zmp_offset(0);
00248 else tmpzoff = lfoot_zmp_offset(0);
00249 min_zmp_offset_x = std::min(min_zmp_offset_x, tmpzoff);
00250 max_zmp_offset_x = std::max(max_zmp_offset_x, tmpzoff);
00251
00252
00253 fprintf(fp_fposvel, "%f ", i * dt);
00254 if ( i == 0 ) prev_rfoot_pos = rfoot_pos;
00255 hrp::Vector3 rfootpos_vel = (rfoot_pos - prev_rfoot_pos)/dt;
00256 for (size_t ii = 0; ii < 3; ii++) {
00257 fprintf(fp_fposvel, "%f ", rfootpos_vel(ii));
00258 }
00259 prev_rfoot_pos = rfoot_pos;
00260 if ( i == 0 ) prev_lfoot_pos = lfoot_pos;
00261 hrp::Vector3 lfootpos_vel = (lfoot_pos - prev_lfoot_pos)/dt;
00262 for (size_t ii = 0; ii < 3; ii++) {
00263 fprintf(fp_fposvel, "%f ", lfootpos_vel(ii));
00264 }
00265 prev_lfoot_pos = lfoot_pos;
00266 fprintf(fp_fposvel, "\n");
00267 fflush(fp_fposvel);
00268
00269
00270 fprintf(fp_frotvel, "%f ", i * dt);
00271 if ( i == 0 ) prev_rfoot_rpy = rfoot_rpy;
00272 hrp::Vector3 rfootrot_vel = (rfoot_rpy - prev_rfoot_rpy)/dt;
00273 for (size_t ii = 0; ii < 3; ii++) {
00274 fprintf(fp_frotvel, "%f ", rfootrot_vel(ii));
00275 }
00276 prev_rfoot_rpy = rfoot_rpy;
00277 if ( i == 0 ) prev_lfoot_rpy = lfoot_rpy;
00278 hrp::Vector3 lfootrot_vel = (lfoot_rpy - prev_lfoot_rpy)/dt;
00279 for (size_t ii = 0; ii < 3; ii++) {
00280 fprintf(fp_frotvel, "%f ", lfootrot_vel(ii));
00281 }
00282 prev_lfoot_rpy = lfoot_rpy;
00283 fprintf(fp_frotvel, "\n");
00284 fflush(fp_frotvel);
00285
00286
00287 fprintf(fp_thpos, "%f ", i * dt);
00288 hrp::Vector3 tmppos;
00289 tmppos = rfoot_pos+rfoot_rot*hrp::Vector3(gg->get_toe_pos_offset_x(), 0, 0);
00290 for (size_t ii = 0; ii < 3; ii++) {
00291 fprintf(fp_thpos, "%f ", tmppos(ii));
00292 min_rfoot_pos(ii) = std::min(min_rfoot_pos(ii), tmppos(ii));
00293 max_rfoot_pos(ii) = std::max(max_rfoot_pos(ii), tmppos(ii));
00294 }
00295 tmppos = lfoot_pos+lfoot_rot*hrp::Vector3(gg->get_toe_pos_offset_x(), 0, 0);
00296 for (size_t ii = 0; ii < 3; ii++) {
00297 fprintf(fp_thpos, "%f ", tmppos(ii));
00298 min_lfoot_pos(ii) = std::min(min_lfoot_pos(ii), tmppos(ii));
00299 max_lfoot_pos(ii) = std::max(max_lfoot_pos(ii), tmppos(ii));
00300 }
00301 tmppos = rfoot_pos+rfoot_rot*hrp::Vector3(gg->get_heel_pos_offset_x(), 0, 0);
00302 for (size_t ii = 0; ii < 3; ii++) {
00303 fprintf(fp_thpos, "%f ", tmppos(ii));
00304 min_rfoot_pos(ii) = std::min(min_rfoot_pos(ii), tmppos(ii));
00305 max_rfoot_pos(ii) = std::max(max_rfoot_pos(ii), tmppos(ii));
00306 }
00307 tmppos = lfoot_pos+lfoot_rot*hrp::Vector3(gg->get_heel_pos_offset_x(), 0, 0);
00308 for (size_t ii = 0; ii < 3; ii++) {
00309 fprintf(fp_thpos, "%f ", tmppos(ii));
00310 min_lfoot_pos(ii) = std::min(min_lfoot_pos(ii), tmppos(ii));
00311 max_lfoot_pos(ii) = std::max(max_lfoot_pos(ii), tmppos(ii));
00312 }
00313 fprintf(fp_thpos, "\n");
00314 fflush(fp_thpos);
00315
00316
00317 fprintf(fp_sstime, "%f ", i * dt);
00318 fprintf(fp_sstime, "%f %f ",
00319 gg->get_current_swing_time(RLEG),
00320 gg->get_current_swing_time(LLEG));
00321
00322 std::vector<leg_type> tmp_current_support_states = gg->get_current_support_states();
00323 bool rleg_contact_states = std::find_if(tmp_current_support_states.begin(), tmp_current_support_states.end(), boost::lambda::_1 == RLEG) != tmp_current_support_states.end();
00324 bool lleg_contact_states = std::find_if(tmp_current_support_states.begin(), tmp_current_support_states.end(), boost::lambda::_1 == LLEG) != tmp_current_support_states.end();
00325 fprintf(fp_sstime, "%d %d %f",
00326 (rleg_contact_states ? 1 : 0), (lleg_contact_states ? 1 : 0),
00327 0.8*gg->get_current_toe_heel_ratio()+0.1);
00328 fprintf(fp_sstime, "\n");
00329 fflush(fp_sstime);
00330
00331
00332 fprintf(fp_ssmc, "%f ", i * dt);
00333 coordinates tmp_ssmc;
00334 gg->get_swing_support_mid_coords(tmp_ssmc);
00335 for (size_t ii = 0; ii < 3; ii++) {
00336 fprintf(fp_ssmc, "%f ", tmp_ssmc.pos(ii));
00337 }
00338 hrp::Vector3 tmp_ssmcr = hrp::rpyFromRot(tmp_ssmc.rot);
00339 for (size_t ii = 0; ii < 3; ii++) {
00340 fprintf(fp_ssmc, "%f ", rad2deg(tmp_ssmcr(ii)));
00341 }
00342 fprintf(fp_ssmc, "\n");
00343 fflush(fp_ssmc);
00344
00345
00346 fprintf(fp_ssmcvel, "%f ", i * dt);
00347 if ( i == 0 ) prev_ssmc = tmp_ssmc;
00348 hrp::Vector3 tmp_ssmcpos_vel = (tmp_ssmc.pos - prev_ssmc.pos)/dt;
00349 for (size_t ii = 0; ii < 3; ii++) {
00350 fprintf(fp_ssmcvel, "%f ", tmp_ssmcpos_vel(ii));
00351 }
00352 hrp::Vector3 prev_ssmcr = hrp::rpyFromRot(prev_ssmc.rot);
00353 hrp::Vector3 tmp_ssmcrot_vel = (tmp_ssmcr - prev_ssmcr)/dt;
00354 for (size_t ii = 0; ii < 3; ii++) {
00355 fprintf(fp_ssmcvel, "%f ", tmp_ssmcrot_vel(ii));
00356 }
00357 fprintf(fp_ssmcvel, "\n");
00358 fflush(fp_ssmcvel);
00359 prev_ssmc = tmp_ssmc;
00360
00361
00362 double tmp_toe_heel_dif_angle = gg->get_toe_heel_dif_angle();
00363 min_toe_heel_dif_angle = std::min(min_toe_heel_dif_angle, tmp_toe_heel_dif_angle);
00364 max_toe_heel_dif_angle = std::max(max_toe_heel_dif_angle, tmp_toe_heel_dif_angle);
00365
00366
00367 if (gg->get_lcg_count() == 0) {
00368 step_time_list.push_back(gg->get_one_step_count()*dt);
00369 min_toe_heel_dif_angle_list.push_back(min_toe_heel_dif_angle);
00370 max_toe_heel_dif_angle_list.push_back(max_toe_heel_dif_angle);
00371 min_toe_heel_dif_angle = 1e10;
00372 max_toe_heel_dif_angle = -1e10;
00373 if ( !eps_eq(min_zmp_offset_x, gg->get_default_zmp_offsets()[0](0), 1e-5) ) min_zmp_offset_x_list.push_back(min_zmp_offset_x);
00374 else min_zmp_offset_x_list.push_back(0.0);
00375 if ( !eps_eq(max_zmp_offset_x, gg->get_default_zmp_offsets()[0](0), 1e-5) ) max_zmp_offset_x_list.push_back(max_zmp_offset_x);
00376 else max_zmp_offset_x_list.push_back(0.0);
00377 min_zmp_offset_x = 1e10;
00378 max_zmp_offset_x = -1e10;
00379 }
00380
00381
00382 {
00383
00384 zmp_error_checker.checkValueError(gg->get_cart_zmp(), gg->get_refzmp());
00385
00386
00387 hrp::Vector3 tmp(gg->get_refzmp());
00388 refzmp_diff_checker.checkValueDiff(tmp);
00389 tmp = gg->get_cart_zmp();
00390 cartzmp_diff_checker.checkValueDiff(tmp);
00391 tmp = gg->get_cog();
00392 cog_diff_checker.checkValueDiff(tmp);
00393
00394 std::vector<hrp::Vector3> tmpvec = boost::assign::list_of(rfoot_pos)(lfoot_pos);
00395 footpos_diff_checker.checkValueDiff(tmpvec);
00396 tmpvec = boost::assign::list_of(rfoot_rpy)(lfoot_rpy);
00397 footrot_diff_checker.checkValueDiff(tmpvec);
00398 tmpvec = boost::assign::list_of(rfootpos_vel)(lfootpos_vel);
00399 footposvel_diff_checker.checkValueDiff(tmpvec);
00400 tmpvec = boost::assign::list_of(rfootrot_vel)(lfootrot_vel);
00401 footrotvel_diff_checker.checkValueDiff(tmpvec);
00402
00403 ssmcpos_diff_checker.checkValueDiff(tmp_ssmc.pos);
00404 ssmcrot_diff_checker.checkValueDiff(tmp_ssmcr);
00405 ssmcposvel_diff_checker.checkValueDiff(tmp_ssmcpos_vel);
00406 ssmcrotvel_diff_checker.checkValueDiff(tmp_ssmcrot_vel);
00407
00408 tmpvec = boost::assign::list_of(rfoot_zmp_offset)(lfoot_zmp_offset);
00409 zmpoffset_diff_checker.checkValueDiff(tmpvec);
00410 }
00411
00412 is_contact_states_swing_support_time_validity = is_contact_states_swing_support_time_validity &&
00413 ((prev_contact_states[0] == rleg_contact_states) ? !eps_eq(prev_swing_support_time[0],dt,1e-5) : eps_eq(prev_swing_support_time[0],dt,1e-5)) &&
00414 ((prev_contact_states[1] == lleg_contact_states) ? !eps_eq(prev_swing_support_time[1],dt,1e-5) : eps_eq(prev_swing_support_time[1],dt,1e-5));
00415 prev_refzmp = gg->get_refzmp();
00416 prev_contact_states[0] = rleg_contact_states;
00417 prev_contact_states[1] = lleg_contact_states;
00418 prev_swing_support_time[0] = gg->get_current_swing_time(RLEG);
00419 prev_swing_support_time[1] = gg->get_current_swing_time(LLEG);
00420 };
00421
00422
00423 void plot_and_print_errorcheck ()
00424 {
00425
00426 if (use_gnuplot) {
00427 size_t gpsize = 12;
00428 FILE* gps[gpsize];
00429 for (size_t ii = 0; ii < gpsize;ii++) {
00430 gps[ii] = popen("gnuplot", "w");
00431 }
00432 {
00433 std::ostringstream oss("");
00434 std::string gtitle("COG_and_ZMP");
00435 size_t tmp_start = 2;
00436 oss << "set multiplot layout 3, 1 title '" << gtitle << "'" << std::endl;
00437 std::string titles[3] = {"X", "Y", "Z"};
00438 for (size_t ii = 0; ii < 3; ii++) {
00439 oss << "set xlabel 'Time [s]'" << std::endl;
00440 oss << "set ylabel '" << titles[ii] << "[m]'" << std::endl;
00441 oss << "plot "
00442 << "'" << fname_cogzmp << "' using 1:" << (tmp_start+ii) << " with lines title 'REFZMP',"
00443 << "'" << fname_cogzmp << "' using 1:" << (tmp_start+3+ii) << " with lines title 'CARTZMP',"
00444 << "'" << fname_cogzmp << "' using 1:" << (tmp_start+6+ii) << " with lines title 'COG'"
00445 << std::endl;
00446 }
00447 plot_and_save(gps[0], gtitle, oss.str());
00448 }
00449 {
00450 std::ostringstream oss("");
00451 std::string gtitle("Swing_support_pos");
00452 size_t tmp_start = 2;
00453 oss << "set multiplot layout 3, 1 title '" << gtitle << "'" << std::endl;
00454 std::string titles[3] = {"X", "Y", "Z"};
00455 for (size_t ii = 0; ii < 3; ii++) {
00456 oss << "set xlabel 'Time [s]'" << std::endl;
00457 oss << "set ylabel '" << titles[ii] << "[m]'" << std::endl;
00458 oss << "plot "
00459 << "'" << fname_fpos << "' using 1:" << (tmp_start+ii) << " with lines title 'rleg',"
00460 << "'" << fname_fpos << "' using 1:" << (tmp_start+3+ii) << " with lines title 'lleg'"
00461 << std::endl;
00462 }
00463 plot_and_save(gps[1], gtitle, oss.str());
00464 }
00465 {
00466 std::ostringstream oss("");
00467 std::string gtitle("Swing_support_rot");
00468 size_t tmp_start = 2;
00469 oss << "set multiplot layout 3, 1 title '" << gtitle << "'" << std::endl;
00470 std::string titles[3] = {"Roll", "Pitch", "Yaw"};
00471 for (size_t ii = 0; ii < 3; ii++) {
00472 oss << "set xlabel 'Time [s]'" << std::endl;
00473 oss << "set ylabel '" << titles[ii] << "[deg]'" << std::endl;
00474 oss << "plot "
00475 << "'" << fname_frot << "' using 1:" << (tmp_start+ii) << " with lines title 'rleg',"
00476 << "'" << fname_frot << "' using 1:" << (tmp_start+3+ii) << " with lines title 'lleg'"
00477 << std::endl;
00478 }
00479 plot_and_save(gps[2], gtitle, oss.str());
00480 }
00481 {
00482 std::ostringstream oss("");
00483 std::string gtitle("Swing_support_zmp_offset");
00484 size_t tmp_start = 2;
00485 oss << "set multiplot layout 3, 1 title '" << gtitle << "'" << std::endl;
00486 std::string titles[3] = {"X", "Y", "Z"};
00487 for (size_t ii = 0; ii < 3; ii++) {
00488 oss << "set xlabel 'Time [s]'" << std::endl;
00489 oss << "set ylabel '" << titles[ii] << "[m]'" << std::endl;
00490 oss << "plot "
00491 << "'" << fname_zoff << "' using 1:" << (tmp_start+ii) << " with lines title 'rleg',"
00492 << "'" << fname_zoff << "' using 1:" << (tmp_start+3+ii) << " with lines title 'lleg'"
00493 << std::endl;
00494 }
00495 plot_and_save(gps[3], gtitle, oss.str());
00496 }
00497 {
00498 std::ostringstream oss("");
00499 std::string gtitle("Swing_support_pos_vel");
00500 size_t tmp_start = 2;
00501 oss << "set multiplot layout 3, 1 title '" << gtitle << "'" << std::endl;
00502 std::string titles[3] = {"X", "Y", "Z"};
00503 for (size_t ii = 0; ii < 3; ii++) {
00504 oss << "set xlabel 'Time [s]'" << std::endl;
00505 oss << "set ylabel '" << titles[ii] << "[m/s]'" << std::endl;
00506 oss << "plot "
00507 << "'" << fname_fposvel << "' using 1:" << (tmp_start+ii) << " with lines title 'rleg',"
00508 << "'" << fname_fposvel << "' using 1:" << (tmp_start+3+ii) << " with lines title 'lleg'"
00509 << std::endl;
00510 }
00511 plot_and_save(gps[4], gtitle, oss.str());
00512 }
00513 {
00514 std::ostringstream oss("");
00515 std::string gtitle("Swing_support_rot_vel");
00516 size_t tmp_start = 2;
00517 oss << "set multiplot layout 3, 1 title '" << gtitle << "'" << std::endl;
00518 std::string titles[3] = {"Roll", "Pitch", "Yaw"};
00519 for (size_t ii = 0; ii < 3; ii++) {
00520 oss << "set xlabel 'Time [s]'" << std::endl;
00521 oss << "set ylabel '" << titles[ii] << "[deg/s]'" << std::endl;
00522 oss << "plot "
00523 << "'" << fname_frotvel << "' using 1:" << (tmp_start+ii) << " with lines title 'rleg',"
00524 << "'" << fname_frotvel << "' using 1:" << (tmp_start+3+ii) << " with lines title 'lleg'"
00525 << std::endl;
00526 }
00527 plot_and_save(gps[5], gtitle, oss.str());
00528 }
00529 {
00530 std::ostringstream oss("");
00531 std::string gtitle("Swing_support_pos_trajectory");
00532 double min_v[3], max_v[3], range[3];
00533 size_t tmp_thpos_start = 2;
00534 for (size_t ii = 0; ii < 3; ii++) {
00535 min_v[ii] = std::min(min_rfoot_pos(ii), min_lfoot_pos(ii));
00536 max_v[ii] = std::max(max_rfoot_pos(ii), max_lfoot_pos(ii));
00537 if (min_v[ii] == 0.0 && max_v[ii] == 0.0) {
00538 min_v[ii] = -0.1;
00539 max_v[ii] = 0.1;
00540 }
00541 range[ii] = max_v[ii] - min_v[ii];
00542 double mid = (max_v[ii]+min_v[ii])/2.0;
00543 min_v[ii] = mid + range[ii] * 1.05 * -0.5;
00544 max_v[ii] = mid + range[ii] * 1.05 * 0.5;
00545 }
00546 oss << "set multiplot layout 2, 1 title '" << gtitle << "'" << std::endl;
00547
00548 oss << "set size ratio " << range[2]/range[0] << std::endl;
00549 oss << "set xlabel 'X [m]'" << std::endl;
00550 oss << "set ylabel 'Z [m]'" << std::endl;
00551 oss << "plot "
00552 << "[" << min_v[0]<< ":" << max_v[0] << "]"
00553 << "[" << min_v[2] << ":" << max_v[2] << "]"
00554 << "'" << fname_fpos << "' using " << (2) << ":" << (2+2) << " with lines title 'rleg ee',"
00555 << "'" << fname_fpos << "' using " << (2+3) << ":" << (2+3+2) << " with lines title 'lleg ee',"
00556 << "'" << fname_thpos << "' using " << (tmp_thpos_start) << ":" << (tmp_thpos_start+2) << " with lines title 'rleg toe',"
00557 << "'" << fname_thpos << "' using " << (tmp_thpos_start+3) << ":" << (tmp_thpos_start+3+2) << " with lines title 'lleg toe',"
00558 << "'" << fname_thpos << "' using " << (tmp_thpos_start+3+3) << ":" << (tmp_thpos_start+3+3+2) << " with lines title 'rleg heel',"
00559 << "'" << fname_thpos << "' using " << (tmp_thpos_start+3+3+3) << ":" << (tmp_thpos_start+3+3+3+2) << " with lines title 'lleg heel'"
00560 << std::endl;
00561
00562 oss << "set size ratio " << range[2]/range[1] << std::endl;
00563 oss << "set xlabel 'Y [m]'" << std::endl;
00564 oss << "set ylabel 'Z [m]'" << std::endl;
00565 oss << "plot "
00566 << "[" << min_v[1]<< ":" << max_v[1] << "]"
00567 << "[" << min_v[2] << ":" << max_v[2] << "]"
00568 << "'" << fname_fpos << "' using " << (2+1) << ":" << (2+2) << " with lines title 'rleg ee',"
00569 << "'" << fname_fpos << "' using " << (2+3+1) << ":" << (2+3+2) << " with lines title 'lleg ee',"
00570 << "'" << fname_thpos << "' using " << (tmp_thpos_start+1) << ":" << (tmp_thpos_start+2) << " with lines title 'rleg toe',"
00571 << "'" << fname_thpos << "' using " << (tmp_thpos_start+3+1) << ":" << (tmp_thpos_start+3+2) << " with lines title 'lleg toe',"
00572 << "'" << fname_thpos << "' using " << (tmp_thpos_start+3+3+1) << ":" << (tmp_thpos_start+3+3+2) << " with lines title 'rleg heel',"
00573 << "'" << fname_thpos << "' using " << (tmp_thpos_start+3+3+3+1) << ":" << (tmp_thpos_start+3+3+3+2) << " with lines title 'lleg heel'"
00574 << std::endl;
00575 plot_and_save(gps[6], gtitle, oss.str());
00576 }
00577 {
00578 std::ostringstream oss("");
00579 std::string gtitle("Swing_support_remain_time");
00580 oss << "set multiplot layout 1, 1 title '" << gtitle << "'" << std::endl;
00581 oss << "set title 'Remain Time'" << std::endl;
00582 oss << "set xlabel 'Time [s]'" << std::endl;
00583 oss << "set ylabel 'Time [s]'" << std::endl;
00584 oss << "plot "
00585 << "'" << fname_sstime << "' using 1:" << 2 << " with lines title 'rleg remain time',"
00586 << "'" << fname_sstime << "' using 1:" << 3 << " with lines title 'lleg remain time',"
00587 << "'" << fname_sstime << "' using 1:" << 4 << " with lines title 'rleg contact states',"
00588 << "'" << fname_sstime << "' using 1:" << 5 << " with lines title 'lleg contact states',"
00589 << "'" << fname_sstime << "' using 1:" << 6 << " with lines title 'toe_heel_ratio*0.8+0.1'"
00590 << std::endl;
00591 plot_and_save(gps[7], gtitle, oss.str());
00592 }
00593 {
00594 std::ostringstream oss("");
00595 std::string gtitle("Swing_support_mid_coords_pos");
00596 size_t tmp_start = 2;
00597 oss << "set multiplot layout 3, 1 title '" << gtitle << "'" << std::endl;
00598 std::string titles[3] = {"X", "Y", "Z"};
00599 for (size_t ii = 0; ii < 3; ii++) {
00600 oss << "set xlabel 'Time [s]'" << std::endl;
00601 oss << "set ylabel 'Pos " << titles[ii] << "[m]'" << std::endl;
00602 oss << "plot "
00603 << "'" << fname_ssmc << "' using 1:" << (tmp_start+ii) << " with lines title ''"
00604 << std::endl;
00605 }
00606 plot_and_save(gps[8], gtitle, oss.str());
00607 }
00608 {
00609 std::ostringstream oss("");
00610 std::string gtitle("Swing_support_mid_coords_rot");
00611 size_t tmp_start = 2;
00612 oss << "set multiplot layout 3, 1 title '" << gtitle << "'" << std::endl;
00613 std::string titles[3] = {"Roll", "Pitch", "Yaw"};
00614 for (size_t ii = 0; ii < 3; ii++) {
00615 oss << "set xlabel 'Time [s]'" << std::endl;
00616 oss << "set ylabel 'Rot " << titles[ii] << "[deg]'" << std::endl;
00617 oss << "plot "
00618 << "'" << fname_ssmc << "' using 1:" << (tmp_start+ii+3) << " with lines title ''"
00619 << std::endl;
00620 }
00621 plot_and_save(gps[9], gtitle, oss.str());
00622 }
00623 {
00624 std::ostringstream oss("");
00625 std::string gtitle("Swing_support_mid_coords_pos_vel");
00626 size_t tmp_start = 2;
00627 oss << "set multiplot layout 3, 1 title '" << gtitle << "'" << std::endl;
00628 std::string titles[3] = {"X", "Y", "Z"};
00629 for (size_t ii = 0; ii < 3; ii++) {
00630 oss << "set xlabel 'Time [s]'" << std::endl;
00631 oss << "set ylabel 'PosVel " << titles[ii] << "[m/s]'" << std::endl;
00632 oss << "plot "
00633 << "'" << fname_ssmcvel << "' using 1:" << (tmp_start+ii) << " with lines title ''"
00634 << std::endl;
00635 }
00636 plot_and_save(gps[10], gtitle, oss.str());
00637 }
00638 {
00639 std::ostringstream oss("");
00640 std::string gtitle("Swing_support_mid_coords_rot_vel");
00641 size_t tmp_start = 2;
00642 oss << "set multiplot layout 3, 1 title '" << gtitle << "'" << std::endl;
00643 std::string titles[3] = {"Roll", "Pitch", "Yaw"};
00644 for (size_t ii = 0; ii < 3; ii++) {
00645 oss << "set xlabel 'Time [s]'" << std::endl;
00646 oss << "set ylabel 'RotVel " << titles[ii] << "[deg/s]'" << std::endl;
00647 oss << "plot "
00648 << "'" << fname_ssmcvel << "' using 1:" << (tmp_start+ii+3) << " with lines title ''"
00649 << std::endl;
00650 }
00651 plot_and_save(gps[11], gtitle, oss.str());
00652 }
00653
00654 if (use_graph_append) {
00655 int ret = 0;
00656 usleep(500000);
00657 ret = system("bash -c 'for f in /tmp/*.eps; do convert -density 250x250 $f ${f//eps}jpg; done'");
00658 ret = system("(cd /tmp; convert +append Swing_support_mid_coords_pos.jpg Swing_support_mid_coords_pos_vel.jpg Swing_support_mid_coords_rot.jpg Swing_support_mid_coords_rot_vel.jpg img1.jpg)");
00659 ret = system("(cd /tmp/; convert +append Swing_support_pos.jpg Swing_support_pos_vel.jpg Swing_support_rot.jpg Swing_support_rot_vel.jpg img2.jpg)");
00660 ret = system("(cd /tmp/; convert +append Swing_support_zmp_offset.jpg Swing_support_remain_time.jpg COG_and_ZMP.jpg Swing_support_pos_trajectory.jpg img3.jpg)");
00661 std::string tmpstr = test_doc_string.substr(0, test_doc_string.find(":"));
00662 for(size_t c = tmpstr.find_first_of(" "); c != std::string::npos; c = c = tmpstr.find_first_of(" ")){
00663 tmpstr.erase(c,1);
00664 }
00665 ret = system(std::string("(cd /tmp/; convert -append img1.jpg img2.jpg img3.jpg testGaitGeneratorResults_"+tmpstr+".jpg; rm -f /tmp/img[123].jpg /tmp/COG_and_ZMP.jpg /tmp/Swing_support*.jpg)").c_str());
00666 } else {
00667 double tmp;
00668 std::cin >> tmp;
00669 }
00670 for (size_t ii = 0; ii < gpsize; ii++) {
00671 fprintf(gps[ii], "exit\n");
00672 fflush(gps[ii]);
00673 pclose(gps[ii]);
00674 }
00675 }
00676 std::string tmpstr = test_doc_string.substr(0, test_doc_string.find(":"));
00677 for(size_t c = tmpstr.find_first_of(" "); c != std::string::npos; c = c = tmpstr.find_first_of(" ")){
00678 tmpstr.erase(c,1);
00679 }
00680 std::cerr << "Checking of " << tmpstr << " : all results = " << (check_all_results()?"true":"false") << std::endl;
00681 std::cerr << " ZMP error : " << (zmp_error_checker.isSmallError()?"true":"false") << ", max_error : " << zmp_error_checker.getMaxValue()*1e3 << "[mm], thre : " << zmp_error_checker.getErrorThre()*1e3 << "[mm]" << std::endl;
00682 std::cerr << " COGZMP error : " << (cogzmp_error_checker.isSmallError()?"true":"false") << ", max_error : " << cogzmp_error_checker.getMaxValue()*1e3 << "[mm], thre : " << cogzmp_error_checker.getErrorThre()*1e3 << "[mm]" << std::endl;
00683 std::cerr << " RefZMP diff : " << (refzmp_diff_checker.isSmallDiff()?"true":"false") << ", max_diff : " << refzmp_diff_checker.getMaxValue()*1e3 << "[mm], thre : " << refzmp_diff_checker.getDiffThre()*1e3 << "[mm]" << std::endl;
00684 std::cerr << " CartZMP diff : " << (cartzmp_diff_checker.isSmallDiff()?"true":"false") << ", max_diff : " << cartzmp_diff_checker.getMaxValue()*1e3 << "[mm], thre : " << cartzmp_diff_checker.getDiffThre()*1e3 << "[mm]" << std::endl;
00685 std::cerr << " COG diff : " << (cog_diff_checker.isSmallDiff()?"true":"false") << ", max_diff : " << cog_diff_checker.getMaxValue()*1e3 << "[mm], thre : " << cog_diff_checker.getDiffThre()*1e3 << "[mm]" <<std::endl;
00686 std::cerr << " FootPos diff : " << (footpos_diff_checker.isSmallDiff()?"true":"false") << ", max_diff : " << footpos_diff_checker.getMaxValue()*1e3 << "[mm], thre : " << footpos_diff_checker.getDiffThre()*1e3 << "[mm]" <<std::endl;
00687 std::cerr << " FootRot diff : " << (footrot_diff_checker.isSmallDiff()?"true":"false") << ", max_diff : " << rad2deg(footrot_diff_checker.getMaxValue()) << "[deg], thre : " << rad2deg(footrot_diff_checker.getDiffThre()) << "[deg]" <<std::endl;
00688 std::cerr << " FootPosVel diff : " << (footposvel_diff_checker.isSmallDiff()?"true":"false") << ", max_diff : " << footposvel_diff_checker.getMaxValue()*1e3 << "[mm/s], thre : " << footposvel_diff_checker.getDiffThre()*1e3 << "[mm/s]" <<std::endl;
00689 std::cerr << " FootRotVel diff : " << (footrotvel_diff_checker.isSmallDiff()?"true":"false") << ", max_diff : " << rad2deg(footrotvel_diff_checker.getMaxValue()) << "[deg/s], thre : " << rad2deg(footrotvel_diff_checker.getDiffThre()) << "[deg/s]" <<std::endl;
00690 std::cerr << " SwingSupportFootMidPos diff : " << (ssmcpos_diff_checker.isSmallDiff()?"true":"false") << ", max_diff : " << ssmcpos_diff_checker.getMaxValue()*1e3 << "[mm], thre : " << ssmcpos_diff_checker.getDiffThre()*1e3 << "[mm]" <<std::endl;
00691 std::cerr << " SwingSupportFootMidRot diff : " << (ssmcrot_diff_checker.isSmallDiff()?"true":"false") << ", max_diff : " << rad2deg(ssmcrot_diff_checker.getMaxValue()) << "[deg], thre : " << rad2deg(ssmcrot_diff_checker.getDiffThre()) << "[deg]" <<std::endl;
00692 std::cerr << " SwingSupportFootMidPosVel diff : " << (ssmcposvel_diff_checker.isSmallDiff()?"true":"false") << ", max_diff : " << ssmcposvel_diff_checker.getMaxValue()*1e3 << "[mm/s], thre : " << ssmcposvel_diff_checker.getDiffThre()*1e3 << "[mm/s]" <<std::endl;
00693 std::cerr << " SwingSupportFootMidRotVel diff : " << (ssmcrotvel_diff_checker.isSmallDiff()?"true":"false") << ", max_diff : " << rad2deg(ssmcrotvel_diff_checker.getMaxValue()) << "[deg/s], thre : " << rad2deg(ssmcrotvel_diff_checker.getDiffThre()) << "[deg/s]" <<std::endl;
00694 std::cerr << " ZMPOffset diff : " << (zmpoffset_diff_checker.isSmallDiff()?"true":"false") << ", max_diff : " << zmpoffset_diff_checker.getMaxValue()*1e3 << "[mm/s], thre : " << zmpoffset_diff_checker.getDiffThre()*1e3 << "[mm/s]" <<std::endl;
00695 std::cerr << " Contact states & swing support time validity : " << (is_contact_states_swing_support_time_validity?"true":"false") << std::endl;
00696 std::cerr << " Step time validity : " << (is_step_time_valid?"true":"false") << std::endl;
00697 std::cerr << " ToeHeel angle validity : " << (is_toe_heel_dif_angle_valid?"true":"false") << std::endl;
00698 std::cerr << " ToeHeel+ZMPoffset validity : " << (is_toe_heel_zmp_offset_x_valid?"true":"false") << std::endl;
00699 };
00700
00701 void check_start_values ()
00702 {
00703
00704 std::vector<size_t> neglect_index = boost::assign::list_of(2);
00705 cogzmp_error_checker.checkValueError(gg->get_cog(), gg->get_refzmp(), neglect_index);
00706 };
00707
00708 void check_end_values ()
00709 {
00710
00711 std::vector<size_t> neglect_index = boost::assign::list_of(2);
00712 cogzmp_error_checker.checkValueError(gg->get_cog(), gg->get_refzmp(), neglect_index);
00713
00714 std::vector< std::vector<step_node> > fsl;
00715 gg->get_footstep_nodes_list(fsl);
00716 is_step_time_valid = step_time_list.size() == fsl.size();
00717 if (is_step_time_valid) {
00718 for (size_t i = 0; i < step_time_list.size(); i++) {
00719 is_step_time_valid = eps_eq(step_time_list[i], fsl[i][0].step_time, 1e-5) && is_step_time_valid;
00720 }
00721 }
00722
00723 is_toe_heel_dif_angle_valid = (min_toe_heel_dif_angle_list.size() == fsl.size()) && (max_toe_heel_dif_angle_list.size() == fsl.size());
00724 if (is_toe_heel_dif_angle_valid) {
00725 if (gg->get_use_toe_heel_auto_set()) {
00726
00727 } else {
00728
00729 for (size_t i = 1; i < min_toe_heel_dif_angle_list.size(); i++) {
00730
00731
00732 is_toe_heel_dif_angle_valid = eps_eq(min_toe_heel_dif_angle_list[i], (-fsl[i][0].heel_angle), 1e-5)
00733 && eps_eq(max_toe_heel_dif_angle_list[i], fsl[i][0].toe_angle, 1e-5)
00734 && is_toe_heel_dif_angle_valid;
00735 }
00736 }
00737 }
00738
00739
00740 is_toe_heel_zmp_offset_x_valid = (min_zmp_offset_x_list.size() == fsl.size()) && (max_zmp_offset_x_list.size() == fsl.size());
00741 if (gg->get_use_toe_heel_transition()) {
00742 for (size_t i = 0; i < min_zmp_offset_x_list.size(); i++) {
00743
00744 bool heel_valid = true;
00745 if ( !eps_eq(min_toe_heel_dif_angle_list[i], 0.0, 1e-5) ) {
00746 heel_valid = eps_eq(min_zmp_offset_x_list[i], gg->get_heel_zmp_offset_x(), 1e-5);
00747 } else {
00748 heel_valid = !eps_eq(min_zmp_offset_x_list[i], gg->get_heel_zmp_offset_x(), 1e-5);
00749 }
00750 bool toe_valid = true;
00751 if ( !eps_eq(max_toe_heel_dif_angle_list[i], 0.0, 1e-5) ) {
00752 toe_valid = eps_eq(max_zmp_offset_x_list[i], gg->get_toe_zmp_offset_x(), 1e-5);
00753 } else {
00754 toe_valid = !eps_eq(max_zmp_offset_x_list[i], gg->get_toe_zmp_offset_x(), 1e-5);
00755 }
00756
00757 is_toe_heel_zmp_offset_x_valid = heel_valid && toe_valid && is_toe_heel_zmp_offset_x_valid;
00758 }
00759 } else {
00760
00761 }
00762 };
00763
00764
00765 void gen_and_plot_walk_pattern(const step_node& initial_support_leg_step, const step_node& initial_swing_leg_dst_step)
00766 {
00767 parse_params(false);
00768 gg->print_param();
00769 gg->initialize_gait_parameter(cog, boost::assign::list_of(initial_support_leg_step), boost::assign::list_of(initial_swing_leg_dst_step));
00770 while ( !gg->proc_one_tick() );
00771
00772
00773 check_start_values();
00774 size_t i = 0;
00775 while ( gg->proc_one_tick() ) {
00776 proc_one_walking_motion(i);
00777 i++;
00778 }
00779 check_end_values();
00780 plot_and_print_errorcheck ();
00781 };
00782
00783 void gen_and_plot_walk_pattern()
00784 {
00785 std::vector<std::string> tmp_string_vector = boost::assign::list_of("rleg");
00786 if (gg->get_footstep_front_leg_names() == tmp_string_vector) {
00787 step_node initial_support_leg_step = step_node(LLEG, coordinates(leg_pos[1]), 0, 0, 0, 0);
00788 step_node initial_swing_leg_dst_step = step_node(RLEG, coordinates(leg_pos[0]), 0, 0, 0, 0);
00789 gen_and_plot_walk_pattern(initial_support_leg_step, initial_swing_leg_dst_step);
00790 } else {
00791 step_node initial_support_leg_step = step_node(RLEG, coordinates(leg_pos[0]), 0, 0, 0, 0);
00792 step_node initial_swing_leg_dst_step = step_node(LLEG, coordinates(leg_pos[1]), 0, 0, 0, 0);
00793 gen_and_plot_walk_pattern(initial_support_leg_step, initial_swing_leg_dst_step);
00794 }
00795 }
00796
00797 public:
00798 std::vector<std::string> arg_strs;
00799 testGaitGenerator(double _dt) : dt(_dt), use_gnuplot(true), use_graph_append(false), is_contact_states_swing_support_time_validity(true),
00800 refzmp_diff_checker(20.0*1e-3), cartzmp_diff_checker(20.0*1e-3), cog_diff_checker(10.0*1e-3),
00801 ssmcpos_diff_checker(10.0*1e-3), ssmcrot_diff_checker(deg2rad(0.1)),
00802 ssmcposvel_diff_checker(10.0*1e-3), ssmcrotvel_diff_checker(deg2rad(1)),
00803 footpos_diff_checker(10.0*1e-3), footrot_diff_checker(deg2rad(1)),
00804 footposvel_diff_checker(40*1e-3), footrotvel_diff_checker(deg2rad(15)),
00805 zmpoffset_diff_checker(20.0*1e-3),
00806 zmp_error_checker(50*1e-3), cogzmp_error_checker(1.5*1e-3),
00807 min_rfoot_pos(1e10,1e10,1e10), min_lfoot_pos(1e10,1e10,1e10), max_rfoot_pos(-1e10,-1e10,-1e10), max_lfoot_pos(-1e10,-1e10,-1e10),
00808 min_toe_heel_dif_angle(1e10), max_toe_heel_dif_angle(-1e10), min_zmp_offset_x(1e10), max_zmp_offset_x(-1e10),
00809 prev_contact_states(2, true),
00810 prev_swing_support_time(2, 1e2),
00811 fname_cogzmp("/tmp/plot-cogzmp.dat"), fp_cogzmp(fopen(fname_cogzmp.c_str(), "w")),
00812 fname_fpos("/tmp/plot-fpos.dat"), fp_fpos(fopen(fname_fpos.c_str(), "w")),
00813 fname_frot("/tmp/plot-frot.dat"), fp_frot(fopen(fname_frot.c_str(), "w")),
00814 fname_zoff("/tmp/plot-zoff.dat"), fp_zoff(fopen(fname_zoff.c_str(), "w")),
00815 fname_fposvel("/tmp/plot-fposvel.dat"), fp_fposvel(fopen(fname_fposvel.c_str(), "w")),
00816 fname_frotvel("/tmp/plot-frotvel.dat"), fp_frotvel(fopen(fname_frotvel.c_str(), "w")),
00817 fname_thpos("/tmp/plot-thpos.dat"), fp_thpos(fopen(fname_thpos.c_str(), "w")),
00818 fname_sstime("/tmp/plot-sstime.dat"), fp_sstime(fopen(fname_sstime.c_str(), "w")),
00819 fname_ssmc("/tmp/plot-ssmc.dat"), fp_ssmc(fopen(fname_ssmc.c_str(), "w")),
00820 fname_ssmcvel("/tmp/plot-ssmcvel.dat"), fp_ssmcvel(fopen(fname_ssmcvel.c_str(), "w"))
00821 {};
00822
00823 virtual ~testGaitGenerator()
00824 {
00825 if (gg != NULL) {
00826 delete gg;
00827 gg = NULL;
00828 }
00829 fclose(fp_cogzmp);
00830 fclose(fp_fpos);
00831 fclose(fp_frot);
00832 fclose(fp_zoff);
00833 fclose(fp_fposvel);
00834 fclose(fp_frotvel);
00835 fclose(fp_thpos);
00836 fclose(fp_sstime);
00837 fclose(fp_ssmc);
00838 fclose(fp_ssmcvel);
00839 };
00840
00841 void test0 ()
00842 {
00843 test_doc_string = "test0 : Set foot steps";
00844
00845 parse_params();
00846 std::vector< std::vector<step_node> > fnsl;
00847 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(0, 0, 0)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
00848 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(0, 0, 0)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
00849 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(100*1e-3, 0, 0)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
00850 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(200*1e-3, 0, 0)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
00851 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(200*1e-3, 0, 0)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
00852 gg->set_foot_steps_list(fnsl);
00853 gen_and_plot_walk_pattern();
00854 };
00855
00856 void test1 ()
00857 {
00858 test_doc_string = "test1 : Go pos x,y,th combination";
00859
00860 parse_params();
00861 gg->clear_footstep_nodes_list();
00862 coordinates start_ref_coords;
00863 mid_coords(start_ref_coords, 0.5, coordinates(leg_pos[0]), coordinates(leg_pos[1]));
00864 gg->go_pos_param_2_footstep_nodes_list(200*1e-3, 100*1e-3, 20, boost::assign::list_of(coordinates(leg_pos[0])), start_ref_coords, boost::assign::list_of(RLEG));
00865 gen_and_plot_walk_pattern();
00866 };
00867
00868 void test2 ()
00869 {
00870 test_doc_string = "test2 : Go pos x";
00871
00872 parse_params();
00873 gg->clear_footstep_nodes_list();
00874 coordinates start_ref_coords;
00875 mid_coords(start_ref_coords, 0.5, coordinates(leg_pos[1]), coordinates(leg_pos[0]));
00876 gg->go_pos_param_2_footstep_nodes_list(300*1e-3, 0, 0, boost::assign::list_of(coordinates(leg_pos[1])), start_ref_coords, boost::assign::list_of(LLEG));
00877 gen_and_plot_walk_pattern();
00878 };
00879
00880 void test3 ()
00881 {
00882 test_doc_string = "test3 : Go pos y";
00883
00884 parse_params();
00885 gg->clear_footstep_nodes_list();
00886 coordinates start_ref_coords;
00887 mid_coords(start_ref_coords, 0.5, coordinates(leg_pos[0]), coordinates(leg_pos[1]));
00888 gg->go_pos_param_2_footstep_nodes_list(0, 150*1e-3, 0, boost::assign::list_of(coordinates(leg_pos[0])), start_ref_coords, boost::assign::list_of(RLEG));
00889 gen_and_plot_walk_pattern();
00890 };
00891
00892 void test4 ()
00893 {
00894 test_doc_string = "test4 : Go pos th";
00895
00896 parse_params();
00897 gg->clear_footstep_nodes_list();
00898 coordinates start_ref_coords;
00899 mid_coords(start_ref_coords, 0.5, coordinates(leg_pos[1]), coordinates(leg_pos[0]));
00900 gg->go_pos_param_2_footstep_nodes_list(0, 0, 30, boost::assign::list_of(coordinates(leg_pos[1])), start_ref_coords, boost::assign::list_of(LLEG));
00901 gen_and_plot_walk_pattern();
00902 };
00903
00904 void test5 ()
00905 {
00906 test_doc_string = "test5 : Set foot steps with Z change";
00907
00908 parse_params();
00909 gg->set_default_orbit_type(CYCLOIDDELAY);
00910 std::vector< std::vector<step_node> > fnsl;
00911 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(0, 0, 0)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
00912 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(0, 0, 0)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
00913 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(100*1e-3, 0, 100*1e-3)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
00914 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(200*1e-3, 0, 200*1e-3)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
00915 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(300*1e-3, 0, 300*1e-3)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
00916 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(300*1e-3, 0, 300*1e-3)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
00917 gg->set_foot_steps_list(fnsl);
00918 gen_and_plot_walk_pattern();
00919 };
00920
00921 void test6 ()
00922 {
00923 test_doc_string = "test6 : Go single step";
00924 parse_params();
00925 gg->clear_footstep_nodes_list();
00926 std::vector< std::vector<step_node> > fnsl;
00927 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(0, 0, 0)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
00928 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(100*1e-3, 75*1e-3, 0)+leg_pos[1]), hrp::rotFromRpy(hrp::Vector3(deg2rad(5), deg2rad(-20), deg2rad(10)))),
00929 gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
00930 gg->set_foot_steps_list(fnsl);
00931 gen_and_plot_walk_pattern();
00932 };
00933
00934 void test7 ()
00935 {
00936 test_doc_string = "test7 : Toe heel walk";
00937
00938 parse_params();
00939 std::vector<hrp::Vector3> dzo;
00940 dzo.push_back(hrp::Vector3(20*1e-3,-30*1e-3,0));
00941 dzo.push_back(hrp::Vector3(20*1e-3,30*1e-3,0));
00942 gg->set_default_zmp_offsets(dzo);
00943 gg->set_toe_zmp_offset_x(137*1e-3);
00944 gg->set_heel_zmp_offset_x(-105*1e-3);
00945 gg->set_toe_pos_offset_x(137*1e-3);
00946 gg->set_heel_pos_offset_x(-105*1e-3);
00947 gg->set_stride_parameters(0.2,0.1,20,0.2,0.1*0.5,20*0.5);
00948 gg->set_use_toe_heel_auto_set(true);
00949 gg->set_toe_angle(30);
00950 gg->set_heel_angle(10);
00951
00952 gg->set_use_toe_heel_transition(true);
00953 gg->clear_footstep_nodes_list();
00954 coordinates start_ref_coords;
00955 mid_coords(start_ref_coords, 0.5, coordinates(leg_pos[1]), coordinates(leg_pos[0]));
00956 gg->go_pos_param_2_footstep_nodes_list(400*1e-3, 0, 0, boost::assign::list_of(coordinates(leg_pos[1])), start_ref_coords, boost::assign::list_of(LLEG));
00957 gen_and_plot_walk_pattern();
00958 };
00959
00960 void test8 ()
00961 {
00962 test_doc_string = "test8 : Toe heel walk on slope";
00963
00964 parse_params();
00965 std::vector<hrp::Vector3> dzo;
00966 dzo.push_back(hrp::Vector3(20*1e-3,-30*1e-3,0));
00967 dzo.push_back(hrp::Vector3(20*1e-3,30*1e-3,0));
00968 gg->set_default_zmp_offsets(dzo);
00969 gg->set_toe_zmp_offset_x(137*1e-3);
00970 gg->set_heel_zmp_offset_x(-105*1e-3);
00971 gg->set_toe_pos_offset_x(137*1e-3);
00972 gg->set_heel_pos_offset_x(-105*1e-3);
00973 gg->set_toe_angle(30);
00974 gg->set_heel_angle(10);
00975
00976 gg->set_use_toe_heel_transition(true);
00977 gg->clear_footstep_nodes_list();
00978 hrp::Matrix33 initial_foot_mid_rot = Eigen::AngleAxis<double>(M_PI/2, hrp::Vector3::UnitZ()).toRotationMatrix();
00979
00980 coordinates start_ref_coords;
00981 mid_coords(start_ref_coords, 0.5, coordinates(initial_foot_mid_rot*leg_pos[1], initial_foot_mid_rot), coordinates(initial_foot_mid_rot*leg_pos[0], initial_foot_mid_rot));
00982 gg->go_pos_param_2_footstep_nodes_list(100*1e-3, 0, 0, boost::assign::list_of(coordinates(initial_foot_mid_rot*leg_pos[1], initial_foot_mid_rot)), start_ref_coords, boost::assign::list_of(LLEG));
00983
00984 std::vector<std::string> tmp_string_vector = boost::assign::list_of("rleg");
00985 if (gg->get_footstep_front_leg_names() == tmp_string_vector) {
00986 step_node initial_support_leg_step = step_node(LLEG, coordinates(hrp::Vector3(initial_foot_mid_rot * leg_pos[1]), initial_foot_mid_rot), 0, 0, 0, 0);
00987 step_node initial_swing_leg_dst_step = step_node(RLEG, coordinates(hrp::Vector3(initial_foot_mid_rot * leg_pos[0]), initial_foot_mid_rot), 0, 0, 0, 0);
00988 gen_and_plot_walk_pattern(initial_support_leg_step, initial_swing_leg_dst_step);
00989 } else {
00990 step_node initial_support_leg_step = step_node(RLEG, coordinates(hrp::Vector3(initial_foot_mid_rot * leg_pos[0]), initial_foot_mid_rot), 0, 0, 0, 0);
00991 step_node initial_swing_leg_dst_step = step_node(LLEG, coordinates(hrp::Vector3(initial_foot_mid_rot * leg_pos[1]), initial_foot_mid_rot), 0, 0, 0, 0);
00992 gen_and_plot_walk_pattern(initial_support_leg_step, initial_swing_leg_dst_step);
00993 }
00994 };
00995
00996 void test9 ()
00997 {
00998 test_doc_string = "test9 : Stair walk";
00999
01000 parse_params();
01001 gg->clear_footstep_nodes_list();
01002 gg->set_default_orbit_type(STAIR);
01003 gg->set_swing_trajectory_delay_time_offset (0.2);
01004 std::vector< std::vector<step_node> > fnsl;
01005 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(0, 0, 0)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01006 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(0, 0, 0)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01007 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(250*1e-3, 0, 200*1e-3)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01008 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(250*1e-3, 0, 200*1e-3)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01009 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(500*1e-3, 0, 400*1e-3)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01010 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(500*1e-3, 0, 400*1e-3)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01011 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(750*1e-3, 0, 600*1e-3)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01012 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(750*1e-3, 0, 600*1e-3)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01013 gg->set_foot_steps_list(fnsl);
01014 gen_and_plot_walk_pattern();
01015 };
01016
01017 void test10 ()
01018 {
01019 test_doc_string = "test10 : Stair walk + toe heel contact";
01020
01021 parse_params();
01022 gg->clear_footstep_nodes_list();
01023 gg->set_default_orbit_type(STAIR);
01024 gg->set_swing_trajectory_delay_time_offset (0.2);
01025 gg->set_toe_zmp_offset_x(137*1e-3);
01026 gg->set_heel_zmp_offset_x(-105*1e-3);
01027 gg->set_toe_pos_offset_x(137*1e-3);
01028 gg->set_heel_pos_offset_x(-105*1e-3);
01029 gg->set_toe_angle(20);
01030 gg->set_heel_angle(5);
01031 gg->set_default_step_time(1.5);
01032 gg->set_default_double_support_ratio_before(0.1);
01033 gg->set_default_double_support_ratio_after(0.1);
01034 double ratio[7] = {0.02, 0.28, 0.2, 0.0, 0.2, 0.25, 0.05};
01035 std::vector<double> ratio2(ratio, ratio+gg->get_NUM_TH_PHASES());
01036 gg->set_toe_heel_phase_ratio(ratio2);
01037 std::vector< std::vector<step_node> > fnsl;
01038 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(0, 0, 0)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01039 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(0, 0, 0)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01040 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(250*1e-3, 0, 200*1e-3)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01041 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(250*1e-3, 0, 200*1e-3)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01042 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(500*1e-3, 0, 400*1e-3)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01043 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(500*1e-3, 0, 400*1e-3)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01044 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(750*1e-3, 0, 600*1e-3)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01045 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(750*1e-3, 0, 600*1e-3)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01046 gg->set_foot_steps_list(fnsl);
01047 gen_and_plot_walk_pattern();
01048 };
01049
01050 void test11 ()
01051 {
01052 test_doc_string = "test11 : Foot rot change";
01053
01054 parse_params();
01055 hrp::Matrix33 tmpr;
01056 std::vector< std::vector<step_node> > fnsl;
01057 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(0, 0, 0)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01058 tmpr = hrp::rotFromRpy(5*M_PI/180.0, 15*M_PI/180.0, 0);
01059 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(250*1e-3, 0, 0*1e-3)+leg_pos[0]), tmpr), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01060 tmpr = hrp::rotFromRpy(-5*M_PI/180.0, -15*M_PI/180.0, 0);
01061 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(250*1e-3, 0, 0*1e-3)+leg_pos[1]), tmpr), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01062 gg->set_foot_steps_list(fnsl);
01063 gen_and_plot_walk_pattern();
01064 };
01065
01066 void test12 ()
01067 {
01068 test_doc_string = "test12 : Change step param in set foot steps";
01069
01070 parse_params();
01071 std::vector< std::vector<step_node> > fnsl;
01072 gg->set_default_step_time(4.0);
01073 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(0, 0, 0)+leg_pos[0])), gg->get_default_step_height(), 1.0, 0, 0)));
01074 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(0, 0, 0)+leg_pos[1])), gg->get_default_step_height(), 2.0, 0, 0)));
01075 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(100*1e-3, 0, 0)+leg_pos[0])), gg->get_default_step_height()*2, 1.5, 0, 0)));
01076 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(200*1e-3, 0, 0)+leg_pos[1])), gg->get_default_step_height(), 2.5, 0, 0)));
01077 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(300*1e-3, 0, 0)+leg_pos[0])), gg->get_default_step_height(), 1.0, 20, 5)));
01078 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(300*1e-3, 0, 0)+leg_pos[1])), gg->get_default_step_height(), 2.0, 0, 0)));
01079 gg->set_foot_steps_list(fnsl);
01080 gen_and_plot_walk_pattern();
01081 };
01082
01083 void test13 ()
01084 {
01085 test_doc_string = "test13 : Arbitrary leg switching";
01086
01087 parse_params();
01088 std::vector< std::vector<step_node> > fnsl;
01089 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(0, 0, 0)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), 0, 0)));
01090 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(0, 0, 0)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), 0, 0)));
01091 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(100*1e-3, 0, 0)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), 0, 0)));
01092 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(100*1e-3, 0, 0)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), 0, 0)));
01093 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(200*1e-3, 0, 0)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), 0, 0)));
01094 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(200*1e-3, 0, 0)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), 0, 0)));
01095 gg->set_foot_steps_list(fnsl);
01096 gen_and_plot_walk_pattern();
01097 };
01098
01099 void test14 ()
01100 {
01101 test_doc_string = "test14 : kick walk";
01102
01103 parse_params();
01104 gg->clear_footstep_nodes_list();
01105 gg->set_default_orbit_type(CYCLOIDDELAYKICK);
01106 coordinates start_ref_coords;
01107 mid_coords(start_ref_coords, 0.5, coordinates(leg_pos[1]), coordinates(leg_pos[0]));
01108 gg->go_pos_param_2_footstep_nodes_list(300*1e-3, 0, 0, boost::assign::list_of(coordinates(leg_pos[1])), start_ref_coords, boost::assign::list_of(LLEG));
01109 gen_and_plot_walk_pattern();
01110 };
01111
01112 void test15 ()
01113 {
01114 test_doc_string = "test15 : Stair walk down";
01115
01116 parse_params();
01117 gg->clear_footstep_nodes_list();
01118 gg->set_default_orbit_type(STAIR);
01119 gg->set_swing_trajectory_delay_time_offset (0.2);
01120 std::vector< std::vector<step_node> > fnsl;
01121 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(0, 0, 0)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01122 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(0, 0, 0)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01123 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(250*1e-3, 0, -200*1e-3)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01124 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(250*1e-3, 0, -200*1e-3)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01125 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(500*1e-3, 0, -400*1e-3)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01126 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(500*1e-3, 0, -400*1e-3)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01127 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(750*1e-3, 0, -600*1e-3)+leg_pos[0])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01128 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(750*1e-3, 0, -600*1e-3)+leg_pos[1])), gg->get_default_step_height(), gg->get_default_step_time(), gg->get_toe_angle(), gg->get_heel_angle())));
01129 gg->set_foot_steps_list(fnsl);
01130 gen_and_plot_walk_pattern();
01131 };
01132
01133 void test16 ()
01134 {
01135 test_doc_string = "test16 : Set foot steps with param (toe heel contact)";
01136
01137 parse_params();
01138 gg->clear_footstep_nodes_list();
01139 std::vector<hrp::Vector3> dzo;
01140 dzo.push_back(hrp::Vector3(20*1e-3,-30*1e-3,0));
01141 dzo.push_back(hrp::Vector3(20*1e-3,30*1e-3,0));
01142 gg->set_default_zmp_offsets(dzo);
01143 gg->set_toe_zmp_offset_x(137*1e-3);
01144 gg->set_heel_zmp_offset_x(-105*1e-3);
01145 gg->set_toe_pos_offset_x(137*1e-3);
01146 gg->set_heel_pos_offset_x(-105*1e-3);
01147 gg->set_toe_angle(20);
01148 gg->set_heel_angle(5);
01149 gg->set_default_step_time(2);
01150 gg->set_default_double_support_ratio_before(0.1);
01151 gg->set_default_double_support_ratio_after(0.1);
01152 gg->set_use_toe_heel_auto_set(true);
01153 gg->set_use_toe_heel_transition(true);
01154
01155 double ratio[7] = {0.07, 0.20, 0.2, 0.0, 0.2, 0.25, 0.08};
01156 std::vector<double> ratio2(ratio, ratio+gg->get_NUM_TH_PHASES());
01157 gg->set_toe_heel_phase_ratio(ratio2);
01158 std::vector< std::vector<step_node> > fnsl;
01159 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(0, 0, 0)+leg_pos[0])), gg->get_default_step_height()*0.5, gg->get_default_step_time()*0.5, gg->get_toe_angle()*0.5, gg->get_heel_angle()*0.5)));
01160 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(100*1e-3, 0, 0)+leg_pos[1])), gg->get_default_step_height()*2.0, gg->get_default_step_time()*2.0, gg->get_toe_angle()*2.0, gg->get_heel_angle()*2.0)));
01161 fnsl.push_back(boost::assign::list_of(step_node("rleg", coordinates(hrp::Vector3(hrp::Vector3(400*1e-3, 0, 0)+leg_pos[0])), gg->get_default_step_height()*0.5, gg->get_default_step_time()*0.5, gg->get_toe_angle()*0.5, gg->get_heel_angle()*0.5)));
01162 fnsl.push_back(boost::assign::list_of(step_node("lleg", coordinates(hrp::Vector3(hrp::Vector3(400*1e-3, 0, 0)+leg_pos[1])), gg->get_default_step_height()*2.0, gg->get_default_step_time()*2.0, gg->get_toe_angle()*2.0, gg->get_heel_angle()*2.0)));
01163 gg->set_foot_steps_list(fnsl);
01164 gen_and_plot_walk_pattern();
01165 };
01166
01167 void test17 ()
01168 {
01169 test_doc_string = "test17 : Test goVelocity (dx = 0.1, dy = 0.05, dth = 10.0)";
01170
01171 parse_params();
01172 gg->clear_footstep_nodes_list();
01173 gg->print_param();
01174 step_node initial_support_leg_step = step_node(LLEG, coordinates(leg_pos[1]), 0, 0, 0, 0);
01175 step_node initial_swing_leg_dst_step = step_node(RLEG, coordinates(leg_pos[0]), 0, 0, 0, 0);
01176 coordinates fm_coords;
01177 mid_coords(fm_coords, 0.5, initial_swing_leg_dst_step.worldcoords, initial_support_leg_step.worldcoords);
01178 gg->initialize_velocity_mode(fm_coords, 0.1, 0.05, 10.0, boost::assign::list_of(RLEG));
01179 gg->initialize_gait_parameter(cog, boost::assign::list_of(initial_support_leg_step), boost::assign::list_of(initial_swing_leg_dst_step));
01180 while ( !gg->proc_one_tick() );
01181
01182 check_start_values();
01183 size_t i = 0;
01184 while ( gg->proc_one_tick() ) {
01185 proc_one_walking_motion(i);
01186 i++;
01187 if ( i > static_cast<size_t>(gg->get_default_step_time()/dt) && gg->get_overwrite_check_timing() ) {
01188 gg->finalize_velocity_mode();
01189 }
01190 }
01191 check_end_values();
01192 plot_and_print_errorcheck ();
01193 };
01194
01195 void test18 ()
01196 {
01197 test_doc_string = "test18 : Test goVelocity with changing velocity (translation and rotation)";
01198
01199 parse_params();
01200 gg->clear_footstep_nodes_list();
01201 gg->set_overwritable_footstep_index_offset(0);
01202 gg->set_default_orbit_type(CYCLOIDDELAY);
01203 gg->print_param();
01204 step_node initial_support_leg_step = step_node(LLEG, coordinates(leg_pos[1]), 0, 0, 0, 0);
01205 step_node initial_swing_leg_dst_step = step_node(RLEG, coordinates(leg_pos[0]), 0, 0, 0, 0);
01206 coordinates fm_coords;
01207 mid_coords(fm_coords, 0.5, initial_swing_leg_dst_step.worldcoords, initial_support_leg_step.worldcoords);
01208 gg->initialize_velocity_mode(fm_coords, 0, 0, 0, boost::assign::list_of(RLEG));
01209 gg->initialize_gait_parameter(cog, boost::assign::list_of(initial_support_leg_step), boost::assign::list_of(initial_swing_leg_dst_step));
01210 while ( !gg->proc_one_tick() );
01211
01212 check_start_values();
01213 size_t i = 0;
01214 while ( gg->proc_one_tick() ) {
01215 proc_one_walking_motion(i);
01216 i++;
01217 if ( i > static_cast<size_t>(gg->get_default_step_time()/dt)*5 && gg->get_overwrite_check_timing() ) {
01218 gg->finalize_velocity_mode();
01219 } else if ( i > static_cast<size_t>(gg->get_default_step_time()/dt)*4 && gg->get_overwrite_check_timing() ) {
01220 gg->set_velocity_param(0, 0, 0);
01221 } else if ( i > static_cast<size_t>(gg->get_default_step_time()/dt)*3 && gg->get_overwrite_check_timing() ) {
01222 gg->set_velocity_param(0, 0, 10);
01223 } else if ( i > static_cast<size_t>(gg->get_default_step_time()/dt)*2 && gg->get_overwrite_check_timing() ) {
01224 gg->set_velocity_param(0, 0, 0);
01225 } else if ( i > static_cast<size_t>(gg->get_default_step_time()/dt) && gg->get_overwrite_check_timing() ) {
01226 gg->set_velocity_param(0.1, 0.05, 0);
01227 }
01228 }
01229 check_end_values();
01230 plot_and_print_errorcheck ();
01231 };
01232
01233 void test19 ()
01234 {
01235 test_doc_string = "test19 : Change stride parameter (translate)";
01236
01237 parse_params();
01238 std::vector<hrp::Vector3> dzo;
01239 dzo.push_back(hrp::Vector3(20*1e-3,-30*1e-3,0));
01240 dzo.push_back(hrp::Vector3(20*1e-3,30*1e-3,0));
01241 gg->set_default_zmp_offsets(dzo);
01242 gg->set_stride_parameters(0.25,0.15,25,0.25,0.1,10);
01243 gg->clear_footstep_nodes_list();
01244 coordinates start_ref_coords;
01245 mid_coords(start_ref_coords, 0.5, coordinates(leg_pos[1]), coordinates(leg_pos[0]));
01246 gg->go_pos_param_2_footstep_nodes_list(600*1e-3, -300*1e-3, 0, boost::assign::list_of(coordinates(leg_pos[1])), start_ref_coords, boost::assign::list_of(LLEG));
01247 gen_and_plot_walk_pattern();
01248 };
01249
01250 void test20 ()
01251 {
01252 test_doc_string = "test20 : Change stride parameter (translate+rotate)";
01253
01254 parse_params();
01255 std::vector<hrp::Vector3> dzo;
01256 dzo.push_back(hrp::Vector3(20*1e-3,-30*1e-3,0));
01257 dzo.push_back(hrp::Vector3(20*1e-3,30*1e-3,0));
01258 gg->set_default_zmp_offsets(dzo);
01259 gg->set_stride_parameters(0.25,0.15,25,0.25,0.1,10);
01260 gg->clear_footstep_nodes_list();
01261 coordinates start_ref_coords;
01262 mid_coords(start_ref_coords, 0.5, coordinates(leg_pos[1]), coordinates(leg_pos[0]));
01263 gg->go_pos_param_2_footstep_nodes_list(400*1e-3, -200*1e-3, -55, boost::assign::list_of(coordinates(leg_pos[1])), start_ref_coords, boost::assign::list_of(LLEG));
01264 gen_and_plot_walk_pattern();
01265 };
01266
01267 void parse_params (bool is_print_doc_setring = true)
01268 {
01269 if (is_print_doc_setring) std::cerr << test_doc_string << std::endl;
01270 for (unsigned int i = 0; i < arg_strs.size(); ++ i) {
01271 if ( arg_strs[i]== "--default-step-time" ) {
01272 if (++i < arg_strs.size()) gg->set_default_step_time(atof(arg_strs[i].c_str()));
01273 } else if ( arg_strs[i]== "--default-step-height" ) {
01274 if (++i < arg_strs.size()) gg->set_default_step_height(atof(arg_strs[i].c_str()));
01275 } else if ( arg_strs[i]== "--default-double-support-ratio-before" ) {
01276 if (++i < arg_strs.size()) gg->set_default_double_support_ratio_before(atof(arg_strs[i].c_str()));
01277 } else if ( arg_strs[i]== "--default-double-support-ratio-after" ) {
01278 if (++i < arg_strs.size()) gg->set_default_double_support_ratio_after(atof(arg_strs[i].c_str()));
01279 } else if ( arg_strs[i]== "--default-orbit-type" ) {
01280 if (++i < arg_strs.size()) {
01281 if (arg_strs[i] == "SHUFFLING") {
01282 gg->set_default_orbit_type(SHUFFLING);
01283 } else if (arg_strs[i] == "CYCLOID") {
01284 gg->set_default_orbit_type(CYCLOID);
01285 } else if (arg_strs[i] == "RECTANGLE") {
01286 gg->set_default_orbit_type(RECTANGLE);
01287 } else if (arg_strs[i] == "STAIR") {
01288 gg->set_default_orbit_type(STAIR);
01289 } else if (arg_strs[i] == "CYCLOIDDELAY") {
01290 gg->set_default_orbit_type(CYCLOIDDELAY);
01291 } else if (arg_strs[i] == "CYCLOIDDELAYKICK") {
01292 gg->set_default_orbit_type(CYCLOIDDELAYKICK);
01293 } else if (arg_strs[i] == "CROSS") {
01294 gg->set_default_orbit_type(CROSS);
01295 } else {
01296 std::cerr << "No such default-orbit-type " << arg_strs[i] << std::endl;
01297 }
01298 }
01299 } else if ( arg_strs[i]== "--default-double-support-static-ratio-before" ) {
01300 if (++i < arg_strs.size()) gg->set_default_double_support_static_ratio_before(atof(arg_strs[i].c_str()));
01301 } else if ( arg_strs[i]== "--default-double-support-static-ratio-after" ) {
01302 if (++i < arg_strs.size()) gg->set_default_double_support_static_ratio_after(atof(arg_strs[i].c_str()));
01303 } else if ( arg_strs[i]== "--default-double-support-ratio-swing-before" ) {
01304 if (++i < arg_strs.size()) gg->set_default_double_support_ratio_swing_before(atof(arg_strs[i].c_str()));
01305 } else if ( arg_strs[i]== "--default-double-support-ratio-swing-after" ) {
01306 if (++i < arg_strs.size()) gg->set_default_double_support_ratio_swing_after(atof(arg_strs[i].c_str()));
01307 } else if ( arg_strs[i]== "--swing-trajectory-delay-time-offset" ) {
01308 if (++i < arg_strs.size()) gg->set_swing_trajectory_delay_time_offset(atof(arg_strs[i].c_str()));
01309 } else if ( arg_strs[i]== "--swing-trajectory-final-distance-weight" ) {
01310 if (++i < arg_strs.size()) gg->set_swing_trajectory_final_distance_weight(atof(arg_strs[i].c_str()));
01311 } else if ( arg_strs[i]== "--swing-trajectory-time-offset-xy2z" ) {
01312 if (++i < arg_strs.size()) gg->set_swing_trajectory_time_offset_xy2z(atof(arg_strs[i].c_str()));
01313 } else if ( arg_strs[i]== "--stair-trajectory-way-point-offset" ) {
01314 if (++i < arg_strs.size()) {
01315 coil::vstring strs = coil::split(std::string(arg_strs[i].c_str()), ",");
01316 gg->set_stair_trajectory_way_point_offset(hrp::Vector3(atof(strs[0].c_str()), atof(strs[1].c_str()), atof(strs[2].c_str())));
01317 }
01318 } else if ( arg_strs[i]== "--cycloid-delay-kick-point-offset" ) {
01319 if (++i < arg_strs.size()) {
01320 coil::vstring strs = coil::split(std::string(arg_strs[i].c_str()), ",");
01321 gg->set_cycloid_delay_kick_point_offset(hrp::Vector3(atof(strs[0].c_str()), atof(strs[1].c_str()), atof(strs[2].c_str())));
01322 }
01323 } else if ( arg_strs[i]== "--toe-angle" ) {
01324 if (++i < arg_strs.size()) gg->set_toe_angle(atof(arg_strs[i].c_str()));
01325 } else if ( arg_strs[i]== "--heel-angle" ) {
01326 if (++i < arg_strs.size()) gg->set_heel_angle(atof(arg_strs[i].c_str()));
01327 } else if ( arg_strs[i]== "--toe-heel-phase-ratio" ) {
01328 if (++i < arg_strs.size()) {
01329 coil::vstring strs = coil::split(std::string(arg_strs[i].c_str()), ",");
01330 std::vector<double> ratio;
01331 for (size_t i_th = 0; i_th < strs.size(); i_th++) {
01332 ratio.push_back(atof(strs[i_th].c_str()));
01333 }
01334 std::cerr << "[] ";
01335 gg->set_toe_heel_phase_ratio(ratio);
01336 }
01337 } else if ( arg_strs[i]== "--optional-go-pos-finalize-footstep-num" ) {
01338 if (++i < arg_strs.size()) gg->set_optional_go_pos_finalize_footstep_num(atoi(arg_strs[i].c_str()));
01339 } else if ( arg_strs[i]== "--use-gnuplot" ) {
01340 if (++i < arg_strs.size()) use_gnuplot = (arg_strs[i]=="true");
01341 } else if ( arg_strs[i]== "--use-graph-append" ) {
01342 if (++i < arg_strs.size()) use_graph_append = (arg_strs[i]=="true");
01343 }
01344 }
01345 };
01346
01347 bool check_all_results () const
01348 {
01349 return refzmp_diff_checker.isSmallDiff() && cartzmp_diff_checker.isSmallDiff() && cog_diff_checker.isSmallDiff()
01350 && ssmcpos_diff_checker.isSmallDiff() && ssmcrot_diff_checker.isSmallDiff()
01351 && ssmcposvel_diff_checker.isSmallDiff() && ssmcrotvel_diff_checker.isSmallDiff()
01352 && footpos_diff_checker.isSmallDiff() && footrot_diff_checker.isSmallDiff()
01353 && zmpoffset_diff_checker.isSmallDiff()
01354 && footposvel_diff_checker.isSmallDiff() && footrotvel_diff_checker.isSmallDiff()
01355 && zmp_error_checker.isSmallError() && cogzmp_error_checker.isSmallError()
01356 && is_step_time_valid && is_toe_heel_dif_angle_valid && is_toe_heel_zmp_offset_x_valid
01357 && is_contact_states_swing_support_time_validity;
01358 };
01359 };
01360
01361 class testGaitGeneratorHRP2JSK : public testGaitGenerator
01362 {
01363 public:
01364 testGaitGeneratorHRP2JSK () : testGaitGenerator(0.004)
01365 {
01366 cog = 1e-3*hrp::Vector3(6.785, 1.54359, 806.831);
01367 leg_pos.push_back(hrp::Vector3(0,1e-3*-105,0));
01368 leg_pos.push_back(hrp::Vector3(0,1e-3* 105,0));
01369 all_limbs.push_back("rleg");
01370 all_limbs.push_back("lleg");
01371 gg = new gait_generator(dt, leg_pos, all_limbs, 1e-3*150, 1e-3*50, 10, 1e-3*50, 1e-3*50*0.5, 10*0.5);
01372 };
01373 };
01374
01375 void print_usage ()
01376 {
01377 std::cerr << "Usage : testGaitGenerator [test-name] [option]" << std::endl;
01378 std::cerr << " [test-name] should be:" << std::endl;
01379 std::cerr << " --test0 : Set foot steps" << std::endl;
01380 std::cerr << " --test1 : Go pos x,y,th combination" << std::endl;
01381 std::cerr << " --test2 : Go pos x" << std::endl;
01382 std::cerr << " --test3 : Go pos y" << std::endl;
01383 std::cerr << " --test4 : Go pos th" << std::endl;
01384 std::cerr << " --test5 : Set foot steps with Z change" << std::endl;
01385 std::cerr << " --test6 : Go single step" << std::endl;
01386 std::cerr << " --test7 : Toe heel walk" << std::endl;
01387 std::cerr << " --test8 : Toe heel walk on slope" << std::endl;
01388 std::cerr << " --test9 : Stair walk" << std::endl;
01389 std::cerr << " --test10 : Stair walk + toe heel contact" << std::endl;
01390 std::cerr << " --test11 : Foot rot change" << std::endl;
01391 std::cerr << " --test12 : Change step param in set foot steps" << std::endl;
01392 std::cerr << " --test13 : Arbitrary leg switching" << std::endl;
01393 std::cerr << " --test14 : kick walk" << std::endl;
01394 std::cerr << " --test15 : Stair walk down" << std::endl;
01395 std::cerr << " --test16 : Set foot steps with param (toe heel contact)" << std::endl;
01396 std::cerr << " --test17 : Test goVelocity (dx = 0.1, dy = 0.05, dth = 10.0)" << std::endl;
01397 std::cerr << " --test18 : Test goVelocity with changing velocity (translation and rotation)" << std::endl;
01398 std::cerr << " --test19 : Change stride parameter (translate)" << std::endl;
01399 std::cerr << " --test20 : Change stride parameter (translate+rotate)" << std::endl;
01400 std::cerr << " [option] should be:" << std::endl;
01401 std::cerr << " --use-gnuplot : Use gnuplot and dump eps file to /tmp. (true/false, true by default)" << std::endl;
01402 std::cerr << " --use-graph-append : Append generated graph to /tmp/testGaitGenerator.jpg. (true/false, false by default)" << std::endl;
01403 std::cerr << " other options : for GaitGenerator" << std::endl;
01404 };
01405
01406 int main(int argc, char* argv[])
01407 {
01408 int ret = 0;
01409 if (argc >= 2) {
01410 testGaitGeneratorHRP2JSK tgg;
01411 for (int i = 1; i < argc; ++ i) {
01412 tgg.arg_strs.push_back(std::string(argv[i]));
01413 }
01414 if (std::string(argv[1]) == "--test0") {
01415 tgg.test0();
01416 } else if (std::string(argv[1]) == "--test1") {
01417 tgg.test1();
01418 } else if (std::string(argv[1]) == "--test2") {
01419 tgg.test2();
01420 } else if (std::string(argv[1]) == "--test3") {
01421 tgg.test3();
01422 } else if (std::string(argv[1]) == "--test4") {
01423 tgg.test4();
01424 } else if (std::string(argv[1]) == "--test5") {
01425 tgg.test5();
01426 } else if (std::string(argv[1]) == "--test6") {
01427 tgg.test6();
01428 } else if (std::string(argv[1]) == "--test7") {
01429 tgg.test7();
01430 } else if (std::string(argv[1]) == "--test8") {
01431 tgg.test8();
01432 } else if (std::string(argv[1]) == "--test9") {
01433 tgg.test9();
01434 } else if (std::string(argv[1]) == "--test10") {
01435 tgg.test10();
01436 } else if (std::string(argv[1]) == "--test11") {
01437 tgg.test11();
01438 } else if (std::string(argv[1]) == "--test12") {
01439 tgg.test12();
01440 } else if (std::string(argv[1]) == "--test13") {
01441 tgg.test13();
01442 } else if (std::string(argv[1]) == "--test14") {
01443 tgg.test14();
01444 } else if (std::string(argv[1]) == "--test15") {
01445 tgg.test15();
01446 } else if (std::string(argv[1]) == "--test16") {
01447 tgg.test16();
01448 } else if (std::string(argv[1]) == "--test17") {
01449 tgg.test17();
01450 } else if (std::string(argv[1]) == "--test18") {
01451 tgg.test18();
01452 } else if (std::string(argv[1]) == "--test19") {
01453 tgg.test19();
01454 } else if (std::string(argv[1]) == "--test20") {
01455 tgg.test20();
01456 } else {
01457 print_usage();
01458 ret = 1;
01459 }
01460 ret = (tgg.check_all_results()?0:2);
01461 } else {
01462 print_usage();
01463 ret = 1;
01464 }
01465 return ret;
01466 }
01467