45 const std::vector<kdl_kinematics_plugin::JointMimic>& mimic_joints,
46 bool position_ik,
double threshold)
47 : mimic_joints_(mimic_joints)
48 , num_mimic_joints_(countMimicJoints(mimic_joints))
53 , svd_(position_ik ? 3 : 6, chain_.getNrOfJoints() - num_mimic_joints_, Eigen::ComputeThinU | Eigen::ComputeThinV)
54 , jac_(chain_.getNrOfJoints())
55 , jac_reduced_(svd_.cols())
57 assert(mimic_joints_.size() == chain.getNrOfJoints());
59 for (
const auto& item : mimic_joints)
60 assert(item.map_index < chain_.getNrOfJoints());
62 svd_.setThreshold(threshold);
73bool ChainIkSolverVelMimicSVD::jacToJacReduced(
const Jacobian& jac, Jacobian& jac_reduced)
88 const Eigen::VectorXd& joint_weights,
89 const Eigen::Matrix<double, 6, 1>& cartesian_weights)
92 if (num_mimic_joints_ > 0)
94 jnt2jac_.JntToJac(q_in, jac_);
96 jacToJacReduced(jac_, jac_reduced_);
99 jnt2jac_.JntToJac(q_in, jac_reduced_);
102 auto& jac = jac_reduced_.data;
103 const Eigen::Index rows = svd_.rows();
104 jac.topRows(rows) *= joint_weights.asDiagonal();
105 jac.topRows(rows).transpose() *= cartesian_weights.topRows(rows).asDiagonal();
108 Eigen::Matrix<double, 6, 1> vin;
109 vin.topRows<3>() = Eigen::Map<const Eigen::Array3d>(v_in.vel.data, 3) * cartesian_weights.topRows<3>().array();
110 vin.bottomRows<3>() = Eigen::Map<const Eigen::Array3d>(v_in.rot.data, 3) * cartesian_weights.bottomRows<3>().array();
113 svd_.compute(jac.topRows(rows));
115 if (num_mimic_joints_ > 0)
117 qdot_out_reduced_.noalias() = svd_.solve(vin.topRows(rows));
118 qdot_out_reduced_.array() *= joint_weights.array();
119 for (
unsigned int i = 0; i < chain_.getNrOfJoints(); ++i)
120 qdot_out(i) = qdot_out_reduced_[mimic_joints_[i].map_index] * mimic_joints_[i].multiplier;
124 qdot_out.data.noalias() = svd_.solve(vin.topRows(rows));
125 qdot_out.data.array() *= joint_weights.array();