Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4931294
Add initial commit of generic state broadcaster
saikishor Nov 9, 2025
6875e65
Add first version of the tests
saikishor Nov 9, 2025
7e8e34a
change to new message types
saikishor Nov 16, 2025
d2a4b58
update tests
saikishor Nov 16, 2025
6e2980f
add state broadcaster params file
saikishor Nov 17, 2025
bfe9c80
rename the package to interfaces state broadcaster
saikishor Nov 17, 2025
a0b0b1c
Add release_notes
saikishor Nov 17, 2025
ce8f111
Merge branch 'master' into add/generic_state_broadcaster
saikishor Dec 10, 2025
dc9b673
Apply suggestions from code review
saikishor Dec 10, 2025
ec48562
Apply suggestions from code review
saikishor Dec 10, 2025
fdb6f6b
Apply suggestions from code review
saikishor Dec 10, 2025
b143897
Apply suggestions from code review
saikishor Dec 10, 2025
839dec3
pre-commit and minor fixes
saikishor Dec 10, 2025
69a46f8
remove wrong include
saikishor Dec 10, 2025
3e2b8ce
fix compilation
saikishor Dec 14, 2025
00c3fc3
Update interfaces_state_broadcaster/src/interfaces_state_broadcaster.cpp
saikishor Dec 14, 2025
7769bc6
Merge branch 'master' into add/generic_state_broadcaster
saikishor Dec 14, 2025
8b381ec
add pre-commit changes
saikishor Dec 14, 2025
a5bbdb1
update the documentation
saikishor Dec 14, 2025
6d07b97
Rename the package to state_interfaces_broadcaster
saikishor Dec 15, 2025
574ecab
add changes to support double data type
saikishor Dec 15, 2025
a8eb06a
Update state_interfaces_broadcaster/doc/userdoc.rst
saikishor Dec 15, 2025
a27c304
Apply suggestions from code review
christophfroehlich Dec 15, 2025
8b317e1
Update CMakeLists.txt
christophfroehlich Dec 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/controllers_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ In the sense of ros2_control, broadcasters are still controllers using the same

Force Torque Sensor Broadcaster <../force_torque_sensor_broadcaster/doc/userdoc.rst>
IMU Sensor Broadcaster <../imu_sensor_broadcaster/doc/userdoc.rst>
Interfaces State Broadcaster <../interfaces_state_broadcaster/doc/userdoc.rst>
Joint State Broadcaster <../joint_state_broadcaster/doc/userdoc.rst>
Range Sensor Broadcaster <../range_sensor_broadcaster/doc/userdoc.rst>
Pose Broadcaster <../pose_broadcaster/doc/userdoc.rst>
Expand Down
4 changes: 4 additions & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Release Notes: Kilted Kaiju to Lyrical Luth

This list summarizes important changes between Kilted Kaiju (previous) and Lyrical Luth (current) releases.

interfaces_state_broadcaster
*********************************
* 🚀 The interfaces_state_broadcaster was added 🎉 (`#2006 <https://github.com/ros-controls/ros2_controllers/pull/2006>`_).

force_torque_sensor_broadcaster
*******************************
* Added support for transforming Wrench messages to a given list of target frames. This is useful when applications need force/torque data in their preferred coordinate frames. (`#2021 <https://github.com/ros-controls/ros2_controllers/pull/2021/files>`__).
Expand Down
93 changes: 93 additions & 0 deletions interfaces_state_broadcaster/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
cmake_minimum_required(VERSION 3.16)
project(interfaces_state_broadcaster)

find_package(ros2_control_cmake REQUIRED)
set_compiler_options()
export_windows_symbols()

set(THIS_PACKAGE_INCLUDE_DEPENDS
builtin_interfaces
control_msgs
controller_interface
generate_parameter_library
pluginlib
rclcpp_lifecycle
realtime_tools
)

find_package(ament_cmake REQUIRED)
find_package(backward_ros REQUIRED)
foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS})
find_package(${Dependency} REQUIRED)
endforeach()

generate_parameter_library(interfaces_state_broadcaster_parameters
src/interfaces_state_broadcaster_parameters.yaml
)

add_library(interfaces_state_broadcaster SHARED
src/interfaces_state_broadcaster.cpp
)
target_compile_features(interfaces_state_broadcaster PUBLIC cxx_std_17)
target_include_directories(interfaces_state_broadcaster PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/interfaces_state_broadcaster>
)
target_link_libraries(interfaces_state_broadcaster PUBLIC
interfaces_state_broadcaster_parameters
controller_interface::controller_interface
pluginlib::pluginlib
rclcpp::rclcpp
rclcpp_lifecycle::rclcpp_lifecycle
realtime_tools::realtime_tools
${control_msgs_TARGETS}
${builtin_interfaces_TARGETS})
pluginlib_export_plugin_description_file(controller_interface interfaces_state_broadcaster_plugin.xml)

if(BUILD_TESTING)
find_package(ament_cmake_gmock REQUIRED)
find_package(controller_manager REQUIRED)
find_package(hardware_interface REQUIRED)
find_package(rclcpp REQUIRED)
find_package(ros2_control_test_assets REQUIRED)

ament_add_gmock(test_load_interfaces_state_broadcaster
test/test_load_interfaces_state_broadcaster.cpp
)
target_link_libraries(test_load_interfaces_state_broadcaster
interfaces_state_broadcaster
controller_manager::controller_manager
hardware_interface::hardware_interface
rclcpp::rclcpp
ros2_control_test_assets::ros2_control_test_assets)
target_compile_definitions(
test_load_interfaces_state_broadcaster
PRIVATE PARAMETERS_FILE_PATH="${CMAKE_CURRENT_LIST_DIR}/test/test_interfaces_state_broadcaster_params.yaml")

ament_add_gmock(test_interfaces_state_broadcaster
test/test_interfaces_state_broadcaster.cpp
)
target_link_libraries(test_interfaces_state_broadcaster
interfaces_state_broadcaster
ros2_control_test_assets::ros2_control_test_assets
rclcpp::rclcpp
${control_msgs_TARGETS})
endif()

install(
DIRECTORY include/
DESTINATION include/interfaces_state_broadcaster
)
install(
TARGETS
interfaces_state_broadcaster
interfaces_state_broadcaster_parameters
EXPORT export_interfaces_state_broadcaster
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)

ament_export_targets(export_interfaces_state_broadcaster HAS_LIBRARY_TARGET)
ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})
ament_package()
28 changes: 28 additions & 0 deletions interfaces_state_broadcaster/doc/userdoc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
:github_url: https://github.com/ros-controls/ros2_controllers/blob/{REPOS_FILE_BRANCH}/interfaces_state_broadcaster/doc/userdoc.rst

.. _interfaces_state_broadcaster_userdoc:

Interfaces State Broadcaster
--------------------------------
The Interfaces State Broadcaster publishes the state of specified hardware interfaces that support double data type.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not 100% true. "is_castable_to_double" is true for all datatypes we currently support, but the get_optional only works for double and bool with additional warning.
We should either limit it to double-only, or support all castable datatypes for real ;)
This is what I started here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change the logic internally to the code to reflect that

The broadcaster publishes two topics:

- ``/interfaces_state_broadcaster/names``: Publishes the names of the hardware interfaces being monitored with a message type of ``control_msgs/msg/Keys``.
- ``/interfaces_state_broadcaster/values``: Publishes the current state values of the specified hardware interfaces with a message type of ``control_msgs/msg/Float64Values``.

Parameters
^^^^^^^^^^^
This controller uses the `generate_parameter_library <https://github.com/PickNikRobotics/generate_parameter_library>`_ to handle its parameters. The parameter `definition file located in the src folder <https://github.com/ros-controls/ros2_controllers/blob/{REPOS_FILE_BRANCH}/interfaces_state_broadcaster/src/interfaces_state_broadcaster_parameters.yaml>`_ contains descriptions for all the parameters used by the controller.

List of parameters
=========================
.. generate_parameter_library_details:: ../src/interfaces_state_broadcaster_parameters.yaml


An example parameter file
=========================

An example parameter file for this controller can be found in `the test directory <https://github.com/ros-controls/ros2_controllers/blob/{REPOS_FILE_BRANCH}/interfaces_state_broadcaster/test/test_interfaces_state_broadcaster_params.yaml>`_:

.. literalinclude:: ../test/test_interfaces_state_broadcaster_params.yaml
:language: yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Copyright (c) 2025, PAL Robotics
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef INTERFACES_STATE_BROADCASTER__INTERFACES_STATE_BROADCASTER_HPP_
#define INTERFACES_STATE_BROADCASTER__INTERFACES_STATE_BROADCASTER_HPP_

#include <memory>
#include <string>
#include <unordered_map>
#include <vector>

#include "control_msgs/msg/float64_values.hpp"
#include "control_msgs/msg/keys.hpp"
#include "controller_interface/controller_interface.hpp"
#include "realtime_tools/realtime_publisher.hpp"

// auto-generated by generate_parameter_library
#include "interfaces_state_broadcaster/interfaces_state_broadcaster_parameters.hpp"

namespace interfaces_state_broadcaster
{
/**
* \brief Interfaces State Broadcaster for selected state interfaces in a ros2_control system.
*
* InterfacesStateBroadcaster publishes the selected state interfaces from ros2_control as ROS
* messages.
*
* Publishes to:
* - \b ~/names (control_msgs::msg::Keys): The list of the interface names that are selected
* to be published by the interfaces state broadcaster. This is published with transient local
* durability.
* - \b ~/values (control_msgs::msg::Float64Values): The list of the values corresponding to the
* interface names that are selected to be published by the interfaces state broadcaster.
*
* \note The values are published at the same rate as the controller update rate.
*/
class InterfacesStateBroadcaster : public controller_interface::ControllerInterface
{
public:
InterfacesStateBroadcaster();

controller_interface::InterfaceConfiguration command_interface_configuration() const override;

controller_interface::InterfaceConfiguration state_interface_configuration() const override;

controller_interface::return_type update(
const rclcpp::Time & time, const rclcpp::Duration & period) override;

controller_interface::CallbackReturn on_init() override;

controller_interface::CallbackReturn on_configure(
const rclcpp_lifecycle::State & previous_state) override;

controller_interface::CallbackReturn on_activate(
const rclcpp_lifecycle::State & previous_state) override;

protected:
// Optional parameters
std::shared_ptr<ParamListener> param_listener_;
Params params_;

// publishers and messages
std::shared_ptr<rclcpp::Publisher<control_msgs::msg::Keys>> names_publisher_;
std::shared_ptr<rclcpp::Publisher<control_msgs::msg::Float64Values>> values_publisher_;
std::shared_ptr<realtime_tools::RealtimePublisher<control_msgs::msg::Float64Values>>
realtime_values_publisher_;
control_msgs::msg::Keys names_msg_;
control_msgs::msg::Float64Values values_msg_;
};

} // namespace interfaces_state_broadcaster

#endif // INTERFACES_STATE_BROADCASTER__INTERFACES_STATE_BROADCASTER_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<library path="interfaces_state_broadcaster">
<class name="interfaces_state_broadcaster/InterfacesStateBroadcaster" type="interfaces_state_broadcaster::InterfacesStateBroadcaster" base_class_type="controller_interface::ControllerInterface">
<description>
The interfaces state broadcaster publishes the values of the requested interfaces from ros2_control system.
</description>
</class>
</library>
43 changes: 43 additions & 0 deletions interfaces_state_broadcaster/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0"?>
<package format="3">
<name>interfaces_state_broadcaster</name>
<version>5.8.0</version>
<description>Broadcaster to publish desired hardware interface states that are castable to double</description>

<maintainer email="[email protected]">Bence Magyar</maintainer>
<maintainer email="[email protected]">Denis Štogl</maintainer>
<maintainer email="[email protected]">Christoph Froehlich</maintainer>
<maintainer email="[email protected]">Sai Kishor Kothakota</maintainer>

<author email="[email protected]">Sai Kishor Kothakota</author>

<license>Apache License 2.0</license>

<url type="website">https://control.ros.org</url>
<url type="bugtracker">https://github.com/ros-controls/ros2_controllers/issues</url>
<url type="repository">https://github.com/ros-controls/ros2_controllers/</url>

<buildtool_depend>ament_cmake</buildtool_depend>

<build_depend>ros2_control_cmake</build_depend>

<depend>backward_ros</depend>
<depend>builtin_interfaces</depend>
<depend>control_msgs</depend>
<depend>controller_interface</depend>
<depend>generate_parameter_library</depend>
<depend>pluginlib</depend>
<depend>rclcpp_lifecycle</depend>
<depend>rclcpp</depend>
<depend>realtime_tools</depend>

<test_depend>ament_cmake_gmock</test_depend>
<test_depend>controller_manager</test_depend>
<test_depend>hardware_interface_testing</test_depend>
<test_depend>hardware_interface</test_depend>
<test_depend>ros2_control_test_assets</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Loading
Loading