2 #ifndef GAITGENERATOR_H 3 #define GAITGENERATOR_H 5 #include "../ImpedanceController/RatsMatrix.h" 9 #include <boost/assign.hpp> 10 #include <boost/lambda/lambda.hpp> 11 #include <boost/shared_ptr.hpp> 13 #ifdef FOR_TESTGAITGENERATOR 14 #warning "Compile for testGaitGenerator" 15 #endif // FOR_TESTGAITGENERATOR 22 const double default_top_ratio = 0.5);
36 step_height(), step_time(),
37 toe_angle(), heel_angle(){};
39 const double _step_height,
const double _step_time,
40 const double _toe_angle,
const double _heel_angle)
41 : l_r(_l_r), worldcoords(_worldcoords),
42 step_height(_step_height), step_time(_step_time),
43 toe_angle(_toe_angle), heel_angle(_heel_angle) {};
45 const double _step_height,
const double _step_time,
46 const double _toe_angle,
const double _heel_angle)
47 : l_r((_l_r ==
"rleg") ?
RLEG :
48 (_l_r ==
"rarm") ?
RARM :
49 (_l_r ==
"larm") ?
LARM :
50 LLEG), worldcoords(_worldcoords),
51 step_height(_step_height), step_time(_step_time),
52 toe_angle(_toe_angle), heel_angle(_heel_angle) {};
55 os <<
"footstep" << std::endl;
56 os <<
" name = [" << ((sn.
l_r==
LLEG)?std::string(
"lleg"):
57 (sn.
l_r==
RARM)?std::string(
"rarm"):
58 (sn.
l_r==
LARM)?std::string(
"larm"):
59 std::string(
"rleg")) <<
"]" << std::endl;
61 os << (sn.
worldcoords.
pos).format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
" [",
"]")) << std::endl;
63 os << (sn.
worldcoords.
rot).format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
"",
" [",
"]")) << std::endl;
78 double stride_fwd_x, stride_outside_y, stride_outside_theta, stride_bwd_x, stride_inside_y, stride_inside_theta;
80 const double _stride_fwd_x,
const double _stride_outside_y,
const double _stride_outside_theta,
81 const double _stride_bwd_x,
const double _stride_inside_y,
const double _stride_inside_theta)
82 : leg_default_translate_pos(_leg_pos),
83 stride_fwd_x(_stride_fwd_x), stride_outside_y(_stride_outside_y), stride_outside_theta(_stride_outside_theta),
84 stride_bwd_x(_stride_bwd_x), stride_inside_y(_stride_inside_y), stride_inside_theta(_stride_inside_theta) {};
92 void set (
const double _vx,
const double _vy,
const double _vth)
96 velocity_theta = _vth;
99 :velocity_x(0), velocity_y(0), velocity_theta(0) {};
131 double ratio_sum = 0.0;
133 ratio_sum += toe_heel_phase_ratio[
i];
134 toe_heel_phase_count[
i] =
static_cast<size_t>(one_step_count * ratio_sum);
141 toe_heel_phase_ratio[
SOLE0] = 0.05;
142 toe_heel_phase_ratio[
SOLE2TOE] = 0.25;
143 toe_heel_phase_ratio[
TOE2SOLE] = 0.2;
144 toe_heel_phase_ratio[
SOLE1] = 0.0;
147 toe_heel_phase_ratio[
SOLE2] = 0.05;
157 double sum_ratio = 0.0;
159 if (std::fabs(sum_ratio-1.0) > 1e-3) {
163 std::cerr <<
"toe_heel_phase_ratio is not set, " 164 <<
", required length = " << NUM_TH_PHASES <<
" != input length " << ratio.size()
165 <<
", sum_ratio = " << sum_ratio <<
" is not 1.0." 168 std::cerr <<
"toe_heel_phase_ratio is successfully set." << std::endl;
175 one_step_count = _count;
176 calc_toe_heel_phase_count_from_raio();
180 if (check_toe_heel_phase_ratio_validity(ratio)) {
195 return (current_count == toe_heel_phase_count[_phase]);
199 return (toe_heel_phase_count[phase0] <= current_count) && (current_count < toe_heel_phase_count[phase1]);
203 return (current_count < toe_heel_phase_count[phase1]);
209 return _dt * (toe_heel_phase_count[goal_phase]-toe_heel_phase_count[start_phase]);
215 return static_cast<double>(current_count-toe_heel_phase_count[start_phase]) / (toe_heel_phase_count[goal_phase]-toe_heel_phase_count[start_phase]);
221 return static_cast<double>(current_count) / (toe_heel_phase_count[goal_phase]);
228 if (is_between_phases(current_count,
SOLE0)) {
230 return 1-calc_phase_ratio(current_count,
SOLE0);
231 }
else if (is_between_phases(current_count,
HEEL2SOLE,
SOLE2) || toe_heel_phase_count[
SOLE2] == current_count) {
250 toe_heel_type_checker (
const double _toe_check_thre,
const double _heel_check_thre) : toe_check_thre(_toe_check_thre), heel_check_thre(_heel_check_thre)
257 if (local_toe_pos(2) < -50*1e-3 && (local_toe_pos(0) + toe_check_thre < 0 || local_heel_pos(0) - heel_check_thre > 0) ) {
259 }
else if (local_toe_pos(0) + toe_check_thre < 0) {
261 }
else if (local_heel_pos(0) - heel_check_thre > 0) {
269 std::cerr <<
"[" << print_str <<
"] toe_check_thre = " << toe_check_thre <<
", heel_check_thre = " << heel_check_thre << std::endl;
300 void calc_current_refzmp (
hrp::Vector3& ret, std::vector<hrp::Vector3>& swing_foot_zmp_offsets,
const double default_double_support_ratio_before,
const double default_double_support_ratio_after,
const double default_double_support_static_ratio_before,
const double default_double_support_static_ratio_after);
309 : refzmp_cur_list(), foot_x_axises_list(), swing_leg_types_list(), step_count_list(), toe_heel_types_list(), default_zmp_offsets(),
310 refzmp_index(0), refzmp_count(0), one_step_count(0),
311 toe_zmp_offset_x(0), heel_zmp_offset_x(0), dt(_dt),
312 thp(), use_toe_heel_transition(false), use_toe_heel_auto_set(false)
314 default_zmp_offsets.push_back(hrp::Vector3::Zero());
315 default_zmp_offsets.push_back(hrp::Vector3::Zero());
316 default_zmp_offsets.push_back(hrp::Vector3::Zero());
317 default_zmp_offsets.push_back(hrp::Vector3::Zero());
318 double zmp_weight_initial_value[4] = {1.0, 1.0, 0.1, 0.1};
319 zmp_weight_map = boost::assign::map_list_of<leg_type, double>(
RLEG, zmp_weight_initial_value[0])(
LLEG, zmp_weight_initial_value[1])(
RARM, zmp_weight_initial_value[2])(
LARM, zmp_weight_initial_value[3]).convert_to_container< std::map<leg_type, double> > ();
321 zmp_weight_interpolator->set(zmp_weight_initial_value);
322 zmp_weight_interpolator->setName(
"GaitGenerator zmp_weight_interpolator");
329 while ( refzmp_cur_list.size() > len) refzmp_cur_list.pop_back();
330 while ( foot_x_axises_list.size() > len) foot_x_axises_list.pop_back();
331 while ( swing_leg_types_list.size() > len) swing_leg_types_list.pop_back();
332 while ( step_count_list.size() > len) step_count_list.pop_back();
333 while ( toe_heel_types_list.size() > len) toe_heel_types_list.pop_back();
335 void reset (
const size_t _refzmp_count)
338 one_step_count = _refzmp_count;
339 set_refzmp_count(_refzmp_count);
340 refzmp_cur_list.clear();
341 foot_x_axises_list.clear();
342 swing_leg_types_list.clear();
343 step_count_list.clear();
344 toe_heel_types_list.clear();
347 void push_refzmp_from_footstep_nodes_for_dual (
const std::vector<step_node>& fns,
348 const std::vector<step_node>& _support_leg_steps,
349 const std::vector<step_node>& _swing_leg_steps);
350 void push_refzmp_from_footstep_nodes_for_single (
const std::vector<step_node>& fns,
const std::vector<step_node>& _support_leg_steps,
const toe_heel_types& tht);
351 void update_refzmp ();
361 double zmp_weight_array[4] = {_map.find(
RLEG)->second, _map.find(
LLEG)->second, _map.find(
RARM)->second, _map.find(
LARM)->second};
362 if (zmp_weight_interpolator->isEmpty()) {
363 zmp_weight_interpolator->clear();
364 double zmp_weight_initial_value[4] = {zmp_weight_map[
RLEG], zmp_weight_map[
LLEG], zmp_weight_map[
RARM], zmp_weight_map[
LARM]};
365 zmp_weight_interpolator->set(zmp_weight_initial_value);
366 zmp_weight_interpolator->setGoal(zmp_weight_array, 2.0,
true);
368 std::cerr <<
"zmp_weight_map cannot be set because interpolating." << std::endl;
373 bool get_current_refzmp (
hrp::Vector3& rzmp, std::vector<hrp::Vector3>& swing_foot_zmp_offsets,
const double default_double_support_ratio_before,
const double default_double_support_ratio_after,
const double default_double_support_static_ratio_before,
const double default_double_support_static_ratio_after)
375 if (refzmp_cur_list.size() > refzmp_index ) calc_current_refzmp(rzmp, swing_foot_zmp_offsets, default_double_support_ratio_before, default_double_support_ratio_after, default_double_support_static_ratio_before, default_double_support_static_ratio_after);
376 return refzmp_cur_list.size() > refzmp_index;
386 if (!zmp_weight_interpolator->isEmpty()) {
387 double zmp_weight_output[4];
388 zmp_weight_interpolator->get(zmp_weight_output,
true);
389 zmp_weight_map = boost::assign::map_list_of<leg_type, double>(
RLEG, zmp_weight_output[0])(
LLEG, zmp_weight_output[1])(
RARM, zmp_weight_output[2])(
LARM, zmp_weight_output[3]).convert_to_container < std::map<leg_type, double> > ();
392 #ifdef FOR_TESTGAITGENERATOR 393 std::vector<hrp::Vector3> get_default_zmp_offsets()
const {
return default_zmp_offsets; };
394 #endif // FOR_TESTGAITGENERATOR 408 void hoffarbib_interpolation (
double& _pos,
double& _vel,
double& _acc,
const double tmp_remain_time,
const double tmp_goal,
const double tmp_goal_vel = 0,
const double tmp_goal_acc = 0)
410 double jerk = (-9.0/ tmp_remain_time) * (_acc - tmp_goal_acc / 3.0) +
411 (-36.0 / (tmp_remain_time * tmp_remain_time)) * (tmp_goal_vel * 2.0 / 3.0 + _vel) +
412 (60.0 / (tmp_remain_time * tmp_remain_time * tmp_remain_time)) * (tmp_goal - _pos);
413 _acc = _acc + dt * jerk;
414 _vel = _vel + dt * _acc;
415 _pos = _pos + dt * _vel;
421 size_t one_step_count, current_count, double_support_count_before, double_support_count_after;
424 delay_hoffarbib_trajectory_generator () : time_offset(0.35), final_distance_weight(1.0), time_offset_xy2z(0), one_step_count(0), current_count(0), double_support_count_before(0), double_support_count_after(0) {};
426 void set_dt (
const double _dt) { dt = _dt; };
430 void reset (
const size_t _one_step_len,
const double default_double_support_ratio_before,
const double default_double_support_ratio_after)
432 one_step_count = _one_step_len;
434 double_support_count_before = (default_double_support_ratio_before*one_step_count);
435 double_support_count_after = (default_double_support_ratio_after*one_step_count);
437 void reset_all (
const double _dt,
const size_t _one_step_len,
438 const double default_double_support_ratio_before,
const double default_double_support_ratio_after,
439 const double _time_offset,
const double _final_distance_weight,
const double _time_offset_xy2z)
442 reset (_one_step_len, default_double_support_ratio_before, default_double_support_ratio_after);
443 set_swing_trajectory_delay_time_offset(_time_offset);
444 set_swing_trajectory_final_distance_weight(_final_distance_weight);
445 set_swing_trajectory_time_offset_xy2z(_time_offset_xy2z);
449 if ( current_count <= double_support_count_before ) {
451 vel = hrp::Vector3::Zero();
452 acc = hrp::Vector3::Zero();
453 }
else if ( current_count >= one_step_count - double_support_count_after ) {
455 vel = hrp::Vector3::Zero();
456 acc = hrp::Vector3::Zero();
458 if ( double_support_count_before <= current_count && current_count < one_step_count - double_support_count_after ) {
459 size_t swing_remain_count = one_step_count - current_count - double_support_count_after;
460 size_t swing_one_step_count = one_step_count - double_support_count_before - double_support_count_after;
461 double final_path_distance_ratio = calc_antecedent_path(start, goal, height);
462 size_t tmp_time_offset_count = time_offset/dt;
464 size_t final_path_count = final_path_distance_ratio * swing_one_step_count;
465 if (final_path_count>static_cast<size_t>(time_offset_xy2z/dt)) final_path_count =
static_cast<size_t>(time_offset_xy2z/dt);
467 if (swing_remain_count > final_path_count+tmp_time_offset_count) {
468 hrp::Vector3 tmpgoal = interpolate_antecedent_path((swing_one_step_count - swing_remain_count) / static_cast<double>(swing_one_step_count - (final_path_count+tmp_time_offset_count)));
469 for (
size_t i = 0;
i < 2;
i++) hoffarbib_interpolation (
pos(
i), vel(
i), acc(
i), time_offset, tmpgoal(
i));
470 }
else if (swing_remain_count > final_path_count) {
471 double tmprt = (swing_remain_count-final_path_count)*dt;
472 for (
size_t i = 0;
i < 2;
i++) hoffarbib_interpolation (
pos(
i), vel(
i), acc(
i), tmprt, goal(
i));
474 for (
size_t i = 0;
i < 2;
i++)
pos(
i) = goal(
i);
477 if (swing_remain_count > tmp_time_offset_count) {
478 hrp::Vector3 tmpgoal = interpolate_antecedent_path((swing_one_step_count - swing_remain_count) / static_cast<double>(swing_one_step_count - tmp_time_offset_count));
479 hoffarbib_interpolation (
pos(2), vel(2), acc(2), time_offset, tmpgoal(2));
480 }
else if (swing_remain_count > 0) {
481 hoffarbib_interpolation (
pos(2), vel(2), acc(2), swing_remain_count*dt, goal(2));
498 total_path_length = 0;
500 distance_vec.clear();
501 point_vec.push_back(org_point_vec.front());
503 for (
size_t i = 0;
i < org_point_vec.size()-1;
i++) {
504 double tmp_distance = (org_point_vec[
i+1]-org_point_vec[
i]).
norm();
505 if (
i==org_point_vec.size()-2) tmp_distance*=final_distance_weight;
506 if ( tmp_distance > 1e-5 ) {
507 point_vec.push_back(org_point_vec[
i+1]);
508 distance_vec.push_back(tmp_distance);
509 total_path_length += tmp_distance;
512 if ( total_path_length < 1e-5 ) {
518 sum_distance_vec.clear();
519 sum_distance_vec.push_back(0);
521 for (
size_t i = 0;
i < distance_vec.size();
i++) {
522 sum_distance_vec.push_back(tmp_dist + distance_vec[
i]);
523 tmp_dist += distance_vec[i];
525 return distance_vec.back()/total_path_length;
529 if ( total_path_length < 1e-5 ) {
530 return point_vec.back();
533 double current_length = tmp_ratio * total_path_length;
534 for (
size_t i = 0;
i < sum_distance_vec.size();
i++) {
535 if ( (sum_distance_vec[
i] <= current_length) && (current_length <= sum_distance_vec[
i+1]) ) {
536 double tmpr = ((current_length - sum_distance_vec[
i]) / distance_vec[
i]);
537 return ((1-tmpr) * point_vec[i] + tmpr * point_vec[1+i]);
541 if (current_length < 0)
return point_vec.front();
542 else return point_vec.back();
550 std::vector<hrp::Vector3> rectangle_path;
551 double max_height =
std::max(start(2), goal(2))+height;
552 rectangle_path.push_back(start);
553 rectangle_path.push_back(
hrp::Vector3(start(0), start(1), max_height));
554 rectangle_path.push_back(
hrp::Vector3(goal(0), goal(1), max_height));
555 rectangle_path.push_back(goal);
556 return calc_antecedent_path_base(rectangle_path);
565 std::vector<hrp::Vector3>
path;
566 double max_height =
std::max(start(2), goal(2))+height;
569 path.push_back(start);
572 if ( diff_vec.norm() > 1e-4 && (goal(2) - start(2)) > 0.02) {
573 path.push_back(
hrp::Vector3(start+-1*way_point_offset(0)*diff_vec.normalized()+
hrp::Vector3(0,0,way_point_offset(2)+max_height-start(2))));
575 path.push_back(
hrp::Vector3(start(0), start(1), max_height));
576 path.push_back(
hrp::Vector3(goal(0), goal(1), max_height));
578 if ( diff_vec.norm() > 1e-4 && (start(2) - goal(2)) > 0.02) {
579 path.push_back(
hrp::Vector3(goal+way_point_offset(0)*diff_vec.normalized()+
hrp::Vector3(0,0,way_point_offset(2)+max_height-goal(2))));
584 path.push_back(goal);
585 return calc_antecedent_path_base(path);
598 std::vector<hrp::Vector3> cycloid_path;
601 via_goal(2) += ratio*height;
602 double tmpheight = ((start(2)+goal(2))/2.0+height-(start(2)+via_goal(2))/2.0);
603 cycloid_path.push_back(start);
605 cycloid_path.push_back(tmpv);
607 cycloid_path.push_back(tmpv);
609 cycloid_path.push_back(tmpv);
611 cycloid_path.push_back(tmpv);
612 cycloid_path.push_back(via_goal);
613 cycloid_path.push_back(goal);
614 return calc_antecedent_path_base(cycloid_path);
630 std::vector<hrp::Vector3> cycloid_path;
633 via_goal(2) += ratio*height;
634 double tmpheight = ((start(2)+goal(2))/2.0+height-(start(2)+via_goal(2))/2.0);
636 cycloid_path.push_back(start);
638 cycloid_path.push_back(start + start_rot * kick_point_offset);
639 cycloid_midpoint(tmpv, 0.2, start + start_rot * kick_point_offset, via_goal, tmpheight);
640 cycloid_path.push_back(tmpv);
641 cycloid_midpoint(tmpv, 0.4, start + start_rot * kick_point_offset, via_goal, tmpheight);
642 cycloid_path.push_back(tmpv);
643 cycloid_midpoint(tmpv, 0.6, start + start_rot * kick_point_offset, via_goal, tmpheight);
644 cycloid_path.push_back(tmpv);
645 cycloid_midpoint(tmpv, 0.8, start + start_rot * kick_point_offset, via_goal, tmpheight);
646 cycloid_path.push_back(tmpv);
648 cycloid_path.push_back(via_goal);
649 cycloid_path.push_back(goal);
650 return calc_antecedent_path_base(cycloid_path);
661 void set_swing_leg (
leg_type _lr) { swing_leg = _lr; };
665 std::vector<hrp::Vector3>
path;
666 double max_height =
std::max(start(2), goal(2))+height;
669 path.push_back(start);
670 if ( swing_leg ==
LLEG ) {
671 path.push_back(
hrp::Vector3(start+-1*way_point_offset(0)*diff_vec.normalized()+
hrp::Vector3(0,way_point_offset(1),way_point_offset(2)+max_height-start(2))));
672 path.push_back(
hrp::Vector3(goal+way_point_offset(0)*diff_vec.normalized()+
hrp::Vector3(0,way_point_offset(1),way_point_offset(2)+max_height-goal(2))));
674 path.push_back(
hrp::Vector3(start+-1*way_point_offset(0)*diff_vec.normalized()+
hrp::Vector3(0,-way_point_offset(1),way_point_offset(2)+max_height-start(2))));
675 path.push_back(
hrp::Vector3(goal+way_point_offset(0)*diff_vec.normalized()+
hrp::Vector3(0,-way_point_offset(1),way_point_offset(2)+max_height-goal(2))));
677 if (height > 30 * 1e-3) {
678 path.push_back(
hrp::Vector3(goal(0), goal(1), 30*1e-3+goal(2)));
680 path.push_back(goal);
681 return calc_antecedent_path_base(path);
696 double default_step_height, default_top_ratio, current_step_height,
swing_ratio, dt, current_toe_angle, current_heel_angle;
708 std::vector<rectangle_delay_hoffarbib_trajectory_generator>
rdtg;
710 std::vector<cycloid_delay_hoffarbib_trajectory_generator>
cdtg;
723 void calc_current_swing_foot_rot (std::map<leg_type, hrp::Vector3>& tmp_swing_foot_rot,
const double _default_double_support_ratio_before,
const double _default_double_support_ratio_after);
724 void calc_current_swing_leg_steps (std::vector<step_node>& rets,
const double step_height,
const double _current_toe_angle,
const double _current_heel_angle,
const double _default_double_support_ratio_before,
const double _default_double_support_ratio_after);
725 double calc_interpolated_toe_heel_angle (
const toe_heel_phase start_phase,
const toe_heel_phase goal_phase,
const double start,
const double goal);
726 void modif_foot_coords_for_toe_heel_phase (
coordinates& org_coords,
const double _current_toe_angle,
const double _current_heel_angle);
728 const coordinates& goal,
const double height)
const;
730 const coordinates& goal,
const double height,
const size_t swing_trajectory_generator_idx);
734 const coordinates& goal,
const double height,
const size_t swing_trajectory_generator_idx);
739 void calc_ratio_from_double_support_ratio (
const double default_double_support_ratio_before,
const double default_double_support_ratio_after);
740 void calc_swing_support_mid_coords ();
745 : support_leg_steps(), swing_leg_steps(), swing_leg_src_steps(), swing_leg_dst_steps(),
746 default_step_height(0.05), default_top_ratio(0.5), current_step_height(0.0), swing_ratio(0), dt(_dt),
747 current_toe_angle(0), current_heel_angle(0),
748 time_offset(0.35), final_distance_weight(1.0), time_offset_xy2z(0),
749 footstep_index(0), lcg_count(0), default_orbit_type(
CYCLOID),
752 foot_midcoords_interpolator(NULL), swing_foot_rot_interpolator(), toe_heel_interpolator(NULL),
753 toe_pos_offset_x(0.0), heel_pos_offset_x(0.0), toe_angle(0.0), heel_angle(0.0), foot_dif_rot_angle(0.0), toe_heel_dif_angle(0.0), use_toe_joint(false), use_toe_heel_auto_set(false),
754 current_src_toe_heel_type(
SOLE), current_dst_toe_heel_type(
SOLE)
756 support_leg_types.assign (1,
RLEG);
757 swing_leg_types.assign (1,
LLEG);
758 current_swing_time.assign (4, 0.0);
762 if (foot_midcoords_interpolator == NULL) foot_midcoords_interpolator =
new interpolator(6, dt);
763 std::vector<leg_type> tmp_leg_types = boost::assign::list_of<leg_type>(
RLEG)(
LLEG)(
RARM)(
LARM);
764 for (
size_t i = 0;
i < tmp_leg_types.size();
i++) {
765 if ( swing_foot_rot_interpolator.find(tmp_leg_types[
i]) == swing_foot_rot_interpolator.end() ) {
766 swing_foot_rot_interpolator.insert(std::pair<leg_type, interpolator*>(tmp_leg_types[i],
new interpolator(3, dt)));
767 swing_foot_rot_interpolator[tmp_leg_types[i]]->setName(
"GaitGenerator swing_foot_rot_interpolator " +
leg_type_to_leg_type_string(tmp_leg_types[i]));
772 if (toe_heel_interpolator == NULL) toe_heel_interpolator =
new interpolator(1, dt);
773 foot_midcoords_interpolator->
setName(
"GaitGenerator foot_midcoords_interpolator");
774 toe_heel_interpolator->
setName(
"GaitGenerator toe_heel_interpolator");
778 if (foot_midcoords_interpolator != NULL) {
779 delete foot_midcoords_interpolator;
780 foot_midcoords_interpolator = NULL;
782 for (std::map<leg_type, interpolator*>::iterator it = swing_foot_rot_interpolator.begin(); it != swing_foot_rot_interpolator.end(); it++) {
783 if (it->second != NULL) {
788 if (toe_heel_interpolator != NULL) {
789 delete toe_heel_interpolator;
790 toe_heel_interpolator = NULL;
801 time_offset = _time_offset;
808 final_distance_weight = _final_distance_weight;
815 time_offset_xy2z = _tmp;
827 std::vector<step_node> prev_support_leg_steps = support_leg_steps_list.front();
828 support_leg_steps_list.clear();
829 swing_leg_dst_steps_list.clear();
830 support_leg_steps_list.push_back(prev_support_leg_steps);
831 swing_leg_dst_steps_list = fnsl;
832 for (
size_t i = 0;
i < fnsl.size();
i++) {
834 if (is_same_footstep_nodes(fnsl.at(
i), fnsl.at(
i-1))) {
835 support_leg_steps_list.push_back(support_leg_steps_list.back());
838 std::vector<step_node> tmp_support_leg_steps = swing_leg_dst_steps_list.at(
i-1);
839 std::copy(support_leg_steps_list.back().begin(),
840 support_leg_steps_list.back().end(),
841 std::back_inserter(tmp_support_leg_steps));
842 for (
size_t j = 0;
j < swing_leg_dst_steps_list.at(
i).size();
j++) {
843 std::vector<step_node>::iterator it = std::remove_if(tmp_support_leg_steps.begin(),
844 tmp_support_leg_steps.end(),
845 (&boost::lambda::_1->* &
step_node::l_r == swing_leg_dst_steps_list.at(
i).at(
j).l_r));
846 tmp_support_leg_steps.erase(it, tmp_support_leg_steps.end());
848 support_leg_steps_list.push_back(tmp_support_leg_steps);
854 void reset(
const size_t _one_step_count,
const size_t _next_one_step_count,
855 const std::vector<step_node>& _swing_leg_dst_steps,
856 const std::vector<step_node>& _swing_leg_src_steps,
857 const std::vector<step_node>& _support_leg_steps,
858 const double default_double_support_ratio_before,
859 const double default_double_support_ratio_after)
861 support_leg_steps_list.clear();
862 swing_leg_dst_steps_list.clear();
864 swing_leg_dst_steps = _swing_leg_dst_steps;
865 swing_leg_src_steps = _swing_leg_src_steps;
866 support_leg_steps = _support_leg_steps;
867 support_leg_steps_list.push_back(support_leg_steps);
868 one_step_count = lcg_count = _one_step_count;
869 next_one_step_count = _next_one_step_count;
872 current_step_height = 0.0;
873 switch (default_orbit_type) {
876 for (
size_t i = 0;
i < swing_leg_dst_steps.size();
i++) {
878 rdtg.back().reset_all(dt, one_step_count,
879 default_double_support_ratio_before, default_double_support_ratio_after,
880 time_offset, final_distance_weight, time_offset_xy2z);
884 sdtg.
reset(one_step_count, default_double_support_ratio_before, default_double_support_ratio_after);
888 for (
size_t i = 0;
i < swing_leg_dst_steps.size();
i++) {
890 cdtg.back().reset_all(dt, one_step_count,
891 default_double_support_ratio_before, default_double_support_ratio_after,
892 time_offset, final_distance_weight, time_offset_xy2z);
896 cdktg.
reset(one_step_count, default_double_support_ratio_before, default_double_support_ratio_after);
899 crdtg.
reset(one_step_count, default_double_support_ratio_before, default_double_support_ratio_after);
904 current_src_toe_heel_type = current_dst_toe_heel_type =
SOLE;
908 for (std::map<leg_type, interpolator*>::iterator it = swing_foot_rot_interpolator.begin(); it != swing_foot_rot_interpolator.end(); it++) {
909 while (!it->second->isEmpty()) it->second->get(tmpsw,
true);
911 double tmpfm[foot_midcoords_interpolator->
dimension()];
912 while (!foot_midcoords_interpolator->
isEmpty()) {
913 foot_midcoords_interpolator->
get(tmpfm,
true);
916 while (!toe_heel_interpolator->
isEmpty()) {
917 toe_heel_interpolator->
get(&tmp,
true);
920 bool is_same_footstep_nodes(
const std::vector<step_node>& fns_1,
const std::vector<step_node>& fns_2)
const;
921 void update_leg_steps (
const std::vector< std::vector<step_node> >& fnsl,
const double default_double_support_ratio_before,
const double default_double_support_ratio_after,
const toe_heel_type_checker& thtc);
922 void calc_swing_leg_src_steps (std::vector<step_node>& ret_swing_leg_src_steps,
const std::vector< std::vector<step_node> >& fnsl,
const size_t _footstep_index)
924 if (_footstep_index > 0) {
925 if (is_same_footstep_nodes(fnsl[_footstep_index], fnsl[_footstep_index-1])) {
926 ret_swing_leg_src_steps = swing_leg_dst_steps_list[_footstep_index-1];
929 std::vector<step_node> tmp_swing_leg_src_steps = support_leg_steps_list[_footstep_index-1];
930 std::copy(swing_leg_dst_steps_list[_footstep_index-1].begin(),
931 swing_leg_dst_steps_list[_footstep_index-1].end(),
932 std::back_inserter(tmp_swing_leg_src_steps));
933 std::vector<step_node> tmp_support_leg_steps = support_leg_steps_list[_footstep_index];
934 for (
size_t i = 0;
i < tmp_support_leg_steps.size();
i++) {
935 std::vector<step_node>::iterator it = std::remove_if(tmp_swing_leg_src_steps.begin(), tmp_swing_leg_src_steps.end(), (&boost::lambda::_1->* &
step_node::l_r == tmp_support_leg_steps.at(
i).l_r));
936 tmp_swing_leg_src_steps.erase(it, tmp_swing_leg_src_steps.end());
938 ret_swing_leg_src_steps = tmp_swing_leg_src_steps;
945 size_t current_footstep_index = (footstep_index < fnsl.size() - 1 ? footstep_index : fnsl.size()-1);
946 swing_leg_dst_steps = fnsl[current_footstep_index];
947 if (footstep_index != 0) {
948 support_leg_steps = support_leg_steps_list[current_footstep_index];
950 support_leg_types.clear();
951 for (std::vector<step_node>::iterator it = support_leg_steps.begin(); it != support_leg_steps.end(); it++) {
952 support_leg_types.push_back(it->l_r);
954 swing_leg_types.clear();
955 for (std::vector<step_node>::iterator it = swing_leg_dst_steps.begin(); it != swing_leg_dst_steps.end(); it++) {
956 swing_leg_types.push_back(it->l_r);
958 calc_swing_leg_src_steps(swing_leg_src_steps, fnsl, current_footstep_index);
974 ret = swing_support_midcoords;
978 if ( is_swing_phase ) {
979 return get_support_leg_types();
981 std::vector<leg_type> tmp_sup_types = get_support_leg_types();
982 std::vector<leg_type> tmp_swg_types = get_swing_leg_types();
983 std::copy(tmp_swg_types.begin(), tmp_swg_types.end(), std::back_inserter(tmp_sup_types));
984 return tmp_sup_types;
1003 if (_use_toe_heel_transition && current_step_height > 0.0) {
1009 #ifdef FOR_TESTGAITGENERATOR 1010 size_t get_one_step_count()
const {
return one_step_count; };
1011 double get_toe_heel_dif_angle()
const {
return toe_heel_dif_angle; };
1012 #endif // FOR_TESTGAITGENERATOR 1059 double leg_margin[4], stride_limitation_for_circle_type[5], overwritable_stride_limitation[5], footstep_modification_gain, cp_check_margin[2], margin_time_ratio;
1070 const std::vector<leg_type>& lts)
1072 append_go_pos_step_nodes(_ref_coords, lts, footstep_nodes_list);
1076 const std::vector<leg_type>& lts,
1077 std::vector< std::vector<step_node> >& _footstep_nodes_list)
const 1079 std::vector<step_node> sns;
1080 for (
size_t i = 0;
i < lts.size();
i++) {
1081 sns.push_back(
step_node(lts.at(
i), _ref_coords,
1086 _footstep_nodes_list.push_back(sns);
1088 void overwrite_refzmp_queue(
const std::vector< std::vector<step_node> >& fnsl);
1090 void calc_next_coords_velocity_mode (std::vector< std::vector<step_node> >& ret_list,
const size_t idx,
const size_t future_step_num = 3);
1091 void append_footstep_list_velocity_mode ();
1092 void append_footstep_list_velocity_mode (std::vector< std::vector<step_node> >& _footstep_nodes_list,
const velocity_mode_parameter& cur_vel_param)
const;
1095 return std::find_if(leg_type_map.begin(), leg_type_map.end(), (&boost::lambda::_1->* &std::map<leg_type, std::string>::value_type::second == ee_name))->first;
1106 const std::vector<hrp::Vector3>& _leg_pos, std::vector<std::string> _all_limbs,
1107 const double _stride_fwd_x,
const double _stride_outside_y,
const double _stride_outside_theta,
1108 const double _stride_bwd_x,
const double _stride_inside_y,
const double _stride_inside_theta)
1109 : footstep_nodes_list(), overwrite_footstep_nodes_list(), rg(_dt), lcg(_dt),
1110 footstep_param(_leg_pos, _stride_fwd_x, _stride_outside_y, _stride_outside_theta, _stride_bwd_x, _stride_inside_y, _stride_inside_theta),
1112 dt(_dt), all_limbs(_all_limbs), default_step_time(1.0), default_double_support_ratio_before(0.1), default_double_support_ratio_after(0.1), default_double_support_static_ratio_before(0.0), default_double_support_static_ratio_after(0.0), default_double_support_ratio_swing_before(0.1), default_double_support_ratio_swing_after(0.1), gravitational_acceleration(
DEFAULT_GRAVITATIONAL_ACCELERATION),
1113 finalize_count(0), optional_go_pos_finalize_footstep_num(0), overwrite_footstep_index(0), overwritable_footstep_index_offset(1),
1114 velocity_mode_flg(VEL_IDLING), emergency_flg(IDLING), margin_time_ratio(0.01), footstep_modification_gain(5e-6),
1115 use_inside_step_limitation(true), use_stride_limitation(false), modify_footsteps(false), default_stride_limitation_type(
SQUARE),
1116 preview_controller_ptr(NULL) {
1117 swing_foot_zmp_offsets.assign (1, hrp::Vector3::Zero());
1118 prev_que_sfzos.assign (1, hrp::Vector3::Zero());
1119 leg_type_map = boost::assign::map_list_of<leg_type, std::string>(
RLEG,
"rleg")(
LLEG,
"lleg")(
RARM,
"rarm")(
LARM,
"larm").convert_to_container < std::map<leg_type, std::string> > ();
1120 for (
size_t i = 0;
i < 4;
i++) leg_margin[
i] = 0.1;
1121 for (
size_t i = 0;
i < 5;
i++) stride_limitation_for_circle_type[
i] = 0.2;
1122 for (
size_t i = 0;
i < 5;
i++) overwritable_stride_limitation[
i] = 0.2;
1123 for (
size_t i = 0;
i < 2;
i++) is_emergency_walking[
i] =
false;
1124 for (
size_t i = 0;
i < 2;
i++) cp_check_margin[
i] = 0.025;
1127 if ( preview_controller_ptr != NULL ) {
1128 delete preview_controller_ptr;
1129 preview_controller_ptr = NULL;
1132 void initialize_gait_parameter (
const hrp::Vector3& cog,
1133 const std::vector<step_node>& initial_support_leg_steps,
1134 const std::vector<step_node>& initial_swing_leg_dst_steps,
1135 const double delay = 1.6);
1136 bool proc_one_tick ();
1137 void limit_stride (
step_node& cur_fs,
const step_node& prev_fs,
const double (&limit)[5])
const;
1138 void modify_footsteps_for_recovery ();
1141 std::vector<step_node> tmp_sns;
1142 for (
size_t i = 0;
i < _legs.size();
i++) {
1145 footstep_nodes_list.push_back(tmp_sns);
1147 void append_footstep_nodes (
const std::vector<std::string>& _legs,
const std::vector<coordinates>& _fss,
const double _step_height,
const double _step_time,
const double _toe_angle,
const double _heel_angle)
1149 std::vector<step_node> tmp_sns;
1150 for (
size_t i = 0;
i < _legs.size();
i++) {
1151 tmp_sns.push_back(
step_node(_legs[
i], _fss[i], _step_height, _step_time, _toe_angle, _heel_angle));
1153 footstep_nodes_list.push_back(tmp_sns);
1156 footstep_nodes_list.clear();
1157 overwrite_footstep_nodes_list.clear();
1158 overwrite_footstep_index = 0;
1161 const std::vector<coordinates>& initial_support_legs_coords,
coordinates start_ref_coords,
1162 const std::vector<leg_type>& initial_support_legs,
1163 const bool is_initialize =
true) {
1164 std::vector< std::vector<step_node> > new_footstep_nodes_list;
1165 return go_pos_param_2_footstep_nodes_list (goal_x, goal_y, goal_theta,
1166 initial_support_legs_coords, start_ref_coords,
1167 initial_support_legs,
1168 new_footstep_nodes_list,
1171 bool go_pos_param_2_footstep_nodes_list (
const double goal_x,
const double goal_y,
const double goal_theta,
1172 const std::vector<coordinates>& initial_support_legs_coords,
coordinates start_ref_coords,
1173 const std::vector<leg_type>& initial_support_legs,
1174 std::vector< std::vector<step_node> >& new_footstep_nodes_list,
1175 const bool is_initialize =
true);
1176 void go_pos_param_2_footstep_nodes_list_core (
const double goal_x,
const double goal_y,
const double goal_theta,
1177 const std::vector<coordinates>& initial_support_legs_coords,
coordinates start_ref_coords,
1178 const std::vector<leg_type>& initial_support_legs,
1179 std::vector< std::vector<step_node> >& new_footstep_nodes_list,
1180 const bool is_initialize,
const size_t overwritable_fs_index)
const;
1181 void go_single_step_param_2_footstep_nodes_list (
const double goal_x,
const double goal_y,
const double goal_z,
const double goal_theta,
1182 const std::string& tmp_swing_leg,
1184 void initialize_velocity_mode (
const coordinates& _ref_coords,
1185 const double vel_x,
const double vel_y,
const double vel_theta,
1186 const std::vector<leg_type>& current_legs);
1187 void finalize_velocity_mode ();
1190 append_finalize_footstep(footstep_nodes_list);
1194 std::vector<step_node> sns = _footstep_nodes_list[_footstep_nodes_list.size()-2];
1195 for (
size_t i = 0;
i < sns.size();
i++) {
1196 sns.at(
i).step_height = sns.at(
i).toe_angle = sns.at(
i).heel_angle = 0.0;
1198 _footstep_nodes_list.push_back(sns);
1202 if (!footstep_nodes_list.empty()) {
1203 velocity_mode_flg = VEL_IDLING;
1204 emergency_flg = EMERGENCY_STOP;
1225 vel_param.
set(vel_x, vel_y, vel_theta);
1229 offset_vel_param.
set(vel_x, vel_y, vel_theta);
1231 void set_stride_parameters (
const double _stride_fwd_x,
const double _stride_outside_y,
const double _stride_outside_theta,
1232 const double _stride_bwd_x,
const double _stride_inside_y,
const double _stride_inside_theta)
1257 return lcgret && rgret;
1262 void set_all_limbs (
const std::vector<std::string>& _all_limbs) { all_limbs = _all_limbs; };
1266 clear_footstep_nodes_list();
1267 footstep_nodes_list = fnsl;
1268 append_finalize_footstep();
1269 print_footstep_nodes_list();
1273 overwrite_footstep_nodes_list.clear();
1274 overwrite_footstep_nodes_list = fnsl;
1275 append_finalize_footstep(overwrite_footstep_nodes_list);
1276 print_footstep_nodes_list(overwrite_footstep_nodes_list);
1279 for (
size_t i = 0;
i < 4;
i++) {
1280 leg_margin[
i] = _leg_margin[
i];
1284 for (
size_t i = 0;
i < 5;
i++) {
1285 stride_limitation_for_circle_type[
i] = _stride_limitation_for_circle_type[
i];
1289 for (
size_t i = 0;
i < 5;
i++) {
1290 overwritable_stride_limitation[
i] = _overwritable_stride_limitation[
i];
1295 for (
size_t i=0;
i < 2;
i++) {
1296 cp_check_margin[
i] = _cp_check_margin[
i];
1300 if (act_contact_states.empty()) act_contact_states.resize(_act_contact_states.size());
1301 for (
size_t i = 0;
i < act_contact_states.size();
i++) {
1302 act_contact_states[
i] = _act_contact_states[
i];
1319 if (idx >= get_overwritable_index()) {
1320 overwrite_footstep_index = idx;
1328 if (footstep_nodes_list.size()-1 >= idx) {
1329 csl = footstep_nodes_list.at(idx);
1337 for (
size_t i = 0;
i < _footstep_nodes_list.size();
i++) {
1338 for (
size_t j = 0;
j < _footstep_nodes_list.at(
i).size();
j++) {
1339 std::cerr <<
"[" <<
i <<
"] " << _footstep_nodes_list.at(
i).at(
j) << std::endl;
1345 print_footstep_nodes_list(footstep_nodes_list);
1350 double refcog_vel[3];
1352 return hrp::Vector3(refcog_vel[0], refcog_vel[1], refcog_vel[2]);
1355 double refcog_acc[3];
1357 return hrp::Vector3(refcog_acc[0], refcog_acc[1], refcog_acc[2]);
1367 std::vector<std::string>
ret;
1368 for (std::vector<leg_type>::const_iterator it = lts.begin(); it != lts.end(); it++) {
1369 ret.push_back(leg_type_map.find(*it)->second);
1375 std::vector<hrp::Vector3>
ret;
1384 leg_type lt = get_leg_type_from_ee_name(ee_name);
1405 std::vector<leg_type> lts;
1406 for (
size_t i = 0;
i < footstep_nodes_list[0].size();
i++) {
1407 lts.push_back(footstep_nodes_list[0].at(
i).l_r);
1409 return convert_leg_types_to_names(lts);
1412 std::vector<leg_type> lts;
1413 for (
size_t i = 0;
i < footstep_nodes_list.back().size();
i++) {
1414 lts.push_back(footstep_nodes_list.back().at(
i).l_r);
1416 return convert_leg_types_to_names(lts);
1432 double& _stride_bwd_x,
double& _stride_inside_y,
double& _stride_inside_theta)
const 1447 return get_current_swing_time( get_leg_type_from_ee_name(ee_name) );
1460 std::vector< std::vector<step_node> > fsnl;
1463 for (
size_t i = 0;
i < fsl_size;
i++) {
1487 leg_type lt = get_leg_type_from_ee_name(ee_name);
1491 ret = get_current_toe_heel_ratio();
1499 const std::vector<leg_type> calc_counter_leg_types_from_footstep_nodes (
const std::vector<step_node>& fns, std::vector<std::string> _all_limbs)
const;
1502 bool is_finalizing (
const double tm)
const {
return ((preview_controller_ptr->
get_delay()*2 - default_step_time/dt)-finalize_count) <= (tm/dt)-1; };
1518 leg_type lt = get_leg_type_from_ee_name(ee_name);
1535 leg_type lt = get_leg_type_from_ee_name(ee_name);
1537 return std::find(tmp.begin(), tmp.end(), lt) != tmp.end();
1539 #ifdef FOR_TESTGAITGENERATOR 1540 size_t get_one_step_count()
const {
return lcg.get_one_step_count(); };
1541 void get_footstep_nodes_list (std::vector< std::vector<step_node> > & fsl)
const 1543 fsl = footstep_nodes_list;
1545 double get_toe_heel_dif_angle ()
const {
return lcg.get_toe_heel_dif_angle(); };
1546 std::vector<hrp::Vector3> get_default_zmp_offsets()
const {
return rg.get_default_zmp_offsets(); };
1547 #endif // FOR_TESTGAITGENERATOR 1550 double stride_fwd_x, stride_outside_y, stride_outside_th, stride_bwd_x, stride_inside_y, stride_inside_th;
1551 get_stride_parameters(stride_fwd_x, stride_outside_y, stride_outside_th, stride_bwd_x, stride_inside_y, stride_inside_th);
1552 std::cerr <<
"[" << print_str <<
"] stride_parameter = " << stride_fwd_x <<
"[m], " << stride_outside_y <<
"[m], " << stride_outside_th <<
"[deg], " 1553 << stride_bwd_x <<
"[m], " << stride_inside_y <<
"[m], " << stride_inside_th <<
"[deg]" << std::endl;
1554 std::cerr <<
"[" << print_str <<
"] leg_default_translate_pos = ";
1556 std::cerr << footstep_param.
leg_default_translate_pos[
i].format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
" [",
"]"));
1558 std::cerr << std::endl;
1559 std::cerr <<
"[" << print_str <<
"] default_step_time = " << get_default_step_time() <<
"[s]" << std::endl;
1560 std::cerr <<
"[" << print_str <<
"] default_step_height = " << get_default_step_height() <<
"[m]" << std::endl;
1561 std::cerr <<
"[" << print_str <<
"] default_double_support_ratio_before = " << get_default_double_support_ratio_before() <<
", default_double_support_ratio_before = " << get_default_double_support_ratio_after() <<
", default_double_support_static_ratio_before = " << get_default_double_support_static_ratio_before() <<
", default_double_support_static_ratio_after = " << get_default_double_support_static_ratio_after() <<
", default_double_support_static_ratio_swing_before = " << get_default_double_support_ratio_swing_before() <<
", default_double_support_static_ratio_swing_after = " << get_default_double_support_ratio_swing_after() << std::endl;
1562 std::cerr <<
"[" << print_str <<
"] default_orbit_type = ";
1563 if (get_default_orbit_type() ==
SHUFFLING) {
1564 std::cerr <<
"SHUFFLING" << std::endl;
1565 }
else if (get_default_orbit_type() ==
CYCLOID) {
1566 std::cerr <<
"CYCLOID" << std::endl;
1567 }
else if (get_default_orbit_type() ==
RECTANGLE) {
1568 std::cerr <<
"RECTANGLE" << std::endl;
1569 }
else if (get_default_orbit_type() ==
STAIR) {
1570 std::cerr <<
"STAIR" << std::endl;
1572 std::cerr <<
"CYCLOIDDELAY" << std::endl;
1574 std::cerr <<
"CYCLOIDDELAYKICK" << std::endl;
1575 }
else if (get_default_orbit_type() == CROSS) {
1576 std::cerr <<
"CROSS" << std::endl;
1578 std::cerr <<
"[" << print_str <<
"] swing_trajectory_delay_time_offset = " << get_swing_trajectory_delay_time_offset() <<
"[s], swing_trajectory_final_distance_weight = " << get_swing_trajectory_final_distance_weight()
1579 <<
", swing_trajectory_time_offset_xy2z = " << get_swing_trajectory_time_offset_xy2z() << std::endl;
1581 tmpv = get_stair_trajectory_way_point_offset();
1582 std::cerr <<
"[" << print_str <<
"] stair_trajectory_way_point_offset = " << tmpv.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
" [",
"]")) <<
"[m]" << std::endl;
1583 tmpv = get_cycloid_delay_kick_point_offset();
1584 std::cerr <<
"[" << print_str <<
"] cycloid_delay_kick_point_offset = " << tmpv.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
" [",
"]")) <<
"[m]" << std::endl;
1585 std::cerr <<
"[" << print_str <<
"] gravitational_acceleration = " << get_gravitational_acceleration() <<
"[m/s^2]" << std::endl;
1586 std::cerr <<
"[" << print_str <<
"] toe_pos_offset_x = " << get_toe_pos_offset_x() <<
"[mm], heel_pos_offset_x = " << get_heel_pos_offset_x() <<
"[mm]" << std::endl;
1587 std::cerr <<
"[" << print_str <<
"] toe_zmp_offset_x = " << get_toe_zmp_offset_x() <<
"[mm], heel_zmp_offset_x = " << get_heel_zmp_offset_x() <<
"[mm]" << std::endl;
1588 std::cerr <<
"[" << print_str <<
"] toe_angle = " << get_toe_angle() <<
"[deg]" << std::endl;
1589 std::cerr <<
"[" << print_str <<
"] heel_angle = " << get_heel_angle() <<
"[deg]" << std::endl;
1590 std::cerr <<
"[" << print_str <<
"] use_toe_joint = " << (get_use_toe_joint()?
"true":
"false") <<
", use_toe_heel_transition = " << (get_use_toe_heel_transition()?
"true":
"false") <<
", use_toe_heel_auto_set = " << (get_use_toe_heel_auto_set()?
"true":
"false") << std::endl;
1591 std::vector<double> tmp_ratio(get_NUM_TH_PHASES(), 0.0);
1592 get_toe_heel_phase_ratio(tmp_ratio);
1593 std::cerr <<
"[" << print_str <<
"] toe_heel_phase_ratio = [";
1594 for (
int i = 0;
i < get_NUM_TH_PHASES();
i++) std::cerr << tmp_ratio[
i] <<
" ";
1595 std::cerr <<
"]" << std::endl;
1596 std::cerr <<
"[" << print_str <<
"] optional_go_pos_finalize_footstep_num = " << optional_go_pos_finalize_footstep_num <<
", overwritable_footstep_index_offset = " << overwritable_footstep_index_offset << std::endl;
1597 std::cerr <<
"[" << print_str <<
"] default_stride_limitation_type = ";
1598 if (default_stride_limitation_type ==
SQUARE) {
1599 std::cerr <<
"SQUARE" << std::endl;
1600 }
else if (default_stride_limitation_type == CIRCLE) {
1601 std::cerr <<
"CIRCLE" << std::endl;
orbit_type get_default_orbit_type() const
void set_overwrite_foot_steps_list(const std::vector< std::vector< step_node > > &fnsl)
const hrp::Vector3 & get_refzmp() const
friend std::ostream & operator<<(std::ostream &os, const step_node &sn)
double get_gravitational_acceleration() const
bool go_pos_param_2_footstep_nodes_list(const double goal_x, const double goal_y, const double goal_theta, const std::vector< coordinates > &initial_support_legs_coords, coordinates start_ref_coords, const std::vector< leg_type > &initial_support_legs, const bool is_initialize=true)
footstep_parameter footstep_param
const std::vector< hrp::Vector3 > & get_swing_foot_zmp_offsets() const
delay_hoffarbib_trajectory_generator()
void set_swing_trajectory_final_distance_weight(const double _final_distance_weight)
void set_gravitational_acceleration(const double ga)
double get_default_step_time() const
void set_swing_trajectory_delay_time_offset(const double _time_offset)
bool get_current_support_state_from_ee_name(const std::string &ee_name) const
bool get_swing_support_foot_zmp_offsets_from_ee_name(hrp::Vector3 &ret, const std::string &ee_name) const
velocity_mode_parameter()
void set_toe_angle(const double _angle)
void set_default_double_support_ratio_swing_before(const double _default_double_support_ratio_swing_before)
std::map< leg_type, std::string > leg_type_map
size_t get_optional_go_pos_finalize_footstep_num() const
void set_default_double_support_static_ratio_after(const double _default_double_support_static_ratio_after)
void hoffarbib_interpolation(double &_pos, double &_vel, double &_acc, const double tmp_remain_time, const double tmp_goal, const double tmp_goal_vel=0, const double tmp_goal_acc=0)
void append_finalize_footstep(std::vector< std::vector< step_node > > &_footstep_nodes_list) const
const std::map< leg_type, double > get_zmp_weight_map() const
void set_stride_limitation_for_circle_type(const double(&_stride_limitation_for_circle_type)[5])
void set_toe_check_thre(const double _a)
void set_all_limbs(const std::vector< std::string > &_all_limbs)
toe_heel_type_checker(const double _toe_check_thre, const double _heel_check_thre)
void set_use_stride_limitation(const bool _use_stride_limitation)
void set_swing_trajectory_delay_time_offset(const double _time_offset)
double calc_phase_ratio(const size_t current_count, const toe_heel_phase start_phase, const toe_heel_phase goal_phase) const
void calc_swing_support_params_from_footstep_nodes_list(const std::vector< std::vector< step_node > > &fnsl)
void set_heel_angle(const double _angle)
const bool is_second_phase() const
double get_swing_trajectory_time_offset_xy2z() const
static const double DEFAULT_GRAVITATIONAL_ACCELERATION
void multi_mid_coords(coordinates &ret, const std::vector< coordinates > &cs, const double eps)
bool use_inside_step_limitation
hrp::Vector3 get_stair_trajectory_way_point_offset() const
std::vector< hrp::Vector3 > swing_foot_zmp_offsets
bool check_toe_heel_phase_ratio_validity(const std::vector< double > &ratio)
double calc_antecedent_path(const hrp::Vector3 &start, const hrp::Vector3 &goal, const double height)
const hrp::Vector3 & get_refzmp_cur() const
stride_limitation_type default_stride_limitation_type
void set_refzmp_count(const size_t _refzmp_count)
void set_default_step_height(const double _tmp)
bool get_use_toe_heel_transition() const
hrp::Vector3 kick_point_offset
void set_use_toe_heel_auto_set(const bool ut)
void set_overwritable_stride_limitation(const double(&_overwritable_stride_limitation)[5])
preview_dynamics_filter< extended_preview_control > * preview_controller_ptr
void print_param(const std::string print_str="") const
double get_current_toe_heel_ratio() const
void reset_all(const double _dt, const size_t _one_step_len, const double default_double_support_ratio_before, const double default_double_support_ratio_after, const double _time_offset, const double _final_distance_weight, const double _time_offset_xy2z)
double get_heel_pos_offset_x() const
stair_delay_hoffarbib_trajectory_generator()
bool is_between_phases(const size_t current_count, const toe_heel_phase phase0, const toe_heel_phase phase1) const
size_t overwrite_footstep_index
void set_swing_trajectory_final_distance_weight(const double _final_distance_weight)
void set_one_step_count(const size_t _count)
const hrp::Vector3 & get_default_zmp_offset(const leg_type lt) const
bool get_modify_footsteps() const
void clear_interpolators()
double calc_phase_ratio(const size_t current_count, const toe_heel_phase goal_phase) const
void set_zmp_weight_map(const std::map< leg_type, double > _map)
void clear_footstep_nodes_list()
coordinates initial_foot_mid_coords
void set_dt(const double _dt)
void set_toe_pos_offset_x(const double _offx)
std::vector< std::vector< step_node > > footstep_nodes_list
void get_cart_zmp(double *ret)
const bool is_second_last_phase() const
void append_go_pos_step_nodes(const coordinates &_ref_coords, const std::vector< leg_type > <s, std::vector< std::vector< step_node > > &_footstep_nodes_list) const
const std::vector< step_node > & get_support_leg_steps() const
void setName(const std::string &_name)
void reset(const size_t _one_step_len, const double default_double_support_ratio_before, const double default_double_support_ratio_after)
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
void set_default_double_support_ratio_swing_after(const double _default_double_support_ratio_swing_after)
std::string leg_type_to_leg_type_string(const leg_type l_r)
void get_leg_default_translate_pos(std::vector< hrp::Vector3 > &off) const
cycloid_delay_kick_hoffarbib_trajectory_generator cdktg
void reset(const size_t _refzmp_count)
void set_swing_trajectory_time_offset_xy2z(const double _tmp)
hrp::Vector3 interpolate_antecedent_path(const double tmp_ratio) const
void set_optional_go_pos_finalize_footstep_num(const size_t num)
hrp::Vector3 get_cycloid_delay_kick_point_offset() const
std::vector< size_t > step_count_list
interpolator * foot_midcoords_interpolator
void set_heel_zmp_offset_x(const double _off)
void set_offset_velocity_param(const double vel_x, const double vel_y, const double vel_theta)
void get_swing_support_mid_coords(coordinates &ret) const
const std::vector< std::string > get_support_leg_names() const
double get_default_double_support_static_ratio_after() const
const coordinates get_dst_foot_midcoords() const
bool get_use_stride_limitation() const
void set_diff_cp(const hrp::Vector3 _cp)
hrp::Vector3 way_point_offset
cross_delay_hoffarbib_trajectory_generator crdtg
hrp::Vector3 get_cycloid_delay_kick_point_offset() const
std::vector< std::string > convert_leg_types_to_names(const std::vector< leg_type > <s) const
void set_use_toe_heel_transition(const bool _u)
const std::vector< step_node > & get_swing_leg_steps() const
size_t get_lcg_count() const
void set_overwritable_footstep_index_offset(const size_t _of)
size_t overwritable_footstep_index_offset
gait_generator(double _dt, const std::vector< hrp::Vector3 > &_leg_pos, std::vector< std::string > _all_limbs, const double _stride_fwd_x, const double _stride_outside_y, const double _stride_outside_theta, const double _stride_bwd_x, const double _stride_inside_y, const double _stride_inside_theta)
toe_heel_type current_src_toe_heel_type
hrp::Vector3 way_point_offset
toe_heel_type_checker thtc
double calc_antecedent_path(const hrp::Vector3 &start, const hrp::Vector3 &goal, const double height)
std::vector< double > current_swing_time
png_infop png_bytep * trans
double get_heel_check_thre() const
bool is_no_SOLE1_phase() const
static double no_using_toe_heel_ratio
size_t get_overwrite_check_timing() const
bool set_toe_heel_phase_ratio(const std::vector< double > &ratio)
double get_toe_pos_offset_x() const
void set_stair_trajectory_way_point_offset(const hrp::Vector3 _offset)
void append_footstep_nodes(const std::vector< std::string > &_legs, const std::vector< coordinates > &_fss, const double _step_height, const double _step_time, const double _toe_angle, const double _heel_angle)
double get_overwritable_stride_limitation(const size_t idx) const
void set_modify_footsteps(const bool _modify_footsteps)
hrp::Vector3 get_cog_vel() const
hrp::Vector3 get_stair_trajectory_way_point_offset() const
bool use_stride_limitation
double calc_antecedent_path_base(const std::vector< hrp::Vector3 > org_point_vec)
void set_default_zmp_offsets(const std::vector< hrp::Vector3 > &tmp)
void set_use_toe_joint(const bool ut)
void set_cycloid_delay_kick_point_offset(const hrp::Vector3 _offset)
double get_stride_limitation_for_circle_type(const size_t idx) const
~delay_hoffarbib_trajectory_generator()
bool set_toe_heel_phase_ratio(const std::vector< double > &ratio)
void set_default_double_support_ratio_before(const double _default_double_support_ratio_before)
void set_leg_margin(const double _leg_margin[4])
std::vector< double > distance_vec
double get_heel_angle() const
std::vector< toe_heel_types > toe_heel_types_list
void set_start_rot(const hrp::Matrix33 _offset)
void append_footstep_nodes(const std::vector< std::string > &_legs, const std::vector< coordinates > &_fss)
double get_default_double_support_static_ratio_before() const
std::vector< hrp::Vector3 > get_support_foot_zmp_offsets() const
void set_use_toe_heel_auto_set(const bool _u)
const bool is_start_double_support_phase() const
bool set_toe_heel_phase_ratio(const std::vector< double > &ratio)
const std::vector< step_node > & get_support_leg_steps() const
bool is_phase_starting(const size_t current_count, const toe_heel_phase _phase) const
bool calc_toe_heel_phase_count_from_raio()
velocity_mode_parameter vel_param
leg_type get_leg_type_from_ee_name(const std::string &ee_name) const
toe_heel_phase_counter thp
double get_default_step_height() const
std::vector< leg_type > get_current_support_states() const
bool is_finalizing(const double tm) const
void append_go_pos_step_nodes(const coordinates &_ref_coords, const std::vector< leg_type > <s)
~stair_delay_hoffarbib_trajectory_generator()
void set_swing_trajectory_final_distance_weight(const double _final_distance_weight)
bool get_footstep_nodes_by_index(std::vector< step_node > &csl, const size_t idx) const
double get_heel_pos_offset_x() const
double calc_phase_period(const toe_heel_phase start_phase, const toe_heel_phase goal_phase, const double _dt) const
double get_current_swing_time(const size_t idx) const
void print_footstep_nodes_list() const
std::vector< leg_type > swing_leg_types
void set_default_zmp_offsets(const std::vector< hrp::Vector3 > &tmp)
void get_toe_heel_phase_ratio(std::vector< double > &ratio) const
const std::map< leg_type, double > get_zmp_weight_map() const
void set_stair_trajectory_way_point_offset(const hrp::Vector3 _offset)
bool set_overwrite_foot_step_index(const size_t idx)
def j(str, encoding="cp932")
void set_act_contact_states(const std::vector< bool > &_act_contact_states)
void set_default_step_height(const double _tmp)
coordinates swing_support_midcoords
double get_toe_zmp_offset_x() const
void set_indices(const size_t idx)
const std::vector< std::string > get_swing_leg_names() const
double get_current_swing_time(const size_t idx) const
std::vector< hrp::Vector3 > refzmp_cur_list
double get_foot_dif_rot_angle() const
bool get_current_toe_heel_ratio_from_ee_name(double &ret, const std::string &ee_name) const
refzmp_generator(const double _dt)
void set_heel_pos_offset_x(const double _offx)
void set_cycloid_delay_kick_point_offset(const hrp::Vector3 _offset)
void set_toe_pos_offset_x(const double _offx)
std::map< leg_type, interpolator * > swing_foot_rot_interpolator
void set_use_inside_step_limitation(const bool uu)
void set_stride_parameters(const double _stride_fwd_x, const double _stride_outside_y, const double _stride_outside_theta, const double _stride_bwd_x, const double _stride_inside_y, const double _stride_inside_theta)
const std::map< leg_type, std::string > get_leg_type_map() const
void set_default_top_ratio(const double _tmp)
void set_toe_zmp_offset_x(const double _off)
void set_default_orbit_type(const orbit_type _tmp)
std::vector< leg_type > get_current_support_states() const
double get_heel_zmp_offset_x() const
stair_delay_hoffarbib_trajectory_generator sdtg
double get_margin_time_ratio() const
void proc_zmp_weight_map_interpolation()
void set_default_double_support_ratio_after(const double _default_double_support_ratio_after)
void append_finalize_footstep()
void set_velocity_param(const double vel_x, const double vel_y, const double vel_theta)
std::vector< step_node > support_leg_steps
void proc_zmp_weight_map_interpolation()
void set_footstep_modification_gain(const double _footstep_modification_gain)
void set_cp_check_margin(const double(&_cp_check_margin)[2])
double get_toe_check_thre() const
std::vector< std::vector< step_node > > overwrite_footstep_nodes_list
cycloid_delay_kick_hoffarbib_trajectory_generator()
double final_distance_weight
void remove_refzmp_cur_list_over_length(const size_t len)
void set_heel_check_thre(const double _heel_check_thre)
std::vector< std::string > all_limbs
void get_toe_heel_phase_ratio(std::vector< double > &ratio) const
double default_double_support_ratio_swing_before
double get_default_double_support_ratio_swing_before() const
const bool is_end_double_support_phase() const
std::vector< std::vector< hrp::Vector3 > > foot_x_axises_list
const hrp::Vector3 & get_cog() const
void set_stride_limitation_type(const stride_limitation_type _tmp)
std::vector< bool > act_contact_states
toe_heel_types(const toe_heel_type _src_type=SOLE, const toe_heel_type _dst_type=SOLE)
void set_default_orbit_type(const orbit_type type)
void get_refcog_vel(double *ret)
void set_default_step_time(const double _default_step_time)
static double using_toe_heel_ratio
bool get_use_toe_joint() const
void set_use_toe_heel_auto_set(const bool _u)
void set_toe_check_thre(const double _toe_check_thre)
orbit_type get_default_orbit_type() const
std::vector< std::string > get_footstep_front_leg_names() const
void set_swing_trajectory_time_offset_xy2z(const double _tmp)
~cross_delay_hoffarbib_trajectory_generator()
void set_swing_support_steps_list(const std::vector< std::vector< step_node > > &fnsl)
std::vector< hrp::Vector3 > default_zmp_offsets
double calc_phase_ratio_for_toe_heel_transition(const size_t current_count) const
velocity_mode_flag velocity_mode_flg
double get_toe_angle() const
double get_default_double_support_ratio_swing_after() const
void set_leg_default_translate_pos(const std::vector< hrp::Vector3 > &off)
std::vector< rectangle_delay_hoffarbib_trajectory_generator > rdtg
bool use_toe_heel_transition
double get_current_toe_heel_ratio(const bool _use_toe_heel_transition) const
std::vector< std::string > get_footstep_back_leg_names() const
bool get_use_toe_heel_transition() const
bool get_use_toe_heel_auto_set() const
const std::vector< step_node > & get_swing_leg_dst_steps() const
bool get_use_toe_joint() const
double get_swing_trajectory_final_distance_weight() const
void calc_swing_leg_src_steps(std::vector< step_node > &ret_swing_leg_src_steps, const std::vector< std::vector< step_node > > &fnsl, const size_t _footstep_index)
double calc_antecedent_path(const hrp::Vector3 &start, const hrp::Vector3 &goal, const double height)
const std::vector< step_node > & get_swing_leg_steps() const
void cycloid_midpoint(hrp::Vector3 &ret, const double ratio, const hrp::Vector3 &start, const hrp::Vector3 &goal, const double height, const double default_top_ratio)
void set_swing_trajectory_time_offset_xy2z(const double _tmp)
std::vector< hrp::Vector3 > point_vec
size_t get_overwritable_index() const
void print_footstep_nodes_list(const std::vector< std::vector< step_node > > _footstep_nodes_list) const
double get_swing_trajectory_delay_time_offset() const
double get_footstep_modification_gain() const
void get_refcog_acc(double *ret)
bool get_use_toe_heel_auto_set() const
double get_current_swing_time_from_ee_name(const std::string ee_name) const
void set_zmp_weight_map(const std::map< leg_type, double > _map)
std::vector< double > sum_distance_vec
double calc_antecedent_path(const hrp::Vector3 &start, const hrp::Vector3 &goal, const double height)
void get(double *x_, bool popp=true)
interpolator * toe_heel_interpolator
void set_heel_check_thre(const double _a)
const std::vector< step_node > & get_swing_leg_dst_steps_idx(const size_t idx) const
void set_heel_angle(const double _angle)
void get_trajectory_point(hrp::Vector3 &ret, const hrp::Vector3 &start, const hrp::Vector3 &goal, const double height)
const std::vector< step_node > & get_support_leg_steps_idx(const size_t idx) const
bool get_swing_support_ee_coords_from_ee_name(hrp::Vector3 &cpos, hrp::Matrix33 &crot, const std::string &ee_name) const
bool is_between_phases(const size_t current_count, const toe_heel_phase phase1) const
void set_stair_trajectory_way_point_offset(const hrp::Vector3 _offset)
boost::shared_ptr< interpolator > zmp_weight_interpolator
double get_leg_margin(const size_t idx) const
void set_toe_zmp_offset_x(const double _off)
double set_value_according_to_toe_heel_type(const toe_heel_type tht, const double toe_value, const double heel_value, const double default_value)
double get_swing_trajectory_time_offset_xy2z() const
double gravitational_acceleration
double get_heel_check_thre() const
void get_stride_parameters(double &_stride_fwd_x, double &_stride_outside_y, double &_stride_outside_theta, double &_stride_bwd_x, double &_stride_inside_y, double &_stride_inside_theta) const
double get_swing_trajectory_final_distance_weight() const
void set_margin_time_ratio(const double _margin_time_ratio)
hrp::Vector3 modified_d_footstep
void get_swing_support_mid_coords(coordinates &ret) const
double get_default_double_support_ratio_after() const
stride_limitation_type get_stride_limitation_type() const
const std::vector< step_node > & get_swing_leg_src_steps() const
leg_coords_generator(const double _dt)
double get_heel_angle() const
bool get_current_refzmp(hrp::Vector3 &rzmp, std::vector< hrp::Vector3 > &swing_foot_zmp_offsets, const double default_double_support_ratio_before, const double default_double_support_ratio_after, const double default_double_support_static_ratio_before, const double default_double_support_static_ratio_after)
double default_double_support_static_ratio_before
double get_foot_dif_rot_angle() const
hrp::Vector3 get_cycloid_delay_kick_point_offset() const
size_t get_footstep_index() const
void print_param(const std::string &print_str="") const
toe_heel_phase_counter thp
const std::vector< step_node > & get_swing_leg_dst_steps() const
double get_toe_angle() const
orbit_type default_orbit_type
double get_default_step_height() const
const std::vector< leg_type > & get_swing_leg_types() const
void set_swing_trajectory_delay_time_offset(const double _time_offset)
void set_toe_angle(const double _angle)
size_t optional_go_pos_finalize_footstep_num
void set_foot_steps_list(const std::vector< std::vector< step_node > > &fnsl)
void set_use_toe_joint(const bool ut)
void set_heel_zmp_offset_x(const double _off)
double get_swing_trajectory_final_distance_weight() const
double get_toe_pos_offset_x() const
const std::vector< leg_type > & get_support_leg_types() const
double get_default_double_support_ratio_before() const
double get_cp_check_margin(const size_t idx) const
hrp::Vector3 get_cart_zmp() const
hrp::Vector3 get_cog_acc() const
double calc_antecedent_path(const hrp::Vector3 &start, const hrp::Vector3 &goal, const double height)
cross_delay_hoffarbib_trajectory_generator()
bool get_use_toe_heel_auto_set() const
std::vector< std::vector< step_node > > swing_leg_dst_steps_list
toe_heel_type check_toe_heel_type_from_swing_support_coords(const coordinates &swing_coords, const coordinates &support_coords, const double toe_pos_offset_x, const double heel_pos_offset_x) const
double get_swing_trajectory_time_offset_xy2z() const
emergency_flag emergency_flg
size_t get_footstep_index() const
void set_use_toe_heel_transition(const bool _u)
double get_swing_trajectory_delay_time_offset() const
double get_swing_trajectory_delay_time_offset() const
double default_double_support_ratio_swing_after
step_node(const std::string &_l_r, const coordinates &_worldcoords, const double _step_height, const double _step_time, const double _toe_angle, const double _heel_angle)
hrp::Vector3 get_stair_trajectory_way_point_offset() const
std::vector< cycloid_delay_hoffarbib_trajectory_generator > cdtg
std::map< leg_type, double > zmp_weight_map
void set_cycloid_delay_kick_point_offset(const hrp::Vector3 _offset)
double get_toe_check_thre() const
void set_default_double_support_static_ratio_before(const double _default_double_support_static_ratio_before)
std::vector< std::vector< leg_type > > swing_leg_types_list
double get_heel_zmp_offset_x() const
size_t get_overwritable_footstep_index_offset() const
std::vector< step_node > swing_leg_steps
step_node(const leg_type _l_r, const coordinates &_worldcoords, const double _step_height, const double _step_time, const double _toe_angle, const double _heel_angle)
void mid_coords(coordinates &mid_coords, const double p, const coordinates &c1, const coordinates &c2, const double eps)
void reset(const size_t _one_step_count, const size_t _next_one_step_count, const std::vector< step_node > &_swing_leg_dst_steps, const std::vector< step_node > &_swing_leg_src_steps, const std::vector< step_node > &_support_leg_steps, const double default_double_support_ratio_before, const double default_double_support_ratio_after)
size_t get_lcg_count() const
std::vector< std::vector< step_node > > get_remaining_footstep_nodes_list() const
int get_NUM_TH_PHASES() const
void set_default_top_ratio(const double _tmp)
double get_toe_zmp_offset_x() const
const std::vector< step_node > & get_swing_leg_src_steps() const
bool set_toe_heel_phase_ratio(const std::vector< double > &ratio)
void set_heel_pos_offset_x(const double _offx)
void get_toe_heel_phase_ratio(std::vector< double > &ratio) const
void set(const double _vx, const double _vy, const double _vth)