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

[Stabilizer] Set detection time whether robot is in air #1090

Merged
merged 3 commits into from
Mar 13, 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
2 changes: 2 additions & 0 deletions idl/StabilizerService.idl
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ module OpenHRP
DblArray2 limb_stretch_avoidance_vlimit;
/// Sequence of limb length margin from max limb length [m]
sequence<double> limb_length_margin;
/// Detection time whether is in air [s]
double detection_time_to_air;
};

/**
Expand Down
10 changes: 9 additions & 1 deletion rtc/Stabilizer/Stabilizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ RTC::ReturnCode_t Stabilizer::onInitialize()
limb_stretch_avoidance_time_const = 1.5;
limb_stretch_avoidance_vlimit[0] = -100 * 1e-3 * dt; // lower limit
limb_stretch_avoidance_vlimit[1] = 50 * 1e-3 * dt; // upper limit
detection_count_to_air = static_cast<int>(0.0 / dt);

// parameters for RUNST
double ke = 0, tc = 0;
Expand Down Expand Up @@ -431,6 +432,7 @@ RTC::ReturnCode_t Stabilizer::onInitialize()
transition_count = 0;
loop = 0;
m_is_falling_counter = 0;
is_air_counter = 0;
total_mass = m_robot->totalMass();
ref_zmp_aux = hrp::Vector3::Zero();
m_actContactStates.data.length(m_contactStates.data.length());
Expand Down Expand Up @@ -617,7 +619,10 @@ RTC::ReturnCode_t Stabilizer::onExecute(RTC::UniqueId ec_id)
} else {
calcTPCC();
}
if ( transition_count == 0 && !on_ground ) control_mode = MODE_SYNC_TO_AIR;
if ( transition_count == 0 && !on_ground ) {
if (is_air_counter < detection_count_to_air) ++is_air_counter;
else control_mode = MODE_SYNC_TO_AIR;
} else is_air_counter = 0;
break;
case MODE_SYNC_TO_IDLE:
sync_2_idle();
Expand Down Expand Up @@ -1913,6 +1918,7 @@ void Stabilizer::getParameter(OpenHRP::StabilizerService::stParam& i_stp)
i_stp.use_limb_stretch_avoidance = use_limb_stretch_avoidance;
i_stp.limb_stretch_avoidance_time_const = limb_stretch_avoidance_time_const;
i_stp.limb_length_margin.length(stikp.size());
i_stp.detection_time_to_air = detection_count_to_air * dt;
for (size_t i = 0; i < 2; i++) {
i_stp.limb_stretch_avoidance_vlimit[i] = limb_stretch_avoidance_vlimit[i];
}
Expand Down Expand Up @@ -2089,6 +2095,7 @@ void Stabilizer::setParameter(const OpenHRP::StabilizerService::stParam& i_stp)
for (size_t i = 0; i < 2; i++) {
limb_stretch_avoidance_vlimit[i] = i_stp.limb_stretch_avoidance_vlimit[i];
}
detection_count_to_air = static_cast<int>(i_stp.detection_time_to_air / dt);
if (control_mode == MODE_IDLE) {
for (size_t i = 0; i < i_stp.end_effector_list.length(); i++) {
std::vector<STIKParam>::iterator it = std::find_if(stikp.begin(), stikp.end(), (&boost::lambda::_1->* &std::vector<STIKParam>::value_type::ee_name == std::string(i_stp.end_effector_list[i].leg)));
Expand Down Expand Up @@ -2168,6 +2175,7 @@ void Stabilizer::setParameter(const OpenHRP::StabilizerService::stParam& i_stp)
std::cerr << "[" << m_profile.instance_name << "] cp_check_margin = [" << cp_check_margin[0] << ", " << cp_check_margin[1] << ", " << cp_check_margin[2] << ", " << cp_check_margin[3] << "] [m]" << std::endl;
std::cerr << "[" << m_profile.instance_name << "] tilt_margin = [" << tilt_margin[0] << ", " << tilt_margin[1] << "] [rad]" << std::endl;
std::cerr << "[" << m_profile.instance_name << "] contact_decision_threshold = " << contact_decision_threshold << "[N]" << std::endl;
std::cerr << "[" << m_profile.instance_name << "] detection_time_to_air = " << detection_count_to_air * dt << "[s]" << std::endl;
// IK limb parameters
std::cerr << "[" << m_profile.instance_name << "] IK limb parameters" << std::endl;
bool is_ik_limb_parameter_valid_length = true;
Expand Down
1 change: 1 addition & 0 deletions rtc/Stabilizer/Stabilizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ class Stabilizer
int transition_count, loop;
int m_is_falling_counter;
std::vector<int> m_will_fall_counter;
int is_air_counter, detection_count_to_air;
bool is_legged_robot, on_ground, is_emergency, is_seq_interpolating, reset_emergency_flag, eefm_use_force_difference_control, eefm_use_swing_damping, initial_cp_too_large_error, use_limb_stretch_avoidance;
bool is_walking, is_estop_while_walking;
hrp::Vector3 current_root_p, target_root_p;
Expand Down