Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <vector>
00019 #include <ros/ros.h>
00020
00021 #include "cob_twist_controller/constraint_solvers/solvers/wln_joint_limit_avoidance_solver.h"
00022
00027 Eigen::MatrixXd WLN_JointLimitAvoidanceSolver::calculateWeighting(const JointStates& joint_states) const
00028 {
00029 std::vector<double> limits_min = this->limiter_params_.limits_min;
00030 std::vector<double> limits_max = this->limiter_params_.limits_max;
00031 uint32_t cols = this->jacobian_data_.cols();
00032 Eigen::VectorXd weighting = Eigen::VectorXd::Zero(cols);
00033
00034 KDL::JntArray q = joint_states.current_q_;
00035 KDL::JntArray q_dot = joint_states.current_q_dot_;
00036
00037 for (uint32_t i = 0; i < cols ; ++i)
00038 {
00039 weighting(i) = 1.0;
00040 if (i < q.rows())
00041 {
00042
00043 if ( (q_dot(i) > 0.0 && ((limits_max[i] - q(i)) < (q(i) - limits_min[i])))
00044 || (q_dot(i) < 0.0 && ((limits_max[i] - q(i)) > (q(i) - limits_min[i]))) )
00045 {
00046
00047 double nominator = pow(limits_max[i]-limits_min[i], 2.0) * (2.0 * q(i) - limits_max[i] - limits_min[i]);
00048 double denominator = 4.0 * pow(limits_max[i] - q(i), 2.0) * pow(q(i) - limits_min[i], 2.0);
00049 if (denominator != 0.0)
00050 {
00051 double partialPerformanceCriterion = fabs(nominator / denominator);
00052 weighting(i) = 1 + partialPerformanceCriterion;
00053 }
00054 }
00055 }
00056 }
00057
00058 return weighting.asDiagonal();
00059 }