Skip to content

Commit

Permalink
Merge branch 'master' into fix/async/controller/deactivation
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor authored Feb 12, 2025
2 parents 772c788 + 5d4933d commit 788a253
Show file tree
Hide file tree
Showing 63 changed files with 899 additions and 142 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/humble-abi-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ concurrency:

jobs:
abi_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ros-industrial/industrial_ci@master
env:
ROS_DISTRO: humble
ROS_REPO: testing
ABICHECK_URL: github:${{ github.repository }}#${{ github.base_ref }}
NOT_TEST_BUILD: true
uses: ros-controls/ros2_control_ci/.github/workflows/reusable-abi-check.yml@master
with:
ros_distro: humble
12 changes: 3 additions & 9 deletions .github/workflows/jazzy-abi-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ concurrency:

jobs:
abi_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ros-industrial/industrial_ci@master
env:
ROS_DISTRO: jazzy
ROS_REPO: testing
ABICHECK_URL: github:${{ github.repository }}#${{ github.base_ref }}
NOT_TEST_BUILD: true
uses: ros-controls/ros2_control_ci/.github/workflows/reusable-abi-check.yml@master
with:
ros_distro: jazzy
12 changes: 3 additions & 9 deletions .github/workflows/rolling-abi-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ concurrency:

jobs:
abi_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ros-industrial/industrial_ci@master
env:
ROS_DISTRO: rolling
ROS_REPO: testing
ABICHECK_URL: github:${{ github.repository }}#${{ github.base_ref }}
NOT_TEST_BUILD: true
uses: ros-controls/ros2_control_ci/.github/workflows/reusable-abi-check.yml@master
with:
ros_distro: rolling
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ repos:
args: ["--ignore=D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D404"]

- repo: https://github.com/psf/black
rev: 24.10.0
rev: 25.1.0
hooks:
- id: black
args: ["--line-length=99"]
Expand All @@ -63,7 +63,7 @@ repos:

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

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.30.0
rev: 0.31.1
hooks:
- id: check-github-workflows
args: ["--verbose"]
Expand Down
11 changes: 11 additions & 0 deletions controller_interface/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
Changelog for package controller_interface
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

4.26.0 (2025-02-07)
-------------------
* add a semantic command interface to "semantic_components" (`#1945 <https://github.com/ros-controls/ros2_control/issues/1945>`_)
* Contributors: Thibault Poignonec

4.25.0 (2025-01-29)
-------------------
* Use `target_compile_definitions` instead of installing test files (`#2009 <https://github.com/ros-controls/ros2_control/issues/2009>`_)
* Add GPS semantic component (`#2000 <https://github.com/ros-controls/ros2_control/issues/2000>`_)
* Contributors: Sai Kishor Kothakota, Wiktor Bajor

4.24.0 (2025-01-13)
-------------------
* Trigger shutdown transition in destructor (`#1979 <https://github.com/ros-controls/ros2_control/issues/1979>`_)
Expand Down
20 changes: 19 additions & 1 deletion controller_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,30 @@ if(BUILD_TESTING)
ament_target_dependencies(test_pose_sensor
geometry_msgs
)

ament_add_gmock(test_gps_sensor test/test_gps_sensor.cpp)
target_link_libraries(test_gps_sensor
controller_interface
hardware_interface::hardware_interface
)

# Semantic component command interface tests

ament_add_gmock(test_semantic_component_command_interface
test/test_semantic_component_command_interface.cpp
)
target_link_libraries(test_semantic_component_command_interface
controller_interface
hardware_interface::hardware_interface
)

ament_add_gmock(test_led_rgb_device test/test_led_rgb_device.cpp)
target_link_libraries(test_led_rgb_device
controller_interface
hardware_interface::hardware_interface
)
ament_target_dependencies(test_led_rgb_device
std_msgs
)
endif()

install(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright (c) 2024, Sherpa Mobile 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 SEMANTIC_COMPONENTS__LED_RGB_DEVICE_HPP_
#define SEMANTIC_COMPONENTS__LED_RGB_DEVICE_HPP_

#include <string>
#include <vector>

#include "semantic_components/semantic_component_command_interface.hpp"
#include "std_msgs/msg/color_rgba.hpp"

namespace semantic_components
{
class LedRgbDevice : public SemanticComponentCommandInterface<std_msgs::msg::ColorRGBA>
{
public:
/**
* Constructor for a LED RGB device with interface names set based on device name.
* The constructor sets the command interface names to "<name>/interface_r",
* "<name>/interface_g", "<name>/interface_b".
*
* \param[in] name name of the LED device, used as a prefix for the command interface names
* \param[in] interface_r name of the command interface for the red channel
* \param[in] interface_g name of the command interface for the green channel
* \param[in] interface_b name of the command interface for the blue channel
*/
explicit LedRgbDevice(
const std::string & name, const std::string & interface_r, const std::string & interface_g,
const std::string & interface_b)
: SemanticComponentCommandInterface(
name, {{name + "/" + interface_r}, {name + "/" + interface_g}, {name + "/" + interface_b}})
{
}

/// Set LED states from ColorRGBA message

/**
* Set the values of the LED RGB device from a ColorRGBA message.
*
* \details Sets the values of the red, green, and blue channels from the message.
* If any of the values are out of the range [0, 1], the function fails and returns false.
*
* \param[in] message ColorRGBA message
*
* \return true if all values were set, false otherwise
*/
bool set_values_from_message(const std_msgs::msg::ColorRGBA & message) override
{
if (
message.r < 0 || message.r > 1 || message.g < 0 || message.g > 1 || message.b < 0 ||
message.b > 1)
{
return false;
}
bool all_set = true;
all_set &= command_interfaces_[0].get().set_value(message.r);
all_set &= command_interfaces_[1].get().set_value(message.g);
all_set &= command_interfaces_[2].get().set_value(message.b);
return all_set;
}
};

} // namespace semantic_components

#endif // SEMANTIC_COMPONENTS__LED_RGB_DEVICE_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// Copyright (c) 2024, Sherpa Mobile 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 SEMANTIC_COMPONENTS__SEMANTIC_COMPONENT_COMMAND_INTERFACE_HPP_
#define SEMANTIC_COMPONENTS__SEMANTIC_COMPONENT_COMMAND_INTERFACE_HPP_

#include <string>
#include <vector>

#include "controller_interface/helpers.hpp"
#include "hardware_interface/loaned_command_interface.hpp"

namespace semantic_components
{
template <typename MessageInputType>
class SemanticComponentCommandInterface
{
public:
SemanticComponentCommandInterface(
const std::string & name, const std::vector<std::string> & interface_names)
: name_(name), interface_names_(interface_names)
{
assert(interface_names.size() > 0);
command_interfaces_.reserve(interface_names.size());
}

virtual ~SemanticComponentCommandInterface() = default;

/// Assign loaned command interfaces from the hardware.
/**
* Assign loaned command interfaces on the controller start.
*
* \param[in] command_interfaces vector of command interfaces provided by the controller.
*/
bool assign_loaned_command_interfaces(
std::vector<hardware_interface::LoanedCommandInterface> & command_interfaces)
{
return controller_interface::get_ordered_interfaces(
command_interfaces, interface_names_, "", command_interfaces_);
}

/// Release loaned command interfaces from the hardware.
void release_interfaces() { command_interfaces_.clear(); }

/// Definition of command interface names for the component.
/**
* The function should be used in "command_interface_configuration()" of a controller to provide
* standardized command interface names semantic component.
*
* \default Default implementation defined command interfaces as "name/NR" where NR is number
* from 0 to size of values;
* \return list of strings with command interface names for the semantic component.
*/
const std::vector<std::string> & get_command_interface_names() const { return interface_names_; }

/// Return all values.
/**
* \return true if it gets all the values, else false (i.e., invalid size or if the method
* ``hardware_interface::LoanedCommandInterface::set_value`` fails).
*/
bool set_values(const std::vector<double> & values)
{
// check we have sufficient memory
if (values.size() != command_interfaces_.size())
{
return false;
}
// set values
bool all_set = true;
for (auto i = 0u; i < values.size(); ++i)
{
all_set &= command_interfaces_[i].get().set_value(values[i]);
}
return all_set;
}

/// Set values from MessageInputType
/**
* \return True if all values were set successfully, false otherwise.
*/
virtual bool set_values_from_message(const MessageInputType & /* message */) = 0;

protected:
std::string name_;
std::vector<std::string> interface_names_;
std::vector<std::reference_wrapper<hardware_interface::LoanedCommandInterface>>
command_interfaces_;
};

} // namespace semantic_components

#endif // SEMANTIC_COMPONENTS__SEMANTIC_COMPONENT_COMMAND_INTERFACE_HPP_
2 changes: 1 addition & 1 deletion controller_interface/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>controller_interface</name>
<version>4.24.0</version>
<version>4.26.0</version>
<description>Description of controller_interface</description>
<maintainer email="[email protected]">Bence Magyar</maintainer>
<maintainer email="[email protected]">Denis Štogl</maintainer>
Expand Down
Loading

0 comments on commit 788a253

Please sign in to comment.