control_policies.h
Go to the documentation of this file.
1 // -- BEGIN LICENSE BLOCK ----------------------------------------------
2 // Copyright 2020 FZI Forschungszentrum Informatik
3 // Created on behalf of Universal Robots A/S
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 // -- END LICENSE BLOCK ------------------------------------------------
17 
18 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
26 
27 #pragma once
28 
37 #include "kdl/chainfksolver.hpp"
39 #include <pluginlib/class_loader.h>
41 
42 // KDL
43 #include <kdl/chain.hpp>
44 #include <kdl/chainfksolvervel_recursive.hpp>
45 #include <kdl/chainiksolverpos_lma.hpp>
46 #include <kdl/chainiksolvervel_wdls.hpp>
47 #include <memory>
48 
50 {
56 template <class HWInterface>
57 using Controller =
59 
66 template <class HWInterface, class HandleType>
67 class JointBasedController : public Controller<HWInterface>
68 {
69 public:
70  JointBasedController() : Controller<HWInterface>(true){}; // optional speedscaling
71 
72  virtual bool init(hardware_interface::RobotHW* hw, ros::NodeHandle& root_nh, ros::NodeHandle& controller_nh) override;
73 
74  CartesianState getState() const;
75 
76 protected:
77  std::vector<HandleType> joint_handles_;
78  std::unique_ptr<KDL::ChainFkSolverVel_recursive> fk_solver_;
80  std::string robot_base_;
81  std::string robot_tip_;
82 };
83 
91 template <class HWInterface>
93 
97 template <>
99  : public Controller<ros_controllers_cartesian::PoseCommandInterface>
100 {
101 public:
103 
104  bool init(hardware_interface::RobotHW* hw, ros::NodeHandle& root_nh, ros::NodeHandle& controller_nh) override;
105 
111  void updateCommand(const CartesianState& cmd);
112 
113  CartesianState getState() const;
114 
115 private:
116  std::string base_;
117  std::string tip_;
119 };
120 
124 template <>
126  : public Controller<ros_controllers_cartesian::TwistCommandInterface>
127 {
128 public:
130  : Controller<ros_controllers_cartesian::TwistCommandInterface>(true) // optional speedscaling
131  {};
132 
138  void updateCommand(const ros_controllers_cartesian::CartesianState& cmd);
139 
141 };
142 
146 template <>
147 class ControlPolicy<hardware_interface::PositionJointInterface>
148  : public JointBasedController<hardware_interface::PositionJointInterface, hardware_interface::JointHandle>
149 {
150 public:
152 
153  bool init(hardware_interface::RobotHW* hw, ros::NodeHandle& root_nh, ros::NodeHandle& controller_nh) override;
154 
163  void updateCommand(const CartesianState& cmd);
164 
165 private:
166  std::unique_ptr<pluginlib::ClassLoader<IKSolver> > solver_loader_;
167  std::unique_ptr<IKSolver> ik_solver_;
168 };
169 
173 template <>
174 class ControlPolicy<hardware_interface::VelocityJointInterface>
175  : public JointBasedController<hardware_interface::VelocityJointInterface, hardware_interface::JointHandle>
176 {
177 public:
179 
180  bool init(hardware_interface::RobotHW* hw, ros::NodeHandle& root_nh, ros::NodeHandle& controller_nh) override;
181 
189  void updateCommand(const CartesianState& cmd);
190 
191 private:
192  std::unique_ptr<KDL::ChainIkSolverVel_wdls> ik_solver_;
193 };
194 
198 template <>
199 class ControlPolicy<hardware_interface::JointStateInterface>
200  : public JointBasedController<hardware_interface::JointStateInterface, hardware_interface::JointStateHandle>
201 {
202 public:
204 
205  bool init(hardware_interface::RobotHW* hw, ros::NodeHandle& root_nh, ros::NodeHandle& controller_nh) override;
206 
212  void updateCommand(const CartesianState& cmd);
213 
214 private:
217 };
218 
219 } // namespace ros_controllers_cartesian
220 
string cmd
A common base class for joint-based control policies.
std::unique_ptr< KDL::ChainFkSolverVel_recursive > fk_solver_
virtual bool init(hardware_interface::RobotHW *hw, ros::NodeHandle &root_nh, ros::NodeHandle &controller_nh) override
controller_interface::MultiInterfaceController< HWInterface, scaled_controllers::SpeedScalingInterface > Controller
A common control type with optional speed scaling interface.


cartesian_trajectory_controller
Author(s):
autogenerated on Thu Feb 23 2023 03:10:48