Skip to content

Commit

Permalink
Add message interfaces generation
Browse files Browse the repository at this point in the history
Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com>
  • Loading branch information
ivanpauno committed Sep 4, 2019
1 parent 80f70d5 commit 6fa5758
Show file tree
Hide file tree
Showing 10 changed files with 244 additions and 0 deletions.
35 changes: 35 additions & 0 deletions rmw_dds_common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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(
)
58 changes: 58 additions & 0 deletions rmw_dds_common/include/rmw_dds_common/visibility_control.h
Original file line number Diff line number Diff line change
@@ -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_
8 changes: 8 additions & 0 deletions rmw_dds_common/msg/Gid.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module rmw_dds_common {
module msg {
typedef char data_t[24];
struct Gid {
data_t data;
};
};
};
15 changes: 15 additions & 0 deletions rmw_dds_common/msg/NodeCustomInfo.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "rmw_dds_common/msg/Gid.idl"

module rmw_dds_common {
module msg {
typedef sequence<rmw_dds_common::msg::Gid, 1024> 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;
};
};
};
12 changes: 12 additions & 0 deletions rmw_dds_common/msg/ParticipantCustomInfo.idl
Original file line number Diff line number Diff line change
@@ -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<rmw_dds_common::msg::NodeCustomInfo, 1024> type;
};
};
};
23 changes: 23 additions & 0 deletions rmw_dds_common/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>rmw_dds_common</name>
<version>0.7.3</version>
<description>Define a common interface between DDS implementations of ROS middleware.</description>
<maintainer email="ivanpauno@ekumenlabs.com">Ivan Paunovic</maintainer>
<license>Apache License 2.0</license>
<author>Ivan Paunovic</author>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>rosidl_cmake</buildtool_depend>
<buildtool_depend>rmw_dds_common_generators</buildtool_depend>

<depend>rmw</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
17 changes: 17 additions & 0 deletions rmw_dds_common/rmw_dds_common_base-extras.cmake
Original file line number Diff line number Diff line change
@@ -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")
14 changes: 14 additions & 0 deletions rmw_dds_common_generators/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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"
)
33 changes: 33 additions & 0 deletions rmw_dds_common_generators/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>rmw_dds_common_generators</name>
<version>0.7.3</version>
<description>Generators used in rmw_dds_common.</description>
<maintainer email="ivanpauno@ekumenlabs.com">Ivan Paunovic</maintainer>
<license>Apache License 2.0</license>
<author>Ivan Paunovic</author>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>rosidl_cmake</buildtool_depend>

<buildtool_export_depend>ament_cmake</buildtool_export_depend>
<buildtool_export_depend>rosidl_cmake</buildtool_export_depend>

<buildtool_export_depend>rosidl_generator_c</buildtool_export_depend>
<buildtool_export_depend>rosidl_generator_cpp</buildtool_export_depend>

<!-- <buildtool_export_depend>rosidl_typesupport_c</buildtool_export_depend> -->
<!-- <buildtool_export_depend>rosidl_typesupport_cpp</buildtool_export_depend> -->
<buildtool_export_depend>rosidl_typesupport_introspection_c</buildtool_export_depend>
<buildtool_export_depend>rosidl_typesupport_introspection_cpp</buildtool_export_depend>

<group_depend>rosidl_typesupport_cpp_packages</group_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 6fa5758

Please sign in to comment.