wln_joint_limit_avoidance_solver.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *   http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
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;    // in the else cases -> weighting always 1
00040         if (i < q.rows())
00041         {
00042             // See Chan paper ISSN 1042-296X [Page 288]
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                 // calculation is only necessary in case of condition is true!
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 }


cob_twist_controller
Author(s): Felix Messmer , Marco Bezzon , Christoph Mark , Francisco Moreno
autogenerated on Thu Jun 6 2019 21:19:26