ros2_control - rolling
pose_broadcaster.hpp
1 // Copyright 2024 FZI Forschungszentrum Informatik
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 #ifndef POSE_BROADCASTER__POSE_BROADCASTER_HPP_
15 #define POSE_BROADCASTER__POSE_BROADCASTER_HPP_
16 
17 #include <array>
18 #include <memory>
19 #include <optional>
20 #include <string>
21 
22 #include "controller_interface/controller_interface.hpp"
23 #include "geometry_msgs/msg/pose_stamped.hpp"
24 #include "pose_broadcaster/visibility_control.h"
25 #include "pose_broadcaster_parameters.hpp"
26 #include "rclcpp/publisher.hpp"
27 #include "rclcpp_lifecycle/state.hpp"
28 #include "realtime_tools/realtime_publisher.hpp"
29 #include "semantic_components/pose_sensor.hpp"
30 #include "tf2_msgs/msg/tf_message.hpp"
31 
32 namespace pose_broadcaster
33 {
34 
36 {
37 public:
38  POSE_BROADCASTER_PUBLIC controller_interface::InterfaceConfiguration
39  command_interface_configuration() const override;
40 
41  POSE_BROADCASTER_PUBLIC controller_interface::InterfaceConfiguration
42  state_interface_configuration() const override;
43 
44  POSE_BROADCASTER_PUBLIC controller_interface::CallbackReturn on_init() override;
45 
46  POSE_BROADCASTER_PUBLIC controller_interface::CallbackReturn on_configure(
47  const rclcpp_lifecycle::State & previous_state) override;
48 
49  POSE_BROADCASTER_PUBLIC controller_interface::CallbackReturn on_activate(
50  const rclcpp_lifecycle::State & previous_state) override;
51 
52  POSE_BROADCASTER_PUBLIC controller_interface::CallbackReturn on_deactivate(
53  const rclcpp_lifecycle::State & previous_state) override;
54 
55  POSE_BROADCASTER_PUBLIC controller_interface::return_type update(
56  const rclcpp::Time & time, const rclcpp::Duration & period) override;
57 
58 private:
59  std::shared_ptr<ParamListener> param_listener_;
60  Params params_;
61 
62  std::unique_ptr<semantic_components::PoseSensor> pose_sensor_;
63 
64  rclcpp::Publisher<geometry_msgs::msg::PoseStamped>::SharedPtr pose_publisher_;
65  std::unique_ptr<realtime_tools::RealtimePublisher<geometry_msgs::msg::PoseStamped>>
66  realtime_publisher_;
67 
68  std::optional<rclcpp::Duration> tf_publish_period_;
69  rclcpp::Time tf_last_publish_time_{0, 0, RCL_CLOCK_UNINITIALIZED};
70  rclcpp::Publisher<tf2_msgs::msg::TFMessage>::SharedPtr tf_publisher_;
71  std::unique_ptr<realtime_tools::RealtimePublisher<tf2_msgs::msg::TFMessage>>
72  realtime_tf_publisher_;
73 };
74 
75 } // namespace pose_broadcaster
76 
77 #endif // POSE_BROADCASTER__POSE_BROADCASTER_HPP_
Definition: controller_interface.hpp:28
Definition: pose_broadcaster.hpp:36
POSE_BROADCASTER_PUBLIC controller_interface::InterfaceConfiguration state_interface_configuration() const override
Get configuration for controller's required state interfaces.
Definition: pose_broadcaster.cpp:35
POSE_BROADCASTER_PUBLIC controller_interface::return_type update(const rclcpp::Time &time, const rclcpp::Duration &period) override
Definition: pose_broadcaster.cpp:138
POSE_BROADCASTER_PUBLIC controller_interface::CallbackReturn on_init() override
Extending interface with initialization method which is individual for each controller.
Definition: pose_broadcaster.cpp:44
POSE_BROADCASTER_PUBLIC controller_interface::InterfaceConfiguration command_interface_configuration() const override
Get configuration for controller's required command interfaces.
Definition: pose_broadcaster.cpp:27
Configuring what command/state interfaces to claim.
Definition: controller_interface_base.hpp:58