38 #include <Eigen/Dense>
39 #include <Eigen/Eigenvalues>
40 #include <boost/math/constants/constants.hpp>
49 double joint_limits_multiplier(1.0);
50 const std::vector<const moveit::core::JointModel*>& joint_model_vector = joint_model_group->
getJointModels();
63 if (bounds[0].min_position_ == -std::numeric_limits<double>::max() ||
64 bounds[0].max_position_ == std::numeric_limits<double>::max() ||
65 bounds[1].min_position_ == -std::numeric_limits<double>::max() ||
66 bounds[1].max_position_ == std::numeric_limits<double>::max() ||
67 bounds[2].min_position_ == -boost::math::constants::pi<double>() ||
68 bounds[2].max_position_ == boost::math::constants::pi<double>())
78 std::vector<double> lower_bounds, upper_bounds;
81 lower_bounds.push_back(
bound.min_position_);
82 upper_bounds.push_back(
bound.max_position_);
84 double lower_bound_distance = joint_model->distance(joint_values, &lower_bounds[0]);
85 double upper_bound_distance = joint_model->distance(joint_values, &upper_bounds[0]);
86 double range = lower_bound_distance + upper_bound_distance;
87 if (range <= boost::math::tools::epsilon<double>())
89 joint_limits_multiplier *= (lower_bound_distance * upper_bound_distance / (range * range));
95 double& manipulability_index,
bool translation)
const
98 if (joint_model_group)
106 double& manipulability_index,
bool translation)
const
109 if (!joint_model_group->
isChain())
114 Eigen::MatrixXd jacobian = state.
getJacobian(joint_model_group);
119 if (jacobian.cols() < 6)
121 Eigen::JacobiSVD<Eigen::MatrixXd> svdsolver(jacobian.topLeftCorner(3, jacobian.cols()));
122 Eigen::MatrixXd singular_values = svdsolver.singularValues();
123 manipulability_index = 1.0;
124 for (
unsigned int i = 0; i < singular_values.rows(); ++i)
126 ROS_DEBUG_NAMED(
"kinematics_metrics",
"Singular value: %d %f", i, singular_values(i, 0));
127 manipulability_index *= singular_values(i, 0);
130 manipulability_index = penalty * manipulability_index;
134 Eigen::MatrixXd jacobian_2 = jacobian.topLeftCorner(3, jacobian.cols());
135 Eigen::MatrixXd matrix = jacobian_2 * jacobian_2.transpose();
137 manipulability_index = penalty * sqrt(matrix.determinant());
142 if (jacobian.cols() < 6)
144 Eigen::JacobiSVD<Eigen::MatrixXd> svdsolver(jacobian);
145 Eigen::MatrixXd singular_values = svdsolver.singularValues();
146 manipulability_index = 1.0;
147 for (
unsigned int i = 0; i < singular_values.rows(); ++i)
149 ROS_DEBUG_NAMED(
"kinematics_metrics",
"Singular value: %d %f", i, singular_values(i, 0));
150 manipulability_index *= singular_values(i, 0);
153 manipulability_index = penalty * manipulability_index;
157 Eigen::MatrixXd matrix = jacobian * jacobian.transpose();
159 manipulability_index = penalty * sqrt(matrix.determinant());
166 Eigen::MatrixXcd& eigen_values,
167 Eigen::MatrixXcd& eigen_vectors)
const
170 if (joint_model_group)
178 Eigen::MatrixXcd& eigen_values,
179 Eigen::MatrixXcd& eigen_vectors)
const
182 if (!joint_model_group->
isChain())
187 Eigen::MatrixXd jacobian = state.
getJacobian(joint_model_group);
188 Eigen::MatrixXd matrix = jacobian * jacobian.transpose();
189 Eigen::EigenSolver<Eigen::MatrixXd> eigensolver(matrix.block(0, 0, 3, 3));
190 eigen_values = eigensolver.eigenvalues();
191 eigen_vectors = eigensolver.eigenvectors();
196 double& manipulability,
bool translation)
const
199 if (joint_model_group)
207 double& manipulability,
bool translation)
const
210 if (!joint_model_group->
isChain())
218 Eigen::MatrixXd jacobian = state.
getJacobian(joint_model_group);
219 Eigen::JacobiSVD<Eigen::MatrixXd> svdsolver(jacobian.topLeftCorner(3, jacobian.cols()));
220 Eigen::MatrixXd singular_values = svdsolver.singularValues();
221 for (
int i = 0; i < singular_values.rows(); ++i)
222 ROS_DEBUG_NAMED(
"kinematics_metrics",
"Singular value: %d %f", i, singular_values(i, 0));
223 manipulability = penalty * singular_values.minCoeff() / singular_values.maxCoeff();
228 Eigen::JacobiSVD<Eigen::MatrixXd> svdsolver(jacobian);
229 Eigen::MatrixXd singular_values = svdsolver.singularValues();
230 for (
int i = 0; i < singular_values.rows(); ++i)
231 ROS_DEBUG_NAMED(
"kinematics_metrics",
"Singular value: %d %f", i, singular_values(i, 0));
232 manipulability = penalty * singular_values.minCoeff() / singular_values.maxCoeff();