cob_twist_controller_data_types.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_COB_TWIST_CONTROLLER_DATA_TYPES_H
19 #define COB_TWIST_CONTROLLER_COB_TWIST_CONTROLLER_DATA_TYPES_H
20 
21 #include <string>
22 #include <vector>
23 #include <map>
24 #include <stdint.h>
25 #include <Eigen/Core>
26 #include <Eigen/LU>
27 #include <kdl/jntarray.hpp>
28 #include <kdl/chainjnttojacsolver.hpp>
29 #include <cob_twist_controller/TwistControllerConfig.h>
30 
31 #define MAX_CRIT true
32 #define MIN_CRIT false
33 #define DEFAULT_CYCLE 0.02
34 #define ZERO_THRESHOLD 1.0e-9
35 #define DIV0_SAFE 1.0e-6
36 
38 {
39  NO_DAMPING = cob_twist_controller::TwistController_NO_DAMPING,
40  CONSTANT = cob_twist_controller::TwistController_CONSTANT,
41  MANIPULABILITY = cob_twist_controller::TwistController_MANIPULABILITY,
42  LEAST_SINGULAR_VALUE = cob_twist_controller::TwistController_LEAST_SINGULAR_VALUE,
43  SIGMOID = cob_twist_controller::TwistController_SIGMOID,
44 };
45 
47 {
48  NO_EXTENSION = cob_twist_controller::TwistController_NO_EXTENSION,
49  BASE_COMPENSATION = cob_twist_controller::TwistController_BASE_COMPENSATION,
50  BASE_ACTIVE = cob_twist_controller::TwistController_BASE_ACTIVE,
51  COB_TORSO = cob_twist_controller::TwistController_COB_TORSO,
52  LOOKAT = cob_twist_controller::TwistController_LOOKAT
53 };
54 
56 {
57  DEFAULT_SOLVER = cob_twist_controller::TwistController_DEFAULT_SOLVER,
58  WLN = cob_twist_controller::TwistController_WLN,
59  GPM = cob_twist_controller::TwistController_GPM,
60  STACK_OF_TASKS = cob_twist_controller::TwistController_STACK_OF_TASKS,
61  TASK_2ND_PRIO = cob_twist_controller::TwistController_TASK_2ND_PRIO,
62  UNIFIED_JLA_SA = cob_twist_controller::TwistController_UNIFIED_JLA_SA,
63 };
64 
66 {
67  CA_OFF = cob_twist_controller::TwistController_CA_OFF,
68  CA_ON = cob_twist_controller::TwistController_CA,
69 };
70 
72 {
73  JLA_OFF = cob_twist_controller::TwistController_JLA_OFF,
74  JLA_ON = cob_twist_controller::TwistController_JLA,
75  JLA_MID_ON = cob_twist_controller::TwistController_JLA_MID,
76  JLA_INEQ_ON = cob_twist_controller::TwistController_JLA_INEQ,
77 };
78 
80 {
87 };
88 
90 {
93  translation_x(0.0),
94  translation_y(0.0),
95  translation_z(0.0),
96  rotation_x(0.0),
97  rotation_y(0.0),
98  rotation_z(0.0),
99  rotation_w(1.0)
100  {}
101 
106  double rotation_x;
107  double rotation_y;
108  double rotation_z;
109  double rotation_w;
110 };
111 
113 {
118 };
119 
121 {
123  lin_x(0.0), lin_y(0.0), lin_z(0.0), rot_x(0.0), rot_y(0.0), rot_z(0.0) {}
124 
125  double lin_x;
126  double lin_y;
127  double lin_z;
128  double rot_x;
129  double rot_y;
130  double rot_z;
131 };
132 
134 {
135  double min_distance;
136  Eigen::Vector3d frame_vector;
137  Eigen::Vector3d nearest_point_frame_vector;
139 };
140 
142 {
143  double activation;
145  double critical;
146 };
147 
149 {
150  uint32_t priority;
151  double k_H;
152  double damping;
154 };
155 
157 {
158  CA,
160 };
161 
163 {
165  keep_direction(true),
166  enforce_input_limits(true),
167  enforce_pos_limits(true),
168  enforce_vel_limits(true),
169  enforce_acc_limits(false),
170  limits_tolerance(5.0),
171  max_lin_twist(0.5),
172  max_rot_twist(0.5),
173  max_vel_lin_base(0.5),
174  max_vel_rot_base(0.5)
175  {}
176 
187 
188  std::vector<double> limits_max;
189  std::vector<double> limits_min;
190  std::vector<double> limits_vel;
191  std::vector<double> limits_acc;
192 };
193 
195 {
197  sigma(0.05),
198  sigma_speed(0.005),
199  delta_pos(0.5),
200  delta_speed(1.0)
201  {}
202 
203  double sigma;
204  double sigma_speed;
205  double delta_pos;
206  double delta_speed;
207 };
208 
210 {
212  dof(0),
213  controller_interface(""),
214  integrator_smoothing(0.2),
215 
216  numerical_filtering(false),
217  damping_method(SIGMOID),
218  damping_factor(0.01),
219  lambda_max(0.001),
220  w_threshold(0.001),
221  beta(0.005),
222  slope_damping(0.05),
223  eps_damping(0.003),
224  eps_truncation(0.001),
225 
226  solver(GPM),
227  priority_main(500),
228  k_H(1.0),
229 
230  constraint_jla(JLA_ON),
231  constraint_ca(CA_ON),
232 
233  kinematic_extension(NO_EXTENSION),
234  extension_ratio(0.0)
235  {
236  ConstraintParams cp_ca;
237  cp_ca.priority = 100;
238  cp_ca.k_H = 2.0;
239  cp_ca.damping = 0.000001;
240  cp_ca.thresholds.activation = 0.1;
241  cp_ca.thresholds.critical = 0.025;
242  cp_ca.thresholds.activation_with_buffer = cp_ca.thresholds.activation * 1.5; // best experienced value
243  constraint_params.insert(std::pair<ConstraintTypes, ConstraintParams>(CA, cp_ca));
244 
245  ConstraintParams cp_jla;
246  cp_jla.priority = 50;
247  cp_jla.k_H = -10.0;
248  cp_jla.damping = 0.000001;
249  cp_jla.thresholds.activation = 0.1;
250  cp_jla.thresholds.critical = 0.05;
251  cp_jla.thresholds.activation_with_buffer = cp_jla.thresholds.activation * 4.0; // best experienced value
252  constraint_params.insert(std::pair<ConstraintTypes, ConstraintParams>(JLA, cp_jla));
253  }
254 
255  uint8_t dof;
256  std::string chain_base_link;
257  std::string chain_tip_link;
258 
259  std::string controller_interface;
261 
265  double lambda_max;
266  double w_threshold;
267  double beta;
269  double eps_damping;
271 
273  uint32_t priority_main;
274  double k_H;
275 
278  std::map<ConstraintTypes, ConstraintParams> constraint_params;
279 
282 
287 
288  std::vector<std::string> frame_names;
289  std::vector<std::string> joints;
290 
291  // vector of links of the chain to be considered for collision avoidance
292  std::vector<std::string> collision_check_links;
293 
294  void from_config(cob_twist_controller::TwistControllerConfig config)
295  {
296  numerical_filtering = config.numerical_filtering;
297  damping_method = static_cast<DampingMethodTypes>(config.damping_method);
298  damping_factor = config.damping_factor;
299  lambda_max = config.lambda_max;
300  w_threshold = config.w_threshold;
301  slope_damping = config.slope_damping;
302  beta = config.beta;
303  eps_damping = config.eps_damping;
304  eps_truncation = config.eps_truncation;
305 
306  solver = static_cast<SolverTypes>(config.solver);
307  priority_main = config.priority;
308  k_H = config.k_H;
309 
310  constraint_jla = static_cast<ConstraintTypesJLA>(config.constraint_jla);
311  constraint_ca = static_cast<ConstraintTypesCA>(config.constraint_ca);
312 
313  ConstraintParams cp_jla;
314  cp_jla.priority = config.priority_jla;
315  cp_jla.k_H = config.k_H_jla;
316  cp_jla.damping = config.damping_jla;
317  const double activation_jla_in_percent = config.activation_threshold_jla;
318  const double activation_buffer_jla_in_percent = config.activation_buffer_jla;
319  const double critical_jla_in_percent = config.critical_threshold_jla;
320  cp_jla.thresholds.activation = activation_jla_in_percent / 100.0;
321  cp_jla.thresholds.critical = critical_jla_in_percent / 100.0;
322  cp_jla.thresholds.activation_with_buffer = cp_jla.thresholds.activation * (1.0 + activation_buffer_jla_in_percent / 100.0);
323  constraint_params[JLA] = cp_jla;
324 
325  ConstraintParams cp_ca;
326  cp_ca.priority = config.priority_ca;
327  cp_ca.k_H = config.k_H_ca;
328  cp_ca.damping = config.damping_ca;
329  const double activaton_buffer_ca_in_percent = config.activation_buffer_ca;
330  cp_ca.thresholds.activation = config.activation_threshold_ca; // in [m]
331  cp_ca.thresholds.critical = config.critical_threshold_ca; // in [m]
332  cp_ca.thresholds.activation_with_buffer = cp_ca.thresholds.activation * (1.0 + activaton_buffer_ca_in_percent / 100.0);
333  constraint_params[CA] = cp_ca;
334 
335  ujs_solver_params.sigma = config.sigma;
336  ujs_solver_params.sigma_speed = config.sigma_speed;
337  ujs_solver_params.delta_pos = config.delta_pos;
338  ujs_solver_params.delta_speed = config.delta_speed;
339 
340  limiter_params.keep_direction = config.keep_direction;
341  limiter_params.enforce_input_limits = config.enforce_input_limits;
342  limiter_params.enforce_pos_limits = config.enforce_pos_limits;
343  limiter_params.enforce_vel_limits = config.enforce_vel_limits;
344  limiter_params.enforce_acc_limits = config.enforce_acc_limits;
345  limiter_params.limits_tolerance = config.limits_tolerance;
346  limiter_params.max_lin_twist = config.max_lin_twist;
347  limiter_params.max_rot_twist = config.max_rot_twist;
348  limiter_params.max_vel_lin_base = config.max_vel_lin_base;
349  limiter_params.max_vel_rot_base = config.max_vel_rot_base;
350 
351  kinematic_extension = static_cast<KinematicExtensionTypes>(config.kinematic_extension);
352  extension_ratio = config.extension_ratio;
353  }
354 
355  void to_config(cob_twist_controller::TwistControllerConfig& config)
356  {
357  config.numerical_filtering = numerical_filtering;
358  config.damping_method = damping_method;
359  config.damping_factor = damping_factor;
360  config.lambda_max = lambda_max;
361  config.w_threshold = w_threshold;
362  config.slope_damping = slope_damping;
363  config.beta = beta;
364  config.eps_damping = eps_damping;
365  config.eps_truncation = eps_truncation;
366 
367  config.solver = solver;
368  config.priority = priority_main;
369  config.k_H = k_H;
370 
371  config.constraint_jla = config.constraint_jla;
372  config.constraint_ca = constraint_ca;
373 
374  config.priority_jla = constraint_params[JLA].priority;
375  config.k_H_jla = constraint_params[JLA].k_H;
376  config.damping_jla = constraint_params[JLA].damping;
377  config.activation_threshold_jla = constraint_params[JLA].thresholds.activation * 100.0;
378  config.critical_threshold_jla = constraint_params[JLA].thresholds.critical * 100.0;
379  config.activation_buffer_jla = (constraint_params[JLA].thresholds.activation_with_buffer/constraint_params[JLA].thresholds.activation - 1.0)*100.0;
380 
381  config.priority_ca = constraint_params[CA].priority;
382  config.k_H_ca = constraint_params[CA].k_H;
383  config.damping_ca = constraint_params[CA].damping;
384  config.activation_threshold_ca = constraint_params[CA].thresholds.activation;
385  config.critical_threshold_ca = constraint_params[CA].thresholds.critical;
386  config.activation_buffer_ca = (constraint_params[CA].thresholds.activation_with_buffer/constraint_params[CA].thresholds.activation - 1.0)*100.0;
387 
388  config.sigma = ujs_solver_params.sigma;
389  config.sigma_speed = ujs_solver_params.sigma_speed;
390  config.delta_pos = ujs_solver_params.delta_pos;
391  config.delta_speed = ujs_solver_params.delta_speed;
392 
393  config.keep_direction = limiter_params.keep_direction;
394  config.enforce_input_limits = limiter_params.enforce_input_limits;
395  config.enforce_pos_limits = limiter_params.enforce_pos_limits;
396  config.enforce_vel_limits = limiter_params.enforce_vel_limits;
397  config.enforce_acc_limits = limiter_params.enforce_acc_limits;
398  config.limits_tolerance = limiter_params.limits_tolerance;
399  config.max_lin_twist = limiter_params.max_lin_twist;
400  config.max_rot_twist = limiter_params.max_rot_twist;
401  config.max_vel_lin_base = limiter_params.max_vel_lin_base;
402  config.max_vel_rot_base = limiter_params.max_vel_rot_base;
403 
404  config.kinematic_extension = kinematic_extension;
405  config.extension_ratio = extension_ratio;
406  }
407 };
408 
410 {
411  NORMAL = 0,
414 };
415 
417 {
418  public:
420  : current_(NORMAL), previous_(NORMAL), transition_(false)
421  {}
422 
423  inline void setState(EN_ConstraintStates next_state)
424  {
425  this->transition_ = this->current_ != next_state;
426  this->previous_ = this->current_;
427  this->current_ = next_state;
428  }
429 
431  {
432  return this->current_;
433  }
434 
436  {
437  return this->previous_;
438  }
439 
440  inline bool isTransition() const
441  {
442  return this->transition_;
443  }
444 
445  private:
449 };
450 
451 typedef Eigen::Matrix<double, 6, Eigen::Dynamic> Matrix6Xd_t;
452 typedef Eigen::Matrix<double, 6, 1> Vector6d_t;
453 typedef std::map<std::string, std::vector<ObstacleDistanceData> > ObstacleDistancesInfo_t;
454 
455 #endif // COB_TWIST_CONTROLLER_COB_TWIST_CONTROLLER_DATA_TYPES_H
std::map< ConstraintTypes, ConstraintParams > constraint_params
std::vector< double > limits_min
EN_ConstraintStates getCurrent() const
Eigen::Matrix< double, 6, 1 > Vector6d_t
KinematicExtensionTypes kinematic_extension
std::vector< std::string > collision_check_links
std::vector< std::string > frame_names
std::vector< double > limits_acc
std::map< std::string, std::vector< ObstacleDistanceData > > ObstacleDistancesInfo_t
void setState(EN_ConstraintStates next_state)
void to_config(cob_twist_controller::TwistControllerConfig &config)
void from_config(cob_twist_controller::TwistControllerConfig config)
std::vector< double > limits_max
Eigen::Matrix< double, 6, Eigen::Dynamic > Matrix6Xd_t
std::vector< std::string > joints
EN_ConstraintStates getPrevious() const
std::vector< double > limits_vel


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