Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
630d20d
reverting last commits to cf69b76
May 29, 2023
2c239b3
Add new ROS2 dynamic SH
Jun 15, 2021
f269f54
Add static and dynamic SHs to CI matrix
jamoralp Jun 16, 2021
f032a5f
Change Integration Service core branch
lauramg15 Jun 16, 2021
d6e8f19
Requested Changes
Jun 16, 2021
4a413af
Fix CMakeList
Jun 16, 2021
5ccddd5
const
Jun 16, 2021
32eea9b
finishedfor
Jun 16, 2021
5aa5086
Add first simple test
jamoralp Jun 16, 2021
4a1f83a
Avoid infinite loop
Jun 17, 2021
53c013e
New functionality for 'using' YAML tag
Jun 17, 2021
7ec885c
Add tests to Dynamic SystemHandle
Jun 21, 2021
16016a8
Fix ROS 2 Dynamic Tests for Galactic
Jun 21, 2021
976a4f9
Change outdated comment
Jun 21, 2021
f0e1cda
Update Readme
Jun 22, 2021
bf26b66
API Reference
Jun 22, 2021
b22d77a
Avoid creation of file no longer neccessary
Jun 22, 2021
6d987bc
Add support for IDLs with several modules and structures
Jul 1, 2021
0c12cdd
Adapt CI until the branches are merged
Jul 1, 2021
24231b1
Add support for QoS
Jul 5, 2021
0b718e4
Fix nanosec calculus
Jul 6, 2021
9b3f9ec
Adapt ROS 2 QoS tests to dynamic SystemHandle
Jul 12, 2021
260286b
Add option to disable internal communication
Jul 14, 2021
2404c57
Add comments to dynamic system handle
Aug 5, 2021
4c000a9
Unify Logger between System Handles [12339] (#33)
lauramg15 Aug 10, 2021
a8dd8bd
Use correct variable to reference the python3 interpreter (#37)
EduPonz Apr 26, 2023
6d7a611
Refs 18334. Fixing tests CMakeLists.txt for humble
Apr 27, 2023
0844470
Refs 18334. Rely on cmake versioning instead of heuristics to select …
Apr 28, 2023
79da828
fix flaky geometry msgs test accounting slow performance of debug bin…
May 3, 2023
35549b6
missing fixes in the rebase
May 29, 2023
b8d7fda
refactor CMake for non-docker use
May 30, 2023
da31158
fixing building issues
May 30, 2023
33e1d2e
fix testing due new topic pub behavior
May 31, 2023
2df9b41
removing pre-merge branch dependencies
Jun 8, 2023
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
19 changes: 10 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,32 @@ jobs:
ros2-sh_CI:
strategy:
matrix:
node: [foxy, galactic]
ros2_version: [foxy, galactic, humble]
sh_mode: [static, dynamic]

runs-on: ubuntu-20.04
container: ros:${{ matrix.node }}
runs-on: ubuntu-22.04
container: ros:${{ matrix.ros2_version }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
path: src/ros2-sh

- name: Download required dependencies
run: |
apt update
DEBIAN_FRONTEND=noninteractive apt install -y cmake gcc g++ git libboost-dev libboost-program-options-dev libyaml-cpp-dev ros-${{ matrix.node }}-rmw-fastrtps-cpp
DEBIAN_FRONTEND=noninteractive apt install -y cmake gcc g++ git libboost-dev libboost-program-options-dev libyaml-cpp-dev ros-${{ matrix.ros2_version }}-rmw-fastrtps-cpp

- name: Download the Integration Service
run: |
git clone --recursive https://github.com/eProsima/Integration-Service src/integration-service
git clone https://github.com/eProsima/Integration-Service src/integration-service

- name: Build
run: |
. /opt/ros/${{ matrix.node }}/setup.sh
colcon build --cmake-args -DCMAKE_BUILD_TYPE=DEBUG -DBUILD_ROS2_TESTS=ON --event-handlers console_direct+
/ros_entrypoint.sh colcon build --cmake-args -DCMAKE_BUILD_TYPE=DEBUG -DBUILD_ROS2_TESTS=ON -DIS_ROS2_SH_MODE=${{ matrix.sh_mode }} --event-handlers console_direct+

- name: Test
run: |
. /opt/ros/${{ matrix.node }}/setup.sh && . install/local_setup.sh && RMW_IMPLEMENTATION=rmw_fastrtps_cpp colcon test --packages-select is-ros2 --event-handlers console_direct+
. install/setup.sh
RMW_IMPLEMENTATION=rmw_fastrtps_cpp colcon test --packages-select is-ros2 --event-handlers console_direct+
colcon test-result
59 changes: 46 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,38 @@ implementation for the *xTypes* protocol, that is, [eProsima xTypes](https://git

<a href="https://docs.ros.org/en/foxy/"><img src="docs/images/ros2_logo.png" align="left" hspace="8" vspace="0" width="90"></a>

This repository contains the source code of *Integration Service* **System Handle**
This repository contains the source code of *Integration Service* **System Handles**
for the [ROS 2](https://docs.ros.org/en/foxy) middleware protocol, widely used in the robotics field.
Two implementations can be distinguished: **static** one based on *ROS 2* `rclcpp` and **dynamic** one based on *Fast DDS* (by the moment it is only available for the Publisher-Subscriber paradigm).

This *System Handle* can be used for two main purposes:
This *System Handles* can be used for two main purposes:

1. Connection between a *ROS 2* application and an application running over a different middleware implementation.
This is the classic use-case approach for *Integration Service*.

1. Connecting two *ROS 2* applications running under different Domain IDs.

The main advantages of the *Dynamic ROS 2 System Handle* over the *Static ROS 2 System Handle* are the following ones:

1. It allows using types defined by *IDL* without previously generating and installing the ROS 2 Type
Support for that type, which gives it a greater versatility with respect to the *Static ROS 2 System
Handle*.

1. It is not necessary to decide which ROS 2 builtin types you are going to use during the compilation
phase, as it allows you to use any of them.

## Dependencies

This section provides a list of the dependencies needed in order to compile *ROS 2 System Handle*.
This section provides a list of the dependencies needed in order to compile *ROS 2 System Handles*.

**Static ROS 2 System Handle**

* [ROS 2](https://docs.ros.org/en/foxy/Installation.html): *Foxy/Galactic ROS 2* distribution.

**Dynamic ROS 2 System Handle**

* [Fast DDS](https://github.com/eProsima/Fast-DDS#installation-guide): eProsima C++ implementation for DDS.

## Configuration

*Integration Service* is configured by means of a YAML configuration file, which specifies
Expand All @@ -51,7 +67,7 @@ To get a more precise idea on how these YAML files have to be filled and which f
in order to succesfully configure and launch an *Integration Service* project, please refer to the
[dedicated configuration section](https://integration-service.docs.eprosima.com/en/latest/user_manual/yaml_config.html) of the official documentation.

Regarding the *ROS 2 System Handle*, there are several specific parameters which can be configured
Regarding the *ROS 2 System Handles*, there are several specific parameters which can be configured
for the ROS 2 middleware. All of these parameters are optional, and fall as suboptions of the main
five sections described in the *Configuration* chapter of the *Integration Service* repository:

Expand Down Expand Up @@ -118,18 +134,31 @@ five sections described in the *Configuration* chapter of the *Integration Servi
* `reliability`: This QoS indicates the level of reliability offered and requested by the service.
There are two possible values: `RELIABLE` and `BEST_EFFORT`.

The *Dynamic ROS 2 System Handle* has an additional parameter:

```yaml
systems:
ros2:
type: ros2_dynamic
namespace: "/"
node_name: "my_ros2_node"
domain: 4
using: [std_msgs/String, geometry_msgs]
```
* `using`: List of the *ROS 2* builtin types or packages that want to be used in the communication.

## Examples

There are several *Integration Service* examples using the *ROS 2 System Handle* available
There are several *Integration Service* examples using the *Static ROS 2 System Handle* available
in the project's [main source code repository]([https://](https://github.com/eProsima/Integration-Service/tree/main/examples)).

Some of these examples, where the *ROS 2 System Handle* plays a different role in each of them, are introduced here.
Some of these examples, where the *Static ROS 2 System Handle* plays a different role in each of them, are introduced here.

<a href="https://integration-service.docs.eprosima.com/en/latest/examples/different_protocols/pubsub/ros1-ros2.html"><img align="left" width="15" height="38" src="https://via.placeholder.com/15/40c15d/000000?text=+" alt="Green icon"></a>

### ROS 2 - ROS 1 bridge (publisher - subscriber)

In this example, *Integration Service* uses both this *ROS 2 System Handle* and the *ROS 1 System Handle*
In this example, *Integration Service* uses both this *Static ROS 2 System Handle* and the *ROS 1 System Handle*
to transmit data coming from a ROS 2 publisher into the ROS 1 data space, so that it can be
consumed by a ROS 1 subscriber on the same topic, and viceversa.

Expand All @@ -147,7 +176,7 @@ For a detailed step by step guide on how to build and test this example, please

### ROS 2 - DDS bridge (publisher - subscriber)

In this example, *Integration Service* uses both this *ROS 2 System Handle* and the *Fast DDS System Handle*
In this example, *Integration Service* uses both this *Static ROS 2 System Handle* and the *Fast DDS System Handle*
to transmit data coming from a ROS 2 publisher into the DDS data space, so that it can be
consumed by a Fast DDS subscriber on the same topic, and viceversa.

Expand All @@ -165,7 +194,7 @@ For a detailed step by step guide on how to build and test this example, please

### ROS 2 - WebSocket bridge (publisher - subscriber)

In this example, *Integration Service* uses both this *ROS 2 System Handle* and the *WebSocket System Handle*
In this example, *Integration Service* uses both this *Static ROS 2 System Handle* and the *WebSocket System Handle*
to transmit data coming from a ROS 2 publisher to a WebSocket Client, and viceversa.

<p align="center">
Expand All @@ -182,7 +211,7 @@ For a detailed step by step guide on how to build and test this example, please

### ROS 2 - FIWARE bridge (publisher - subscriber)

In this example, *Integration Service* uses both this *ROS 2 System Handle* and the *FIWARE System Handle*
In this example, *Integration Service* uses both this *Static ROS 2 System Handle* and the *FIWARE System Handle*
to transmit data coming from a ROS 2 publisher and update them in a FIWARE Context Broker MongoDB database, and viceversa.

<p align="center">
Expand All @@ -200,7 +229,7 @@ For a detailed step by step guide on how to build and test this example, please

### ROS 2 service server

In this example, the *ROS 2 System Handle* tackles the task of bridging a ROS 2 server with one or more client applications,
In this example, the *Static ROS 2 System Handle* tackles the task of bridging a ROS 2 server with one or more client applications,
playing the role of a service server capable of processing incoming requests from several middlewares (*DDS*, *ROS1*,
*WebSocket*) and producing an appropriate answer for them.

Expand Down Expand Up @@ -254,7 +283,7 @@ For a detailed step by step guide on how to build and test this example, please

Besides the [global compilation flags](https://integration-service.docs.eprosima.com/en/latest/installation_manual/installation.html#global-compilation-flags) available for the
whole *Integration Service* product suite, there are some specific flags which apply only to the
*ROS 2 System Handle*; they are listed below:
*ROS 2 System Handles*; they are listed below:

* `BUILD_ROS2_TESTS`: Allows to specifically compile the *ROS 2 System Handle* unitary and
integration tests; this is useful to avoid compiling each *System Handle's* test suite present
Expand All @@ -265,6 +294,10 @@ whole *Integration Service* product suite, there are some specific flags which a
~/is_ws$ colcon build --cmake-args -DBUILD_ROS2_TESTS=ON
```

* `IS_ROS2_SH_MODE`: This flag is to decide which *ROS 2 System Handle* mode will be compiled, as the static and dynamic modes are exclusive which means that they cannot be compiled at the same time. It accepts two different values: `static` or `dynamic`.

The following flags are only applicable for the *Static ROS 2 System Handle*:

* `MIX_ROS_PACKAGES`: It accepts as an argument a list of [ROS packages](https://index.ros.org/packages/),
such as `std_msgs`, `geometry_msgs`, `sensor_msgs`, `nav_msgs`... for which the required transformation
library to convert the specific ROS 2 type definitions into *xTypes*, and the other way around, will be built.
Expand Down Expand Up @@ -299,7 +332,7 @@ whole *Integration Service* product suite, there are some specific flags which a

## Documentation

The official documentation for the *ROS 2 System Handle* is included within the official *Integration Service*
The official documentation for the *ROS 2 System Handles* is included within the official *Integration Service*
documentation, hosted by [Read the Docs](https://integration-service.docs.eprosima.com/), and comprises the following sections:

* [Installation Manual](https://integration-service.docs.eprosima.com/en/latest/installation_manual/installation_manual.html)
Expand Down
140 changes: 22 additions & 118 deletions ros2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,124 +26,26 @@ project(is-ros2 VERSION "3.1.0" LANGUAGES CXX)
# Configure options
###################################################################################
option(BUILD_LIBRARY "Compile the ROS 2 SystemHandle" ON)
set(IS_ROS2_SH_MODE "Static" CACHE STRING "Select the ROS 2 SystemHandle Mode")

###################################################################################
# Load external CMake Modules.
# Build ROS2 Static SH or ROS2 Dynamic SH
###################################################################################
if(BUILD_LIBRARY)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${SANITIZERS_ROOT}/cmake)
set(IS_ROS2_SH_MODE_LOWERCASE "" CACHE STRING "Build mode to lowercase")
string(TOLOWER "${IS_ROS2_SH_MODE}" IS_ROS2_SH_MODE_LOWERCASE)

find_package(Sanitizers QUIET)

if(SANITIZE_ADDRESS)
message(STATUS "Preloading AddressSanitizer library could be done using \"${ASan_WRAPPER}\" to run your program.")
endif()
endif()

###################################################################################
# External dependencies for the Integration Service ROS 2 SystemHandle library
###################################################################################
if(BUILD_LIBRARY)
find_package(is-core REQUIRED)
find_package(rclcpp REQUIRED)
endif()

###################################################################################
# Configure the Integration Service ROS 2 SystemHandle library
###################################################################################
if(BUILD_LIBRARY)
add_library(${PROJECT_NAME}
SHARED
src/Factory.cpp
src/MetaPublisher.cpp
$<IF:$<VERSION_GREATER:${rclcpp_VERSION},2.4.2>,src/SystemHandle.cpp,src/SystemHandle__foxy.cpp>
)

if (Sanitizers_FOUND)
add_sanitizers(${PROJECT_NAME})
endif()

set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION
${PROJECT_VERSION}
SOVERSION
${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
CXX_STANDARD
17
CXX_STANDARD_REQUIRED
YES
)

target_compile_options(${PROJECT_NAME}
PRIVATE
$<$<CXX_COMPILER_ID:GNU>:-pedantic>
$<$<CXX_COMPILER_ID:GNU>:-fstrict-aliasing>
$<$<CXX_COMPILER_ID:GNU>:-Wall>
$<$<CXX_COMPILER_ID:GNU>:-Wextra>
$<$<CXX_COMPILER_ID:GNU>:-Wcast-align>
$<$<CXX_COMPILER_ID:GNU>:-Wshadow>
$<$<CXX_COMPILER_ID:MSVC>:/W4>
$<$<CXX_COMPILER_ID:MSVC>:/wd4700>
$<$<CXX_COMPILER_ID:MSVC>:/wd4996>
$<$<CXX_COMPILER_ID:MSVC>:/wd4820>
$<$<CXX_COMPILER_ID:MSVC>:/wd4255>
$<$<CXX_COMPILER_ID:MSVC>:/wd4668>
)

include(GNUInstallDirs)
message(STATUS "Configuring [${PROJECT_NAME}]...")

target_link_libraries(${PROJECT_NAME}
PUBLIC
is::core
${rclcpp_LIBRARIES}
)

target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
${rclcpp_INCLUDE_DIRS}
)

is_generate_export_header(ros2)

if (NOT rosidl_runtime_cpp_FOUND)
target_compile_definitions(${PROJECT_NAME}
PUBLIC
"IS_SH_ROS2__ROSIDL_GENERATOR_CPP"
)
if("${IS_ROS2_SH_MODE_LOWERCASE}" STREQUAL "static")
add_subdirectory(static)
if(BUILD_TESTS OR BUILD_ROS2_TESTS)
enable_testing()
endif()
endif()

###################################################################################
# Install the Integration Service ROS 2 SystemHandle library
###################################################################################
if(BUILD_LIBRARY)
is_install_middleware_plugin(
MIDDLEWARE
ros2
TARGET
${PROJECT_NAME}
DEPENDENCIES
rclcpp
)

file(
COPY
${CMAKE_CURRENT_LIST_DIR}/include/
DESTINATION
${CMAKE_INSTALL_PREFIX}/include/
)
endif()

###################################################################################
# Integration Service ROS 2 SystemHandle tests
###################################################################################
if(BUILD_LIBRARY)
elseif("${IS_ROS2_SH_MODE_LOWERCASE}" STREQUAL "dynamic")
add_subdirectory(dynamic)
if(BUILD_TESTS OR BUILD_ROS2_TESTS)
add_subdirectory(test)
enable_testing()
endif()
else()
message(WARNING "Invalid mode selected. Please choose between 'static' or 'dynamic'")
endif()

###################################################################################
Expand All @@ -160,14 +62,16 @@ if(BUILD_API_REFERENCE)
COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/doxygen/html
COMMENT "Creating documentation directories" VERBATIM)

set(IS_ROS2_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/include/is/sh/ros2")
set(IS_ROS2_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src")
set(IS_ROS2_STATIC_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/static/include/is/sh/ros2")
set(IS_ROS2_STATIC_SOURCE_DIR "${CMAKE_SOURCE_DIR}/static/src")
set(IS_ROS2_DYNAMIC_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/dynamic/include/is/sh/ros2")
file(GLOB_RECURSE HPP_FILES
"${IS_ROS2_INCLUDE_DIR}/*.h*"
"${IS_ROS2_SOURCE_DIR}/*.h*")
"${IS_ROS2_STATIC_INCLUDE_DIR}/*.h*"
"${IS_ROS2_STATIC_SOURCE_DIR}/*.h*"
"${IS_ROS2_DYNAMIC_INCLUDE_DIR}/*.h*")

# Doxygen related variables
set(DOXYGEN_INPUT_DIR "${IS_ROS2_INCLUDE_DIR} ${IS_ROS2_SOURCE_DIR}")
set(DOXYGEN_INPUT_DIR "${IS_ROS2_STATIC_INCLUDE_DIR} ${IS_ROS2_STATIC_SOURCE_DIR} ${IS_ROS2_DYNAMIC_INCLUDE_DIR}")
set(DOXYGEN_OUTPUT_DIR "${PROJECT_BINARY_DIR}/doxygen")
set(DOXYGEN_INDEX_FILE "${PROJECT_BINARY_DIR}/doxygen/xml/index.xml")
set(DOXYFILE_IN "${IS_DOXYGEN_CONFIG_FILE}")
Expand Down Expand Up @@ -195,8 +99,8 @@ if(BUILD_API_REFERENCE)
install(DIRECTORY ${PROJECT_BINARY_DIR}/doxygen/xml
DESTINATION doxygen
COMPONENT doxygen-${PROJECT_NAME})
set(CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "ROS2 System Handle doxygen")
set(CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "ROS2 System Handles doxygen")
set(CPACK_COMPONENT_EXAMPLES_DESCRIPTION
"eProsima ROS2 System Handle doxygen documentation")
"eProsima ROS2 System Handles doxygen documentation")
set(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} doxygen-${PROJECT_NAME})
endif()
34 changes: 34 additions & 0 deletions ros2/config.hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2021 - present Proyectos y Sistemas de Mantenimiento SL (eProsima).
*
* 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 _IS_ROS2_DISTRO_HPP_
#define _IS_ROS2_DISTRO_HPP_

namespace eprosima {
namespace is {
namespace sh {
namespace ros2 {

const std::string ROS2_DISTRO = "@IS_ROS2_DISTRO@";

} //namespace ros2
} //namespace is
} //namespace sh
} //namespace eprosima


#endif // _IS_ROS2_DISTRO_HPP_
Loading