1 #ifndef IMPEDANCETRGETGENERATOR_H 2 #define IMPEDANCETRGETGENERATOR_H 25 M_p(10), D_p(200), K_p(400), M_r(5), D_r(100), K_r(200),
47 const double _dt,
const bool printp =
false,
const std::string& print_str =
"",
const std::string& ee_name =
"")
50 std::cerr <<
"[" << print_str <<
"] impedance calc [" << ee_name <<
"] (Old version)" << std::endl;
51 std::cerr <<
"[" << print_str <<
"] cur1 = " << current_p1.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[m]" << std::endl;
52 std::cerr <<
"[" << print_str <<
"] out1 = " << output_p1.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[m]" << std::endl;
53 std::cerr <<
"[" << print_str <<
"] out2 = " << output_p2.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[m]" << std::endl;
54 std::cerr <<
"[" << print_str <<
"] tgt0 = " << target_p0.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[m]" << std::endl;
55 std::cerr <<
"[" << print_str <<
"] tgt1 = " << target_p1.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[m]" << std::endl;
58 hrp::Vector3 dif_output_pos, dif_target_pos, vel_target_pos, err_pos;
59 hrp::Vector3 dif_output_rot, dif_target_rot, vel_target_rot, err_rot;
72 std::cerr <<
"[" << print_str <<
"] dif_out_p = " << dif_output_pos.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[m]" << std::endl;
73 std::cerr <<
"[" << print_str <<
"] dif_tgt_p = " << dif_target_pos.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[m]" << std::endl;
74 std::cerr <<
"[" << print_str <<
"] vel_tgt_p = " << vel_target_pos.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[m]" << std::endl;
75 std::cerr <<
"[" << print_str <<
"] err_pos = " << err_pos.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[m]" << std::endl;
76 std::cerr <<
"[" << print_str <<
"] dif_out_r = " << dif_output_rot.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[rad]" << std::endl;
77 std::cerr <<
"[" << print_str <<
"] dif_tgt_r = " << dif_target_rot.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[rad]" << std::endl;
78 std::cerr <<
"[" << print_str <<
"] vel_tgt_r = " << vel_target_rot.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[rad]" << std::endl;
79 std::cerr <<
"[" << print_str <<
"] err_rot = " << err_rot.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[rad]" << std::endl;
81 vel_p = ( eeR * (force_gain * (eeR.transpose() * force_diff)) * _dt * _dt
82 + M_p * ( dif_output_pos + err_pos )
83 + D_p * ( dif_target_pos + err_pos ) * _dt
84 + K_p * ( vel_target_pos * _dt * _dt ) ) /
85 (M_p + (D_p * _dt) + (K_p * _dt * _dt));
86 vel_r = ( eeR * (moment_gain * (eeR.transpose() * moment_diff)) * _dt * _dt
87 + M_r * ( dif_output_rot + err_rot )
88 + D_r * ( dif_target_rot + err_rot ) * _dt
89 + K_r * ( vel_target_rot * _dt * _dt ) ) /
90 (M_r + (D_r * _dt) + (K_r * _dt * _dt));
93 std::cerr <<
"[" << print_str <<
"] vel_p = " << vel_p.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[m]" << std::endl;
94 std::cerr <<
"[" << print_str <<
"] vel_r = " << vel_r.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[rad]" << std::endl;
101 output_p1 = current_p1 + vel_p;
103 if ( vel_r.norm() != 0.0 ) {
105 Eigen::AngleAxis<double> tmpr(vel_r.norm(), vel_r.normalized());
118 const double _dt,
const bool printp =
false,
const std::string& print_str =
"",
const std::string& ee_name =
"")
121 std::cerr <<
"[" << print_str <<
"] impedance calc [" << ee_name <<
"] (New version)" << std::endl;
122 std::cerr <<
"[" << print_str <<
"] cur1 = " << current_p1.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[m]" << std::endl;
123 std::cerr <<
"[" << print_str <<
"] out1 = " << output_p1.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[m]" << std::endl;
124 std::cerr <<
"[" << print_str <<
"] out2 = " << output_p2.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[m]" << std::endl;
125 std::cerr <<
"[" << print_str <<
"] tgt0 = " << target_p0.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[m]" << std::endl;
126 std::cerr <<
"[" << print_str <<
"] tgt1 = " << target_p1.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[m]" << std::endl;
127 std::cerr <<
"[" << print_str <<
"] tgt2 = " << target_p2.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[m]" << std::endl;
129 hrp::Vector3 dif_pos1, dif_rot1, dif_pos2, dif_rot2, vel_target_pos, vel_target_rot;
136 vel_p = ( eeR * (force_gain * (eeR.transpose() * force_diff)) * _dt * _dt
137 + (2 * M_p + D_p * _dt) * dif_pos1
139 (M_p + (D_p * _dt) + (K_p * _dt * _dt))
141 vel_r = ( eeR * (moment_gain * (eeR.transpose() * moment_diff)) * _dt * _dt
142 + (2 * M_r + D_r * _dt) * dif_rot1
144 (M_r + (D_r * _dt) + (K_r * _dt * _dt))
148 std::cerr <<
"[" << print_str <<
"] vel_p = " << vel_p.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[m]" << std::endl;
149 std::cerr <<
"[" << print_str <<
"] vel_r = " << vel_r.format(Eigen::IOFormat(Eigen::StreamPrecision, 0,
", ",
", ",
"",
"",
"[",
"]")) <<
"[rad]" << std::endl;
156 output_p1 = current_p1 + vel_p;
158 if ( vel_r.norm() != 0.0 ) {
160 Eigen::AngleAxis<double> tmpr(vel_r.norm(), vel_r.normalized());
173 #endif // IMPEDANCETRGETGENERATOR_H
void calcTargetVelocityOrg(hrp::Vector3 &vel_p, hrp::Vector3 &vel_r, const hrp::Matrix33 &eeR, const hrp::Vector3 &force_diff, const hrp::Vector3 &moment_diff, const double _dt, const bool printp=false, const std::string &print_str="", const std::string &ee_name="")
void difference_rotation(hrp::Vector3 &ret_dif_rot, const hrp::Matrix33 &self_rot, const hrp::Matrix33 &target_rot)
const hrp::Vector3 & getOutputPos()
OpenHRP::matrix33 Matrix33
void resetPreviousTargetParam()
void resetPreviousCurrentParam()
hrp::Matrix33 moment_gain
void rotm3times(hrp::Matrix33 &m12, const hrp::Matrix33 &m1, const hrp::Matrix33 &m2)
ImpedanceOutputGenerator()
const hrp::Matrix33 & getOutputRot()
void calcTargetVelocity(hrp::Vector3 &vel_p, hrp::Vector3 &vel_r, const hrp::Matrix33 &eeR, const hrp::Vector3 &force_diff, const hrp::Vector3 &moment_diff, const double _dt, const bool printp=false, const std::string &print_str="", const std::string &ee_name="")