wln_joint_limit_avoidance_solver.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #include <vector>
19 #include <ros/ros.h>
20 
22 
27 Eigen::MatrixXd WLN_JointLimitAvoidanceSolver::calculateWeighting(const JointStates& joint_states) const
28 {
29  std::vector<double> limits_min = this->limiter_params_.limits_min;
30  std::vector<double> limits_max = this->limiter_params_.limits_max;
31  uint32_t cols = this->jacobian_data_.cols();
32  Eigen::VectorXd weighting = Eigen::VectorXd::Zero(cols);
33 
34  KDL::JntArray q = joint_states.current_q_;
35  KDL::JntArray q_dot = joint_states.current_q_dot_;
36 
37  for (uint32_t i = 0; i < cols ; ++i)
38  {
39  weighting(i) = 1.0; // in the else cases -> weighting always 1
40  if (i < q.rows())
41  {
42  // See Chan paper ISSN 1042-296X [Page 288]
43  if ( (q_dot(i) > 0.0 && ((limits_max[i] - q(i)) < (q(i) - limits_min[i])))
44  || (q_dot(i) < 0.0 && ((limits_max[i] - q(i)) > (q(i) - limits_min[i]))) )
45  {
46  // calculation is only necessary in case of condition is true!
47  double nominator = pow(limits_max[i]-limits_min[i], 2.0) * (2.0 * q(i) - limits_max[i] - limits_min[i]);
48  double denominator = 4.0 * pow(limits_max[i] - q(i), 2.0) * pow(q(i) - limits_min[i], 2.0);
49  if (denominator != 0.0)
50  {
51  double partialPerformanceCriterion = fabs(nominator / denominator);
52  weighting(i) = 1 + partialPerformanceCriterion;
53  }
54  }
55  }
56  }
57 
58  return weighting.asDiagonal();
59 }
virtual Eigen::MatrixXd calculateWeighting(const JointStates &joint_states) const
std::vector< double > limits_min
const LimiterParams & limiter_params_
References the inv. diff. kin. solver parameters.
unsigned int rows() const
Matrix6Xd_t jacobian_data_
References the limiter parameters (up-to-date according to KinematicExtension).
INLINE Rall1d< T, V, S > pow(const Rall1d< T, V, S > &arg, double m)
std::vector< double > limits_max


cob_twist_controller
Author(s): Felix Messmer , Marco Bezzon , Christoph Mark , Francisco Moreno
autogenerated on Thu Apr 8 2021 02:40:01