ros2_control - humble
Loading...
Searching...
No Matches
chainable_controller_interface.hpp
1// Copyright (c) 2022, Stogl Robotics Consulting UG (haftungsbeschrä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 CONTROLLER_INTERFACE__CHAINABLE_CONTROLLER_INTERFACE_HPP_
16#define CONTROLLER_INTERFACE__CHAINABLE_CONTROLLER_INTERFACE_HPP_
17
18#include <vector>
19
20#include "controller_interface/controller_interface_base.hpp"
21#include "controller_interface/visibility_control.h"
22#include "hardware_interface/handle.hpp"
23
24namespace controller_interface
25{
28
35{
36public:
37 CONTROLLER_INTERFACE_PUBLIC
39
40 CONTROLLER_INTERFACE_PUBLIC
41 virtual ~ChainableControllerInterface() = default;
42
52 CONTROLLER_INTERFACE_PUBLIC
53 return_type update(const rclcpp::Time & time, const rclcpp::Duration & period) final;
54
55 CONTROLLER_INTERFACE_PUBLIC
56 bool is_chainable() const final;
57
58 CONTROLLER_INTERFACE_PUBLIC
59 std::vector<hardware_interface::CommandInterface> export_reference_interfaces() final;
60
61 CONTROLLER_INTERFACE_PUBLIC
62 bool set_chained_mode(bool chained_mode) final;
63
64 CONTROLLER_INTERFACE_PUBLIC
65 bool is_in_chained_mode() const final;
66
67protected:
70
77 virtual std::vector<hardware_interface::CommandInterface> on_export_reference_interfaces() = 0;
78
80
91 virtual bool on_set_chained_mode(bool chained_mode);
92
94
100 virtual return_type update_reference_from_subscribers() = 0;
101
103
113 virtual return_type update_and_write_commands(
114 const rclcpp::Time & time, const rclcpp::Duration & period) = 0;
115
117 std::vector<double> reference_interfaces_;
118
119private:
121 bool in_chained_mode_ = false;
122};
123
124} // namespace controller_interface
125
126#endif // CONTROLLER_INTERFACE__CHAINABLE_CONTROLLER_INTERFACE_HPP_
Definition chainable_controller_interface.hpp:35
virtual return_type update_and_write_commands(const rclcpp::Time &time, const rclcpp::Duration &period)=0
Execute calculations of the controller and update command interfaces.
std::vector< double > reference_interfaces_
Storage of values for reference interfaces.
Definition chainable_controller_interface.hpp:117
virtual bool on_set_chained_mode(bool chained_mode)
Virtual method that each chainable controller should implement to switch chained mode.
Definition chainable_controller_interface.cpp:114
CONTROLLER_INTERFACE_PUBLIC bool is_in_chained_mode() const final
Get information if a controller is currently in chained mode.
Definition chainable_controller_interface.cpp:112
virtual std::vector< hardware_interface::CommandInterface > on_export_reference_interfaces()=0
virtual return_type update_reference_from_subscribers()=0
Update reference from input topics when not in chained mode.
CONTROLLER_INTERFACE_PUBLIC return_type update(const rclcpp::Time &time, const rclcpp::Duration &period) final
Definition chainable_controller_interface.cpp:28
CONTROLLER_INTERFACE_PUBLIC std::vector< hardware_interface::CommandInterface > export_reference_interfaces() final
Definition chainable_controller_interface.cpp:48
CONTROLLER_INTERFACE_PUBLIC bool set_chained_mode(bool chained_mode) final
Definition chainable_controller_interface.cpp:87
CONTROLLER_INTERFACE_PUBLIC bool is_chainable() const final
Get information if a controller is chainable.
Definition chainable_controller_interface.cpp:26
Definition controller_interface_base.hpp:67