ros2_control - rolling
passthrough_controller.hpp
1 // Copyright (c) 2023, PAL Robotics
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 PASSTHROUGH_CONTROLLER__PASSTHROUGH_CONTROLLER_HPP_
16 #define PASSTHROUGH_CONTROLLER__PASSTHROUGH_CONTROLLER_HPP_
17 
18 // system
19 #include <limits>
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include "controller_interface/chainable_controller_interface.hpp"
25 #include "realtime_tools/realtime_buffer.h"
26 #include "std_msgs/msg/float64_multi_array.hpp"
27 // auto-generated by generate_parameter_library
28 #include "passthrough_controller_parameters.hpp"
29 
36 {
37 using DataType = std_msgs::msg::Float64MultiArray;
39 {
40 public:
41  controller_interface::CallbackReturn on_init() override;
42 
44 
46 
47  controller_interface::CallbackReturn on_configure(
48  const rclcpp_lifecycle::State & previous_state) override;
49 
50  controller_interface::CallbackReturn on_activate(
51  const rclcpp_lifecycle::State & previous_state) override;
52 
53  controller_interface::CallbackReturn on_deactivate(
54  const rclcpp_lifecycle::State & previous_state) override;
55 
56  bool on_set_chained_mode(bool chained_mode) override;
57 
58  controller_interface::return_type update_and_write_commands(
59  const rclcpp::Time & time, const rclcpp::Duration & period) override;
60 
61 protected:
62  std::vector<hardware_interface::CommandInterface> on_export_reference_interfaces() override;
63 
64  controller_interface::return_type update_reference_from_subscribers(
65  const rclcpp::Time & time, const rclcpp::Duration & period) override;
66 
67  std::shared_ptr<ParamListener> param_listener_;
68  Params params_;
69 
71  rclcpp::Subscription<DataType>::SharedPtr joints_cmd_sub_;
72 
73  std::vector<std::string> reference_interface_names_;
74 
75  std::vector<std::string> command_interface_names_;
76 };
77 } // namespace passthrough_controller
78 
79 #endif // PASSTHROUGH_CONTROLLER__PASSTHROUGH_CONTROLLER_HPP_
Definition: chainable_controller_interface.hpp:36
Definition: passthrough_controller.hpp:39
controller_interface::return_type update_reference_from_subscribers(const rclcpp::Time &time, const rclcpp::Duration &period) override
Update reference from input topics when not in chained mode.
Definition: passthrough_controller.cpp:160
controller_interface::CallbackReturn on_init() override
Extending interface with initialization method which is individual for each controller.
Definition: passthrough_controller.cpp:22
controller_interface::return_type update_and_write_commands(const rclcpp::Time &time, const rclcpp::Duration &period) override
Execute calculations of the controller and update command interfaces.
Definition: passthrough_controller.cpp:132
controller_interface::InterfaceConfiguration state_interface_configuration() const override
Get configuration for controller's required state interfaces.
Definition: passthrough_controller.cpp:47
bool on_set_chained_mode(bool chained_mode) override
Virtual method that each chainable controller should implement to switch chained mode.
Definition: passthrough_controller.cpp:130
controller_interface::InterfaceConfiguration command_interface_configuration() const override
Get configuration for controller's required command interfaces.
Definition: passthrough_controller.cpp:38
std::vector< hardware_interface::CommandInterface > on_export_reference_interfaces() override
Definition: passthrough_controller.cpp:147
Definition: realtime_buffer.h:49
Definition: passthrough_controller.hpp:36
Configuring what command/state interfaces to claim.
Definition: controller_interface_base.hpp:56