ros2_control - rolling
forward_controllers_base.hpp
1 // Copyright 2021 Stogl Robotics Consulting UG (haftungsbescrhänkt)
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef FORWARD_COMMAND_CONTROLLER__FORWARD_CONTROLLERS_BASE_HPP_
16 #define FORWARD_COMMAND_CONTROLLER__FORWARD_CONTROLLERS_BASE_HPP_
17 
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
22 #include "controller_interface/controller_interface.hpp"
23 #include "forward_command_controller/visibility_control.h"
24 #include "rclcpp/subscription.hpp"
25 #include "rclcpp_lifecycle/state.hpp"
26 #include "realtime_tools/realtime_buffer.hpp"
27 #include "std_msgs/msg/float64_multi_array.hpp"
28 
29 namespace forward_command_controller
30 {
31 using CmdType = std_msgs::msg::Float64MultiArray;
32 
42 {
43 public:
44  FORWARD_COMMAND_CONTROLLER_PUBLIC
46 
47  FORWARD_COMMAND_CONTROLLER_PUBLIC
48  ~ForwardControllersBase() = default;
49 
50  FORWARD_COMMAND_CONTROLLER_PUBLIC
52 
53  FORWARD_COMMAND_CONTROLLER_PUBLIC
55 
56  FORWARD_COMMAND_CONTROLLER_PUBLIC
57  controller_interface::CallbackReturn on_init() override;
58 
59  FORWARD_COMMAND_CONTROLLER_PUBLIC
60  controller_interface::CallbackReturn on_configure(
61  const rclcpp_lifecycle::State & previous_state) override;
62 
63  FORWARD_COMMAND_CONTROLLER_PUBLIC
64  controller_interface::CallbackReturn on_activate(
65  const rclcpp_lifecycle::State & previous_state) override;
66 
67  FORWARD_COMMAND_CONTROLLER_PUBLIC
68  controller_interface::CallbackReturn on_deactivate(
69  const rclcpp_lifecycle::State & previous_state) override;
70 
71  FORWARD_COMMAND_CONTROLLER_PUBLIC
72  controller_interface::return_type update(
73  const rclcpp::Time & time, const rclcpp::Duration & period) override;
74 
75 protected:
80  virtual void declare_parameters() = 0;
81 
92  virtual controller_interface::CallbackReturn read_parameters() = 0;
93 
94  std::vector<std::string> joint_names_;
95  std::string interface_name_;
96 
97  std::vector<std::string> command_interface_types_;
98 
100  rclcpp::Subscription<CmdType>::SharedPtr joints_command_subscriber_;
101 };
102 
103 } // namespace forward_command_controller
104 
105 #endif // FORWARD_COMMAND_CONTROLLER__FORWARD_CONTROLLERS_BASE_HPP_
Definition: controller_interface.hpp:28
Forward command controller for a set of joints and interfaces.
Definition: forward_controllers_base.hpp:42
FORWARD_COMMAND_CONTROLLER_PUBLIC controller_interface::InterfaceConfiguration command_interface_configuration() const override
Get configuration for controller's required command interfaces.
Definition: forward_controllers_base.cpp:68
FORWARD_COMMAND_CONTROLLER_PUBLIC controller_interface::CallbackReturn on_init() override
Extending interface with initialization method which is individual for each controller.
Definition: forward_controllers_base.cpp:35
FORWARD_COMMAND_CONTROLLER_PUBLIC controller_interface::return_type update(const rclcpp::Time &time, const rclcpp::Duration &period) override
Definition: forward_controllers_base.cpp:118
FORWARD_COMMAND_CONTROLLER_PUBLIC controller_interface::InterfaceConfiguration state_interface_configuration() const override
Get configuration for controller's required state interfaces.
Definition: forward_controllers_base.cpp:77
virtual controller_interface::CallbackReturn read_parameters()=0
Definition: realtime_buffer.hpp:44
Configuring what command/state interfaces to claim.
Definition: controller_interface_base.hpp:58