Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gg step_count_list access bug. #1159

Merged
merged 2 commits into from
Jun 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions rtc/AutoBalancer/GaitGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,19 @@ namespace rats
}
};

void refzmp_generator::update_refzmp (const std::vector< std::vector<step_node> >& fnsl)
void refzmp_generator::update_refzmp ()
{
if ( 1 <= refzmp_count ) {
refzmp_count--;
} else {
refzmp_index++;
refzmp_count = one_step_count = step_count_list[refzmp_index];
thp.set_one_step_count(one_step_count);
// Check length of step_count_list and refzmp_index
// The case if !(refzmp_index <= step_count_list.size()-1) is finalizing of gait_generator.
// If finalizing, this can be neglected.
if (refzmp_index <= step_count_list.size()-1) {
refzmp_count = one_step_count = step_count_list[refzmp_index];
thp.set_one_step_count(one_step_count);
}
//std::cerr << "fs " << fs_index << "/" << fnl.size() << " rf " << refzmp_index << "/" << refzmp_cur_list.size() << " flg " << std::endl;
}
};
Expand Down Expand Up @@ -720,7 +725,7 @@ namespace rats
solved = preview_controller_ptr->update(refzmp, cog, swing_foot_zmp_offsets, rzmp, sfzos, (refzmp_exist_p || finalize_count < preview_controller_ptr->get_delay()-default_step_time/dt));
}

rg.update_refzmp(footstep_nodes_list);
rg.update_refzmp();
// { // debug
// double cart_zmp[3];
// preview_controller_ptr->get_cart_zmp(cart_zmp);
Expand Down Expand Up @@ -1118,12 +1123,12 @@ namespace rats
for (size_t i = overwrite_idx; i < queue_size - 1; i++) {
refzmp_exist_p = rg.get_current_refzmp(rzmp, sfzos, default_double_support_ratio_before, default_double_support_ratio_after, default_double_support_static_ratio_before, default_double_support_static_ratio_after);
preview_controller_ptr->set_preview_queue(rzmp, sfzos, i+1);
rg.update_refzmp(footstep_nodes_list);
rg.update_refzmp();
sfzos.clear();
}
refzmp_exist_p = rg.get_current_refzmp(rzmp, sfzos, default_double_support_ratio_before, default_double_support_ratio_after, default_double_support_static_ratio_before, default_double_support_static_ratio_after);
solved = preview_controller_ptr->update(refzmp, cog, swing_foot_zmp_offsets, rzmp, sfzos, refzmp_exist_p);
rg.update_refzmp(footstep_nodes_list);
rg.update_refzmp();
};

const std::vector<leg_type> gait_generator::calc_counter_leg_types_from_footstep_nodes(const std::vector<step_node>& fns, std::vector<std::string> _all_limbs) const {
Expand Down
2 changes: 1 addition & 1 deletion rtc/AutoBalancer/GaitGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ namespace rats
const std::vector<step_node>& _support_leg_steps,
const std::vector<step_node>& _swing_leg_steps);
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);
void update_refzmp (const std::vector< std::vector<step_node> >& fnsl);
void update_refzmp ();
// setter
void set_indices (const size_t idx) { refzmp_index = idx; };
void set_refzmp_count(const size_t _refzmp_count) { refzmp_count = _refzmp_count; };
Expand Down