24 #include <VirtualRobot/Robot.h>
53 inline Eigen::MatrixXf
55 const Eigen::Ref<const Eigen::VectorXf>& jointLimitsLow,
56 const Eigen::Ref<const Eigen::VectorXf>& jointLimitsHigh,
57 Eigen::VectorXf& jointAngleLimitGradient)
62 Eigen::VectorXf weights(nbJoints);
63 Eigen::VectorXf gradient = Eigen::VectorXf::Zero(nbJoints);
65 if (jointAngleLimitGradient.rows() == 0)
67 jointAngleLimitGradient = Eigen::VectorXf::Zero(nbJoints);
70 for (
int i = 0; i < nbJoints; i++)
72 if ((jointLimitsLow(i) == 0 && jointLimitsHigh(i) == 0) || jointLimitsHigh(i) > 1e8)
79 gradient(i) = std::pow(jointLimitsHigh(i) - jointLimitsLow(i), 2) *
80 (2 *
jointAngles(i) - jointLimitsHigh(i) - jointLimitsLow(i)) /
81 (4 * std::pow(jointLimitsHigh(i) -
jointAngles(i), 2) *
96 jointAngleLimitGradient = gradient;
97 return weights.asDiagonal();