support multiple type supports
This commit is contained in:
parent
9c2149e5ef
commit
9607869ef2
4 changed files with 43 additions and 30 deletions
|
@ -3,36 +3,14 @@ cmake_minimum_required(VERSION 2.8.3)
|
|||
project(rclcpp)
|
||||
|
||||
find_package(ament_cmake REQUIRED)
|
||||
find_package(ros_middleware_interface REQUIRED)
|
||||
|
||||
ament_export_dependencies(ros_middleware_interface)
|
||||
|
||||
set(_dds_vendor "$ENV{ROS_DDS_IMPLEMENTATION}")
|
||||
set(_dds_type "$ENV{ROS_DDS_TYPE}")
|
||||
|
||||
if(NOT "${_dds_type}" STREQUAL "dynamic" AND NOT "${_dds_type}" STREQUAL "static")
|
||||
message(FATAL_ERROR "Set the environment variable 'ROS_DDS_TYPE' to either 'dynamic' or 'static'.")
|
||||
endif()
|
||||
|
||||
if("${_dds_vendor}" STREQUAL "connext")
|
||||
if("${_dds_type}" STREQUAL "dynamic")
|
||||
ament_export_dependencies(ros_dds_connext_dynamic)
|
||||
elseif("${_dds_type}" STREQUAL "static")
|
||||
ament_export_dependencies(rosidl_typesupport_connext_cpp ros_middleware_connext_cpp)
|
||||
endif()
|
||||
elseif("${_dds_vendor}" STREQUAL "opensplice")
|
||||
if("${_dds_type}" STREQUAL "dynamic")
|
||||
message(FATAL_ERROR "The DDS implementation '${_dds_vendor}' does not support the type '${_dds_type}'.")
|
||||
elseif("${_dds_type}" STREQUAL "static")
|
||||
ament_export_dependencies(rosidl_typesupport_opensplice_cpp)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Set the environment variable 'ROS_DDS_IMPLEMENTATION' to either 'connext' or 'opensplice'.")
|
||||
endif()
|
||||
|
||||
ament_export_include_directories(include)
|
||||
|
||||
ament_package()
|
||||
ament_package(
|
||||
CONFIG_EXTRAS "rclcpp-extras.cmake"
|
||||
)
|
||||
|
||||
install(
|
||||
DIRECTORY include/
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#include "ros_middleware_interface/functions.h"
|
||||
#include "ros_middleware_interface/handles.h"
|
||||
|
||||
#include "ros_middleware_interface/get_type_support_handle.h"
|
||||
|
||||
|
||||
namespace rclcpp
|
||||
{
|
||||
|
@ -21,7 +23,7 @@ public:
|
|||
template<typename ROSMessage>
|
||||
Publisher<ROSMessage>* create_publisher(const char * topic_name)
|
||||
{
|
||||
const rosidl_generator_cpp::MessageTypeSupportHandle & type_support_handle = rosidl_generator_cpp::MessageTypeSupport<ROSMessage>::get_type_support_handle();
|
||||
const rosidl_generator_cpp::MessageTypeSupportHandle & type_support_handle = ::ros_middleware_interface::get_type_support_handle<ROSMessage>();
|
||||
ros_middleware_interface::PublisherHandle publisher_handle = ::ros_middleware_interface::create_publisher(node_handle_, type_support_handle, topic_name);
|
||||
return new Publisher<ROSMessage>(publisher_handle);
|
||||
}
|
||||
|
|
|
@ -8,8 +8,5 @@
|
|||
|
||||
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||
|
||||
<build_depend>ros_middleware_interface</build_depend>
|
||||
<build_depend>rosidl_default_generators</build_depend>
|
||||
|
||||
<build_depend>ros_dds_connext_dynamic</build_depend>
|
||||
<build_export_depend>ros_middleware_interface</build_export_depend>
|
||||
</package>
|
||||
|
|
36
rclcpp/rclcpp-extras.cmake
Normal file
36
rclcpp/rclcpp-extras.cmake
Normal file
|
@ -0,0 +1,36 @@
|
|||
# copied from rclcpp/rclcpp-extras.cmake
|
||||
|
||||
# option()
|
||||
set(_middleware_implementation "")
|
||||
if(NOT "${ROS_MIDDLEWARE_IMPLEMENTATION}" STREQUAL "")
|
||||
set(_middleware_implementation "${ROS_MIDDLEWARE_IMPLEMENTATION}")
|
||||
elseif(NOT "$ENV{ROS_MIDDLEWARE_IMPLEMENTATION}" STREQUAL "")
|
||||
set(_middleware_implementation "$ENV{ROS_MIDDLEWARE_IMPLEMENTATION}")
|
||||
else()
|
||||
# detemine "default" implementation based on the available ones
|
||||
set(_middleware_implementation "ros_middleware_connext_cpp")
|
||||
if("${_middleware_implementation}" STREQUAL "")
|
||||
message(FATAL_ERROR "No middleware implementation available.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message("rclcpp_DEFINITIONS ${rclcpp_DEFINITIONS}")
|
||||
message("rclcpp_INCLUDE_DIRS ${rclcpp_INCLUDE_DIRS}")
|
||||
message("rclcpp_LIBRARIES ${rclcpp_LIBRARIES}")
|
||||
|
||||
message(STATUS "Using middleware implementation: ${_middleware_implementation}")
|
||||
find_package("${_middleware_implementation}" REQUIRED)
|
||||
|
||||
# persist implementation decision in cache
|
||||
set(
|
||||
ROS_MIDDLEWARE_IMPLEMENTATION "${_middleware_implementation}"
|
||||
CACHE STRING "Select ROS middleware implementation to link against" FORCE
|
||||
)
|
||||
|
||||
list(APPEND rclcpp_DEFINITIONS ${${ROS_MIDDLEWARE_IMPLEMENTATION}_DEFINITIONS})
|
||||
list(APPEND rclcpp_INCLUDE_DIRS ${${ROS_MIDDLEWARE_IMPLEMENTATION}_INCLUDE_DIRS})
|
||||
list(APPEND rclcpp_LIBRARIES ${${ROS_MIDDLEWARE_IMPLEMENTATION}_LIBRARIES})
|
||||
|
||||
message("rclcpp_DEFINITIONS ${rclcpp_DEFINITIONS}")
|
||||
message("rclcpp_INCLUDE_DIRS ${rclcpp_INCLUDE_DIRS}")
|
||||
message("rclcpp_LIBRARIES ${rclcpp_LIBRARIES}")
|
Loading…
Add table
Add a link
Reference in a new issue