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 2 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 sync_to_air_max_time;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

細かいことだけど、 sync_to_air_max_time は変数名として分かりにくくないかな?
説明文は書いてあって、読めば分かる(し思い出す)とは思うけど、変数名から機能の推測がしにくそうです。
説明文の中にある単語を組み合わせるくらいが良くない? (air と timeは入ってるけど、 detectionは欲しいところ)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コメントありがとうございます
そうですね,かなり微妙な感じです
コミット前にこちらでご意見伺いたいのですが,
detection_time_to_air
detection_counter_to_air
current_detection_counter_to_air
などで分かりやすいでしょうか?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1
detection_time_to_air

};

/**
Expand Down
9 changes: 8 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
sync_to_air_max_counter = 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;
sync_to_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 (sync_to_air_counter < sync_to_air_max_counter) ++sync_to_air_counter;
else control_mode = MODE_SYNC_TO_AIR;
} else sync_to_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.sync_to_air_max_time = sync_to_air_max_counter * 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];
}
sync_to_air_max_counter = static_cast<int>(i_stp.sync_to_air_max_time / 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
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 sync_to_air_counter, sync_to_air_max_counter;
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