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 impedance codes2 #441

Merged
merged 2 commits into from
Jan 5, 2015
Merged
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
16 changes: 13 additions & 3 deletions rtc/ImpedanceController/ImpedanceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,13 @@ RTC::ReturnCode_t ImpedanceController::onExecute(RTC::UniqueId ec_id)
// std::cerr << "ref_moment = " << param.ref_moment[0] << " " << param.ref_moment[1] << " " << param.ref_moment[2] << std::endl;

// ref_force/ref_moment and force_gain/moment_gain are expressed in global coordinates.
vel_p = ( param.force_gain * (abs_forces[it->first] - abs_ref_forces[it->first]) * m_dt * m_dt
hrp::Matrix33 eeR = target->R * ee_map[target->name].localR;
vel_p = ( eeR * (param.force_gain * (eeR.transpose() * (abs_forces[it->first] - abs_ref_forces[it->first]))) * m_dt * m_dt
+ param.M_p * ( vel_pos1 - vel_pos0 )
+ param.D_p * ( dif_target_pos - vel_pos0 ) * m_dt
+ param.K_p * ( dif_pos * m_dt * m_dt ) ) /
(param.M_p + (param.D_p * m_dt) + (param.K_p * m_dt * m_dt));
vel_r = ( param.moment_gain * (abs_moments[it->first] - abs_ref_moments[it->first]) * m_dt * m_dt
vel_r = ( eeR * (param.moment_gain * (eeR.transpose() * (abs_moments[it->first] - abs_ref_moments[it->first]))) * m_dt * m_dt
+ param.M_r * ( vel_rot1 - vel_rot0 )
+ param.D_r * ( dif_target_rot - vel_rot0 ) * m_dt
+ param.K_r * ( dif_rot * m_dt * m_dt ) ) /
Expand All @@ -449,7 +450,6 @@ RTC::ReturnCode_t ImpedanceController::onExecute(RTC::UniqueId ec_id)
std::cerr << "[" << m_profile.instance_name << "] vel_p = " << vel_p.format(Eigen::IOFormat(Eigen::StreamPrecision, 0, ", ", ", ", "", "", "[", "]")) << "[m]" << std::endl;
std::cerr << "[" << m_profile.instance_name << "] vel_r = " << vel_r.format(Eigen::IOFormat(Eigen::StreamPrecision, 0, ", ", ", ", "", "", "[", "]")) << "[rad]" << std::endl;
}
manip->calcInverseKinematics2Loop(vel_p, vel_r, 1.0, param.avoid_gain, param.reference_gain, &qrefv);

param.current_p2 = param.current_p1;
param.current_r2 = param.current_r1;
Expand All @@ -468,6 +468,16 @@ RTC::ReturnCode_t ImpedanceController::onExecute(RTC::UniqueId ec_id)
param.target_p1 = param.target_p0;
param.target_r1 = param.target_r0;

// Solve ik
// Fix ee frame objective vel => link frame objective vel
hrp::Vector3 link_frame_pos;
hrp::Matrix33 link_frame_rot;
link_frame_rot = param.current_r1 * ee_map[target->name].localR.transpose();
link_frame_pos = param.current_p1 - link_frame_rot * ee_map[target->name].localPos;
vel_p = link_frame_pos - target->p;
rats::difference_rotation(vel_r, target->R, link_frame_rot);
manip->calcInverseKinematics2Loop(vel_p, vel_r, 1.0, param.avoid_gain, param.reference_gain, &qrefv);

if ( param.transition_count < 0 ) {
param.transition_count++;
}
Expand Down