constraint.h
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 #ifndef COB_TWIST_CONTROLLER_CONSTRAINTS_CONSTRAINT_H
19 #define COB_TWIST_CONTROLLER_CONSTRAINTS_CONSTRAINT_H
20 
21 #include <set>
22 #include <string>
23 #include <limits>
24 #include <kdl/chainjnttojacsolver.hpp>
25 #include <kdl/chainfksolvervel_recursive.hpp>
26 
30 
31 /* BEGIN ConstraintsBuilder *************************************************************************************/
33 template <typename PRIO = uint32_t>
35 {
36  public:
37  static std::set<ConstraintBase_t> createConstraints(const TwistControllerParams& params,
38  const LimiterParams& limiter_params,
39  KDL::ChainJntToJacSolver& jnt_to_jac_,
40  KDL::ChainFkSolverVel_recursive& fk_solver_vel,
41  CallbackDataMediator& data_mediator);
42 
43  private:
46 };
47 /* END ConstraintsBuilder ***************************************************************************************/
48 
49 /* BEGIN CollisionAvoidance *************************************************************************************/
51 template <typename T_PARAMS, typename PRIO = uint32_t>
52 class CollisionAvoidance : public ConstraintBase<T_PARAMS, PRIO>
53 {
54  public:
56  T_PARAMS constraint_params,
58  KDL::ChainJntToJacSolver& jnt_to_jac,
59  KDL::ChainFkSolverVel_recursive& fk_solver_vel) :
60  ConstraintBase<T_PARAMS, PRIO>(prio, constraint_params, cbdm),
61  jnt_to_jac_(jnt_to_jac),
62  fk_solver_vel_(fk_solver_vel)
63  {}
64 
66  {}
67 
68  virtual std::string getTaskId() const;
69  virtual Eigen::MatrixXd getTaskJacobian() const;
70  virtual Eigen::VectorXd getTaskDerivatives() const;
71 
72  virtual void calculate();
73 
74  virtual double getActivationGain() const;
75  virtual double getSelfMotionMagnitude(const Eigen::MatrixXd& particular_solution,
76  const Eigen::MatrixXd& homogeneous_solution) const;
77 
78  double getActivationGain(double current_cost_func_value) const;
79  double getSelfMotionMagnitude(double current_cost_func_value) const;
80 
81  private:
82  virtual double getCriticalValue() const;
83 
84  void calcValue();
85  void calcDerivativeValue();
86  void calcPartialValues();
87  void calcPredictionValue();
88  double getActivationThresholdWithBuffer() const;
89 
92 
93  Eigen::VectorXd values_;
94  Eigen::VectorXd derivative_values_;
95  Eigen::MatrixXd task_jacobian_;
96 };
97 /* END CollisionAvoidance ***************************************************************************************/
98 
99 /* BEGIN JointLimitAvoidance ************************************************************************************/
101 template <typename T_PARAMS, typename PRIO = uint32_t>
102 class JointLimitAvoidance : public ConstraintBase<T_PARAMS, PRIO>
103 {
104  public:
106  T_PARAMS constraint_params,
107  CallbackDataMediator& cbdm)
108  : ConstraintBase<T_PARAMS, PRIO>(prio, constraint_params, cbdm),
109  abs_delta_max_(std::numeric_limits<double>::max()),
110  abs_delta_min_(std::numeric_limits<double>::max()), // max. delta away from min
111  rel_max_(1.0), // 100% rel. range to max limit
112  rel_min_(1.0) // 100% rel. range to min limit
113  {}
114 
116  {}
117 
118  virtual std::string getTaskId() const;
119 
120  virtual void calculate();
121  virtual Eigen::MatrixXd getTaskJacobian() const;
122  virtual Eigen::VectorXd getTaskDerivatives() const;
123 
124  virtual double getActivationGain() const;
125  virtual double getSelfMotionMagnitude(const Eigen::MatrixXd& particular_solution, const Eigen::MatrixXd& homogeneous_solution) const;
126 
127  private:
128  void calcValue();
129  void calcDerivativeValue();
130  void calcPartialValues();
131 
134  double rel_max_;
135  double rel_min_;
136 };
137 /* END JointLimitAvoidance **************************************************************************************/
138 
139 /* BEGIN JointLimitAvoidanceMid *********************************************************************************/
141 template <typename T_PARAMS, typename PRIO = uint32_t>
142 class JointLimitAvoidanceMid : public ConstraintBase<T_PARAMS, PRIO>
143 {
144  public:
146  T_PARAMS constraint_params,
147  CallbackDataMediator& cbdm)
148  : ConstraintBase<T_PARAMS, PRIO>(prio, constraint_params, cbdm)
149  {}
150 
152  {}
153 
154  virtual std::string getTaskId() const;
155 
156  virtual void calculate();
157 
158  virtual double getActivationGain() const;
159  virtual double getSelfMotionMagnitude(const Eigen::MatrixXd& particular_solution, const Eigen::MatrixXd& homogeneous_solution) const;
160 
161  private:
162  void calcValue();
163  void calcDerivativeValue();
164  void calcPartialValues();
165 };
166 /* END JointLimitAvoidanceMid ***********************************************************************************/
167 
168 /* BEGIN JointLimitAvoidanceIneq ************************************************************************************/
170 template <typename T_PARAMS, typename PRIO = uint32_t>
171 class JointLimitAvoidanceIneq : public ConstraintBase<T_PARAMS, PRIO>
172 {
173  public:
175  T_PARAMS constraint_params,
176  CallbackDataMediator& cbdm)
177  : ConstraintBase<T_PARAMS, PRIO>(prio, constraint_params, cbdm),
178  abs_delta_max_(std::numeric_limits<double>::max()),
179  abs_delta_min_(std::numeric_limits<double>::max()),
180  rel_max_(1.0),
181  rel_min_(1.0)
182  {}
183 
185  {}
186 
187  virtual std::string getTaskId() const;
188  virtual Eigen::MatrixXd getTaskJacobian() const;
189  virtual Eigen::VectorXd getTaskDerivatives() const;
190 
191  virtual void calculate();
192 
193  virtual double getActivationGain() const;
194  virtual double getSelfMotionMagnitude(const Eigen::MatrixXd& particular_solution, const Eigen::MatrixXd& homogeneous_solution) const;
195 
196  private:
197  void calcValue();
198  void calcDerivativeValue();
199  void calcPartialValues();
200 
203  double rel_max_;
204  double rel_min_;
205 };
206 /* END JointLimitAvoidanceIneq **************************************************************************************/
207 
209 
210 #include "cob_twist_controller/constraints/constraint_impl.h" // implementation of templated class
211 
212 #endif // COB_TWIST_CONTROLLER_CONSTRAINTS_CONSTRAINT_H
KDL::ChainJntToJacSolver & jnt_to_jac_
Definition: constraint.h:90
Class providing a static method to create constraints.
Definition: constraint.h:34
JointLimitAvoidance(PRIO prio, T_PARAMS constraint_params, CallbackDataMediator &cbdm)
Definition: constraint.h:105
virtual ~JointLimitAvoidance()
Definition: constraint.h:115
Eigen::VectorXd values_
Definition: constraint.h:93
Class providing methods that realize a JointLimitAvoidance constraint based on inequalities.
Definition: constraint.h:171
static std::set< ConstraintBase_t > createConstraints(const TwistControllerParams &params, const LimiterParams &limiter_params, KDL::ChainJntToJacSolver &jnt_to_jac_, KDL::ChainFkSolverVel_recursive &fk_solver_vel, CallbackDataMediator &data_mediator)
ConstraintsBuilder< uint32_t > ConstraintsBuilder_t
Definition: constraint.h:208
virtual ~JointLimitAvoidanceIneq()
Definition: constraint.h:184
CollisionAvoidance(PRIO prio, T_PARAMS constraint_params, CallbackDataMediator &cbdm, KDL::ChainJntToJacSolver &jnt_to_jac, KDL::ChainFkSolverVel_recursive &fk_solver_vel)
Definition: constraint.h:55
Eigen::MatrixXd task_jacobian_
Definition: constraint.h:95
virtual ~CollisionAvoidance()
Definition: constraint.h:65
KDL::ChainFkSolverVel_recursive & fk_solver_vel_
Definition: constraint.h:91
JointLimitAvoidanceMid(PRIO prio, T_PARAMS constraint_params, CallbackDataMediator &cbdm)
Definition: constraint.h:145
Class providing methods that realize a JointLimitAvoidance constraint.
Definition: constraint.h:102
virtual ~JointLimitAvoidanceMid()
Definition: constraint.h:151
Class providing methods that realize a CollisionAvoidance constraint.
Definition: constraint.h:52
JointLimitAvoidanceIneq(PRIO prio, T_PARAMS constraint_params, CallbackDataMediator &cbdm)
Definition: constraint.h:174
Class providing methods that realize a JointLimitAvoidanceMid constraint.
Definition: constraint.h:142
double max(double a, double b)
Represents a data pool for distribution of collected data from ROS callback.
Eigen::VectorXd derivative_values_
Definition: constraint.h:94


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