From 6fa5758b8c8078a92f5ac15f9d2e8f1326820ec7 Mon Sep 17 00:00:00 2001 From: ivanpauno Date: Tue, 3 Sep 2019 13:18:33 -0700 Subject: [PATCH] Add message interfaces generation Signed-off-by: ivanpauno --- rmw_dds_common/CMakeLists.txt | 35 +++++++++++ .../rmw_dds_common/visibility_control.h | 58 +++++++++++++++++++ rmw_dds_common/msg/Gid.idl | 8 +++ rmw_dds_common/msg/NodeCustomInfo.idl | 15 +++++ rmw_dds_common/msg/ParticipantCustomInfo.idl | 12 ++++ rmw_dds_common/package.xml | 23 ++++++++ .../rmw_dds_common_base-extras.cmake | 17 ++++++ rmw_dds_common_generators/CMakeLists.txt | 14 +++++ rmw_dds_common_generators/package.xml | 33 +++++++++++ .../rmw_dds_common_generators-extras.cmake.in | 29 ++++++++++ 10 files changed, 244 insertions(+) create mode 100644 rmw_dds_common/CMakeLists.txt create mode 100644 rmw_dds_common/include/rmw_dds_common/visibility_control.h create mode 100644 rmw_dds_common/msg/Gid.idl create mode 100644 rmw_dds_common/msg/NodeCustomInfo.idl create mode 100644 rmw_dds_common/msg/ParticipantCustomInfo.idl create mode 100644 rmw_dds_common/package.xml create mode 100644 rmw_dds_common/rmw_dds_common_base-extras.cmake create mode 100644 rmw_dds_common_generators/CMakeLists.txt create mode 100644 rmw_dds_common_generators/package.xml create mode 100644 rmw_dds_common_generators/rmw_dds_common_generators-extras.cmake.in diff --git a/rmw_dds_common/CMakeLists.txt b/rmw_dds_common/CMakeLists.txt new file mode 100644 index 0000000..cd1ad23 --- /dev/null +++ b/rmw_dds_common/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.5) + +project(rmw_dds_common) + +# Default to C++14 +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 14) +endif() + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +find_package(ament_cmake REQUIRED) +find_package(rosidl_cmake REQUIRED) +find_package(rmw_dds_common_generators REQUIRED) + +ament_export_dependencies(ament_cmake_core) +ament_export_dependencies(rosidl_cmake) + +rosidl_generate_interfaces( + ${PROJECT_NAME} + "msg/Gid.idl" + "msg/NodeCustomInfo.idl" + "msg/ParticipantCustomInfo.idl" + SKIP_GROUP_MEMBERSHIP_CHECK +) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + ament_lint_auto_find_test_dependencies() +endif() + +ament_package( +) diff --git a/rmw_dds_common/include/rmw_dds_common/visibility_control.h b/rmw_dds_common/include/rmw_dds_common/visibility_control.h new file mode 100644 index 0000000..4070132 --- /dev/null +++ b/rmw_dds_common/include/rmw_dds_common/visibility_control.h @@ -0,0 +1,58 @@ +// Copyright 2019 Open Source Robotics Foundation, Inc. +// +// 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 RMW_DDS_COMMON__VISIBILITY_CONTROL_H_ +#define RMW_DDS_COMMON__VISIBILITY_CONTROL_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + +// This logic was borrowed (then namespaced) from the examples on the gcc wiki: +// https://gcc.gnu.org/wiki/Visibility + +#if defined _WIN32 || defined __CYGWIN__ + #ifdef __GNUC__ + #define RMW_DDS_COMMON_EXPORT __attribute__ ((dllexport)) + #define RMW_DDS_COMMON_IMPORT __attribute__ ((dllimport)) + #else + #define RMW_DDS_COMMON_EXPORT __declspec(dllexport) + #define RMW_DDS_COMMON_IMPORT __declspec(dllimport) + #endif + #ifdef RMW_DDS_COMMON_BUILDING_DLL + #define RMW_DDS_COMMON_PUBLIC RMW_DDS_COMMON_EXPORT + #else + #define RMW_DDS_COMMON_PUBLIC RMW_DDS_COMMON_IMPORT + #endif + #define RMW_DDS_COMMON_PUBLIC_TYPE RMW_DDS_COMMON_PUBLIC + #define RMW_DDS_COMMON_LOCAL +#else + #define RMW_DDS_COMMON_EXPORT __attribute__ ((visibility("default"))) + #define RMW_DDS_COMMON_IMPORT + #if __GNUC__ >= 4 + #define RMW_DDS_COMMON_PUBLIC __attribute__ ((visibility("default"))) + #define RMW_DDS_COMMON_LOCAL __attribute__ ((visibility("hidden"))) + #else + #define RMW_DDS_COMMON_PUBLIC + #define RMW_DDS_COMMON_LOCAL + #endif + #define RMW_DDS_COMMON_PUBLIC_TYPE +#endif + +#ifdef __cplusplus +} +#endif + +#endif // RMW_DDS_COMMON__VISIBILITY_CONTROL_H_ diff --git a/rmw_dds_common/msg/Gid.idl b/rmw_dds_common/msg/Gid.idl new file mode 100644 index 0000000..c3acdb1 --- /dev/null +++ b/rmw_dds_common/msg/Gid.idl @@ -0,0 +1,8 @@ +module rmw_dds_common { + module msg { + typedef char data_t[24]; + struct Gid { + data_t data; + }; + }; +}; diff --git a/rmw_dds_common/msg/NodeCustomInfo.idl b/rmw_dds_common/msg/NodeCustomInfo.idl new file mode 100644 index 0000000..8ab069b --- /dev/null +++ b/rmw_dds_common/msg/NodeCustomInfo.idl @@ -0,0 +1,15 @@ +#include "rmw_dds_common/msg/Gid.idl" + +module rmw_dds_common { + module msg { + typedef sequence gid_sequence_t; + struct NodeCustomInfo { + @key + string<256> node_name; + gid_sequence_t clients; + gid_sequence_t publishers; + gid_sequence_t services; + gid_sequence_t subscriptions; + }; + }; +}; diff --git a/rmw_dds_common/msg/ParticipantCustomInfo.idl b/rmw_dds_common/msg/ParticipantCustomInfo.idl new file mode 100644 index 0000000..41f7d02 --- /dev/null +++ b/rmw_dds_common/msg/ParticipantCustomInfo.idl @@ -0,0 +1,12 @@ +#include "rmw_dds_common/msg/Gid.idl" +#include "rmw_dds_common/msg/NodeCustomInfo.idl" + +module rmw_dds_common { + module msg { + struct ParticipantCustomInfo { + @key + rmw_dds_common::msg::Gid id; + sequence type; + }; + }; +}; diff --git a/rmw_dds_common/package.xml b/rmw_dds_common/package.xml new file mode 100644 index 0000000..dd1bffe --- /dev/null +++ b/rmw_dds_common/package.xml @@ -0,0 +1,23 @@ + + + + rmw_dds_common + 0.7.3 + Define a common interface between DDS implementations of ROS middleware. + Ivan Paunovic + Apache License 2.0 + Ivan Paunovic + + ament_cmake + rosidl_cmake + rmw_dds_common_generators + + rmw + + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/rmw_dds_common/rmw_dds_common_base-extras.cmake b/rmw_dds_common/rmw_dds_common_base-extras.cmake new file mode 100644 index 0000000..a11d8f5 --- /dev/null +++ b/rmw_dds_common/rmw_dds_common_base-extras.cmake @@ -0,0 +1,17 @@ +# Copyright 2019 Open Source Robotics Foundation, Inc. +# +# 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. + +# copied from rmw_dds_common_base/rmw_dds_common_base-extras.cmake + +include("${rmw_dds_common_base_DIR}/rosidl_generate_some_interface_files.cmake") diff --git a/rmw_dds_common_generators/CMakeLists.txt b/rmw_dds_common_generators/CMakeLists.txt new file mode 100644 index 0000000..4b00e30 --- /dev/null +++ b/rmw_dds_common_generators/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.5) + +project(rmw_dds_common_generators NONE) + +find_package(ament_cmake REQUIRED) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + ament_lint_auto_find_test_dependencies() +endif() + +ament_package( + CONFIG_EXTRAS "rmw_dds_common_generators-extras.cmake.in" +) diff --git a/rmw_dds_common_generators/package.xml b/rmw_dds_common_generators/package.xml new file mode 100644 index 0000000..01113f4 --- /dev/null +++ b/rmw_dds_common_generators/package.xml @@ -0,0 +1,33 @@ + + + + rmw_dds_common_generators + 0.7.3 + Generators used in rmw_dds_common. + Ivan Paunovic + Apache License 2.0 + Ivan Paunovic + + ament_cmake + rosidl_cmake + + ament_cmake + rosidl_cmake + + rosidl_generator_c + rosidl_generator_cpp + + + + rosidl_typesupport_introspection_c + rosidl_typesupport_introspection_cpp + + rosidl_typesupport_cpp_packages + + ament_lint_auto + ament_lint_common + + + ament_cmake + + \ No newline at end of file diff --git a/rmw_dds_common_generators/rmw_dds_common_generators-extras.cmake.in b/rmw_dds_common_generators/rmw_dds_common_generators-extras.cmake.in new file mode 100644 index 0000000..6b08294 --- /dev/null +++ b/rmw_dds_common_generators/rmw_dds_common_generators-extras.cmake.in @@ -0,0 +1,29 @@ +# generated from +# rmw_dds_common_generators/rmw_dds_common_generators-extras.cmake + +find_package(ament_cmake_core REQUIRED) +ament_index_get_resources(rosidl_typesupport_cpp_packages "rosidl_typesupport_cpp") +ament_index_get_resources(rosidl_generator_packages "rosidl_generator_packages") +set(_exported_dependencies + ${rosidl_typesupport_cpp_packages} + ${rosidl_generator_packages} +) + +# find_package() all dependencies (if available) +# and append their DEFINITIONS INCLUDE_DIRS and LIBRARIES variables +# to @PROJECT_NAME@_DEFINITIONS , @PROJECT_NAME@_INCLUDE_DIRS and +# @PROJECT_NAME@_LIBRARIES. +foreach(_dep ${_exported_dependencies}) + find_package("${_dep}" QUIET) + if(${_dep}_FOUND) + if(${_dep}_DEFINITIONS) + list(APPEND @PROJECT_NAME@_DEFINITIONS "${${_dep}_DEFINITIONS}") + endif() + if(${_dep}_INCLUDE_DIRS) + list(APPEND @PROJECT_NAME@_INCLUDE_DIRS "${${_dep}_INCLUDE_DIRS}") + endif() + if(${_dep}_LIBRARIES) + list(APPEND @PROJECT_NAME@_LIBRARIES "${${_dep}_LIBRARIES}") + endif() + endif() +endforeach()