constraint_impl.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_IMPL_H
19 #define COB_TWIST_CONTROLLER_CONSTRAINTS_CONSTRAINT_IMPL_H
20 
21 #include <sstream>
22 #include <set>
23 #include <vector>
24 #include <string>
25 #include <ros/ros.h>
26 
27 #include <boost/shared_ptr.hpp>
28 #include <boost/pointer_cast.hpp>
29 
30 #include <kdl/chainjnttojacsolver.hpp>
31 
34 
35 /* BEGIN ConstraintsBuilder *************************************************************************************/
39 template <typename PRIO>
40 std::set<ConstraintBase_t> ConstraintsBuilder<PRIO>::createConstraints(const TwistControllerParams& tc_params,
41  const LimiterParams& limiter_params,
42  KDL::ChainJntToJacSolver& jnt_to_jac,
43  KDL::ChainFkSolverVel_recursive& fk_solver_vel,
44  CallbackDataMediator& data_mediator)
45 {
46  std::set<ConstraintBase_t> constraints;
47  // Joint limit avoidance part
48  if (JLA_ON == tc_params.constraint_jla)
49  {
51 
52  ConstraintParamsJLA params = ConstraintParamsJLA(tc_params.constraint_params.at(JLA), limiter_params);
53  uint32_t startPrio = params.params_.priority;
54  for (uint32_t i = 0; i < tc_params.joints.size(); ++i)
55  {
56  // TODO: take care PRIO could be of different type than UINT32
57  params.joint_ = tc_params.joints[i];
58  params.joint_idx_ = static_cast<int32_t>(i);
59  boost::shared_ptr<Jla_t > jla(new Jla_t(startPrio++, params, data_mediator));
60  constraints.insert(boost::static_pointer_cast<PriorityBase<PRIO> >(jla));
61  }
62  }
63  else if (JLA_MID_ON == tc_params.constraint_jla)
64  {
66 
67  ConstraintParamsJLA params = ConstraintParamsJLA(tc_params.constraint_params.at(JLA), limiter_params);
68  // TODO: take care PRIO could be of different type than UINT32
69  boost::shared_ptr<JlaMid_t > jla(new JlaMid_t(params.params_.priority, params, data_mediator));
70  constraints.insert(boost::static_pointer_cast<PriorityBase<PRIO> >(jla));
71  }
72  else if (JLA_INEQ_ON == tc_params.constraint_jla)
73  {
75 
76  ConstraintParamsJLA params = ConstraintParamsJLA(tc_params.constraint_params.at(JLA), limiter_params);
77  uint32_t startPrio = params.params_.priority;
78  for (uint32_t i = 0; i < tc_params.joints.size(); ++i)
79  {
80  // TODO: take care PRIO could be of different type than UINT32
81  params.joint_ = tc_params.joints[i];
82  params.joint_idx_ = static_cast<int32_t>(i);
83  boost::shared_ptr<Jla_t > jla(new Jla_t(startPrio++, params, data_mediator));
84  constraints.insert(boost::static_pointer_cast<PriorityBase<PRIO> >(jla));
85  }
86  }
87  else
88  {
89  // JLA_OFF selected.
90  }
91 
92  // Collision avoidance part
93  if (CA_ON == tc_params.constraint_ca)
94  {
95  typedef CollisionAvoidance<ConstraintParamsCA, PRIO> CollisionAvoidance_t;
96  uint32_t startPrio = tc_params.constraint_params.at(CA).priority;
97 
98  for (std::vector<std::string>::const_iterator it = tc_params.collision_check_links.begin();
99  it != tc_params.collision_check_links.end(); it++)
100  {
101  ConstraintParamsCA params = ConstraintParamsCA(tc_params.constraint_params.at(CA),tc_params.frame_names, *it);
102  data_mediator.fill(params);
103  // TODO: take care PRIO could be of different type than UINT32
104  boost::shared_ptr<CollisionAvoidance_t > ca(new CollisionAvoidance_t(startPrio--, params, data_mediator, jnt_to_jac, fk_solver_vel));
105  constraints.insert(boost::static_pointer_cast<PriorityBase<PRIO> >(ca));
106  }
107  }
108  else
109  {
110  // CA_OFF selected.
111  }
112 
113  return constraints;
114 }
115 /* END ConstraintsBuilder *******************************************************************************************/
116 
117 // Collision Avoidance Constraint Implementation
119 
120 // Joint Limit Avoidance Constraint Implementation
122 
123 #endif // COB_TWIST_CONTROLLER_CONSTRAINTS_CONSTRAINT_IMPL_H
std::map< ConstraintTypes, ConstraintParams > constraint_params
Class that represents the parameters for the Collision Avoidance constraint.
const ConstraintParams params_
std::vector< std::string > collision_check_links
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)
std::vector< std::string > frame_names
Class that represents the parameters for the Collision Avoidance constraint.
bool fill(ConstraintParamsCA &params_ca)
Consumer: Consumes elements from distances container.
Class providing methods that realize a JointLimitAvoidance constraint.
Definition: constraint.h:102
std::vector< std::string > joints
Class providing methods that realize a CollisionAvoidance constraint.
Definition: constraint.h:52
Class providing methods that realize a JointLimitAvoidanceMid constraint.
Definition: constraint.h:142
Represents a data pool for distribution of collected data from ROS callback.


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