Skip to content

Commit 904065d

Browse files
authored
Merge branch 'master' into integrate/pal_statistics
2 parents 9b750b1 + 5d4933d commit 904065d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+750
-138
lines changed

.github/workflows/humble-abi-compatibility.yml

+3-9
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ concurrency:
2121

2222
jobs:
2323
abi_check:
24-
runs-on: ubuntu-latest
25-
steps:
26-
- uses: actions/checkout@v4
27-
- uses: ros-industrial/industrial_ci@master
28-
env:
29-
ROS_DISTRO: humble
30-
ROS_REPO: testing
31-
ABICHECK_URL: github:${{ github.repository }}#${{ github.base_ref }}
32-
NOT_TEST_BUILD: true
24+
uses: ros-controls/ros2_control_ci/.github/workflows/reusable-abi-check.yml@master
25+
with:
26+
ros_distro: humble

.github/workflows/jazzy-abi-compatibility.yml

+3-9
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ concurrency:
2121

2222
jobs:
2323
abi_check:
24-
runs-on: ubuntu-latest
25-
steps:
26-
- uses: actions/checkout@v4
27-
- uses: ros-industrial/industrial_ci@master
28-
env:
29-
ROS_DISTRO: jazzy
30-
ROS_REPO: testing
31-
ABICHECK_URL: github:${{ github.repository }}#${{ github.base_ref }}
32-
NOT_TEST_BUILD: true
24+
uses: ros-controls/ros2_control_ci/.github/workflows/reusable-abi-check.yml@master
25+
with:
26+
ros_distro: jazzy

.github/workflows/rolling-abi-compatibility.yml

+3-9
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ concurrency:
2121

2222
jobs:
2323
abi_check:
24-
runs-on: ubuntu-latest
25-
steps:
26-
- uses: actions/checkout@v4
27-
- uses: ros-industrial/industrial_ci@master
28-
env:
29-
ROS_DISTRO: rolling
30-
ROS_REPO: testing
31-
ABICHECK_URL: github:${{ github.repository }}#${{ github.base_ref }}
32-
NOT_TEST_BUILD: true
24+
uses: ros-controls/ros2_control_ci/.github/workflows/reusable-abi-check.yml@master
25+
with:
26+
ros_distro: rolling

.pre-commit-config.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ repos:
5050
args: ["--ignore=D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D404"]
5151

5252
- repo: https://github.com/psf/black
53-
rev: 24.10.0
53+
rev: 25.1.0
5454
hooks:
5555
- id: black
5656
args: ["--line-length=99"]
@@ -63,7 +63,7 @@ repos:
6363

6464
# CPP hooks
6565
- repo: https://github.com/pre-commit/mirrors-clang-format
66-
rev: v19.1.5
66+
rev: v19.1.7
6767
hooks:
6868
- id: clang-format
6969
args: ['-fallback-style=none', '-i']
@@ -126,14 +126,14 @@ repos:
126126
# Spellcheck in comments and docs
127127
# skipping of *.svg files is not working...
128128
- repo: https://github.com/codespell-project/codespell
129-
rev: v2.3.0
129+
rev: v2.4.1
130130
hooks:
131131
- id: codespell
132132
args: ['--write-changes', '--uri-ignore-words-list=ist', '-L manuel']
133133
exclude: CHANGELOG\.rst|\.(svg|pyc|drawio)$
134134

135135
- repo: https://github.com/python-jsonschema/check-jsonschema
136-
rev: 0.30.0
136+
rev: 0.31.1
137137
hooks:
138138
- id: check-github-workflows
139139
args: ["--verbose"]

controller_interface/CHANGELOG.rst

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
Changelog for package controller_interface
33
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44

5+
4.26.0 (2025-02-07)
6+
-------------------
7+
* add a semantic command interface to "semantic_components" (`#1945 <https://github.com/ros-controls/ros2_control/issues/1945>`_)
8+
* Contributors: Thibault Poignonec
9+
510
4.25.0 (2025-01-29)
611
-------------------
712
* Use `target_compile_definitions` instead of installing test files (`#2009 <https://github.com/ros-controls/ros2_control/issues/2009>`_)

controller_interface/CMakeLists.txt

+19-1
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,30 @@ if(BUILD_TESTING)
8787
ament_target_dependencies(test_pose_sensor
8888
geometry_msgs
8989
)
90-
9190
ament_add_gmock(test_gps_sensor test/test_gps_sensor.cpp)
9291
target_link_libraries(test_gps_sensor
9392
controller_interface
9493
hardware_interface::hardware_interface
9594
)
95+
96+
# Semantic component command interface tests
97+
98+
ament_add_gmock(test_semantic_component_command_interface
99+
test/test_semantic_component_command_interface.cpp
100+
)
101+
target_link_libraries(test_semantic_component_command_interface
102+
controller_interface
103+
hardware_interface::hardware_interface
104+
)
105+
106+
ament_add_gmock(test_led_rgb_device test/test_led_rgb_device.cpp)
107+
target_link_libraries(test_led_rgb_device
108+
controller_interface
109+
hardware_interface::hardware_interface
110+
)
111+
ament_target_dependencies(test_led_rgb_device
112+
std_msgs
113+
)
96114
endif()
97115

98116
install(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Copyright (c) 2024, Sherpa Mobile 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 SEMANTIC_COMPONENTS__LED_RGB_DEVICE_HPP_
16+
#define SEMANTIC_COMPONENTS__LED_RGB_DEVICE_HPP_
17+
18+
#include <string>
19+
#include <vector>
20+
21+
#include "semantic_components/semantic_component_command_interface.hpp"
22+
#include "std_msgs/msg/color_rgba.hpp"
23+
24+
namespace semantic_components
25+
{
26+
class LedRgbDevice : public SemanticComponentCommandInterface<std_msgs::msg::ColorRGBA>
27+
{
28+
public:
29+
/**
30+
* Constructor for a LED RGB device with interface names set based on device name.
31+
* The constructor sets the command interface names to "<name>/interface_r",
32+
* "<name>/interface_g", "<name>/interface_b".
33+
*
34+
* \param[in] name name of the LED device, used as a prefix for the command interface names
35+
* \param[in] interface_r name of the command interface for the red channel
36+
* \param[in] interface_g name of the command interface for the green channel
37+
* \param[in] interface_b name of the command interface for the blue channel
38+
*/
39+
explicit LedRgbDevice(
40+
const std::string & name, const std::string & interface_r, const std::string & interface_g,
41+
const std::string & interface_b)
42+
: SemanticComponentCommandInterface(
43+
name, {{name + "/" + interface_r}, {name + "/" + interface_g}, {name + "/" + interface_b}})
44+
{
45+
}
46+
47+
/// Set LED states from ColorRGBA message
48+
49+
/**
50+
* Set the values of the LED RGB device from a ColorRGBA message.
51+
*
52+
* \details Sets the values of the red, green, and blue channels from the message.
53+
* If any of the values are out of the range [0, 1], the function fails and returns false.
54+
*
55+
* \param[in] message ColorRGBA message
56+
*
57+
* \return true if all values were set, false otherwise
58+
*/
59+
bool set_values_from_message(const std_msgs::msg::ColorRGBA & message) override
60+
{
61+
if (
62+
message.r < 0 || message.r > 1 || message.g < 0 || message.g > 1 || message.b < 0 ||
63+
message.b > 1)
64+
{
65+
return false;
66+
}
67+
bool all_set = true;
68+
all_set &= command_interfaces_[0].get().set_value(message.r);
69+
all_set &= command_interfaces_[1].get().set_value(message.g);
70+
all_set &= command_interfaces_[2].get().set_value(message.b);
71+
return all_set;
72+
}
73+
};
74+
75+
} // namespace semantic_components
76+
77+
#endif // SEMANTIC_COMPONENTS__LED_RGB_DEVICE_HPP_
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// Copyright (c) 2024, Sherpa Mobile 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 SEMANTIC_COMPONENTS__SEMANTIC_COMPONENT_COMMAND_INTERFACE_HPP_
16+
#define SEMANTIC_COMPONENTS__SEMANTIC_COMPONENT_COMMAND_INTERFACE_HPP_
17+
18+
#include <string>
19+
#include <vector>
20+
21+
#include "controller_interface/helpers.hpp"
22+
#include "hardware_interface/loaned_command_interface.hpp"
23+
24+
namespace semantic_components
25+
{
26+
template <typename MessageInputType>
27+
class SemanticComponentCommandInterface
28+
{
29+
public:
30+
SemanticComponentCommandInterface(
31+
const std::string & name, const std::vector<std::string> & interface_names)
32+
: name_(name), interface_names_(interface_names)
33+
{
34+
assert(interface_names.size() > 0);
35+
command_interfaces_.reserve(interface_names.size());
36+
}
37+
38+
virtual ~SemanticComponentCommandInterface() = default;
39+
40+
/// Assign loaned command interfaces from the hardware.
41+
/**
42+
* Assign loaned command interfaces on the controller start.
43+
*
44+
* \param[in] command_interfaces vector of command interfaces provided by the controller.
45+
*/
46+
bool assign_loaned_command_interfaces(
47+
std::vector<hardware_interface::LoanedCommandInterface> & command_interfaces)
48+
{
49+
return controller_interface::get_ordered_interfaces(
50+
command_interfaces, interface_names_, "", command_interfaces_);
51+
}
52+
53+
/// Release loaned command interfaces from the hardware.
54+
void release_interfaces() { command_interfaces_.clear(); }
55+
56+
/// Definition of command interface names for the component.
57+
/**
58+
* The function should be used in "command_interface_configuration()" of a controller to provide
59+
* standardized command interface names semantic component.
60+
*
61+
* \default Default implementation defined command interfaces as "name/NR" where NR is number
62+
* from 0 to size of values;
63+
* \return list of strings with command interface names for the semantic component.
64+
*/
65+
const std::vector<std::string> & get_command_interface_names() const { return interface_names_; }
66+
67+
/// Return all values.
68+
/**
69+
* \return true if it gets all the values, else false (i.e., invalid size or if the method
70+
* ``hardware_interface::LoanedCommandInterface::set_value`` fails).
71+
*/
72+
bool set_values(const std::vector<double> & values)
73+
{
74+
// check we have sufficient memory
75+
if (values.size() != command_interfaces_.size())
76+
{
77+
return false;
78+
}
79+
// set values
80+
bool all_set = true;
81+
for (auto i = 0u; i < values.size(); ++i)
82+
{
83+
all_set &= command_interfaces_[i].get().set_value(values[i]);
84+
}
85+
return all_set;
86+
}
87+
88+
/// Set values from MessageInputType
89+
/**
90+
* \return True if all values were set successfully, false otherwise.
91+
*/
92+
virtual bool set_values_from_message(const MessageInputType & /* message */) = 0;
93+
94+
protected:
95+
std::string name_;
96+
std::vector<std::string> interface_names_;
97+
std::vector<std::reference_wrapper<hardware_interface::LoanedCommandInterface>>
98+
command_interfaces_;
99+
};
100+
101+
} // namespace semantic_components
102+
103+
#endif // SEMANTIC_COMPONENTS__SEMANTIC_COMPONENT_COMMAND_INTERFACE_HPP_

controller_interface/package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
33
<package format="2">
44
<name>controller_interface</name>
5-
<version>4.25.0</version>
5+
<version>4.26.0</version>
66
<description>Description of controller_interface</description>
77
<maintainer email="bence.magyar.robotics@gmail.com">Bence Magyar</maintainer>
88
<maintainer email="denis@stoglrobotics.de">Denis Štogl</maintainer>

0 commit comments

Comments
 (0)