Skip to content

Commit

Permalink
Merge branch 'ros-controls:master' into feature/issue-815-hardware-in…
Browse files Browse the repository at this point in the history
…terface-add-return-value
  • Loading branch information
flochre authored Sep 30, 2023
2 parents edb9c92 + 8141212 commit 4e0d021
Show file tree
Hide file tree
Showing 19 changed files with 219 additions and 47 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci-coverage-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on:
workflow_dispatch:
branches:
- master
push:
branches:
- master
pull_request:
branches:
- master
Expand All @@ -19,7 +22,7 @@ jobs:
- uses: ros-tooling/[email protected]
with:
required-ros-distributions: ${{ env.ROS_DISTRO }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ros-tooling/[email protected]
with:
target-ros2-distro: ${{ env.ROS_DISTRO }}
Expand Down Expand Up @@ -49,7 +52,7 @@ jobs:
file: ros_ws/lcov/total_coverage.info
flags: unittests
name: codecov-umbrella
- uses: actions/[email protected].2
- uses: actions/[email protected].3
with:
name: colcon-logs-ubuntu-22.04-coverage-rolling
path: ros_ws/log
2 changes: 1 addition & 1 deletion .github/workflows/ci-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
python-version: '3.10'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-ros-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
env:
AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ros-tooling/[email protected]
- uses: ros-tooling/[email protected]
with:
Expand All @@ -37,7 +37,7 @@ jobs:
matrix:
linter: [cpplint]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ros-tooling/[email protected]
- uses: ros-tooling/[email protected]
with:
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ jobs:

steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_release
tags: |
Expand All @@ -42,7 +42,7 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand All @@ -59,21 +59,21 @@ jobs:

steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}_source
tags: |
Expand All @@ -82,7 +82,7 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/humble-abi-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
abi_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ros-industrial/industrial_ci@master
env:
ROS_DISTRO: humble
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/humble-rhel-binary-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
ROS_DISTRO: humble
container: ghcr.io/ros-controls/ros:humble-rhel
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
path: src/ros2_control
- run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/iron-abi-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
abi_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ros-industrial/industrial_ci@master
env:
ROS_DISTRO: iron
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/iron-rhel-binary-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
ROS_DISTRO: iron
container: ghcr.io/ros-controls/ros:iron-rhel
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
path: src/ros2_control
- run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prerelease-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
pre_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- name: industrial_ci
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reusable-industrial-ci-with-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ jobs:
steps:
- name: Checkout ${{ inputs.ref }} when build is not scheduled
if: ${{ github.event_name != 'schedule' }}
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Checkout ${{ inputs.ref }} on scheduled build
if: ${{ github.event_name == 'schedule' }}
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref_for_scheduled_build }}
- name: cache target_ws
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reusable-ros-tooling-source-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- uses: ros-tooling/[email protected]
with:
required-ros-distributions: ${{ inputs.ros_distro }}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- uses: ros-tooling/[email protected]
Expand All @@ -49,7 +49,7 @@ jobs:
https://raw.githubusercontent.com/ros2/ros2/${{ inputs.ros2_repo_branch }}/ros2.repos
https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/ros2_control.${{ inputs.ros_distro }}.repos?token=${{ secrets.GITHUB_TOKEN }}
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
- uses: actions/[email protected].2
- uses: actions/[email protected].3
with:
name: colcon-logs-ubuntu-22.04
path: ros_ws/log
2 changes: 1 addition & 1 deletion .github/workflows/reviewer_lottery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: uesteibar/reviewer-lottery@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/rolling-rhel-binary-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
ROS_DISTRO: rolling
container: ghcr.io/ros-controls/ros:rolling-rhel
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
path: src/ros2_control
- run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class ControllerInterfaceBase : public rclcpp_lifecycle::node_interfaces::Lifecy
CONTROLLER_INTERFACE_PUBLIC
virtual return_type init(
const std::string & controller_name, const std::string & namespace_ = "",
const rclcpp::NodeOptions & node_options = rclcpp::NodeOptions());
const rclcpp::NodeOptions & node_options = rclcpp::NodeOptions().enable_logger_service(true));

/// Custom configure method to read additional parameters for controller-nodes
/*
Expand Down
14 changes: 10 additions & 4 deletions controller_manager/src/controller_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1639,11 +1639,17 @@ void ControllerManager::list_controllers_srv_cb(
}
}
// check reference interfaces only if controller is inactive or active
auto references = controllers[i].c->export_reference_interfaces();
controller_state.reference_interfaces.reserve(references.size());
for (const auto & reference : references)
if (controllers[i].c->is_chainable())
{
controller_state.reference_interfaces.push_back(reference.get_interface_name());
auto references =
resource_manager_->get_controller_reference_interface_names(controllers[i].info.name);
controller_state.reference_interfaces.reserve(references.size());
for (const auto & reference : references)
{
const std::string prefix_name = controllers[i].c->get_node()->get_name();
const std::string interface_name = reference.substr(prefix_name.size() + 1);
controller_state.reference_interfaces.push_back(interface_name);
}
}
}
response->controller.push_back(controller_state);
Expand Down
5 changes: 4 additions & 1 deletion controller_manager/test/test_controller_manager_srvs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ TEST_F(TestControllerManagerSrvs, list_chained_controllers_srv)
ASSERT_EQ(result->controller[0].is_chainable, true);
ASSERT_EQ(result->controller[0].is_chained, false);
ASSERT_EQ(result->controller[0].reference_interfaces.size(), 2u);
;
ASSERT_EQ("joint1/position", result->controller[0].reference_interfaces[0]);
ASSERT_EQ("joint1/velocity", result->controller[0].reference_interfaces[1]);

ASSERT_EQ(result->controller[0].chain_connections.size(), 0u);
// check test controller
ASSERT_EQ(result->controller[1].state, "inactive");
Expand Down Expand Up @@ -300,6 +302,7 @@ TEST_F(TestControllerManagerSrvs, list_chained_controllers_srv)
test_chainable_controller::TEST_CONTROLLER_NAME,
result->controller[0].chain_connections[0].name);
ASSERT_EQ(2u, result->controller[0].chain_connections[0].reference_interfaces.size());
ASSERT_EQ("test_chainable_controller_name", result->controller[0].chain_connections[0].name);
ASSERT_EQ("joint1/position", result->controller[0].chain_connections[0].reference_interfaces[0]);
ASSERT_EQ("joint1/velocity", result->controller[0].chain_connections[0].reference_interfaces[1]);
}
Expand Down
32 changes: 21 additions & 11 deletions hardware_interface/doc/hardware_components_userdoc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@ Guidelines and Best Practices
.. toctree::
:titlesonly:

Writing a Hardware Interface <writing_new_hardware_interface.rst>
Hardware Interface Types <hardware_interface_types_userdoc.rst>
Writing a Hardware Component <writing_new_hardware_component.rst>


Handling of errors that happen during read() and write() calls
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If ``hardware_interface::return_type::ERROR`` is returned from ``read()`` or ``write()`` methods of a hardware interface, ``on_error(previous_state)`` method will be called to handle any error that happened.
If ``hardware_interface::return_type::ERROR`` is returned from ``read()`` or ``write()`` methods of a hardware_interface class, ``on_error(previous_state)`` method will be called to handle any error that happened.

Error handling follows the `node lifecycle <https://design.ros2.org/articles/node_lifecycle.html>`_.
If successful ``CallbackReturn::SUCCESS`` is returned and hardware is again in ``UNCONFIGURED`` state, if any ``ERROR`` or ``FAILURE`` happens the hardware ends in ``FINALIZED`` state and can not be recovered.
The only option is to reload the complete plugin, but there is currently no service for this in the Controller Manager.

Migration from Foxy to Galactic
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Migration from Foxy to newer versions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Between Foxy and Galactic we made substantial changes to the interface of hardware components to enable management of their lifecycle.
The following list shows a set of quick changes to port existing hardware components to Galactic:
Expand All @@ -36,20 +37,29 @@ The following list shows a set of quick changes to port existing hardware compon

2. If using BaseInterface as base class then you should remove it. Specifically, change:

hardware_interface::BaseInterface<hardware_interface::[Actuator|Sensor|System]Interface> to hardware_interface::[Actuator|Sensor|System]Interface
.. code-block:: c++

hardware_interface::BaseInterface<hardware_interface::[Actuator|Sensor|System]Interface>

to

.. code-block:: c++

hardware_interface::[Actuator|Sensor|System]Interface

3. Remove include of headers ``base_interface.hpp`` and ``hardware_interface_status_values.hpp``

4. Add include of header ``rclcpp_lifecycle/state.hpp`` although this may not be strictly necessary

5. replace first three lines in ``on_init`` to:
5. replace first three lines in ``on_init`` to

.. code-block:: c++

.. code-block:: c++
if (hardware_interface::[Actuator|Sensor|System]Interface::on_init(info) != CallbackReturn::SUCCESS)
{
return CallbackReturn::ERROR;
}

if (hardware_interface::[Actuator|Sensor|System]Interface::on_init(info) != CallbackReturn::SUCCESS)
{
return CallbackReturn::ERROR;
}

6. Change last return of ``on_init`` to ``return CallbackReturn::SUCCESS;``

Expand Down
Loading

0 comments on commit 4e0d021

Please sign in to comment.