57 inline Eigen::MatrixXf
59 const Eigen::Ref<const Eigen::VectorXf>& jointLimitsLow,
60 const Eigen::Ref<const Eigen::VectorXf>& jointLimitsHigh,
61 Eigen::VectorXf& jointAngleLimitGradient)
66 Eigen::VectorXf weights(nbJoints);
67 Eigen::VectorXf gradient = Eigen::VectorXf::Zero(nbJoints);
69 if (jointAngleLimitGradient.rows() == 0)
71 jointAngleLimitGradient = Eigen::VectorXf::Zero(nbJoints);
74 for (
int i = 0; i < nbJoints; i++)
76 if ((jointLimitsLow(i) == 0 && jointLimitsHigh(i) == 0) || jointLimitsHigh(i) > 1e8)
83 gradient(i) = std::pow(jointLimitsHigh(i) - jointLimitsLow(i), 2) *
84 (2 *
jointAngles(i) - jointLimitsHigh(i) - jointLimitsLow(i)) /
85 (4 * std::pow(jointLimitsHigh(i) -
jointAngles(i), 2) *
100 jointAngleLimitGradient = gradient;
101 return weights.asDiagonal();