Skip to content

Commit

Permalink
Merge branch 'master' into improve/memory_allocation/buffer_variables
Browse files Browse the repository at this point in the history
  • Loading branch information
destogl authored Feb 12, 2025
2 parents 636fdd0 + 5d4933d commit 0308c61
Show file tree
Hide file tree
Showing 98 changed files with 4,530 additions and 460 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
16 changes: 16 additions & 0 deletions controller_interface/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
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>`_)
* Contributors: Christoph Fröhlich

4.23.0 (2024-12-29)
-------------------
* Remove boilerplate visibility macros (`#1972 <https://github.com/ros-controls/ros2_control/issues/1972>`_)
Expand Down
29 changes: 27 additions & 2 deletions controller_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ if(BUILD_TESTING)
)

ament_add_gmock(test_controller_with_options test/test_controller_with_options.cpp)
install(FILES test/test_controller_node_options.yaml
DESTINATION test)
target_link_libraries(test_controller_with_options
controller_interface
)
target_compile_definitions(
test_controller_with_options
PRIVATE PARAMETERS_FILE_PATH="${CMAKE_CURRENT_LIST_DIR}/test/")

ament_add_gmock(test_chainable_controller_interface test/test_chainable_controller_interface.cpp)
target_link_libraries(test_chainable_controller_interface
Expand Down Expand Up @@ -86,6 +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
Expand Up @@ -99,7 +99,7 @@ class ControllerInterfaceBase : public rclcpp_lifecycle::node_interfaces::Lifecy
public:
ControllerInterfaceBase() = default;

virtual ~ControllerInterfaceBase() = default;
virtual ~ControllerInterfaceBase();

/// Get configuration for controller's required command interfaces.
/**
Expand Down
136 changes: 136 additions & 0 deletions controller_interface/include/semantic_components/gps_sensor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// Copyright 2025 ros2_control development team
//
// 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__GPS_SENSOR_HPP_
#define SEMANTIC_COMPONENTS__GPS_SENSOR_HPP_

#include <array>
#include <string>

#include "semantic_components/semantic_component_interface.hpp"
#include "sensor_msgs/msg/nav_sat_fix.hpp"

namespace semantic_components
{

enum class GPSSensorOption
{
WithCovariance,
WithoutCovariance
};

template <GPSSensorOption sensor_option>
class GPSSensor : public SemanticComponentInterface<sensor_msgs::msg::NavSatFix>
{
public:
static_assert(
sensor_option == GPSSensorOption::WithCovariance ||
sensor_option == GPSSensorOption::WithoutCovariance,
"Invalid GPSSensorOption");
explicit GPSSensor(const std::string & name)
: SemanticComponentInterface(
name, {{name + "/" + "status"},
{name + "/" + "service"},
{name + "/" + "latitude"},
{name + "/" + "longitude"},
{name + "/" + "altitude"}})
{
if constexpr (sensor_option == GPSSensorOption::WithCovariance)
{
interface_names_.emplace_back(name + "/" + "latitude_covariance");
interface_names_.emplace_back(name + "/" + "longitude_covariance");
interface_names_.emplace_back(name + "/" + "altitude_covariance");
}
}

/**
* Return GPS's status e.g. fix/no_fix
*
* \return Status
*/
int8_t get_status() const { return static_cast<int8_t>(state_interfaces_[0].get().get_value()); }

/**
* Return service used by GPS e.g. fix/no_fix
*
* \return Service
*/
uint16_t get_service() const
{
return static_cast<uint16_t>(state_interfaces_[1].get().get_value());
}

/**
* Return latitude reported by a GPS
*
* \return Latitude.
*/
double get_latitude() const { return state_interfaces_[2].get().get_value(); }

/**
* Return longitude reported by a GPS
*
* \return Longitude.
*/
double get_longitude() const { return state_interfaces_[3].get().get_value(); }

/**
* Return altitude reported by a GPS
*
* \return Altitude.
*/
double get_altitude() const { return state_interfaces_[4].get().get_value(); }

/**
* Return covariance reported by a GPS.
*
* \return Covariance array.
*/
template <
typename U = void,
typename = std::enable_if_t<sensor_option == GPSSensorOption::WithCovariance, U>>
const std::array<double, 9> & get_covariance()
{
covariance_[0] = state_interfaces_[5].get().get_value();
covariance_[4] = state_interfaces_[6].get().get_value();
covariance_[8] = state_interfaces_[7].get().get_value();
return covariance_;
}

/**
* Fills a NavSatFix message from the current values.
*/
bool get_values_as_message(sensor_msgs::msg::NavSatFix & message)
{
message.status.status = get_status();
message.status.service = get_service();
message.latitude = get_latitude();
message.longitude = get_longitude();
message.altitude = get_altitude();

if constexpr (sensor_option == GPSSensorOption::WithCovariance)
{
message.position_covariance = get_covariance();
}

return true;
}

private:
std::array<double, 9> covariance_{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}};
};

} // namespace semantic_components

#endif // SEMANTIC_COMPONENTS__GPS_SENSOR_HPP_
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_
Loading

0 comments on commit 0308c61

Please sign in to comment.