ros2_control - rolling
Loading...
Searching...
No Matches
joint_command_topic_hardware_interface.hpp
1// Copyright 2026 ros2_control Development Team
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/* Author: Kamalkant Thangaraju */
16
17#pragma once
18
19// C++
20#include <map>
21#include <memory>
22#include <string>
23#include <vector>
24
25// ROS
26#include <hardware_interface/system_interface.hpp>
27#include <hardware_interface/types/hardware_component_interface_params.hpp>
28#include <rclcpp/node.hpp>
29#include <rclcpp/publisher.hpp>
30#include <rclcpp/subscription.hpp>
31#include <realtime_tools/realtime_buffer.hpp>
32
33#include <control_msgs/msg/joint_command.hpp>
34#include <sensor_msgs/msg/joint_state.hpp>
35
36namespace joint_command_topic_hardware_interface
37{
38using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn;
39
41{
42public:
43 CallbackReturn on_init(const hardware_interface::HardwareComponentInterfaceParams& params) override;
44
45 hardware_interface::return_type read(const rclcpp::Time& time, const rclcpp::Duration& period) override;
46
47 hardware_interface::return_type write(const rclcpp::Time& time, const rclcpp::Duration& period) override;
48
49private:
50 struct JointCommandGroup
51 {
52 std::string interface_name;
53 std::vector<std::string> joint_names;
54 std::vector<std::string> command_keys;
55 control_msgs::msg::JointCommand msg;
56 };
57
58 rclcpp::Subscription<sensor_msgs::msg::JointState>::SharedPtr topic_based_joint_states_subscriber_;
59 std::map<std::string, rclcpp::Publisher<control_msgs::msg::JointCommand>::SharedPtr>
60 topic_based_joint_command_publishers_;
61 std::map<std::string, JointCommandGroup> command_groups_;
63 bool sum_wrapped_joint_states_{ false };
64
65 double trigger_joint_command_threshold_ = 1e-5;
66};
67
68} // namespace joint_command_topic_hardware_interface
Virtual Class to implement when integrating a complex system into ros2_control.
Definition system_interface.hpp:67
Definition joint_command_topic_hardware_interface.hpp:41
hardware_interface::return_type read(const rclcpp::Time &time, const rclcpp::Duration &period) override
Read the current state values from the hardware.
Definition joint_command_topic_hardware_interface.cpp:110
hardware_interface::return_type write(const rclcpp::Time &time, const rclcpp::Duration &period) override
Write the current command values to the hardware.
Definition joint_command_topic_hardware_interface.cpp:183
CallbackReturn on_init(const hardware_interface::HardwareComponentInterfaceParams &params) override
Initialization of the hardware interface from data parsed from the robot's URDF.
Definition joint_command_topic_hardware_interface.cpp:44
Definition realtime_buffer.hpp:57
Parameters required for the initialization of a specific hardware component plugin....
Definition hardware_component_interface_params.hpp:32