├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── rtt_ros2 ├── CMakeLists.txt ├── cmake │ ├── rtt_ros2-extras.cmake │ ├── rtt_ros2_export_plugin_depend.cmake │ ├── rtt_ros2_export_plugin_depend_hook-extras.cmake │ ├── rtt_ros2_export_plugin_depend_hook.cmake │ └── rtt_ros2_use_orocos.cmake ├── env_hook │ ├── pkg_config_path.sh.in │ └── rtt_component_path.sh.in ├── include │ └── orocos │ │ └── rtt_ros2 │ │ ├── detail │ │ └── rclcpp_version.h.in │ │ ├── getter_setter_datasource.hpp │ │ └── rtt_ros2.hpp ├── package.xml └── src │ ├── rtt_ros2.cpp │ └── rtt_ros2_service.cpp ├── rtt_ros2_idl ├── CMakeLists.txt ├── cmake │ ├── rtt_ros2_idl-extras.cmake.in │ └── rtt_ros2_idl-generate_typekit.cmake ├── include │ └── orocos │ │ └── rtt_ros2_idl │ │ └── RosIntrospectionTypeInfo.hpp ├── package.xml └── src │ └── rtt_ros2_idl │ ├── __init__.py │ ├── __main__.py │ └── resource │ ├── Types.hpp.em │ ├── __init__.py │ ├── action_Types.hpp.em │ ├── action_typekit.cpp.em │ ├── msg_Types.hpp.em │ ├── msg_typekit.cpp.em │ ├── srv_Types.hpp.em │ ├── srv_typekit.cpp.em │ └── typekit_plugin.cpp.em ├── rtt_ros2_interfaces ├── CMakeLists.txt ├── cmake │ └── rtt_ros2_interfaces-generate_interfaces_plugins.cmake ├── package.xml ├── scripts │ └── create_typekit_package └── template │ ├── AMENT_IGNORE │ ├── CMakeLists.txt │ └── package.xml ├── rtt_ros2_node ├── CMakeLists.txt ├── include │ └── orocos │ │ └── rtt_ros2_node │ │ └── rtt_ros2_node.hpp ├── package.xml └── src │ ├── rtt_ros2_node.cpp │ └── rtt_ros2_node_service.cpp ├── rtt_ros2_params ├── CMakeLists.txt ├── README.md ├── include │ └── orocos │ │ └── rtt_ros2_params │ │ ├── rosparam.hpp │ │ └── rtt_ros2_params_service.hpp ├── package.xml └── src │ ├── rtt_ros2_params_plugin.cpp │ └── rtt_ros2_params_service.cpp ├── rtt_ros2_services ├── CMakeLists.txt ├── cmake │ ├── rtt_ros2_services-extras.cmake.in │ └── rtt_ros2_services-generate_ros_service_plugin.cmake ├── include │ └── orocos │ │ └── rtt_ros2_services │ │ ├── rosservice.hpp │ │ ├── rtt_ros2_services_proxy.hpp │ │ └── rtt_ros2_services_registry.hpp ├── package.xml └── src │ ├── rtt_ros2_services │ ├── __init__.py │ ├── __main__.py │ └── resource │ │ ├── __init__.py │ │ └── ros_service_plugin.cpp.em │ ├── rtt_ros2_services_plugin.cpp │ ├── rtt_ros2_services_proxy.cpp │ ├── rtt_ros2_services_registry.cpp │ └── rtt_ros2_services_registry_plugin.cpp ├── rtt_ros2_topics ├── CMakeLists.txt ├── cmake │ ├── rtt_ros2_topics-extras.cmake.in │ └── rtt_ros2_topics-generate_ros_transport.cmake ├── include │ └── orocos │ │ └── rtt_ros2_topics │ │ ├── protocol_id.h │ │ ├── ros_publisher.hpp │ │ ├── ros_subscription.hpp │ │ ├── ros_type_transporter.hpp │ │ ├── rostopic.hpp │ │ ├── utilities.hpp │ │ └── waitable.hpp ├── package.xml └── src │ ├── rtt_ros2_topics │ ├── __init__.py │ ├── __main__.py │ └── resource │ │ ├── __init__.py │ │ └── ros_transport_plugin.cpp.em │ └── rtt_ros2_topics_plugin.cpp ├── tests ├── rtt_ros2_idl_tests │ ├── CMakeLists.txt │ ├── package.xml │ └── test │ │ └── test_typekit.cpp ├── rtt_ros2_params_tests │ ├── CMakeLists.txt │ ├── package.xml │ └── test │ │ └── test_ros_params.cpp ├── rtt_ros2_services_tests │ ├── CMakeLists.txt │ ├── package.xml │ └── test │ │ └── test_ros_service.cpp ├── rtt_ros2_test_msgs │ ├── CMakeLists.txt │ ├── include │ │ └── orocos │ │ │ └── rtt_ros2_test_msgs │ │ │ └── srv │ │ │ └── empty.hpp │ └── package.xml ├── rtt_ros2_tests │ ├── CMakeLists.txt │ ├── package.xml │ ├── src │ │ └── test_service.cpp │ └── test │ │ ├── test_find.cpp │ │ └── test_import.cpp └── rtt_ros2_topics_tests │ ├── CMakeLists.txt │ ├── package.xml │ └── test │ ├── test_ros_transport.cpp │ └── test_topics_service.cpp └── typekits ├── rtt_ros2_action_msgs ├── CMakeLists.txt └── package.xml ├── rtt_ros2_builtin_interfaces ├── CMakeLists.txt └── package.xml ├── rtt_ros2_primitives_typekit ├── CMakeLists.txt ├── include │ └── orocos │ │ └── rtt_ros2_primitives_typekit │ │ └── Types.hpp ├── package.xml └── src │ └── typekit │ ├── ros2_bool_type.cpp │ ├── ros2_float32_type.cpp │ ├── ros2_float64_type.cpp │ ├── ros2_int16_type.cpp │ ├── ros2_int32_type.cpp │ ├── ros2_int64_type.cpp │ ├── ros2_int8_type.cpp │ ├── ros2_primitives_typekit.cpp │ ├── ros2_string_type.cpp │ ├── ros2_uint16_type.cpp │ ├── ros2_uint32_type.cpp │ ├── ros2_uint64_type.cpp │ ├── ros2_uint8_type.cpp │ └── ros2_wstring_type.cpp ├── rtt_ros2_rclcpp_typekit ├── CMakeLists.txt ├── include │ └── orocos │ │ └── rtt_ros2_rclcpp_typekit │ │ ├── parameter_value_conversions.hpp │ │ ├── ros2_duration_type.hpp │ │ ├── ros2_node_options_type.hpp │ │ ├── ros2_parameter_type.hpp │ │ ├── ros2_parameter_value_type.hpp │ │ ├── ros2_publisher_options_type.hpp │ │ ├── ros2_qos_type.hpp │ │ ├── ros2_time_type.hpp │ │ ├── time_conversions.hpp │ │ ├── time_io.hpp │ │ ├── time_operators.hpp │ │ ├── wrapped_duration.hpp │ │ └── wrapped_qos.hpp ├── package.xml └── src │ ├── ros2_duration_type.cpp │ ├── ros2_node_options_type.cpp │ ├── ros2_parameter_type.cpp │ ├── ros2_parameter_value_type.cpp │ ├── ros2_publisher_options_type.cpp │ ├── ros2_qos_type.cpp │ ├── ros2_time_type.cpp │ └── rtt_ros2_rclcpp_typekit.cpp └── rtt_ros2_unique_identifier_msgs ├── CMakeLists.txt └── package.xml /.gitignore: -------------------------------------------------------------------------------- 1 | # Build artifacts (colcon) 2 | /bin/ 3 | /build/ 4 | /COLCON_IGNORE 5 | /.colcon_install_layout 6 | /env.sh 7 | /etc/ 8 | /include/ 9 | /lib/ 10 | /local_setup.* 11 | /*_local_setup_util_*.py 12 | /log/ 13 | /install/ 14 | /setup.* 15 | /share/ 16 | 17 | # Orocos-generated files 18 | orocos.log 19 | .tb_history 20 | 21 | # VSCode 22 | /.vscode/ 23 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # This config uses industrial_ci (https://github.com/ros-industrial/industrial_ci.git). 2 | # For troubleshooting, see readme (https://github.com/ros-industrial/industrial_ci/blob/master/README.rst) 3 | 4 | language: generic # optional, just removes the language badge 5 | 6 | services: 7 | - docker 8 | 9 | # include the following block if the C/C++ build artifacts should get cached by Travis, 10 | # CCACHE_DIR needs to get set as well to actually fill the cache 11 | cache: 12 | directories: 13 | - $HOME/.ccache 14 | 15 | git: 16 | quiet: true # optional, silences the cloning of the target repository 17 | 18 | # limit automatic builds to certain branches (and pull requests) 19 | branches: 20 | only: 21 | - master 22 | 23 | # configure the build environment(s) 24 | # https://github.com/ros-industrial/industrial_ci/blob/master/doc/index.rst#variables-you-can-configure 25 | env: 26 | global: # global settings for all jobs 27 | - CCACHE_DIR=$HOME/.ccache # enables C/C++ caching in industrial_ci 28 | - ROSDEP_SKIP_KEYS="log4cpp rtt ocl" # preinstalled in the docker images 29 | - AFTER_INIT_EMBED="source /opt/orocos/\${ROS_DISTRO}/setup.sh" 30 | matrix: # each line is a job 31 | - ROS_DISTRO="dashing" DOCKER_IMAGE="orocos/ros2-ci:dashing-ros-base-bionic" 32 | - ROS_DISTRO="eloquent" DOCKER_IMAGE="orocos/ros2-ci:eloquent-ros-base-bionic" 33 | - ROS_DISTRO="foxy" DOCKER_IMAGE="orocos/ros2-ci:foxy-ros-base-focal" 34 | 35 | # allow failures, e.g. for unsupported distros 36 | # matrix: 37 | # allow_failures: 38 | # - env: ROS_DISTRO="lunar" ROS_REPO=ros-shadow-fixed 39 | 40 | # clone and run industrial_ci 41 | install: 42 | - git clone --quiet --depth 1 https://github.com/ros-industrial/industrial_ci.git .industrial_ci -b master 43 | script: 44 | - .industrial_ci/travis.sh 45 | -------------------------------------------------------------------------------- /rtt_ros2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2) 3 | 4 | # Default to C99 5 | if(NOT CMAKE_C_STANDARD) 6 | set(CMAKE_C_STANDARD 99) 7 | endif() 8 | 9 | # Default to C++14 10 | if(NOT CMAKE_CXX_STANDARD) 11 | set(CMAKE_CXX_STANDARD 14) 12 | endif() 13 | 14 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 15 | add_compile_options(-Wall -Wextra -Wpedantic) 16 | endif() 17 | 18 | # find dependencies 19 | find_package(ament_cmake REQUIRED) 20 | find_package(ament_index_cpp REQUIRED) 21 | find_package(Boost REQUIRED COMPONENTS filesystem system) 22 | find_package(LibXml2 REQUIRED) 23 | find_package(rclcpp REQUIRED) 24 | find_package(OROCOS-RTT REQUIRED COMPONENTS rtt-marshalling rtt-scripting) 25 | include(${OROCOS-RTT_USE_FILE_PATH}/UseOROCOS-RTT.cmake) 26 | 27 | # generate detail headers 28 | foreach(generated_header 29 | include/orocos/${PROJECT_NAME}/detail/rclcpp_version.h 30 | ) 31 | configure_file( 32 | ${generated_header}.in 33 | ${CMAKE_BINARY_DIR}/${generated_header} 34 | @ONLY 35 | ) 36 | endforeach() 37 | 38 | # setup targets 39 | include_directories(include/orocos) 40 | orocos_library(rtt_ros2 41 | src/rtt_ros2.cpp 42 | EXPORT ${PROJECT_NAME} 43 | INCLUDES DESTINATION include/orocos 44 | ) 45 | # Note: Dependency ament_index_cpp is actually not PUBLIC, but 46 | # ament_target_dependencies() does not support PRIVATE... 47 | # (https://github.com/ament/ament_cmake/issues/158) 48 | #ament_target_dependencies(rtt_ros2 PUBLIC ament_index_cpp) 49 | ament_target_dependencies(rtt_ros2 ament_index_cpp) 50 | target_link_libraries(rtt_ros2 Boost::filesystem) 51 | if(TARGET LibXml2::LibXml2) 52 | target_link_libraries(rtt_ros2 LibXml2::LibXml2) 53 | else() 54 | target_compile_definitions(rtt_ros2 PRIVATE ${LIBXML2_DEFINITIONS}) 55 | target_include_directories(rtt_ros2 PRIVATE ${LIBXML2_INCLUDE_DIR}) 56 | target_link_libraries(rtt_ros2 ${LIBXML2_LIBRARIES}) 57 | endif() 58 | 59 | orocos_plugin(rtt_ros2_service 60 | src/rtt_ros2_service.cpp 61 | ) 62 | target_link_libraries(rtt_ros2_service rtt_ros2) 63 | 64 | # install 65 | install( 66 | DIRECTORY cmake 67 | DESTINATION share/${PROJECT_NAME} 68 | ) 69 | install( 70 | DIRECTORY include/ 71 | DESTINATION include 72 | ) 73 | install( 74 | DIRECTORY ${CMAKE_BINARY_DIR}/include/ 75 | DESTINATION include 76 | ) 77 | 78 | # export information to downstream packages 79 | ament_export_dependencies(ament_index_cpp) 80 | #ament_export_dependencies(Boost) # exported in rtt_ros2-extras.cmake 81 | #ament_export_dependencies(LibXml2) # exported in rtt_ros2-extras.cmake 82 | ament_export_include_directories(include/orocos) 83 | if(COMMAND ament_export_targets) 84 | ament_export_targets(${PROJECT_NAME} HAS_LIBRARY_TARGET) 85 | else() 86 | ament_export_interfaces(${PROJECT_NAME} HAS_LIBRARY_TARGET) 87 | endif() 88 | 89 | # linters 90 | if(BUILD_TESTING) 91 | find_package(ament_lint_auto REQUIRED) 92 | ament_lint_auto_find_test_dependencies() 93 | endif() 94 | 95 | # export no plugin dependencies for this package, such that package.xml is not searched 96 | # for recursive dependencies 97 | ament_index_register_resource("rtt_ros2_plugin_depends" CONTENT "") 98 | 99 | # register environment hooks to prepend to RTT_COMPONENT_PATH and PKG_CONFIG_PATH 100 | set( 101 | AMENT_CMAKE_ENVIRONMENT_HOOKS_DESC_rtt_component_path 102 | "prepend-non-duplicate;RTT_COMPONENT_PATH;lib/orocos" 103 | ) 104 | ament_environment_hooks(env_hook/rtt_component_path.sh.in) 105 | set( 106 | AMENT_CMAKE_ENVIRONMENT_HOOKS_DESC_pkg_config_path 107 | "prepend-non-duplicate;PKG_CONFIG_PATH;lib/pkgconfig" 108 | ) 109 | ament_environment_hooks(env_hook/pkg_config_path.sh.in) 110 | 111 | # must be called *after* the targets to check exported libraries etc. 112 | ament_package( 113 | CONFIG_EXTRAS 114 | cmake/${PROJECT_NAME}-extras.cmake 115 | cmake/${PROJECT_NAME}_export_plugin_depend_hook-extras.cmake 116 | cmake/${PROJECT_NAME}_export_plugin_depend.cmake 117 | cmake/${PROJECT_NAME}_use_orocos.cmake 118 | ) 119 | 120 | # orocos_generate_package() is deprecated for ROS 2. 121 | # Prefer cmake target export and import instead, in combination with 122 | # ament_export_interfaces() or ament_export_targets() when building with 123 | # ament_cmake. 124 | orocos_generate_package() 125 | -------------------------------------------------------------------------------- /rtt_ros2/cmake/rtt_ros2-extras.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Intermodalics BVBA 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Find Boost with required components filesystem and system in downstream 16 | # packages. 17 | # See also https://github.com/ament/ament_cmake/issues/199 for why 18 | # ament_export_dependencies() cannot be used here. 19 | find_package(Boost REQUIRED COMPONENTS filesystem system) 20 | 21 | # Find LibXml2 in downstream packages 22 | find_package(LibXml2 REQUIRED) 23 | -------------------------------------------------------------------------------- /rtt_ros2/cmake/rtt_ros2_export_plugin_depend.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Intermodalics BVBA 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | macro(rtt_ros2_export_plugin_depend) 16 | if(${ARGC}) 17 | message(STATUS 18 | "[rtt_ros2] Adding RTT plugin dependency '${ARGN}' for package " 19 | "'${PROJECT_NAME}'") 20 | else() 21 | message(WARNING 22 | "[rtt_ros2] rtt_ros2_export_plugin_depend() was called without " 23 | "arguments. This is okay if you want to skip parsing package.xml for RTT " 24 | "plugin dependencies.") 25 | endif() 26 | 27 | list_append_unique(${PROJECT_NAME}_RTT_ROS2_PLUGIN_DEPENDS "${ARGN}") 28 | 29 | # Each plugin dependency is also a run-time () dependency. 30 | list_append_unique(${PROJECT_NAME}_EXEC_DEPENDS "${ARGN}") 31 | endmacro() 32 | -------------------------------------------------------------------------------- /rtt_ros2/cmake/rtt_ros2_export_plugin_depend_hook-extras.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Intermodalics BVBA 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | ament_register_extension( 16 | "ament_package" 17 | "rtt_ros2" 18 | "rtt_ros2_export_plugin_depend_hook.cmake" 19 | ) 20 | -------------------------------------------------------------------------------- /rtt_ros2/cmake/rtt_ros2_export_plugin_depend_hook.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Intermodalics BVBA 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | if(DEFINED ${PROJECT_NAME}_RTT_ROS2_PLUGIN_DEPENDS) 16 | message(STATUS "[rtt_ros2] Exporting RTT plugin dependencies '${${PROJECT_NAME}_RTT_ROS2_PLUGIN_DEPENDS}' of package '${PROJECT_NAME}'") 17 | ament_index_register_resource( 18 | "rtt_ros2_plugin_depends" 19 | CONTENT ${${PROJECT_NAME}_RTT_ROS2_PLUGIN_DEPENDS} 20 | ) 21 | endif() 22 | -------------------------------------------------------------------------------- /rtt_ros2/cmake/rtt_ros2_use_orocos.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Intermodalics BVBA 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # 16 | # Find Orocos RTT and its CMake macros (UseOROCOS-RTT.cmake) 17 | # 18 | # By default this macro also finds the RTT core plugins rtt-marshalling and 19 | # rtt-scripting. To include more plugins, you can add them as additional 20 | # arguments. 21 | # 22 | # The rtt_ros2_use_orocos() macro can be called more than once. 23 | # 24 | macro(rtt_ros2_use_orocos) 25 | find_package(OROCOS-RTT REQUIRED 26 | COMPONENTS rtt-marshalling rtt-scripting ${ARGN}) 27 | include(${OROCOS-RTT_USE_FILE_PATH}/UseOROCOS-RTT.cmake) 28 | endmacro() 29 | 30 | rtt_ros2_use_orocos() 31 | -------------------------------------------------------------------------------- /rtt_ros2/env_hook/pkg_config_path.sh.in: -------------------------------------------------------------------------------- 1 | ament_prepend_unique_value PKG_CONFIG_PATH "$AMENT_CURRENT_PREFIX/lib/pkgconfig" 2 | -------------------------------------------------------------------------------- /rtt_ros2/env_hook/rtt_component_path.sh.in: -------------------------------------------------------------------------------- 1 | ament_prepend_unique_value RTT_COMPONENT_PATH "$AMENT_CURRENT_PREFIX/lib/orocos" 2 | -------------------------------------------------------------------------------- /rtt_ros2/include/orocos/rtt_ros2/detail/rclcpp_version.h.in: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2__DETAIL__RCLCPP_VERSION_H_ 16 | #define OROCOS__RTT_ROS2__DETAIL__RCLCPP_VERSION_H_ 17 | 18 | /* True if the version of rclcpp is at least major.minor.patch */ 19 | // (from https://github.com/ros2/rmw_cyclonedds/pull/51) 20 | #ifndef rclcpp_VERSION_GTE 21 | #define rclcpp_VERSION_GTE(major, minor, patch) ( \ 22 | (major < @rclcpp_VERSION_MAJOR@) ? true \ 23 | : (major > @rclcpp_VERSION_MAJOR@) ? false \ 24 | : (minor < @rclcpp_VERSION_MINOR@) ? true \ 25 | : (minor > @rclcpp_VERSION_MINOR@) ? false \ 26 | : (patch < @rclcpp_VERSION_PATCH@) ? true \ 27 | : (patch > @rclcpp_VERSION_PATCH@) ? false \ 28 | : true) 29 | #endif 30 | 31 | #endif // OROCOS__RTT_ROS2__DETAIL__RCLCPP_VERSION_H_ 32 | -------------------------------------------------------------------------------- /rtt_ros2/include/orocos/rtt_ros2/rtt_ros2.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2__RTT_ROS2_HPP_ 16 | #define OROCOS__RTT_ROS2__RTT_ROS2_HPP_ 17 | 18 | #include 19 | 20 | namespace rtt_ros2 21 | { 22 | 23 | /// Find a ROS package's share directory 24 | /** 25 | * @param[in] package The package name 26 | * @returns The full path to the package's share directory if it has been found. 27 | * Otherwise an empty string is returned. 28 | */ 29 | std::string find(const std::string & package); 30 | 31 | /// Import a ROS package and all of its rtt_ros2/plugin_depend dependencies 32 | /** 33 | * @param[in] package The package name 34 | * @returns true on success. The packages might already have been imported before, 35 | * which is not considered a failure. 36 | */ 37 | bool import(const std::string & package); 38 | 39 | } // namespace rtt_ros2 40 | 41 | #endif // OROCOS__RTT_ROS2__RTT_ROS2_HPP_ 42 | -------------------------------------------------------------------------------- /rtt_ros2/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2 5 | 0.0.0 6 | 7 | This package provides CMake helpers, scripts and launch files to find and use 8 | Orocos RTT and OCL in a ROS 2 package and an RTT service plugin to find and 9 | import ROS packages into Orocos. 10 | 11 | Orocos Developers 12 | Apache License 2.0 13 | 14 | ament_cmake 15 | 16 | ament_index_cpp 17 | boost 18 | libxml2 19 | ocl 20 | rtt 21 | 22 | rclcpp 23 | 24 | ament_lint_auto 25 | ament_lint_common 26 | 27 | 28 | ament_cmake 29 | 30 | 31 | -------------------------------------------------------------------------------- /rtt_ros2/src/rtt_ros2_service.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "rtt/internal/GlobalService.hpp" 18 | 19 | #include "rtt_ros2/rtt_ros2.hpp" 20 | 21 | namespace rtt_ros2 22 | { 23 | 24 | static void loadROSService() 25 | { 26 | RTT::Service::shared_ptr ros = 27 | RTT::internal::GlobalService::Instance()->provides("ros"); 28 | ros->doc("ROS operations and services"); 29 | 30 | ros->addOperation("find", &rtt_ros2::find) 31 | .doc( 32 | "Finds the given ROS package and returns the full path to its share " 33 | "directory.") 34 | .arg("package", "The ROS package name"); 35 | 36 | ros->addOperation("import", &rtt_ros2::import) 37 | .doc( 38 | "Imports the Orocos plugins from a given ROS package (if found) " 39 | "along with the plugins of all of the package's " 40 | "dependencies as listed in the package.xml.") 41 | .arg("package", "The ROS package name"); 42 | } 43 | 44 | extern "C" { 45 | bool loadRTTPlugin(RTT::TaskContext * tc) 46 | { 47 | if (tc != nullptr) {return false;} 48 | loadROSService(); 49 | return true; 50 | } 51 | std::string getRTTPluginName() {return "ros2";} 52 | std::string getRTTTargetName() {return OROCOS_TARGET_NAME;} 53 | } 54 | 55 | } // namespace rtt_ros2 56 | -------------------------------------------------------------------------------- /rtt_ros2_idl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2_idl) 3 | 4 | # Default to C99 5 | if(NOT CMAKE_C_STANDARD) 6 | set(CMAKE_C_STANDARD 99) 7 | endif() 8 | 9 | # Default to C++14 10 | if(NOT CMAKE_CXX_STANDARD) 11 | set(CMAKE_CXX_STANDARD 14) 12 | endif() 13 | 14 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 15 | add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter) 16 | endif() 17 | 18 | # find dependencies 19 | find_package(ament_cmake REQUIRED) 20 | find_package(ament_cmake_python REQUIRED) 21 | find_package(rtt_ros2 REQUIRED) 22 | 23 | # setup Python module 24 | ament_python_install_package(${PROJECT_NAME} 25 | PACKAGE_DIR src/${PROJECT_NAME} 26 | ) 27 | 28 | # install 29 | install( 30 | DIRECTORY include/ 31 | DESTINATION include 32 | ) 33 | 34 | # linters 35 | if(BUILD_TESTING) 36 | find_package(ament_lint_auto REQUIRED) 37 | ament_lint_auto_find_test_dependencies() 38 | endif() 39 | 40 | # export information to downstream packages 41 | ament_export_dependencies(rosidl_cmake) 42 | ament_export_dependencies(rosidl_generator_cpp) 43 | ament_export_dependencies(rosidl_typesupport_introspection_cpp) 44 | ament_export_dependencies(rtt_ros2) 45 | ament_export_include_directories(include/orocos) 46 | 47 | # must be called *after* the targets to check exported libraries etc. 48 | ament_package( 49 | CONFIG_EXTRAS 50 | cmake/${PROJECT_NAME}-extras.cmake.in 51 | cmake/${PROJECT_NAME}-generate_typekit.cmake 52 | ) 53 | 54 | # orocos_generate_package() is deprecated for ROS 2. 55 | # Prefer cmake target export and import instead, in combination with 56 | # ament_export_interfaces() or ament_export_targets() when building with 57 | # ament_cmake. 58 | orocos_generate_package( 59 | DEPENDS_TARGETS rtt_ros2 60 | ) 61 | -------------------------------------------------------------------------------- /rtt_ros2_idl/cmake/rtt_ros2_idl-extras.cmake.in: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Intermodalics BVBA 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | set(rtt_ros2_idl_GENERATOR_FILES 16 | "${rtt_ros2_idl_DIR}/../../../@PYTHON_INSTALL_DIR@/rtt_ros2_idl/__init__.py") 17 | normalize_path(rtt_ros2_idl_GENERATOR_FILES "${rtt_ros2_idl_GENERATOR_FILES}") 18 | 19 | set(rtt_ros2_idl_TEMPLATE_DIR "${rtt_ros2_idl_DIR}/../../../@PYTHON_INSTALL_DIR@/rtt_ros2_idl/resource") 20 | normalize_path(rtt_ros2_idl_TEMPLATE_DIR "${rtt_ros2_idl_TEMPLATE_DIR}") 21 | -------------------------------------------------------------------------------- /rtt_ros2_idl/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2_idl 5 | 0.0.0 6 | 7 | This package provides a CMake function, templates and a TypeInfoGenerator implementation 8 | that leverages ROS 2 C++ introspection type support in order to generate and build 9 | Orocos RTT typekit plugins for existing ROS 2 interface (messages, services, actions) packages. 10 | 11 | Orocos Developers 12 | Apache License 2.0 13 | 14 | ament_cmake 15 | 16 | rtt_ros2 17 | rosidl_cmake 18 | rosidl_generator_cpp 19 | rosidl_typesupport_introspection_cpp 20 | 21 | rtt_ros2_primitives_typekit 22 | 23 | ament_lint_auto 24 | ament_lint_common 25 | 26 | 27 | ament_cmake 28 | 29 | 30 | -------------------------------------------------------------------------------- /rtt_ros2_idl/src/rtt_ros2_idl/__main__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Intermodalics BVBA 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import sys 16 | from rtt_ros2_idl import main 17 | 18 | sys.exit(main()) 19 | -------------------------------------------------------------------------------- /rtt_ros2_idl/src/rtt_ros2_idl/resource/Types.hpp.em: -------------------------------------------------------------------------------- 1 | @{ 2 | from rosidl_cmake import convert_camel_case_to_lower_case_underscore 3 | }@ 4 | // generated from rtt_ros2_idl/src/rtt_ros2_idl/resource/Types.hpp.em 5 | // generated code does not contain a copyright notice 6 | 7 | #ifndef OROCOS__@(pkg_name)__TYPES_HPP 8 | #define OROCOS__@(pkg_name)__TYPES_HPP 9 | 10 | @[for message in messages]@ 11 | #include "msg/@(convert_camel_case_to_lower_case_underscore(message))_Types.hpp" 12 | @[end for]@ 13 | 14 | @[for service in services]@ 15 | #include "srv/@(convert_camel_case_to_lower_case_underscore(service))_Types.hpp" 16 | @[end for]@ 17 | 18 | @[for action in actions]@ 19 | #include "action/@(convert_camel_case_to_lower_case_underscore(action))_Types.hpp" 20 | @[end for]@ 21 | 22 | #endif // OROCOS__@(pkg_name)__TYPES_HPP 23 | -------------------------------------------------------------------------------- /rtt_ros2_idl/src/rtt_ros2_idl/resource/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Intermodalics BVBA 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import pathlib 16 | 17 | 18 | TEMPLATE_DIR = pathlib.Path(__file__).parent 19 | -------------------------------------------------------------------------------- /rtt_ros2_idl/src/rtt_ros2_idl/resource/action_Types.hpp.em: -------------------------------------------------------------------------------- 1 | // generated from rtt_ros2_idl/src/rtt_ros2_idl/resource/action_Types.hpp.em 2 | // generated code does not contain a copyright notice 3 | 4 | #ifndef OROCOS__@(pkg_name)__ACTION__@(action_name)__TYPES_HPP 5 | #define OROCOS__@(pkg_name)__ACTION__@(action_name)__TYPES_HPP 6 | 7 | #include "rtt/internal/AssignCommand.hpp" 8 | #include "rtt/internal/DataSources.hpp" 9 | #include "rtt/Attribute.hpp" 10 | #include "rtt/InputPort.hpp" 11 | #include "rtt/OutputPort.hpp" 12 | #include "rtt/Property.hpp" 13 | 14 | #include "@(action_header)" 15 | 16 | extern template class RTT::internal::DataSource< @(pkg_name)::action::@(action_name)::Goal >; 17 | extern template class RTT::internal::AssignableDataSource< @(pkg_name)::action::@(action_name)::Goal >; 18 | extern template class RTT::internal::AssignCommand< @(pkg_name)::action::@(action_name)::Goal >; 19 | extern template class RTT::internal::ValueDataSource< @(pkg_name)::action::@(action_name)::Goal >; 20 | extern template class RTT::internal::ConstantDataSource< @(pkg_name)::action::@(action_name)::Goal >; 21 | extern template class RTT::internal::ReferenceDataSource< @(pkg_name)::action::@(action_name)::Goal >; 22 | extern template class RTT::OutputPort< @(pkg_name)::action::@(action_name)::Goal >; 23 | extern template class RTT::InputPort< @(pkg_name)::action::@(action_name)::Goal >; 24 | extern template class RTT::Property< @(pkg_name)::action::@(action_name)::Goal >; 25 | extern template class RTT::Attribute< @(pkg_name)::action::@(action_name)::Goal >; 26 | extern template class RTT::Constant< @(pkg_name)::action::@(action_name)::Goal >; 27 | 28 | extern template class RTT::internal::DataSource< @(pkg_name)::action::@(action_name)::Feedback >; 29 | extern template class RTT::internal::AssignableDataSource< @(pkg_name)::action::@(action_name)::Feedback >; 30 | extern template class RTT::internal::AssignCommand< @(pkg_name)::action::@(action_name)::Feedback >; 31 | extern template class RTT::internal::ValueDataSource< @(pkg_name)::action::@(action_name)::Feedback >; 32 | extern template class RTT::internal::ConstantDataSource< @(pkg_name)::action::@(action_name)::Feedback >; 33 | extern template class RTT::internal::ReferenceDataSource< @(pkg_name)::action::@(action_name)::Feedback >; 34 | extern template class RTT::OutputPort< @(pkg_name)::action::@(action_name)::Feedback >; 35 | extern template class RTT::InputPort< @(pkg_name)::action::@(action_name)::Feedback >; 36 | extern template class RTT::Property< @(pkg_name)::action::@(action_name)::Feedback >; 37 | extern template class RTT::Attribute< @(pkg_name)::action::@(action_name)::Feedback >; 38 | extern template class RTT::Constant< @(pkg_name)::action::@(action_name)::Feedback >; 39 | 40 | extern template class RTT::internal::DataSource< @(pkg_name)::action::@(action_name)::Result >; 41 | extern template class RTT::internal::AssignableDataSource< @(pkg_name)::action::@(action_name)::Result >; 42 | extern template class RTT::internal::AssignCommand< @(pkg_name)::action::@(action_name)::Result >; 43 | extern template class RTT::internal::ValueDataSource< @(pkg_name)::action::@(action_name)::Result >; 44 | extern template class RTT::internal::ConstantDataSource< @(pkg_name)::action::@(action_name)::Result >; 45 | extern template class RTT::internal::ReferenceDataSource< @(pkg_name)::action::@(action_name)::Result >; 46 | extern template class RTT::OutputPort< @(pkg_name)::action::@(action_name)::Result >; 47 | extern template class RTT::InputPort< @(pkg_name)::action::@(action_name)::Result >; 48 | extern template class RTT::Property< @(pkg_name)::action::@(action_name)::Result >; 49 | extern template class RTT::Attribute< @(pkg_name)::action::@(action_name)::Result >; 50 | extern template class RTT::Constant< @(pkg_name)::action::@(action_name)::Result >; 51 | 52 | #endif // OROCOS__@(pkg_name)__ACTION__@(action_name)__TYPES_HPP 53 | -------------------------------------------------------------------------------- /rtt_ros2_idl/src/rtt_ros2_idl/resource/action_typekit.cpp.em: -------------------------------------------------------------------------------- 1 | // generated from rtt_ros2_idl/src/rtt_ros2_idl/resource/action_typekit.cpp.em 2 | // generated code does not contain a copyright notice 3 | 4 | #include "@(header_name)_Types.hpp" 5 | 6 | #include "rtt_ros2_idl/RosIntrospectionTypeInfo.hpp" 7 | 8 | template class RTT::internal::DataSource< @(pkg_name)::action::@(action_name)::Goal >; 9 | template class RTT::internal::AssignableDataSource< @(pkg_name)::action::@(action_name)::Goal >; 10 | template class RTT::internal::AssignCommand< @(pkg_name)::action::@(action_name)::Goal >; 11 | template class RTT::internal::ValueDataSource< @(pkg_name)::action::@(action_name)::Goal >; 12 | template class RTT::internal::ConstantDataSource< @(pkg_name)::action::@(action_name)::Goal >; 13 | template class RTT::internal::ReferenceDataSource< @(pkg_name)::action::@(action_name)::Goal >; 14 | template class RTT::OutputPort< @(pkg_name)::action::@(action_name)::Goal >; 15 | template class RTT::InputPort< @(pkg_name)::action::@(action_name)::Goal >; 16 | template class RTT::Property< @(pkg_name)::action::@(action_name)::Goal >; 17 | template class RTT::Attribute< @(pkg_name)::action::@(action_name)::Goal >; 18 | template class RTT::Constant< @(pkg_name)::action::@(action_name)::Goal >; 19 | 20 | template class RTT::internal::DataSource< @(pkg_name)::action::@(action_name)::Feedback >; 21 | template class RTT::internal::AssignableDataSource< @(pkg_name)::action::@(action_name)::Feedback >; 22 | template class RTT::internal::AssignCommand< @(pkg_name)::action::@(action_name)::Feedback >; 23 | template class RTT::internal::ValueDataSource< @(pkg_name)::action::@(action_name)::Feedback >; 24 | template class RTT::internal::ConstantDataSource< @(pkg_name)::action::@(action_name)::Feedback >; 25 | template class RTT::internal::ReferenceDataSource< @(pkg_name)::action::@(action_name)::Feedback >; 26 | template class RTT::OutputPort< @(pkg_name)::action::@(action_name)::Feedback >; 27 | template class RTT::InputPort< @(pkg_name)::action::@(action_name)::Feedback >; 28 | template class RTT::Property< @(pkg_name)::action::@(action_name)::Feedback >; 29 | template class RTT::Attribute< @(pkg_name)::action::@(action_name)::Feedback >; 30 | template class RTT::Constant< @(pkg_name)::action::@(action_name)::Feedback >; 31 | 32 | template class RTT::internal::DataSource< @(pkg_name)::action::@(action_name)::Result >; 33 | template class RTT::internal::AssignableDataSource< @(pkg_name)::action::@(action_name)::Result >; 34 | template class RTT::internal::AssignCommand< @(pkg_name)::action::@(action_name)::Result >; 35 | template class RTT::internal::ValueDataSource< @(pkg_name)::action::@(action_name)::Result >; 36 | template class RTT::internal::ConstantDataSource< @(pkg_name)::action::@(action_name)::Result >; 37 | template class RTT::internal::ReferenceDataSource< @(pkg_name)::action::@(action_name)::Result >; 38 | template class RTT::OutputPort< @(pkg_name)::action::@(action_name)::Result >; 39 | template class RTT::InputPort< @(pkg_name)::action::@(action_name)::Result >; 40 | template class RTT::Property< @(pkg_name)::action::@(action_name)::Result >; 41 | template class RTT::Attribute< @(pkg_name)::action::@(action_name)::Result >; 42 | template class RTT::Constant< @(pkg_name)::action::@(action_name)::Result >; 43 | 44 | template class rtt_ros2_idl::RosIntrospectionTypeInfo< @(pkg_name)::action::@(action_name)::Goal >; 45 | template class rtt_ros2_idl::RosIntrospectionTypeInfo< @(pkg_name)::action::@(action_name)::Feedback >; 46 | template class rtt_ros2_idl::RosIntrospectionTypeInfo< @(pkg_name)::action::@(action_name)::Result >; 47 | -------------------------------------------------------------------------------- /rtt_ros2_idl/src/rtt_ros2_idl/resource/msg_Types.hpp.em: -------------------------------------------------------------------------------- 1 | // generated from rtt_ros2_idl/src/rtt_ros2_idl/resource/msg_Types.hpp.em 2 | // generated code does not contain a copyright notice 3 | 4 | #ifndef OROCOS__@(pkg_name)__MSG__@(msg_name)__TYPES_HPP 5 | #define OROCOS__@(pkg_name)__MSG__@(msg_name)__TYPES_HPP 6 | 7 | #include "rtt/internal/AssignCommand.hpp" 8 | #include "rtt/internal/DataSources.hpp" 9 | #include "rtt/Attribute.hpp" 10 | #include "rtt/InputPort.hpp" 11 | #include "rtt/OutputPort.hpp" 12 | #include "rtt/Property.hpp" 13 | 14 | #include "@(msg_header)" 15 | 16 | extern template class RTT::internal::DataSource< @(pkg_name)::msg::@(msg_name) >; 17 | extern template class RTT::internal::AssignableDataSource< @(pkg_name)::msg::@(msg_name) >; 18 | extern template class RTT::internal::AssignCommand< @(pkg_name)::msg::@(msg_name) >; 19 | extern template class RTT::internal::ValueDataSource< @(pkg_name)::msg::@(msg_name) >; 20 | extern template class RTT::internal::ConstantDataSource< @(pkg_name)::msg::@(msg_name) >; 21 | extern template class RTT::internal::ReferenceDataSource< @(pkg_name)::msg::@(msg_name) >; 22 | extern template class RTT::OutputPort< @(pkg_name)::msg::@(msg_name) >; 23 | extern template class RTT::InputPort< @(pkg_name)::msg::@(msg_name) >; 24 | extern template class RTT::Property< @(pkg_name)::msg::@(msg_name) >; 25 | extern template class RTT::Attribute< @(pkg_name)::msg::@(msg_name) >; 26 | extern template class RTT::Constant< @(pkg_name)::msg::@(msg_name) >; 27 | 28 | #endif // OROCOS__@(pkg_name)__MSG__@(msg_name)__TYPES_HPP 29 | -------------------------------------------------------------------------------- /rtt_ros2_idl/src/rtt_ros2_idl/resource/msg_typekit.cpp.em: -------------------------------------------------------------------------------- 1 | // generated from rtt_ros2_idl/src/rtt_ros2_idl/resource/msg_typekit.cpp.em 2 | // generated code does not contain a copyright notice 3 | 4 | #include "@(header_name)_Types.hpp" 5 | 6 | #include 7 | 8 | #include "rtt_ros2_idl/RosIntrospectionTypeInfo.hpp" 9 | #include "rtt/types/PrimitiveSequenceTypeInfo.hpp" 10 | #include "rtt/types/CArrayTypeInfo.hpp" 11 | 12 | template class RTT::internal::DataSource< @(pkg_name)::msg::@(msg_name) >; 13 | template class RTT::internal::AssignableDataSource< @(pkg_name)::msg::@(msg_name) >; 14 | template class RTT::internal::AssignCommand< @(pkg_name)::msg::@(msg_name) >; 15 | template class RTT::internal::ValueDataSource< @(pkg_name)::msg::@(msg_name) >; 16 | template class RTT::internal::ConstantDataSource< @(pkg_name)::msg::@(msg_name) >; 17 | template class RTT::internal::ReferenceDataSource< @(pkg_name)::msg::@(msg_name) >; 18 | template class RTT::OutputPort< @(pkg_name)::msg::@(msg_name) >; 19 | template class RTT::InputPort< @(pkg_name)::msg::@(msg_name) >; 20 | template class RTT::Property< @(pkg_name)::msg::@(msg_name) >; 21 | template class RTT::Attribute< @(pkg_name)::msg::@(msg_name) >; 22 | template class RTT::Constant< @(pkg_name)::msg::@(msg_name) >; 23 | 24 | template class rtt_ros2_idl::RosIntrospectionTypeInfo< @(pkg_name)::msg::@(msg_name) >; 25 | template class RTT::types::PrimitiveSequenceTypeInfo >; 26 | template class RTT::types::CArrayTypeInfo >; 27 | -------------------------------------------------------------------------------- /rtt_ros2_idl/src/rtt_ros2_idl/resource/srv_Types.hpp.em: -------------------------------------------------------------------------------- 1 | // generated from rtt_ros2_idl/src/rtt_ros2_idl/resource/srv_Types.hpp.em 2 | // generated code does not contain a copyright notice 3 | 4 | #ifndef OROCOS__@(pkg_name)__SRV__@(srv_name)__TYPES_HPP 5 | #define OROCOS__@(pkg_name)__SRV__@(srv_name)__TYPES_HPP 6 | 7 | #include "rtt/internal/AssignCommand.hpp" 8 | #include "rtt/internal/DataSources.hpp" 9 | #include "rtt/Attribute.hpp" 10 | #include "rtt/InputPort.hpp" 11 | #include "rtt/OutputPort.hpp" 12 | #include "rtt/Property.hpp" 13 | 14 | #include "@(srv_header)" 15 | 16 | extern template class RTT::internal::DataSource< @(pkg_name)::srv::@(srv_name)::Request >; 17 | extern template class RTT::internal::AssignableDataSource< @(pkg_name)::srv::@(srv_name)::Request >; 18 | extern template class RTT::internal::AssignCommand< @(pkg_name)::srv::@(srv_name)::Request >; 19 | extern template class RTT::internal::ValueDataSource< @(pkg_name)::srv::@(srv_name)::Request >; 20 | extern template class RTT::internal::ConstantDataSource< @(pkg_name)::srv::@(srv_name)::Request >; 21 | extern template class RTT::internal::ReferenceDataSource< @(pkg_name)::srv::@(srv_name)::Request >; 22 | extern template class RTT::OutputPort< @(pkg_name)::srv::@(srv_name)::Request >; 23 | extern template class RTT::InputPort< @(pkg_name)::srv::@(srv_name)::Request >; 24 | extern template class RTT::Property< @(pkg_name)::srv::@(srv_name)::Request >; 25 | extern template class RTT::Attribute< @(pkg_name)::srv::@(srv_name)::Request >; 26 | extern template class RTT::Constant< @(pkg_name)::srv::@(srv_name)::Request >; 27 | 28 | extern template class RTT::internal::DataSource< @(pkg_name)::srv::@(srv_name)::Response >; 29 | extern template class RTT::internal::AssignableDataSource< @(pkg_name)::srv::@(srv_name)::Response >; 30 | extern template class RTT::internal::AssignCommand< @(pkg_name)::srv::@(srv_name)::Response >; 31 | extern template class RTT::internal::ValueDataSource< @(pkg_name)::srv::@(srv_name)::Response >; 32 | extern template class RTT::internal::ConstantDataSource< @(pkg_name)::srv::@(srv_name)::Response >; 33 | extern template class RTT::internal::ReferenceDataSource< @(pkg_name)::srv::@(srv_name)::Response >; 34 | extern template class RTT::OutputPort< @(pkg_name)::srv::@(srv_name)::Response >; 35 | extern template class RTT::InputPort< @(pkg_name)::srv::@(srv_name)::Response >; 36 | extern template class RTT::Property< @(pkg_name)::srv::@(srv_name)::Response >; 37 | extern template class RTT::Attribute< @(pkg_name)::srv::@(srv_name)::Response >; 38 | extern template class RTT::Constant< @(pkg_name)::srv::@(srv_name)::Response >; 39 | 40 | #endif // OROCOS__@(pkg_name)__SRV__@(srv_name)__TYPES_HPP 41 | -------------------------------------------------------------------------------- /rtt_ros2_idl/src/rtt_ros2_idl/resource/srv_typekit.cpp.em: -------------------------------------------------------------------------------- 1 | // generated from rtt_ros2_idl/src/rtt_ros2_idl/resource/srv_typekit.cpp.em 2 | // generated code does not contain a copyright notice 3 | 4 | #include "@(header_name)_Types.hpp" 5 | 6 | #include "rtt_ros2_idl/RosIntrospectionTypeInfo.hpp" 7 | 8 | template class RTT::internal::DataSource< @(pkg_name)::srv::@(srv_name)::Request >; 9 | template class RTT::internal::AssignableDataSource< @(pkg_name)::srv::@(srv_name)::Request >; 10 | template class RTT::internal::AssignCommand< @(pkg_name)::srv::@(srv_name)::Request >; 11 | template class RTT::internal::ValueDataSource< @(pkg_name)::srv::@(srv_name)::Request >; 12 | template class RTT::internal::ConstantDataSource< @(pkg_name)::srv::@(srv_name)::Request >; 13 | template class RTT::internal::ReferenceDataSource< @(pkg_name)::srv::@(srv_name)::Request >; 14 | template class RTT::OutputPort< @(pkg_name)::srv::@(srv_name)::Request >; 15 | template class RTT::InputPort< @(pkg_name)::srv::@(srv_name)::Request >; 16 | template class RTT::Property< @(pkg_name)::srv::@(srv_name)::Request >; 17 | template class RTT::Attribute< @(pkg_name)::srv::@(srv_name)::Request >; 18 | template class RTT::Constant< @(pkg_name)::srv::@(srv_name)::Request >; 19 | 20 | template class RTT::internal::DataSource< @(pkg_name)::srv::@(srv_name)::Response >; 21 | template class RTT::internal::AssignableDataSource< @(pkg_name)::srv::@(srv_name)::Response >; 22 | template class RTT::internal::AssignCommand< @(pkg_name)::srv::@(srv_name)::Response >; 23 | template class RTT::internal::ValueDataSource< @(pkg_name)::srv::@(srv_name)::Response >; 24 | template class RTT::internal::ConstantDataSource< @(pkg_name)::srv::@(srv_name)::Response >; 25 | template class RTT::internal::ReferenceDataSource< @(pkg_name)::srv::@(srv_name)::Response >; 26 | template class RTT::OutputPort< @(pkg_name)::srv::@(srv_name)::Response >; 27 | template class RTT::InputPort< @(pkg_name)::srv::@(srv_name)::Response >; 28 | template class RTT::Property< @(pkg_name)::srv::@(srv_name)::Response >; 29 | template class RTT::Attribute< @(pkg_name)::srv::@(srv_name)::Response >; 30 | template class RTT::Constant< @(pkg_name)::srv::@(srv_name)::Response >; 31 | 32 | template class rtt_ros2_idl::RosIntrospectionTypeInfo< @(pkg_name)::srv::@(srv_name)::Request >; 33 | template class rtt_ros2_idl::RosIntrospectionTypeInfo< @(pkg_name)::srv::@(srv_name)::Response >; 34 | -------------------------------------------------------------------------------- /rtt_ros2_idl/src/rtt_ros2_idl/resource/typekit_plugin.cpp.em: -------------------------------------------------------------------------------- 1 | // generated from rtt_ros2_idl/src/rtt_ros2_idl/resource/typekit_plugin.cpp.em 2 | // generated code does not contain a copyright notice 3 | 4 | #include "rtt/types/TypekitPlugin.hpp" 5 | 6 | #include "rtt_ros2_idl/RosIntrospectionTypeInfo.hpp" 7 | #include "rtt/types/PrimitiveSequenceTypeInfo.hpp" 8 | #include "rtt/types/CArrayTypeInfo.hpp" 9 | 10 | #include "Types.hpp" 11 | 12 | // extern template declarations for TypeInfo generators 13 | @[for msg_name in messages]@ 14 | extern template class rtt_ros2_idl::RosIntrospectionTypeInfo<@(pkg_name)::msg::@(msg_name)>; 15 | extern template class RTT::types::PrimitiveSequenceTypeInfo>; 16 | extern template class RTT::types::CArrayTypeInfo>; 17 | @[end for]@ 18 | @[for srv_name in services]@ 19 | extern template class rtt_ros2_idl::RosIntrospectionTypeInfo<@(pkg_name)::srv::@(srv_name)::Request>; 20 | extern template class rtt_ros2_idl::RosIntrospectionTypeInfo<@(pkg_name)::srv::@(srv_name)::Response>; 21 | @[end for]@ 22 | @[for action_name in actions]@ 23 | extern template class rtt_ros2_idl::RosIntrospectionTypeInfo<@(pkg_name)::action::@(action_name)::Goal>; 24 | extern template class rtt_ros2_idl::RosIntrospectionTypeInfo<@(pkg_name)::action::@(action_name)::Feedback>; 25 | extern template class rtt_ros2_idl::RosIntrospectionTypeInfo<@(pkg_name)::action::@(action_name)::Result>; 26 | @[end for]@ 27 | 28 | namespace rtt_ros2_@(pkg_name) { 29 | 30 | class TypekitPlugin : public RTT::types::TypekitPlugin 31 | { 32 | public: 33 | bool loadTypes() override 34 | { 35 | // Only the .msg type is sent over ports. The msg[] (variable size) and cmsg[] (fixed size) exist only as members of larger messages. 36 | @[for msg_name in messages]@ 37 | RTT::types::Types()->addType(new rtt_ros2_idl::RosIntrospectionTypeInfo<@(pkg_name)::msg::@(msg_name)>("/@(pkg_name)/msg/@(msg_name)")); 38 | RTT::types::Types()->addType(new RTT::types::PrimitiveSequenceTypeInfo >("/@(pkg_name)/msg/@(msg_name)[]")); 39 | RTT::types::Types()->addType(new RTT::types::CArrayTypeInfo >("/@(pkg_name)/msg/@(msg_name)[c]")); 40 | @[end for]@ 41 | @[for srv_name in services]@ 42 | RTT::types::Types()->addType(new rtt_ros2_idl::RosIntrospectionTypeInfo<@(pkg_name)::srv::@(srv_name)::Request>("/@(pkg_name)/srv/@(srv_name)_Request")); 43 | RTT::types::Types()->addType(new rtt_ros2_idl::RosIntrospectionTypeInfo<@(pkg_name)::srv::@(srv_name)::Response>("/@(pkg_name)/srv/@(srv_name)_Response")); 44 | @[end for]@ 45 | @[for action_name in actions]@ 46 | RTT::types::Types()->addType(new rtt_ros2_idl::RosIntrospectionTypeInfo<@(pkg_name)::action::@(action_name)::Goal>("/@(pkg_name)/action/@(action_name)_Goal")); 47 | RTT::types::Types()->addType(new rtt_ros2_idl::RosIntrospectionTypeInfo<@(pkg_name)::action::@(action_name)::Feedback>("/@(pkg_name)/action/@(action_name)_Feedback")); 48 | RTT::types::Types()->addType(new rtt_ros2_idl::RosIntrospectionTypeInfo<@(pkg_name)::action::@(action_name)::Result>("/@(pkg_name)/action/@(action_name)_Result")); 49 | @[end for]@ 50 | return true; 51 | } 52 | 53 | bool loadOperators() override { return true; } 54 | bool loadConstructors() override { return true; } 55 | bool loadGlobals() { return true; } 56 | 57 | std::string getName() override 58 | { 59 | return "ros2-@(pkg_name)"; 60 | } 61 | }; 62 | 63 | } // namespace rtt_ros2_@(pkg_name) 64 | 65 | ORO_TYPEKIT_PLUGIN(rtt_ros2_@(pkg_name)::TypekitPlugin) 66 | -------------------------------------------------------------------------------- /rtt_ros2_interfaces/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2_interfaces) 3 | 4 | # find dependencies 5 | find_package(ament_cmake REQUIRED) 6 | find_package(rtt_ros2_idl REQUIRED) 7 | find_package(rtt_ros2_services REQUIRED) 8 | find_package(rtt_ros2_topics REQUIRED) 9 | 10 | # install typekit package template and create_typekit_package script 11 | install( 12 | DIRECTORY template 13 | DESTINATION share/${PROJECT_NAME}/ 14 | ) 15 | install(PROGRAMS scripts/create_typekit_package 16 | DESTINATION lib/${PROJECT_NAME}/ 17 | ) 18 | 19 | # linters 20 | if(BUILD_TESTING) 21 | find_package(ament_lint_auto REQUIRED) 22 | ament_lint_auto_find_test_dependencies() 23 | endif() 24 | 25 | # export information to downstream packages 26 | ament_export_dependencies(rtt_ros2_idl) 27 | ament_export_dependencies(rtt_ros2_topics) 28 | ament_export_dependencies(rtt_ros2_services) 29 | 30 | # must be called *after* the targets to check exported libraries etc. 31 | ament_package( 32 | CONFIG_EXTRAS 33 | cmake/${PROJECT_NAME}-generate_interfaces_plugins.cmake 34 | ) 35 | 36 | # orocos_generate_package() is deprecated for ROS 2. 37 | # Prefer cmake target export and import instead, in combination with 38 | # ament_export_interfaces() or ament_export_targets() when building with 39 | # ament_cmake. 40 | orocos_generate_package( 41 | DEPENDS_TARGETS 42 | rtt_ros2_idl 43 | rtt_ros2_services 44 | rtt_ros2_topics 45 | ) 46 | -------------------------------------------------------------------------------- /rtt_ros2_interfaces/cmake/rtt_ros2_interfaces-generate_interfaces_plugins.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Intermodalics BVBA 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # 16 | # Generate an RTT typekit, ROS transport and ROS service plugins for all 17 | # messages, services and actions defined in a ROS interface packages. 18 | # 19 | macro(rtt_ros2_generate_interfaces_plugins _package) 20 | rtt_ros2_generate_typekit(${_package} ${ARGN}) 21 | rtt_ros2_generate_ros_transport(${_package} ${ARGN}) 22 | rtt_ros2_generate_ros_service_plugin(${_package} ${ARGN}) 23 | endmacro() 24 | 25 | macro(rtt_ros2_generate_typekit_and_transports _package) 26 | message(WARNING 27 | "rtt_ros2_generate_typekit_and_transports() is deprecated. Please use macro" 28 | "rtt_ros2_generate_interfaces_plugins() instead.") 29 | rtt_ros2_generate_interfaces_plugins(${_package} ${ARGN}) 30 | endmacro() 31 | -------------------------------------------------------------------------------- /rtt_ros2_interfaces/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2_interfaces 5 | 0.0.0 6 | 7 | All-in-one package which provides a CMake function to generate ROS 2 typekit and transport 8 | plugins for ROS 2 interface packages (messages, services, actions). 9 | 10 | Orocos Developers 11 | Apache License 2.0 12 | 13 | ament_cmake 14 | 15 | rtt_ros2_idl 16 | rtt_ros2_services 17 | rtt_ros2_topics 18 | 19 | 20 | ament_index_python 21 | rosidl_cmake 22 | 23 | ament_lint_auto 24 | ament_lint_common 25 | 26 | 27 | ament_cmake 28 | 29 | 30 | -------------------------------------------------------------------------------- /rtt_ros2_interfaces/scripts/create_typekit_package: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright 2020 Intermodalics BVBA 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | import argparse 17 | from pathlib import Path 18 | import sys 19 | 20 | from ament_index_python.packages import get_package_share_directory 21 | from rosidl_cmake import expand_template 22 | 23 | TEMPLATE_DIR = Path(get_package_share_directory('rtt_ros2_interfaces')) / 'template' 24 | AVAILABLE_TRANSPORTS = ( 25 | 'ros', 26 | ) 27 | DEFAULT_TRANSPORTS = ['ros'] 28 | 29 | 30 | def create_typekit_package(package, transports, **kwargs): 31 | # Create package directory 32 | if kwargs.get('destination_directory', None): 33 | destination_directory = Path(kwargs['destination_directory']) 34 | else: 35 | destination_directory = Path.cwd() 36 | destination_directory = destination_directory / f"rtt_ros2_{package}" 37 | destination_directory.mkdir(parents=True) 38 | 39 | # Generate files 40 | data = kwargs 41 | data.update({ 42 | 'package': package, 43 | 'transports': transports, 44 | }) 45 | for file in ('package.xml', 'CMakeLists.txt'): 46 | expand_template( 47 | file, 48 | data=data, 49 | output_file=(destination_directory / file), 50 | template_basepath=TEMPLATE_DIR) 51 | 52 | 53 | def main(argv=sys.argv[1:]): 54 | parser = argparse.ArgumentParser( 55 | description='Generate an RTT typekit package.', 56 | formatter_class=argparse.ArgumentDefaultsHelpFormatter) 57 | parser.add_argument( 58 | 'package', metavar='PACKAGE', 59 | help='The name of the interface package') 60 | 61 | parser.add_argument( 62 | '--destination-directory', '-d', 63 | default='.', 64 | help='Directory where to create the package directory (not including the package name)') 65 | 66 | plugins_group = parser.add_argument_group('plugin options') 67 | plugins_group.add_argument( 68 | '--transports', nargs='+', metavar='TRANSPORT', choices=AVAILABLE_TRANSPORTS, 69 | default=DEFAULT_TRANSPORTS, 70 | help='Whether to add a ROS transport plugin (available: ' + 71 | ' '.join(AVAILABLE_TRANSPORTS) + ')') 72 | plugins_group.add_argument( 73 | '--no-transport', action='store_const', dest='transports', const=[], 74 | default=argparse.SUPPRESS, 75 | help='Create a pure typekit package (no transport plugins)') 76 | 77 | package_xml_group = parser.add_argument_group('package.xml options') 78 | package_xml_group.add_argument( 79 | '--description', 80 | default='Automatic-generated rtt typekit from ros2 interface', 81 | help='The description given in the package.xml') 82 | package_xml_group.add_argument( 83 | '--license', 84 | default='Apache License 2.0', 85 | help='The license attached to this package') 86 | package_xml_group.add_argument( 87 | '--maintainer-email', 88 | default='orocos-dev@orocos.org', 89 | help='email address of the maintainer of this package') 90 | package_xml_group.add_argument( 91 | '--maintainer-name', 92 | default='Orocos Developers', 93 | help='name of the maintainer of this package') 94 | 95 | args = parser.parse_args(argv) 96 | return create_typekit_package(**vars(args)) 97 | 98 | 99 | if __name__ == '__main__': 100 | main() 101 | -------------------------------------------------------------------------------- /rtt_ros2_interfaces/template/AMENT_IGNORE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orocos/rtt_ros2_integration/18b20fdd3d0b47a28f729703a26f1a162d427d3e/rtt_ros2_interfaces/template/AMENT_IGNORE -------------------------------------------------------------------------------- /rtt_ros2_interfaces/template/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2_@(package)) 3 | 4 | # Default to C99 5 | if(NOT CMAKE_C_STANDARD) 6 | set(CMAKE_C_STANDARD 99) 7 | endif() 8 | 9 | # Default to C++14 10 | if(NOT CMAKE_CXX_STANDARD) 11 | set(CMAKE_CXX_STANDARD 14) 12 | endif() 13 | 14 | # if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 15 | # add_compile_options(-Wall -Wextra -Wpedantic) 16 | # endif() 17 | 18 | # find dependencies 19 | find_package(ament_cmake REQUIRED) 20 | @[if transports]@ 21 | find_package(rtt_ros2_interfaces REQUIRED) 22 | @[else]@ 23 | find_package(rtt_ros2_idl REQUIRED) 24 | @[end if]@ 25 | 26 | @[if transports]@ 27 | rtt_ros2_generate_interfaces_plugins(@(package)) 28 | @[else]@ 29 | rtt_ros2_generate_typekit(@(package)) 30 | @[end if]@ 31 | 32 | # linters 33 | if(BUILD_TESTING) 34 | find_package(ament_lint_auto REQUIRED) 35 | ament_lint_auto_find_test_dependencies() 36 | endif() 37 | 38 | # must be called *after* the targets to check exported libraries etc. 39 | ament_package() 40 | 41 | # orocos_generate_package() is deprecated for ROS 2. 42 | # Prefer cmake target export and import instead, in combination with 43 | # ament_export_interfaces() or ament_export_targets() when building with 44 | # ament_cmake. 45 | orocos_generate_package( 46 | @[if transports]@ 47 | DEPENDS_TARGETS rtt_ros2_interfaces 48 | @[else]@ 49 | DEPENDS_TARGETS rtt_ros2_idl 50 | @[end if]@ 51 | ) 52 | -------------------------------------------------------------------------------- /rtt_ros2_interfaces/template/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2_@(package) 5 | 0.0.0 6 | @(description or f"RTT typekit {'and transport plugins ' if transports else ''}for {package}") 7 | @(maintainer_name or "Orocos Developers") 8 | @(license or "Apache License 2.0") 9 | 10 | ament_cmake 11 | 12 | builtin_interfaces 13 | @[if transports]@ 14 | rtt_ros2_interfaces 15 | @[else]@ 16 | rtt_ros2_idl 17 | @[end if]@ 18 | 19 | ament_lint_auto 20 | ament_lint_common 21 | 22 | 23 | ament_cmake 24 | 25 | 26 | -------------------------------------------------------------------------------- /rtt_ros2_node/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2_node) 3 | 4 | # Default to C99 5 | if(NOT CMAKE_C_STANDARD) 6 | set(CMAKE_C_STANDARD 99) 7 | endif() 8 | 9 | # Default to C++14 10 | if(NOT CMAKE_CXX_STANDARD) 11 | set(CMAKE_CXX_STANDARD 14) 12 | endif() 13 | 14 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 15 | add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter) 16 | endif() 17 | 18 | # find dependencies 19 | find_package(ament_cmake REQUIRED) 20 | find_package(rclcpp REQUIRED) 21 | find_package(rtt_ros2 REQUIRED) 22 | 23 | # setup targets 24 | include_directories(include/orocos) 25 | orocos_library(rtt_ros2_node 26 | src/rtt_ros2_node.cpp 27 | EXPORT ${PROJECT_NAME} 28 | INCLUDES DESTINATION include/orocos 29 | ) 30 | ament_target_dependencies(rtt_ros2_node rclcpp) 31 | orocos_plugin(rtt_ros2_node_service 32 | src/rtt_ros2_node_service.cpp 33 | ) 34 | target_link_libraries(rtt_ros2_node_service rtt_ros2_node) 35 | ament_target_dependencies(rtt_ros2_node_service rclcpp) 36 | 37 | # install 38 | install( 39 | DIRECTORY include/ 40 | DESTINATION include 41 | ) 42 | 43 | # linters 44 | if(BUILD_TESTING) 45 | find_package(ament_lint_auto REQUIRED) 46 | ament_lint_auto_find_test_dependencies() 47 | endif() 48 | 49 | # export information to downstream packages 50 | # ament_export_dependencies(rtt_ros2) 51 | ament_export_dependencies(rclcpp) 52 | ament_export_include_directories(include/orocos) 53 | if(COMMAND ament_export_targets) 54 | ament_export_targets(${PROJECT_NAME} HAS_LIBRARY_TARGET) 55 | else() 56 | ament_export_interfaces(${PROJECT_NAME} HAS_LIBRARY_TARGET) 57 | endif() 58 | 59 | # must be called *after* the targets to check exported libraries etc. 60 | ament_package() 61 | 62 | # orocos_generate_package() is deprecated for ROS 2. 63 | # Prefer cmake target export and import instead, in combination with 64 | # ament_export_interfaces() or ament_export_targets() when building with 65 | # ament_cmake. 66 | orocos_generate_package() 67 | -------------------------------------------------------------------------------- /rtt_ros2_node/include/orocos/rtt_ros2_node/rtt_ros2_node.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_NODE__RTT_ROS2_NODE_HPP_ 16 | #define OROCOS__RTT_ROS2_NODE__RTT_ROS2_NODE_HPP_ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "rclcpp/rclcpp.hpp" 23 | 24 | #include "rtt/Service.hpp" 25 | 26 | namespace rtt_ros2_node 27 | { 28 | 29 | /// Return the default rclcpp::NodeOptions to be used within RTT and rtt_ros2_integration. 30 | rclcpp::NodeOptions getDefaultNodeOptions(); 31 | 32 | /// Wrap a rclcpp::Node instance in an RTT::Service. 33 | struct Node : public RTT::Service 34 | { 35 | public: 36 | using shared_ptr = boost::shared_ptr; 37 | 38 | explicit Node(RTT::TaskContext * owner = nullptr); 39 | Node( 40 | const rclcpp::NodeOptions & options = getDefaultNodeOptions(), 41 | RTT::TaskContext * owner = nullptr); 42 | Node( 43 | const std::string & node_name, 44 | const rclcpp::NodeOptions & options = getDefaultNodeOptions(), 45 | RTT::TaskContext * owner = nullptr); 46 | Node( 47 | const std::string & node_name, 48 | const std::string & _namespace, 49 | const rclcpp::NodeOptions & options = getDefaultNodeOptions(), 50 | RTT::TaskContext * owner = nullptr); 51 | virtual ~Node(); 52 | 53 | rclcpp::Node::SharedPtr node() {return node_;} 54 | rclcpp::executor::Executor::SharedPtr executor() {return executor_;} 55 | 56 | void spin(unsigned int number_of_threads = 1); 57 | void cancel(); 58 | 59 | protected: 60 | rclcpp::Node::SharedPtr node_; 61 | rclcpp::executor::Executor::SharedPtr executor_; 62 | std::thread thread_; 63 | }; 64 | 65 | /// Retrieve a pointer to the rtt_ros2_node::Node service to be used for the given TaskContext. 66 | /** 67 | * @param tc The TaskContext instance for which to retrieve a Node pointer. If nullptr, consider 68 | * only the global (process-wide) node. 69 | * @returns the Node instance loaded as an RTT service in the given TaskContext, 70 | * or falls back to the global (process-wide) Node loaded into the GlobalService. 71 | * If none of both is loaded, the function returns nullptr. 72 | */ 73 | Node::shared_ptr getNodeService(RTT::TaskContext * tc = nullptr); 74 | 75 | /// Retrieve a rclcpp::Node::SharedPtr to be used for the given TaskContext. 76 | /** 77 | * @sa \ref getNodeService() 78 | * @returns getNodeService(tc) ? getNodeService(tc)->node() : nullptr 79 | */ 80 | rclcpp::Node::SharedPtr getNode(RTT::TaskContext * tc = nullptr); 81 | 82 | } // namespace rtt_ros2_node 83 | 84 | #endif // OROCOS__RTT_ROS2_NODE__RTT_ROS2_NODE_HPP_ 85 | -------------------------------------------------------------------------------- /rtt_ros2_node/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2_node 5 | 0.0.0 6 | 7 | RTT service plugin to instantiate a ROS 2 node per process or per Orocos component. 8 | 9 | Orocos Developers 10 | Apache License 2.0 11 | 12 | ament_cmake 13 | 14 | rclcpp 15 | rtt_ros2 16 | 17 | ament_lint_auto 18 | ament_lint_common 19 | 20 | 21 | ament_cmake 22 | 23 | 24 | -------------------------------------------------------------------------------- /rtt_ros2_params/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2_params) 3 | 4 | # Default to C99 5 | if(NOT CMAKE_C_STANDARD) 6 | set(CMAKE_C_STANDARD 99) 7 | endif() 8 | 9 | # Default to C++14 10 | if(NOT CMAKE_CXX_STANDARD) 11 | set(CMAKE_CXX_STANDARD 14) 12 | endif() 13 | 14 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 15 | add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter) 16 | endif() 17 | 18 | # find dependencies 19 | find_package(ament_cmake REQUIRED) 20 | find_package(rclcpp REQUIRED) 21 | find_package(rtt_ros2 REQUIRED) 22 | find_package(rtt_ros2_node REQUIRED) 23 | 24 | # setup targets 25 | include_directories(include/orocos) 26 | 27 | orocos_library(rtt_ros2_params 28 | src/rtt_ros2_params_service.cpp 29 | EXPORT ${PROJECT_NAME} 30 | INCLUDES DESTINATION include/orocos 31 | ) 32 | target_link_libraries(rtt_ros2_params rtt_ros2_node::rtt_ros2_node) 33 | ament_target_dependencies(rtt_ros2_params 34 | rclcpp 35 | ) 36 | 37 | orocos_plugin(rtt_ros2_params_service 38 | src/rtt_ros2_params_plugin.cpp 39 | ) 40 | target_link_libraries(rtt_ros2_params_service rtt_ros2_params) 41 | 42 | # install 43 | install( 44 | DIRECTORY include/ 45 | DESTINATION include 46 | ) 47 | 48 | # linters 49 | if(BUILD_TESTING) 50 | find_package(ament_lint_auto REQUIRED) 51 | ament_lint_auto_find_test_dependencies() 52 | endif() 53 | 54 | # export information to downstream packages 55 | # ament_export_dependencies(rtt_ros2) 56 | ament_export_dependencies(rclcpp) 57 | ament_export_include_directories(include/orocos) 58 | if(COMMAND ament_export_targets) 59 | ament_export_targets(${PROJECT_NAME} HAS_LIBRARY_TARGET) 60 | else() 61 | ament_export_interfaces(${PROJECT_NAME} HAS_LIBRARY_TARGET) 62 | endif() 63 | rtt_ros2_export_plugin_depend(rtt_ros2_node) 64 | rtt_ros2_export_plugin_depend(rtt_ros2_rclcpp_typekit) 65 | 66 | # must be called *after* the targets to check exported libraries etc. 67 | ament_package() 68 | 69 | # orocos_generate_package() is deprecated for ROS 2. 70 | # Prefer cmake target export and import instead, in combination with 71 | # ament_export_interfaces() or ament_export_targets() when building with 72 | # ament_cmake. 73 | orocos_generate_package() 74 | -------------------------------------------------------------------------------- /rtt_ros2_params/README.md: -------------------------------------------------------------------------------- 1 | 2 | `rtt_ros2_params` - ROS parameter support 3 | ========================================= 4 | 5 | # Description 6 | 7 | ROS2 provides a slightly different infrastructure to deal with parameters compared to ROS 1. An introduction guide can be found in [Understanding ROS2 parameters](https://index.ros.org/doc/ros2/Tutorials/Parameters/Understanding-ROS2-Parameters/). 8 | The main difference is that there is no longer a centralized parameter server, but instead, parameters are maintained per node. 9 | 10 | ## `rosparam` service 11 | 12 | This package provides a new Orocos service called `rosparam` that can be loaded globally and per Orocos component. The service provides 4 operations: 13 | * `getParameter()`: loads a parameter from the ROS2 node parameter facility and returns its value. 14 | * `loadProperty()`: loads a parameter from the ROS2 node parameter facility into an Orocos property. 15 | * `setParameter()`: sets a parameter into the ROS2 node parameter facility. With the default `rtt_ros2_node::Node`, if the parameter does not exist, `rosnode` declares one. 16 | * `storeProperty()`: sets a parameter into the ROS2 node parameter facility from the value of an Orocos property. With the default `rtt_ros2_node::Node`, if the parameter does not exist, `rosnode` declares one. 17 | 18 | ## Scripting Interface 19 | 20 | This package can be imported with: 21 | ``` 22 | import("rtt_ros2_params") 23 | ``` 24 | 25 | Then, the service can be loaded into a component named `` with: 26 | ``` 27 | .loadService('rosparam') 28 | ``` 29 | 30 | `` will have a new service named `rosparam` that provides the operations described. These operations can be called with: 31 | ``` 32 | .rosparam.setParameter( ) 33 | .rosparam.getParameter( ) 34 | .rosparam.loadProperty( ) 35 | .rosparam.storeProperty( ) 36 | ``` 37 | 38 | ## Requirements 39 | 40 | In order to work, this service requires two other elements being loaded before calling the operations. 41 | * A ROS2 node service must exist for the component where this service is loaded or globally. 42 | * The typekits provided in `rtt_ros2_rclcpp_typekit` and its dependencies must be loaded 43 | 44 | These prerequirements can be achieved by: 45 | ``` 46 | import("rtt_ros2") 47 | ros.import("rtt_ros2_params") 48 | ``` 49 | 50 | To load a ROS2 node specific for a component, please, read the [related documentation](../rtt_ros2_node/README.md). 51 | -------------------------------------------------------------------------------- /rtt_ros2_params/include/orocos/rtt_ros2_params/rosparam.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_PARAMS__ROSPARAM_HPP_ 16 | #define OROCOS__RTT_ROS2_PARAMS__ROSPARAM_HPP_ 17 | 18 | #include 19 | 20 | #include "rtt/OperationCaller.hpp" 21 | #include "rtt/ServiceRequester.hpp" 22 | 23 | #include "rclcpp/parameter_value.hpp" 24 | 25 | namespace rtt_ros2_params 26 | { 27 | 28 | class RosParam : public RTT::ServiceRequester 29 | { 30 | public: 31 | typedef boost::shared_ptr shared_ptr; 32 | 33 | explicit RosParam(RTT::TaskContext * owner) 34 | : RTT::ServiceRequester("rosparam", owner), 35 | getParameter("getParameter"), 36 | setParameter("setParameter"), 37 | setOrDeclareParameter("setOrDeclareParameter"), 38 | loadProperty("loadProperty"), 39 | storeProperty("storeProperty") 40 | { 41 | this->addOperationCaller(getParameter); 42 | this->addOperationCaller(setParameter); 43 | this->addOperationCaller(setOrDeclareParameter); 44 | 45 | // Operations loadProperty and storeProperty are only available if the requester is connected 46 | // to a service loaded into a component. They are added dynamically in connectTo(). 47 | } 48 | virtual ~RosParam() = default; 49 | 50 | bool connectTo(RTT::Service::shared_ptr sp) override 51 | { 52 | const bool has_owner = (sp->getOwner() != nullptr); 53 | if (has_owner) { 54 | this->addOperationCaller(loadProperty); 55 | this->addOperationCaller(storeProperty); 56 | } 57 | return RTT::ServiceRequester::connectTo(sp); 58 | } 59 | 60 | RTT::OperationCaller getParameter; 61 | RTT::OperationCaller setParameter; 64 | RTT::OperationCaller setOrDeclareParameter; 67 | RTT::OperationCaller loadProperty; 70 | RTT::OperationCaller storeProperty; 73 | }; 74 | 75 | } // namespace rtt_ros2_params 76 | 77 | #endif // OROCOS__RTT_ROS2_PARAMS__ROSPARAM_HPP_ 78 | -------------------------------------------------------------------------------- /rtt_ros2_params/include/orocos/rtt_ros2_params/rtt_ros2_params_service.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_PARAMS__RTT_ROS2_PARAMS_SERVICE_HPP_ 16 | #define OROCOS__RTT_ROS2_PARAMS__RTT_ROS2_PARAMS_SERVICE_HPP_ 17 | 18 | #include 19 | #include 20 | 21 | #include "rtt/Service.hpp" 22 | 23 | #include "rclcpp/rclcpp.hpp" 24 | #include "rclcpp/parameter.hpp" 25 | #include "rclcpp/parameter_value.hpp" 26 | 27 | namespace rtt_ros2_params 28 | { 29 | 30 | class RosParamService : public RTT::Service 31 | { 32 | public: 33 | typedef boost::shared_ptr shared_ptr; 34 | 35 | explicit RosParamService(RTT::TaskContext * owner); 36 | virtual ~RosParamService(); 37 | 38 | protected: 39 | rclcpp::ParameterValue getParameter(const std::string & name); 40 | bool setParameter( 41 | const std::string & name, 42 | const rclcpp::ParameterValue & value); 43 | bool setOrDeclareParameter( 44 | const std::string & name, 45 | const rclcpp::ParameterValue & value); 46 | bool loadProperty( 47 | const std::string & property_name, 48 | const std::string & param_name = std::string()); 49 | bool storeProperty( 50 | const std::string & property_name, 51 | const std::string & param_name); 52 | }; // class RosParamService 53 | 54 | } // namespace rtt_ros2_params 55 | 56 | #endif // OROCOS__RTT_ROS2_PARAMS__RTT_ROS2_PARAMS_SERVICE_HPP_ 57 | -------------------------------------------------------------------------------- /rtt_ros2_params/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2_params 5 | 0.0.0 6 | 7 | RTT service plugin to use ROS 2 parameters from Orocos components. 8 | 9 | Orocos Developers 10 | Apache License 2.0 11 | 12 | ament_cmake 13 | 14 | rclcpp 15 | rtt_ros2 16 | rtt_ros2_node 17 | 18 | rtt_ros2_rclcpp_typekit 19 | 20 | ament_lint_auto 21 | ament_lint_common 22 | 23 | 24 | ament_cmake 25 | 26 | 27 | -------------------------------------------------------------------------------- /rtt_ros2_params/src/rtt_ros2_params_plugin.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | 18 | #include "rtt/deployment/ComponentLoader.hpp" 19 | #include "rtt/internal/GlobalService.hpp" 20 | #include "rtt/plugin/ServicePlugin.hpp" 21 | 22 | #include "boost/make_shared.hpp" 23 | 24 | #include "rtt_ros2_params/rtt_ros2_params_service.hpp" 25 | 26 | namespace rtt_ros2_params 27 | { 28 | 29 | static bool loadGlobalROSService() 30 | { 31 | RTT::Service::shared_ptr ros = 32 | RTT::internal::GlobalService::Instance()->provides("ros"); 33 | ros->doc("ROS operations and services"); 34 | 35 | RTT::Service::shared_ptr params = 36 | boost::make_shared(nullptr); 37 | 38 | if (!ros->addService(std::move(params))) { 39 | // addService() can fail if a service of the same name already exists in ros 40 | RTT::log(RTT::Error) << "The global ROS service could not load rosparam " 41 | "support" << RTT::endlog(); 42 | return false; 43 | } 44 | 45 | RTT::log(RTT::Info) << 46 | "Initializing interface to ROS params" << 47 | RTT::endlog(); 48 | return true; 49 | } 50 | 51 | static bool loadROSServiceIntoTaskContext(RTT::TaskContext * tc) 52 | { 53 | if (tc->provides()->hasService("rosparam")) { 54 | RTT::log(RTT::Error) << 55 | "Another rosparam interface was already instantiated for component " << 56 | tc->getName() << "." << 57 | RTT::endlog(); 58 | 59 | return false; 60 | } 61 | 62 | auto params = boost::make_shared(tc); 63 | tc->provides()->addService(std::move(params)); 64 | return true; 65 | } 66 | 67 | extern "C" { 68 | bool loadRTTPlugin(RTT::TaskContext * tc) 69 | { 70 | if (tc == nullptr) { 71 | return loadGlobalROSService(); 72 | } else { 73 | return loadROSServiceIntoTaskContext(tc); 74 | } 75 | } 76 | std::string getRTTPluginName() {return "rosparam";} 77 | std::string getRTTTargetName() {return OROCOS_TARGET_NAME;} 78 | 79 | } // extern "C" 80 | 81 | } // namespace rtt_ros2_params 82 | -------------------------------------------------------------------------------- /rtt_ros2_services/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2_services) 3 | 4 | # Default to C99 5 | if(NOT CMAKE_C_STANDARD) 6 | set(CMAKE_C_STANDARD 99) 7 | endif() 8 | 9 | # Default to C++14 10 | if(NOT CMAKE_CXX_STANDARD) 11 | set(CMAKE_CXX_STANDARD 14) 12 | endif() 13 | 14 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 15 | add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter) 16 | endif() 17 | 18 | # find dependencies 19 | find_package(ament_cmake REQUIRED) 20 | find_package(ament_cmake_python REQUIRED) 21 | find_package(rclcpp REQUIRED) 22 | find_package(rcpputils REQUIRED) 23 | find_package(rtt_ros2 REQUIRED) 24 | find_package(rtt_ros2_node REQUIRED) 25 | 26 | # setup Python module 27 | ament_python_install_package(${PROJECT_NAME} 28 | PACKAGE_DIR src/${PROJECT_NAME} 29 | ) 30 | 31 | # setup targets 32 | include_directories(include/orocos) 33 | 34 | orocos_library(rtt_ros2_services 35 | src/rtt_ros2_services_proxy.cpp 36 | src/rtt_ros2_services_registry.cpp 37 | EXPORT ${PROJECT_NAME} 38 | INCLUDES DESTINATION include/orocos 39 | ) 40 | target_link_libraries(rtt_ros2_services 41 | rtt_ros2_node::rtt_ros2_node 42 | ) 43 | ament_target_dependencies(rtt_ros2_services rclcpp) 44 | 45 | orocos_plugin(rtt_ros2_services_service 46 | src/rtt_ros2_services_plugin.cpp 47 | ) 48 | target_link_libraries(rtt_ros2_services_service 49 | rtt_ros2_services 50 | ) 51 | ament_target_dependencies(rtt_ros2_services_service rclcpp) 52 | ament_target_dependencies(rtt_ros2_services_service rcpputils) 53 | 54 | orocos_plugin(rtt_ros2_services_registry_service 55 | src/rtt_ros2_services_registry_plugin.cpp 56 | ) 57 | target_link_libraries(rtt_ros2_services_registry_service 58 | rtt_ros2_services 59 | ) 60 | 61 | # install 62 | install( 63 | DIRECTORY include/ 64 | DESTINATION include 65 | ) 66 | 67 | # linters 68 | if(BUILD_TESTING) 69 | find_package(ament_lint_auto REQUIRED) 70 | ament_lint_auto_find_test_dependencies() 71 | endif() 72 | 73 | # export information to downstream packages 74 | ament_export_dependencies(rosidl_cmake) 75 | ament_export_dependencies(rclcpp) 76 | ament_export_dependencies(rcpputils) 77 | ament_export_dependencies(rtt_ros2) 78 | ament_export_dependencies(rtt_ros2_node) 79 | ament_export_include_directories(include/orocos) 80 | if(COMMAND ament_export_targets) 81 | ament_export_targets(${PROJECT_NAME} HAS_LIBRARY_TARGET) 82 | else() 83 | ament_export_interfaces(${PROJECT_NAME} HAS_LIBRARY_TARGET) 84 | endif() 85 | 86 | # must be called *after* the targets to check exported libraries etc. 87 | ament_package( 88 | CONFIG_EXTRAS 89 | cmake/${PROJECT_NAME}-extras.cmake.in 90 | cmake/${PROJECT_NAME}-generate_ros_service_plugin.cmake 91 | ) 92 | 93 | # orocos_generate_package() is deprecated for ROS 2. 94 | # Prefer cmake target export and import instead, in combination with 95 | # ament_export_interfaces() or ament_export_targets() when building with 96 | # ament_cmake. 97 | orocos_generate_package( 98 | DEPENDS_TARGETS rtt_ros2 rtt_ros2_node 99 | ) 100 | -------------------------------------------------------------------------------- /rtt_ros2_services/cmake/rtt_ros2_services-extras.cmake.in: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Intermodalics BVBA 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | set(rtt_ros2_services_GENERATOR_FILES 16 | "${rtt_ros2_services_DIR}/../../../@PYTHON_INSTALL_DIR@/rtt_ros2_services/__init__.py") 17 | normalize_path(rtt_ros2_services_GENERATOR_FILES "${rtt_ros2_services_GENERATOR_FILES}") 18 | 19 | set(rtt_ros2_services_TEMPLATE_DIR "${rtt_ros2_services_DIR}/../../../@PYTHON_INSTALL_DIR@/rtt_ros2_services/resource") 20 | normalize_path(rtt_ros2_services_TEMPLATE_DIR "${rtt_ros2_services_TEMPLATE_DIR}") 21 | -------------------------------------------------------------------------------- /rtt_ros2_services/include/orocos/rtt_ros2_services/rosservice.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_SERVICES__ROSSERVICE_HPP_ 16 | #define OROCOS__RTT_ROS2_SERVICES__ROSSERVICE_HPP_ 17 | 18 | #include 19 | 20 | #include "rtt/OperationCaller.hpp" 21 | #include "rtt/ServiceRequester.hpp" 22 | 23 | namespace rtt_ros2_services 24 | { 25 | 26 | class RosService : public RTT::ServiceRequester 27 | { 28 | public: 29 | typedef boost::shared_ptr SharedPtr; 30 | 31 | explicit RosService(RTT::TaskContext * owner) 32 | : RTT::ServiceRequester("rosservice", owner), 33 | connect("connect"), 34 | disconnect("disconnect"), 35 | disconnectAll("disconnectAll") 36 | { 37 | this->addOperationCaller(connect); 38 | this->addOperationCaller(disconnect); 39 | this->addOperationCaller(disconnectAll); 40 | } 41 | 42 | RTT::OperationCaller connect; 43 | RTT::OperationCaller disconnect; 44 | RTT::OperationCaller disconnectAll; 45 | }; 46 | 47 | } // namespace rtt_ros2_services 48 | 49 | #endif // OROCOS__RTT_ROS2_SERVICES__ROSSERVICE_HPP_ 50 | -------------------------------------------------------------------------------- /rtt_ros2_services/include/orocos/rtt_ros2_services/rtt_ros2_services_registry.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_SERVICES__RTT_ROS2_SERVICES_REGISTRY_HPP_ 16 | #define OROCOS__RTT_ROS2_SERVICES__RTT_ROS2_SERVICES_REGISTRY_HPP_ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "rtt/os/Mutex.hpp" 23 | 24 | namespace rtt_ros2_services 25 | { 26 | 27 | class RosServiceRegistry; 28 | using RosServiceRegistryPtr = std::shared_ptr; 29 | 30 | class RosServiceProxyFactoryBase; 31 | using RosServiceProxyFactoryBasePtr = std::shared_ptr; 32 | 33 | class RosServiceRegistry 34 | { 35 | public: 36 | static RosServiceRegistryPtr Instance(); 37 | static void Release(); 38 | 39 | /** \brief Register a ROS service proxy factory 40 | * 41 | * This enables the RosServiceRegistryService to construct ROS service clients and 42 | * servers from a string name. 43 | */ 44 | bool registerServiceFactory(RosServiceProxyFactoryBasePtr factory); 45 | 46 | bool hasServiceFactory(const std::string & service_type); 47 | 48 | RosServiceProxyFactoryBasePtr getServiceFactory(const std::string & service_type); 49 | 50 | void listSrvs(); 51 | 52 | private: 53 | //! ROS service proxy factories 54 | std::map factories_; 55 | RTT::os::MutexRecursive factory_lock_; 56 | 57 | //! The singleton instance 58 | static RosServiceRegistryPtr s_instance_; 59 | }; 60 | 61 | } // namespace rtt_ros2_services 62 | 63 | #endif // OROCOS__RTT_ROS2_SERVICES__RTT_ROS2_SERVICES_REGISTRY_HPP_ 64 | -------------------------------------------------------------------------------- /rtt_ros2_services/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2_services 5 | 0.0.0 6 | 7 | This package provides a CMake function and templates to generate ROS 2 service plugins 8 | for existing ROS 2 interface (messages, services, actions) packages. 9 | 10 | Orocos Developers 11 | Apache License 2.0 12 | 13 | ament_cmake 14 | rosidl_cmake 15 | 16 | rclcpp 17 | rcpputils 18 | rtt_ros2 19 | rtt_ros2_node 20 | 21 | ament_lint_auto 22 | ament_lint_common 23 | 24 | 25 | ament_cmake 26 | 27 | 28 | -------------------------------------------------------------------------------- /rtt_ros2_services/src/rtt_ros2_services/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Intermodalics BVBA 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import argparse 16 | import pathlib 17 | import sys 18 | 19 | from rosidl_cmake import expand_template 20 | 21 | from .resource import TEMPLATE_DIR 22 | 23 | 24 | def generate_service_plugin(package, output_dir, services=[], extra_includes=[]): 25 | output_dir = pathlib.Path(output_dir) 26 | 27 | data = { 28 | 'pkg_name': package, 29 | 'services': services, 30 | 'extra_includes': extra_includes, 31 | } 32 | expand_template( 33 | 'ros_service_plugin.cpp.em', 34 | data=data, 35 | output_file=(output_dir / "ros_service_plugin.cpp"), 36 | template_basepath=TEMPLATE_DIR) 37 | 38 | 39 | def main(argv=sys.argv[1:]): 40 | parser = argparse.ArgumentParser( 41 | description='Generate an RTT plugin for services in a ROS interface package.', 42 | formatter_class=argparse.ArgumentDefaultsHelpFormatter) 43 | parser.add_argument( 44 | '--package', required=True, 45 | help='The name of the package') 46 | parser.add_argument( 47 | '--services', metavar='MESSAGE', nargs='*', 48 | help='The service types') 49 | parser.add_argument( 50 | '--output-dir', required=True, 51 | help='The base directory for generated source files') 52 | parser.add_argument( 53 | '--extra-includes', metavar='MESSAGE', nargs='*', 54 | help='Additional files to be included in each generated source file') 55 | args = parser.parse_args(argv) 56 | 57 | return generate_service_plugin(**vars(args)) 58 | -------------------------------------------------------------------------------- /rtt_ros2_services/src/rtt_ros2_services/__main__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Intermodalics BVBA 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import sys 16 | from rtt_ros2_services import main 17 | 18 | sys.exit(main()) 19 | -------------------------------------------------------------------------------- /rtt_ros2_services/src/rtt_ros2_services/resource/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Intermodalics BVBA 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import pathlib 16 | 17 | 18 | TEMPLATE_DIR = pathlib.Path(__file__).parent 19 | -------------------------------------------------------------------------------- /rtt_ros2_services/src/rtt_ros2_services/resource/ros_service_plugin.cpp.em: -------------------------------------------------------------------------------- 1 | @{ 2 | from rosidl_cmake import convert_camel_case_to_lower_case_underscore 3 | }@ 4 | // generated from rtt_ros2_services/src/rtt_ros2_services/resource/ros_service_plugin.cpp.em 5 | // generated code does not contain a copyright notice 6 | 7 | #include "rtt/Logger.hpp" 8 | #include "rtt/plugin/ServicePlugin.hpp" 9 | 10 | #include "rtt_ros2_services/rtt_ros2_services_proxy.hpp" 11 | #include "rtt_ros2_services/rtt_ros2_services_registry.hpp" 12 | 13 | @[for service in services]@ 14 | #include "@(pkg_name)/srv/@(convert_camel_case_to_lower_case_underscore(service)).hpp" 15 | @[end for]@ 16 | @[for extra_include in extra_includes]@ 17 | #include "@(extra_include)" 18 | @[end for]@ 19 | 20 | namespace rtt_ros2_services 21 | { 22 | 23 | static bool registerRosServiceProxies() 24 | { 25 | // Get the ros service registry service 26 | auto rosservice_registry = RosServiceRegistry::Instance(); 27 | if (!rosservice_registry) { 28 | RTT::log(RTT::Error) << 29 | "Could not get an instance of the RosServiceRegistry! Not registering service proxies " 30 | "for @(pkg_name)" << RTT::endlog(); 31 | return false; 32 | } 33 | 34 | @[for service in services]@ 35 | if (!rosservice_registry->registerServiceFactory( 36 | std::make_shared>( 37 | "@(pkg_name)/srv/@(service)"))) 38 | { 39 | return false; 40 | } 41 | @[end for]@ 42 | 43 | return true; 44 | } 45 | 46 | } // namespace rtt_ros2_services 47 | 48 | extern "C" { 49 | bool loadRTTPlugin(RTT::TaskContext * c) 50 | { 51 | if (c != nullptr) {return false;} 52 | return rtt_ros2_services::registerRosServiceProxies(); 53 | } 54 | std::string getRTTPluginName() 55 | { 56 | return "ros-@(pkg_name)-services"; 57 | } 58 | std::string getRTTTargetName() 59 | { 60 | return OROCOS_TARGET_NAME; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /rtt_ros2_services/src/rtt_ros2_services_proxy.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "rtt_ros2_services/rtt_ros2_services_proxy.hpp" 16 | 17 | #include 18 | 19 | namespace rtt_ros2_services 20 | { 21 | 22 | RosServiceProxyBase::RosServiceProxyBase(const std::string & service_name) 23 | : service_name_(service_name) 24 | {} 25 | 26 | RosServiceProxyBase::~RosServiceProxyBase() = default; 27 | 28 | RosServiceServerProxyBase::RosServiceServerProxyBase(const std::string & service_name) 29 | : RosServiceProxyBase(service_name) 30 | {} 31 | 32 | RosServiceClientProxyBase::RosServiceClientProxyBase(const std::string & service_name) 33 | : RosServiceProxyBase(service_name) 34 | {} 35 | 36 | RosServiceProxyFactoryBase::RosServiceProxyFactoryBase(const std::string & service_type) 37 | : service_type_(service_type) {} 38 | 39 | } // namespace rtt_ros2_services 40 | -------------------------------------------------------------------------------- /rtt_ros2_services/src/rtt_ros2_services_registry.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #include "rtt_ros2_services/rtt_ros2_services_proxy.hpp" 20 | #include "rtt_ros2_services/rtt_ros2_services_registry.hpp" 21 | 22 | #include "rtt/Logger.hpp" 23 | #include "rtt/os/MutexLock.hpp" 24 | 25 | namespace rtt_ros2_services 26 | { 27 | 28 | RosServiceRegistryPtr RosServiceRegistry::s_instance_; 29 | 30 | RosServiceRegistryPtr RosServiceRegistry::Instance() 31 | { 32 | if (!s_instance_) { 33 | s_instance_ = std::make_shared(); 34 | } 35 | return s_instance_; 36 | } 37 | 38 | void RosServiceRegistry::Release() 39 | { 40 | s_instance_.reset(); 41 | } 42 | 43 | /** \brief Register a ROS service proxy factory 44 | * 45 | * This enables the RosServiceRegistry to construct ROS service clients and 46 | * servers from a string name. 47 | */ 48 | bool RosServiceRegistry::registerServiceFactory(RosServiceProxyFactoryBasePtr factory) 49 | { 50 | RTT::os::MutexLock lock(factory_lock_); 51 | if (factory == nullptr) { 52 | RTT::log(RTT::Error) << 53 | "Failed to register ROS service factory: nullptr given." << 54 | RTT::endlog(); 55 | return false; 56 | } 57 | 58 | const std::string & ros_service_type = factory->getType(); 59 | factories_[ros_service_type] = std::move(factory); 60 | 61 | RTT::log(RTT::Info) << 62 | "Successfully registered ROS service factory for \"" << ros_service_type << "\"." << 63 | RTT::endlog(); 64 | 65 | return true; 66 | } 67 | 68 | bool RosServiceRegistry::hasServiceFactory(const std::string & service_type) 69 | { 70 | RTT::os::MutexLock lock(factory_lock_); 71 | return factories_.find(service_type) != factories_.end(); 72 | } 73 | 74 | RosServiceProxyFactoryBasePtr RosServiceRegistry::getServiceFactory( 75 | const std::string & service_type) 76 | { 77 | RTT::os::MutexLock lock(factory_lock_); 78 | if (factories_.find(service_type) != factories_.end()) { 79 | return factories_[service_type]; 80 | } 81 | 82 | RTT::log(RTT::Error) << 83 | "Service type \"" << service_type << "\" " 84 | "has not been registered with the rosservice_registry service." << RTT::endlog(); 85 | return nullptr; 86 | } 87 | 88 | void RosServiceRegistry::listSrvs() 89 | { 90 | RTT::os::MutexLock lock(factory_lock_); 91 | 92 | RTT::log(RTT::Info) << "Available ROS .srv types:" << RTT::endlog(); 93 | for (const auto & factory : factories_) { 94 | RTT::log(RTT::Info) << " -- " << factory.first << RTT::endlog(); 95 | } 96 | } 97 | 98 | } // namespace rtt_ros2_services 99 | -------------------------------------------------------------------------------- /rtt_ros2_services/src/rtt_ros2_services_registry_plugin.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "rtt/plugin/ServicePlugin.hpp" 16 | #include "rtt/Service.hpp" 17 | 18 | #include "rtt_ros2_services/rtt_ros2_services_registry.hpp" 19 | 20 | namespace rtt_ros2_services 21 | { 22 | 23 | class RosServiceRegistryService : public RTT::Service 24 | { 25 | public: 26 | /** 27 | * Instantiates this service. 28 | * @param owner The owner or null in case of global. 29 | */ 30 | explicit RosServiceRegistryService(RTT::TaskContext * owner) 31 | : RTT::Service("rosservice_registry", owner), instance_(RosServiceRegistry::Instance()) 32 | { 33 | this->doc("Global RTT Service for registering ROS service types."); 34 | this->addOperation( 35 | "registerServiceFactory", &RosServiceRegistry::registerServiceFactory, instance_.get(), 36 | RTT::ClientThread); 37 | this->addOperation( 38 | "hasServiceFactory", &RosServiceRegistry::hasServiceFactory, instance_.get(), 39 | RTT::ClientThread); 40 | this->addOperation( 41 | "getServiceFactory", &RosServiceRegistry::getServiceFactory, instance_.get(), 42 | RTT::ClientThread); 43 | this->addOperation( 44 | "listSrvs", &RosServiceRegistry::listSrvs, instance_.get(), 45 | RTT::ClientThread); 46 | } 47 | 48 | private: 49 | //! The singleton instance 50 | RosServiceRegistryPtr instance_; 51 | }; 52 | 53 | } // namespace rtt_ros2_services 54 | 55 | ORO_GLOBAL_SERVICE_NAMED_PLUGIN(rtt_ros2_services::RosServiceRegistryService, "rosservice_registry") 56 | -------------------------------------------------------------------------------- /rtt_ros2_topics/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2_topics) 3 | 4 | # Default to C99 5 | if(NOT CMAKE_C_STANDARD) 6 | set(CMAKE_C_STANDARD 99) 7 | endif() 8 | 9 | # Default to C++14 10 | if(NOT CMAKE_CXX_STANDARD) 11 | set(CMAKE_CXX_STANDARD 14) 12 | endif() 13 | 14 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 15 | add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter) 16 | endif() 17 | 18 | # find dependencies 19 | find_package(ament_cmake REQUIRED) 20 | find_package(ament_cmake_python REQUIRED) 21 | find_package(rclcpp REQUIRED) 22 | find_package(rtt_ros2 REQUIRED) 23 | find_package(rtt_ros2_node REQUIRED) 24 | 25 | # setup Python module 26 | ament_python_install_package(${PROJECT_NAME} 27 | PACKAGE_DIR src/${PROJECT_NAME} 28 | ) 29 | 30 | # setup targets 31 | include_directories(include/orocos) 32 | 33 | # rtt_ros2_topics is a pure interface target (no library). It is only to export the installed 34 | # include directory as a target for target_link_libraries(). 35 | add_library(rtt_ros2_topics INTERFACE) 36 | install(TARGETS rtt_ros2_topics 37 | EXPORT ${PROJECT_NAME} 38 | INCLUDES DESTINATION include/orocos 39 | ) 40 | 41 | orocos_plugin(rtt_ros2_topics_service 42 | src/rtt_ros2_topics_plugin.cpp 43 | ) 44 | 45 | # install 46 | install( 47 | DIRECTORY include/ 48 | DESTINATION include 49 | ) 50 | 51 | # linters 52 | if(BUILD_TESTING) 53 | find_package(ament_lint_auto REQUIRED) 54 | # TODO: check why cppcheck fails on foxy 55 | list(APPEND AMENT_LINT_AUTO_EXCLUDE 56 | ament_cmake_cppcheck 57 | ) 58 | ament_lint_auto_find_test_dependencies() 59 | endif() 60 | 61 | # export information to downstream packages 62 | ament_export_dependencies(rosidl_cmake) 63 | ament_export_dependencies(rclcpp) 64 | ament_export_dependencies(rtt_ros2) 65 | ament_export_dependencies(rtt_ros2_node) 66 | ament_export_include_directories(include/orocos) 67 | if(COMMAND ament_export_targets) 68 | ament_export_targets(${PROJECT_NAME} HAS_LIBRARY_TARGET) 69 | else() 70 | ament_export_interfaces(${PROJECT_NAME} HAS_LIBRARY_TARGET) 71 | endif() 72 | 73 | # must be called *after* the targets to check exported libraries etc. 74 | ament_package( 75 | CONFIG_EXTRAS 76 | cmake/${PROJECT_NAME}-extras.cmake.in 77 | cmake/${PROJECT_NAME}-generate_ros_transport.cmake 78 | ) 79 | 80 | # orocos_generate_package() is deprecated for ROS 2. 81 | # Prefer cmake target export and import instead, in combination with 82 | # ament_export_interfaces() or ament_export_targets() when building with 83 | # ament_cmake. 84 | orocos_generate_package( 85 | DEPENDS_TARGETS rtt_ros2 rtt_ros2_node 86 | ) 87 | -------------------------------------------------------------------------------- /rtt_ros2_topics/cmake/rtt_ros2_topics-extras.cmake.in: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Intermodalics BVBA 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | set(rtt_ros2_topics_GENERATOR_FILES 16 | "${rtt_ros2_topics_DIR}/../../../@PYTHON_INSTALL_DIR@/rtt_ros2_topics/__init__.py") 17 | normalize_path(rtt_ros2_topics_GENERATOR_FILES "${rtt_ros2_topics_GENERATOR_FILES}") 18 | 19 | set(rtt_ros2_topics_TEMPLATE_DIR "${rtt_ros2_topics_DIR}/../../../@PYTHON_INSTALL_DIR@/rtt_ros2_topics/resource") 20 | normalize_path(rtt_ros2_topics_TEMPLATE_DIR "${rtt_ros2_topics_TEMPLATE_DIR}") 21 | -------------------------------------------------------------------------------- /rtt_ros2_topics/include/orocos/rtt_ros2_topics/protocol_id.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_TOPICS__PROTOCOL_ID_H_ 16 | #define OROCOS__RTT_ROS2_TOPICS__PROTOCOL_ID_H_ 17 | 18 | // ROS 1 uses protocol id 3, so for ROS 2 we use 3 + 2 = 32 ;-) 19 | #ifndef ORO_ROS2_PROTOCOL_ID 20 | #define ORO_ROS2_PROTOCOL_ID 32 21 | #endif 22 | 23 | #endif // OROCOS__RTT_ROS2_TOPICS__PROTOCOL_ID_H_ 24 | -------------------------------------------------------------------------------- /rtt_ros2_topics/include/orocos/rtt_ros2_topics/ros_subscription.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_TOPICS__ROS_SUBSCRIPTION_HPP_ 16 | #define OROCOS__RTT_ROS2_TOPICS__ROS_SUBSCRIPTION_HPP_ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "rclcpp/node.hpp" 23 | #include "rclcpp/subscription.hpp" 24 | 25 | #include "rtt/ConnPolicy.hpp" 26 | #include "rtt/TaskContext.hpp" 27 | #include "rtt/base/ChannelElement.hpp" 28 | #include "rtt/base/PortInterface.hpp" 29 | 30 | #include "rtt_ros2_topics/utilities.hpp" 31 | 32 | namespace rtt_ros2_topics 33 | { 34 | 35 | template 36 | class RosSubscriptionChannelElement 37 | : public RTT::base::ChannelElement 38 | { 39 | public: 40 | RosSubscriptionChannelElement( 41 | RTT::base::PortInterface * port, 42 | const RTT::ConnPolicy & policy, 43 | rclcpp::Node::SharedPtr node) 44 | : node_(std::move(node)) 45 | { 46 | const std::string topic = utilities::find_topic(port, policy); 47 | if (port->getInterface() && port->getInterface()->getOwner()) { 48 | RTT::log(RTT::Debug) << 49 | "Creating ROS subscription for port " << 50 | port->getInterface()->getOwner()->getName() << "." << port->getName() << " on topic " << 51 | topic << RTT::endlog(); 52 | } else { 53 | RTT::log(RTT::Debug) << 54 | "Creating ROS subscription for port " << port->getName() << 55 | " on topic " << topic << RTT::endlog(); 56 | } 57 | 58 | rclcpp::QoS qos(static_cast(std::max(1, policy.size))); 59 | if (policy.init) {qos.transient_local();} 60 | subscription_ = node_->create_subscription( 61 | topic, qos, std::bind(&RosSubscriptionChannelElement::callback, this, std::placeholders::_1)); 62 | } 63 | 64 | virtual ~RosSubscriptionChannelElement() = default; 65 | 66 | void callback(const typename T::SharedPtr msg) 67 | { 68 | (void) this->write(*msg); 69 | } 70 | 71 | bool inputReady() override 72 | { 73 | return true; 74 | } 75 | 76 | bool isRemoteElement() const override 77 | { 78 | return true; 79 | } 80 | 81 | std::string getElementName() const override 82 | { 83 | return "RosSubscriptionChannelElement"; 84 | } 85 | 86 | std::string getRemoteURI() const override 87 | { 88 | return subscription_->get_topic_name(); 89 | } 90 | 91 | private: 92 | rclcpp::Node::SharedPtr node_; 93 | typename rclcpp::Subscription::SharedPtr subscription_; 94 | }; 95 | 96 | } // namespace rtt_ros2_topics 97 | 98 | #endif // OROCOS__RTT_ROS2_TOPICS__ROS_SUBSCRIPTION_HPP_ 99 | -------------------------------------------------------------------------------- /rtt_ros2_topics/include/orocos/rtt_ros2_topics/ros_type_transporter.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_TOPICS__ROS_TYPE_TRANSPORTER_HPP_ 16 | #define OROCOS__RTT_ROS2_TOPICS__ROS_TYPE_TRANSPORTER_HPP_ 17 | 18 | #include 19 | 20 | #include "rclcpp/node.hpp" 21 | #include "rclcpp/utilities.hpp" 22 | 23 | #include "rtt/DataFlowInterface.hpp" 24 | #include "rtt/Logger.hpp" 25 | #include "rtt/TaskContext.hpp" 26 | #include "rtt/internal/ConnFactory.hpp" 27 | #include "rtt/types/TypeTransporter.hpp" 28 | #include "rtt_ros2_node/rtt_ros2_node.hpp" 29 | 30 | #include "rtt_ros2_topics/protocol_id.h" 31 | #include "rtt_ros2_topics/ros_publisher.hpp" 32 | #include "rtt_ros2_topics/ros_subscription.hpp" 33 | 34 | namespace rtt_ros2_topics 35 | { 36 | 37 | template 38 | class RosTypeTransporter : public RTT::types::TypeTransporter 39 | { 40 | public: 41 | virtual RTT::base::ChannelElementBase::shared_ptr createStream( 42 | RTT::base::PortInterface * port, 43 | const RTT::ConnPolicy & policy, 44 | bool is_sender) const 45 | { 46 | // Pull connections are not supported by the ROS message transport. 47 | if (policy.pull) { 48 | RTT::log(RTT::Error) << 49 | "Pull connections are not supported by the ROS message transport." << 50 | RTT::endlog(); 51 | return RTT::base::ChannelElementBase::shared_ptr(); 52 | } 53 | 54 | // Retrieve rclcpp::Node::SharedPtr to be used for this port 55 | const RTT::DataFlowInterface * interface = port->getInterface(); 56 | RTT::TaskContext * owner = (interface != nullptr ? interface->getOwner() : nullptr); 57 | rclcpp::Node::SharedPtr node = rtt_ros2_node::getNode(owner); 58 | if (node == nullptr) { 59 | RTT::log(RTT::Error) << 60 | "Cannot create a ROS topic stream for port " << port->getName(); 61 | if (owner != nullptr) { 62 | RTT::log() << 63 | " owned by component " << owner->getName(); 64 | } 65 | RTT::log() << 66 | ". Did you load the Node service" << 67 | " into either this component or initialized a global ROS node for this process?" << 68 | RTT::endlog(); 69 | return RTT::base::ChannelElementBase::shared_ptr(); 70 | } 71 | 72 | RTT::log(RTT::Debug) << 73 | "Using node '" << node->get_fully_qualified_name() << "'" << 74 | " to create a new ROS topic stream for port " << port->getName() << 75 | " owned by component " << owner->getName() << RTT::endlog(); 76 | 77 | RTT::base::ChannelElementBase::shared_ptr channel; 78 | if (is_sender) { 79 | channel = new RosPublisherChannelElement(port, policy, std::move(node)); 80 | 81 | if (policy.type == RTT::ConnPolicy::UNBUFFERED) { 82 | RTT::log(RTT::Debug) << "Creating unbuffered publisher connection for port " << 83 | port->getName() << ". This may not be real-time safe!" << RTT::endlog(); 84 | return channel; 85 | } 86 | 87 | RTT::base::ChannelElementBase::shared_ptr buf = 88 | RTT::internal::ConnFactory::buildDataStorage(policy); 89 | if (!buf) {return RTT::base::ChannelElementBase::shared_ptr();} 90 | buf->connectTo(channel); 91 | return buf; 92 | 93 | } else { 94 | channel = new RosSubscriptionChannelElement(port, policy, std::move(node)); 95 | return channel; 96 | } 97 | } 98 | }; 99 | 100 | } // namespace rtt_ros2_topics 101 | 102 | #endif // OROCOS__RTT_ROS2_TOPICS__ROS_TYPE_TRANSPORTER_HPP_ 103 | -------------------------------------------------------------------------------- /rtt_ros2_topics/include/orocos/rtt_ros2_topics/utilities.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_TOPICS__UTILITIES_HPP_ 16 | #define OROCOS__RTT_ROS2_TOPICS__UTILITIES_HPP_ 17 | 18 | #include 19 | #include 20 | 21 | #include "rtt/ConnPolicy.hpp" 22 | #include "rtt/base/PortInterface.hpp" 23 | 24 | namespace rtt_ros2_topics 25 | { 26 | 27 | namespace utilities 28 | { 29 | 30 | static std::string convert_camel_case_to_lower_case_underscore(std::string str) 31 | { 32 | // insert _ before capitals 33 | for (std::size_t i = 1; i < str.size(); ++i) { 34 | if (std::isupper(str[i])) { 35 | str.insert(i, "_"); 36 | ++i; 37 | } 38 | } 39 | 40 | // convert to lower case 41 | std::transform( 42 | str.begin(), str.end(), str.begin(), 43 | [](char c) {return static_cast(std::tolower(c));}); 44 | 45 | return str; 46 | } 47 | 48 | static std::string find_topic( 49 | RTT::base::PortInterface * port, 50 | const RTT::ConnPolicy & policy) 51 | { 52 | std::string topic = policy.name_id; 53 | if (topic.empty()) { 54 | // fall back to the port name, converted to lower-case with underscores 55 | topic = convert_camel_case_to_lower_case_underscore(port->getName()); 56 | } 57 | if (topic.empty()) { 58 | throw std::runtime_error("policy.name_id cannot be empty for an unnamed port"); 59 | } 60 | 61 | // TODO(meyerj): Check whether topic is a valid ROS topic name 62 | return topic; 63 | } 64 | 65 | } // namespace utilities 66 | } // namespace rtt_ros2_topics 67 | 68 | #endif // OROCOS__RTT_ROS2_TOPICS__UTILITIES_HPP_ 69 | -------------------------------------------------------------------------------- /rtt_ros2_topics/include/orocos/rtt_ros2_topics/waitable.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_TOPICS__WAITABLE_HPP_ 16 | #define OROCOS__RTT_ROS2_TOPICS__WAITABLE_HPP_ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "rcl/guard_condition.h" 24 | #include "rclcpp/context.hpp" 25 | #include "rclcpp/logger.hpp" 26 | #include "rclcpp/exceptions.hpp" 27 | #include "rclcpp/macros.hpp" 28 | #include "rclcpp/waitable.hpp" 29 | 30 | namespace rtt_ros2_topics 31 | { 32 | 33 | class Waitable 34 | : public rclcpp::Waitable 35 | { 36 | public: 37 | RCLCPP_SMART_PTR_DEFINITIONS_NOT_COPYABLE(Waitable) 38 | 39 | Waitable( 40 | std::function func, 41 | rclcpp::Context::SharedPtr context) 42 | : func_(std::move(func)), 43 | context_(std::move(context)), 44 | rcl_guard_condition_(rcl_get_zero_initialized_guard_condition()) 45 | { 46 | const rcl_ret_t ret = rcl_guard_condition_init( 47 | &rcl_guard_condition_, 48 | context_->get_rcl_context().get(), 49 | rcl_guard_condition_get_default_options()); 50 | if (RCL_RET_OK != ret) { 51 | rclcpp::exceptions::throw_from_rcl_error(ret); 52 | } 53 | } 54 | 55 | virtual ~Waitable() noexcept 56 | { 57 | rcl_ret_t ret = rcl_guard_condition_fini(&rcl_guard_condition_); 58 | if (RCL_RET_OK != ret) { 59 | try { 60 | rclcpp::exceptions::throw_from_rcl_error(ret); 61 | } catch (const std::exception & exception) { 62 | RCLCPP_ERROR( 63 | rclcpp::get_logger("rtt_ros2_topics"), 64 | "Error in destruction of rcl guard condition: %s", exception.what()); 65 | } 66 | } 67 | } 68 | 69 | void trigger() 70 | { 71 | has_work_ = true; 72 | // TODO(meyerj) Check whether the following call is safe in a real-time context 73 | // (e.g. Xenomai). For FastRTPS this locks an std::mutex and notifies a 74 | // std::condition_variable. 75 | const rcl_ret_t ret = rcl_trigger_guard_condition(&rcl_guard_condition_); 76 | if (RCL_RET_OK != ret) { 77 | rclcpp::exceptions::throw_from_rcl_error(ret); 78 | } 79 | } 80 | 81 | /// Notify this Waitable instance about its pending destruction. 82 | /** 83 | * func_() must not be called anymore after cancel() returned. 84 | */ 85 | void cancel() noexcept 86 | { 87 | std::lock_guard lock(execute_mutex_); 88 | func_ = decltype(func_) {}; 89 | } 90 | 91 | size_t get_number_of_ready_guard_conditions() override 92 | { 93 | return 1u; 94 | } 95 | 96 | bool add_to_wait_set(rcl_wait_set_t * wait_set) override 97 | { 98 | std::lock_guard lock(reentrant_mutex_); 99 | 100 | const rcl_ret_t ret = rcl_wait_set_add_guard_condition( 101 | wait_set, &rcl_guard_condition_, nullptr); 102 | return RCL_RET_OK == ret; 103 | } 104 | 105 | bool is_ready(rcl_wait_set_t *) override 106 | { 107 | return has_work_; 108 | } 109 | 110 | void execute() override 111 | { 112 | std::lock_guard lock(execute_mutex_); 113 | if (!func_) {return;} 114 | 115 | has_work_ = false; 116 | if (!func_()) { 117 | // eventually there is more work for us... 118 | trigger(); 119 | } 120 | } 121 | 122 | private: 123 | std::recursive_mutex reentrant_mutex_; 124 | std::mutex execute_mutex_; 125 | 126 | std::function func_; 127 | rclcpp::Context::SharedPtr context_; 128 | 129 | std::atomic has_work_; 130 | rcl_guard_condition_t rcl_guard_condition_; 131 | }; 132 | 133 | } // namespace rtt_ros2_topics 134 | 135 | #endif // OROCOS__RTT_ROS2_TOPICS__WAITABLE_HPP_ 136 | -------------------------------------------------------------------------------- /rtt_ros2_topics/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2_topics 5 | 0.0.0 6 | 7 | This package provides a CMake function and templates to generate ROS 2 transport plugins 8 | for existing ROS 2 interface (messages, services, actions) packages. 9 | 10 | Orocos Developers 11 | Apache License 2.0 12 | 13 | ament_cmake 14 | rosidl_cmake 15 | 16 | rclcpp 17 | rtt_ros2 18 | rtt_ros2_node 19 | 20 | ament_lint_auto 21 | ament_lint_common 22 | 23 | 24 | ament_cmake 25 | 26 | 27 | -------------------------------------------------------------------------------- /rtt_ros2_topics/src/rtt_ros2_topics/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Intermodalics BVBA 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import argparse 16 | import pathlib 17 | import sys 18 | 19 | from rosidl_cmake import expand_template 20 | 21 | from .resource import TEMPLATE_DIR 22 | 23 | 24 | def generate_ros_transport(package, output_dir, messages=[]): 25 | output_dir = pathlib.Path(output_dir) 26 | 27 | data = { 28 | 'pkg_name': package, 29 | 'messages': messages, 30 | } 31 | expand_template( 32 | 'ros_transport_plugin.cpp.em', 33 | data=data, 34 | output_file=(output_dir / "ros_transport_plugin.cpp"), 35 | template_basepath=TEMPLATE_DIR) 36 | 37 | 38 | def main(argv=sys.argv[1:]): 39 | parser = argparse.ArgumentParser( 40 | description='Generate an RTT transport plugin for messages in a ROS interface package.', 41 | formatter_class=argparse.ArgumentDefaultsHelpFormatter) 42 | parser.add_argument( 43 | '--package', required=True, 44 | help='The name of the package') 45 | parser.add_argument( 46 | '--messages', metavar='MESSAGE', nargs='*', 47 | help='The message types') 48 | parser.add_argument( 49 | '--output-dir', required=True, 50 | help='The base directory for generated source files') 51 | args = parser.parse_args(argv) 52 | 53 | return generate_ros_transport(**vars(args)) 54 | -------------------------------------------------------------------------------- /rtt_ros2_topics/src/rtt_ros2_topics/__main__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Intermodalics BVBA 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import sys 16 | from rtt_ros2_topics import main 17 | 18 | sys.exit(main()) 19 | -------------------------------------------------------------------------------- /rtt_ros2_topics/src/rtt_ros2_topics/resource/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Intermodalics BVBA 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import pathlib 16 | 17 | 18 | TEMPLATE_DIR = pathlib.Path(__file__).parent 19 | -------------------------------------------------------------------------------- /rtt_ros2_topics/src/rtt_ros2_topics/resource/ros_transport_plugin.cpp.em: -------------------------------------------------------------------------------- 1 | @{ 2 | from rosidl_cmake import convert_camel_case_to_lower_case_underscore 3 | }@ 4 | // generated from rtt_ros2_topics/src/rtt_ros2_topics/resource/ros_transport_plugin.cpp.em 5 | // generated code does not contain a copyright notice 6 | 7 | #include "rtt/types/TransportPlugin.hpp" 8 | #include "rtt/types/TypekitPlugin.hpp" 9 | 10 | #include "rtt_ros2_topics/protocol_id.h" 11 | #include "rtt_ros2_topics/ros_type_transporter.hpp" 12 | 13 | @[for message in messages]@ 14 | #include "@(pkg_name)/msg/@(convert_camel_case_to_lower_case_underscore(message)).hpp" 15 | @[end for]@ 16 | 17 | namespace rtt_ros2_@(pkg_name) 18 | { 19 | 20 | class RosTransportPlugin : public RTT::types::TransportPlugin 21 | { 22 | public: 23 | bool registerTransport(std::string, RTT::types::TypeInfo * ti) 24 | { 25 | if (ti == nullptr) {return false;} 26 | const auto * type_info = ti->getTypeId(); 27 | if (type_info == nullptr) {return false;} 28 | @[for msg_name in messages]@ 29 | if (*type_info == typeid(@(pkg_name)::msg::@(msg_name))) { 30 | return ti->addProtocol( 31 | ORO_ROS2_PROTOCOL_ID, 32 | new rtt_ros2_topics::RosTypeTransporter<@(pkg_name)::msg::@(msg_name)>()); 33 | } 34 | @[end for]@ 35 | return false; 36 | } 37 | 38 | std::string getTransportName() const 39 | { 40 | return "ros2"; 41 | } 42 | 43 | std::string getTypekitName() const 44 | { 45 | return "ros2-@(pkg_name)"; 46 | } 47 | 48 | std::string getName() const 49 | { 50 | return "ros2-@(pkg_name)-transport"; 51 | } 52 | }; 53 | 54 | } // namespace rtt_ros2_@(pkg_name) 55 | 56 | ORO_TYPEKIT_PLUGIN(rtt_ros2_@(pkg_name)::RosTransportPlugin) 57 | -------------------------------------------------------------------------------- /rtt_ros2_topics/src/rtt_ros2_topics_plugin.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "rtt/internal/GlobalService.hpp" 18 | #include "rtt/plugin/ServicePlugin.hpp" 19 | 20 | #include "rtt_ros2_topics/rostopic.hpp" 21 | 22 | namespace rtt_ros2_topics 23 | { 24 | 25 | static void loadGlobalROSService() 26 | { 27 | RTT::Service::shared_ptr ros = 28 | RTT::internal::GlobalService::Instance()->provides("ros"); 29 | ros->doc("ROS operations and services"); 30 | 31 | ros->addOperation("topic", &topic) 32 | .doc("Returns a ConnPolicy object for streaming to or from the given ROS topic.") 33 | .arg("topic", "The topic") 34 | .arg( 35 | "latch", 36 | "If true, new subscribers will see old messages published before, i.e. " 37 | "set durability to transient local."); 38 | 39 | ros->addOperation("topicLatched", &topicLatched) 40 | .doc("Returns a ConnPolicy object for streaming to or from the given ROS topic (latched).") 41 | .arg("topic", "The topic"); 42 | 43 | ros->addOperation("topicBuffered", &topicBuffered) 44 | .doc("Returns a ConnPolicy object for streaming to or from the given ROS topic.") 45 | .arg("topic", "The topic") 46 | .arg("size", "The size of buffers created by RTT and queues in the ROS middleware (depth)") 47 | .arg( 48 | "latch", 49 | "If true, new subscribers will see old messages published before, i.e. " 50 | "set durability to transient local."); 51 | 52 | ros->addOperation("topicDirect", &topicDirect) 53 | .doc("Returns a ConnPolicy object for streaming to or from the given ROS topic.") 54 | .arg("topic", "The topic") 55 | .arg("size", "The size of queues in the ROS middleware (depth)") 56 | .arg( 57 | "latch", 58 | "If true, new subscribers will see old messages published before, i.e. " 59 | "set durability to transient local."); 60 | } 61 | 62 | extern "C" { 63 | bool loadRTTPlugin(RTT::TaskContext * tc) 64 | { 65 | // This service cannot be loaded into individual components. 66 | if (tc != nullptr) {return false;} 67 | loadGlobalROSService(); 68 | return true; 69 | } 70 | std::string getRTTPluginName() {return "rostopic";} 71 | std::string getRTTTargetName() {return OROCOS_TARGET_NAME;} 72 | } 73 | 74 | } // namespace rtt_ros2_topics 75 | -------------------------------------------------------------------------------- /tests/rtt_ros2_idl_tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2_idl_tests) 3 | 4 | # Skip building this package if BUILD_TESTING is OFF 5 | option(BUILD_TESTING "Build the testing tree." ON) 6 | if(NOT BUILD_TESTING) 7 | install(CODE 8 | "message(STATUS \"Skipping installation of package ${PROJECT_NAME} because BUILD_TESTING is OFF.\")" 9 | ) 10 | return() 11 | endif() 12 | 13 | # Default to C99 14 | if(NOT CMAKE_C_STANDARD) 15 | set(CMAKE_C_STANDARD 99) 16 | endif() 17 | 18 | # Default to C++14 19 | if(NOT CMAKE_CXX_STANDARD) 20 | set(CMAKE_CXX_STANDARD 14) 21 | endif() 22 | 23 | # if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 24 | # add_compile_options(-Wall -Wextra -Wpedantic) 25 | # endif() 26 | 27 | # find dependencies 28 | find_package(ament_cmake REQUIRED) 29 | find_package(rtt_ros2 REQUIRED) 30 | find_package(rtt_ros2_idl REQUIRED) 31 | find_package(rtt_ros2_test_msgs REQUIRED) 32 | 33 | if(BUILD_TESTING) 34 | find_package(ament_lint_auto REQUIRED) 35 | ament_lint_auto_find_test_dependencies() 36 | endif() 37 | 38 | ament_package() 39 | 40 | # unit tests 41 | find_package(ament_cmake_gtest REQUIRED) 42 | 43 | include_directories(${CMAKE_CURRENT_BINARY_DIR}/rtt_ros2_idl) 44 | ament_add_gtest(test_typekit test/test_typekit.cpp) 45 | orocos_configure_executable(test_typekit) 46 | target_link_libraries(test_typekit 47 | rtt_ros2::rtt_ros2 48 | rtt_ros2_test_msgs::rtt_test_msgs_typekit 49 | ) 50 | target_compile_definitions(test_typekit 51 | PRIVATE 52 | test_msgs_VERSION_MAJOR=${test_msgs_VERSION_MAJOR} 53 | test_msgs_VERSION_MINOR=${test_msgs_VERSION_MINOR} 54 | test_msgs_VERSION_PATCH=${test_msgs_VERSION_PATCH} 55 | ) 56 | -------------------------------------------------------------------------------- /tests/rtt_ros2_idl_tests/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2_idl_tests 5 | 0.0.0 6 | 7 | Test interfaces and unit test cases for rtt_ros2_idl 8 | 9 | Orocos Developers 10 | Apache License 2.0 11 | 12 | ament_cmake 13 | 14 | rtt_ros2 15 | rtt_ros2_idl 16 | rtt_ros2_test_msgs 17 | 18 | ament_cmake_gtest 19 | ament_lint_auto 20 | ament_lint_common 21 | 22 | 23 | ament_cmake 24 | 25 | 26 | -------------------------------------------------------------------------------- /tests/rtt_ros2_params_tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2_params_tests) 3 | 4 | # Skip building this package if BUILD_TESTING is OFF 5 | option(BUILD_TESTING "Build the testing tree." ON) 6 | if(NOT BUILD_TESTING) 7 | install(CODE 8 | "message(STATUS \"Skipping installation of package ${PROJECT_NAME} because BUILD_TESTING is OFF.\")" 9 | ) 10 | return() 11 | endif() 12 | 13 | # Default to C99 14 | if(NOT CMAKE_C_STANDARD) 15 | set(CMAKE_C_STANDARD 99) 16 | endif() 17 | 18 | # Default to C++14 19 | if(NOT CMAKE_CXX_STANDARD) 20 | set(CMAKE_CXX_STANDARD 14) 21 | endif() 22 | 23 | # if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 24 | # add_compile_options(-Wall -Wextra -Wpedantic) 25 | # endif() 26 | 27 | # find dependencies 28 | find_package(ament_cmake REQUIRED) 29 | find_package(rtt_ros2 REQUIRED) 30 | find_package(rtt_ros2_node REQUIRED) 31 | find_package(rtt_ros2_params REQUIRED) 32 | 33 | if(BUILD_TESTING) 34 | find_package(ament_lint_auto REQUIRED) 35 | ament_lint_auto_find_test_dependencies() 36 | endif() 37 | 38 | ament_package() 39 | 40 | # unit tests 41 | find_package(ament_cmake_gtest REQUIRED) 42 | 43 | # The test_ros_params fails with 44 | # 45 | # double free or corruption (fasttop) 46 | # 47 | # during destruction in ROS dashing. This seems to be a known problem: 48 | # https://gitlab.com/ApexAI/performance_test/-/issues/87 49 | # ==> workaround: disable the test for dashing 50 | # 51 | set(ROS_DISTRO $ENV{ROS_DISTRO}) 52 | if(ROS_DISTRO STREQUAL "dashing") 53 | return() 54 | endif() 55 | 56 | ament_add_gtest(test_ros_params test/test_ros_params.cpp) 57 | orocos_configure_executable(test_ros_params) 58 | target_link_libraries(test_ros_params 59 | rtt_ros2::rtt_ros2 60 | rtt_ros2_node::rtt_ros2_node 61 | # rtt_ros2_params::rtt_ros2_params # not needed thanks to RosParam service requester 62 | ) 63 | -------------------------------------------------------------------------------- /tests/rtt_ros2_params_tests/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2_params_tests 5 | 0.0.0 6 | 7 | Unit tests for rtt_ros2_params 8 | 9 | Orocos Developers 10 | Apache License 2.0 11 | 12 | ament_cmake 13 | 14 | rtt_ros2 15 | rtt_ros2_node 16 | rtt_ros2_params 17 | 18 | ament_cmake_gtest 19 | ament_lint_auto 20 | ament_lint_common 21 | 22 | 23 | 24 | ament_cmake 25 | 26 | 27 | -------------------------------------------------------------------------------- /tests/rtt_ros2_services_tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2_services_tests) 3 | 4 | # Skip building this package if BUILD_TESTING is OFF 5 | option(BUILD_TESTING "Build the testing tree." ON) 6 | if(NOT BUILD_TESTING) 7 | install(CODE 8 | "message(STATUS \"Skipping installation of package ${PROJECT_NAME} because BUILD_TESTING is OFF.\")" 9 | ) 10 | return() 11 | endif() 12 | 13 | # Default to C99 14 | if(NOT CMAKE_C_STANDARD) 15 | set(CMAKE_C_STANDARD 99) 16 | endif() 17 | 18 | # Default to C++14 19 | if(NOT CMAKE_CXX_STANDARD) 20 | set(CMAKE_CXX_STANDARD 14) 21 | endif() 22 | 23 | # if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 24 | # add_compile_options(-Wall -Wextra -Wpedantic) 25 | # endif() 26 | 27 | # find dependencies 28 | find_package(ament_cmake REQUIRED) 29 | find_package(rtt_ros2 REQUIRED) 30 | find_package(rtt_ros2_services REQUIRED) 31 | find_package(rtt_ros2_test_msgs REQUIRED) 32 | 33 | if(BUILD_TESTING) 34 | find_package(ament_lint_auto REQUIRED) 35 | ament_lint_auto_find_test_dependencies() 36 | endif() 37 | 38 | ament_package() 39 | 40 | # unit tests 41 | find_package(ament_cmake_gtest REQUIRED) 42 | 43 | # The test_ros_service fails with 44 | # 45 | # double free or corruption (fasttop) 46 | # 47 | # during destruction in ROS dashing. This seems to be a known problem: 48 | # https://gitlab.com/ApexAI/performance_test/-/issues/87 49 | # ==> workaround: disable the test for dashing 50 | # 51 | set(ROS_DISTRO $ENV{ROS_DISTRO}) 52 | if(ROS_DISTRO STREQUAL "dashing") 53 | return() 54 | endif() 55 | 56 | ament_add_gtest(test_ros_service test/test_ros_service.cpp) 57 | orocos_configure_executable(test_ros_service) 58 | ament_target_dependencies(test_ros_service test_msgs) 59 | target_link_libraries(test_ros_service 60 | rtt_ros2::rtt_ros2 61 | rtt_ros2_node::rtt_ros2_node 62 | rtt_ros2_services::rtt_ros2_services 63 | ) 64 | target_compile_definitions(test_ros_service 65 | PRIVATE 66 | test_msgs_VERSION_MAJOR=${test_msgs_VERSION_MAJOR} 67 | test_msgs_VERSION_MINOR=${test_msgs_VERSION_MINOR} 68 | test_msgs_VERSION_PATCH=${test_msgs_VERSION_PATCH} 69 | ) 70 | -------------------------------------------------------------------------------- /tests/rtt_ros2_services_tests/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2_services_tests 5 | 0.0.0 6 | 7 | Unit tests for rtt_ros2_services 8 | 9 | Orocos Developers 10 | Apache License 2.0 11 | 12 | ament_cmake 13 | 14 | rtt_ros2 15 | rtt_ros2_services 16 | rtt_ros2_test_msgs 17 | 18 | ament_cmake_gtest 19 | ament_lint_auto 20 | ament_lint_common 21 | 22 | 23 | ament_cmake 24 | 25 | 26 | -------------------------------------------------------------------------------- /tests/rtt_ros2_test_msgs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2_test_msgs) 3 | 4 | # Skip building this package if BUILD_TESTING is OFF 5 | option(BUILD_TESTING "Build the testing tree." ON) 6 | if(NOT BUILD_TESTING) 7 | install(CODE 8 | "message(STATUS \"Skipping installation of package ${PROJECT_NAME} because BUILD_TESTING is OFF.\")" 9 | ) 10 | return() 11 | endif() 12 | 13 | # Default to C99 14 | if(NOT CMAKE_C_STANDARD) 15 | set(CMAKE_C_STANDARD 99) 16 | endif() 17 | 18 | # Default to C++14 19 | if(NOT CMAKE_CXX_STANDARD) 20 | set(CMAKE_CXX_STANDARD 14) 21 | endif() 22 | 23 | # if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 24 | # add_compile_options(-Wall -Wextra -Wpedantic) 25 | # endif() 26 | 27 | # find dependencies 28 | find_package(ament_cmake REQUIRED) 29 | find_package(rtt_ros2_interfaces REQUIRED) 30 | 31 | include_directories(include/orocos) 32 | rtt_ros2_generate_interfaces_plugins(test_msgs 33 | EXTRA_INCLUDES 34 | ${PROJECT_NAME}/srv/empty.hpp 35 | ) 36 | 37 | # linters 38 | if(BUILD_TESTING) 39 | find_package(ament_lint_auto REQUIRED) 40 | ament_lint_auto_find_test_dependencies() 41 | endif() 42 | 43 | # must be called *after* the targets to check exported libraries etc. 44 | ament_package() 45 | 46 | # orocos_generate_package() is deprecated for ROS 2. 47 | # Prefer cmake target export and import instead, in combination with 48 | # ament_export_interfaces() or ament_export_targets() when building with 49 | # ament_cmake. 50 | orocos_generate_package( 51 | DEPENDS_TARGETS rtt_ros2_interfaces 52 | ) 53 | -------------------------------------------------------------------------------- /tests/rtt_ros2_test_msgs/include/orocos/rtt_ros2_test_msgs/srv/empty.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_TEST_MSGS__SRV__EMPTY_HPP_ 16 | #define OROCOS__RTT_ROS2_TEST_MSGS__SRV__EMPTY_HPP_ 17 | 18 | #include 19 | #include 20 | 21 | #include "rtt_ros2_services/rtt_ros2_services_proxy.hpp" 22 | #include "test_msgs/srv/empty.h" 23 | 24 | // Specialized implementations of RosServiceServerOperationCallerWrapper for test_msgs/srv/Empty. 25 | // 26 | // Accepted signatures: 27 | // - void empty(Request&, Response&) // the default signature 28 | // - void empty() 29 | // 30 | 31 | namespace rtt_ros2_services 32 | { 33 | 34 | template<> 35 | struct RosServiceServerOperationCallerWrapper 36 | { 37 | typedef void Signature (); 38 | typedef RTT::OperationCaller ProxyOperationCallerType; 39 | template 40 | static void dispatch( 41 | Callable & call, 42 | std::shared_ptr, 43 | test_msgs::srv::Empty::Request::SharedPtr, 44 | test_msgs::srv::Empty::Response::SharedPtr) 45 | { 46 | call(); 47 | } 48 | }; 49 | 50 | } // namespace rtt_ros2_services 51 | 52 | #endif // OROCOS__RTT_ROS2_TEST_MSGS__SRV__EMPTY_HPP_ 53 | -------------------------------------------------------------------------------- /tests/rtt_ros2_test_msgs/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2_test_msgs 5 | 0.0.0 6 | RTT typekit and transport plugins for test_msgs 7 | Orocos Developers 8 | Apache License 2.0 9 | 10 | ament_cmake 11 | 12 | rtt_ros2_interfaces 13 | test_msgs 14 | 15 | ament_lint_auto 16 | ament_lint_common 17 | 18 | 19 | ament_cmake 20 | 21 | 22 | -------------------------------------------------------------------------------- /tests/rtt_ros2_tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2_tests) 3 | 4 | # Skip building this package if BUILD_TESTING is OFF 5 | option(BUILD_TESTING "Build the testing tree." ON) 6 | if(NOT BUILD_TESTING) 7 | install(CODE 8 | "message(STATUS \"Skipping installation of package ${PROJECT_NAME} because BUILD_TESTING is OFF.\")" 9 | ) 10 | return() 11 | endif() 12 | 13 | # Default to C99 14 | if(NOT CMAKE_C_STANDARD) 15 | set(CMAKE_C_STANDARD 99) 16 | endif() 17 | 18 | # Default to C++14 19 | if(NOT CMAKE_CXX_STANDARD) 20 | set(CMAKE_CXX_STANDARD 14) 21 | endif() 22 | 23 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 24 | add_compile_options(-Wall -Wextra -Wpedantic) 25 | endif() 26 | 27 | # find dependencies 28 | find_package(ament_cmake REQUIRED) 29 | find_package(rtt_ros2 REQUIRED) 30 | 31 | # declare RTT plugin dependencies 32 | rtt_ros2_export_plugin_depend() # empty (to skip parsing package.xml on import even if there would be no other plugin dependencies declared in CMakeLists.txt) 33 | rtt_ros2_export_plugin_depend(rtt_ros2) 34 | 35 | # build test service plugin 36 | orocos_service(test_service src/test_service.cpp) 37 | 38 | # linters 39 | if(BUILD_TESTING) 40 | find_package(ament_lint_auto REQUIRED) 41 | ament_lint_auto_find_test_dependencies() 42 | endif() 43 | 44 | # must be called *after* the targets to check exported libraries etc. 45 | ament_package() 46 | 47 | # unit tests 48 | find_package(ament_cmake_gtest REQUIRED) 49 | 50 | ament_add_gtest(test_find test/test_find.cpp) 51 | orocos_configure_executable(test_find) 52 | ament_target_dependencies(test_find rtt_ros2) 53 | target_link_libraries(test_find rtt_ros2::rtt_ros2) 54 | target_compile_definitions(test_find PRIVATE "-DCMAKE_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\"") 55 | 56 | ament_add_gtest(test_import test/test_import.cpp) 57 | orocos_configure_executable(test_import) 58 | ament_target_dependencies(test_import rtt_ros2) 59 | target_link_libraries(test_import rtt_ros2::rtt_ros2) 60 | -------------------------------------------------------------------------------- /tests/rtt_ros2_tests/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2_tests 5 | 0.0.0 6 | 7 | Unit test cases for rtt_ros2 8 | 9 | Orocos Developers 10 | Apache License 2.0 11 | 12 | ament_cmake 13 | 14 | rtt_ros2 15 | 16 | ament_cmake_gtest 17 | ament_lint_auto 18 | ament_lint_common 19 | 20 | 21 | ament_cmake 22 | 23 | 25 | should_be_ignored 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /tests/rtt_ros2_tests/src/test_service.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | namespace rtt_ros2_tests 21 | { 22 | 23 | class TestService : public RTT::Service 24 | { 25 | public: 26 | explicit TestService(RTT::TaskContext * owner = 0) 27 | : RTT::Service("TestService", owner) 28 | { 29 | this->setValue(new RTT::Constant("constant", 5.0)); 30 | 31 | if (owner == nullptr) { 32 | RTT::log(RTT::Info) << 33 | "Loaded service " << getName() << " into the global service." << 34 | RTT::endlog(); 35 | } else { 36 | RTT::log(RTT::Info) << 37 | "Loaded service " << getName() << " into component " << 38 | owner->getName() << "." << 39 | RTT::endlog(); 40 | } 41 | } 42 | }; 43 | 44 | } // namespace rtt_ros2_tests 45 | 46 | ORO_SERVICE_PLUGIN(rtt_ros2_tests::TestService) 47 | -------------------------------------------------------------------------------- /tests/rtt_ros2_tests/test/test_find.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "rtt_ros2/rtt_ros2.hpp" 16 | 17 | #include "rtt/os/main.h" 18 | 19 | #include "gtest/gtest.h" 20 | 21 | TEST(TestFind, find) 22 | { 23 | EXPECT_EQ( 24 | rtt_ros2::find("rtt_ros2_tests"), 25 | CMAKE_INSTALL_PREFIX "/share/rtt_ros2_tests"); 26 | } 27 | 28 | int ORO_main(int argc, char ** argv) 29 | { 30 | testing::InitGoogleTest(&argc, argv); 31 | return RUN_ALL_TESTS(); 32 | } 33 | -------------------------------------------------------------------------------- /tests/rtt_ros2_tests/test/test_import.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "rtt_ros2/rtt_ros2.hpp" 16 | 17 | #include "rtt/TaskContext.hpp" 18 | #include "rtt/os/main.h" 19 | 20 | #include "gtest/gtest.h" 21 | 22 | TEST(TestImport, import) 23 | { 24 | EXPECT_TRUE(rtt_ros2::import("rtt_ros2_tests")); 25 | 26 | RTT::TaskContext tc("TestComponent"); 27 | EXPECT_TRUE(tc.loadService("rtt_ros2_tests::TestService")); 28 | EXPECT_TRUE(tc.provides("TestService")); 29 | 30 | EXPECT_FALSE(tc.loadService("rtt_ros2_tests::UnknownService")); 31 | } 32 | 33 | int ORO_main(int argc, char ** argv) 34 | { 35 | testing::InitGoogleTest(&argc, argv); 36 | return RUN_ALL_TESTS(); 37 | } 38 | -------------------------------------------------------------------------------- /tests/rtt_ros2_topics_tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2_topics_tests) 3 | 4 | # Skip building this package if BUILD_TESTING is OFF 5 | option(BUILD_TESTING "Build the testing tree." ON) 6 | if(NOT BUILD_TESTING) 7 | install(CODE 8 | "message(STATUS \"Skipping installation of package ${PROJECT_NAME} because BUILD_TESTING is OFF.\")" 9 | ) 10 | return() 11 | endif() 12 | 13 | # Default to C99 14 | if(NOT CMAKE_C_STANDARD) 15 | set(CMAKE_C_STANDARD 99) 16 | endif() 17 | 18 | # Default to C++14 19 | if(NOT CMAKE_CXX_STANDARD) 20 | set(CMAKE_CXX_STANDARD 14) 21 | endif() 22 | 23 | # if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 24 | # add_compile_options(-Wall -Wextra -Wpedantic) 25 | # endif() 26 | 27 | # find dependencies 28 | find_package(ament_cmake REQUIRED) 29 | find_package(rtt_ros2 REQUIRED) 30 | find_package(rtt_ros2_topics REQUIRED) 31 | find_package(rtt_ros2_test_msgs REQUIRED) 32 | 33 | if(BUILD_TESTING) 34 | find_package(ament_lint_auto REQUIRED) 35 | ament_lint_auto_find_test_dependencies() 36 | endif() 37 | 38 | ament_package() 39 | 40 | # unit tests 41 | find_package(ament_cmake_gtest REQUIRED) 42 | 43 | # The test_ros_transport fails with 44 | # 45 | # double free or corruption (fasttop) 46 | # 47 | # during destruction in ROS dashing. This seems to be a known problem: 48 | # https://gitlab.com/ApexAI/performance_test/-/issues/87 49 | # ==> workaround: disable the test for dashing 50 | # 51 | set(ROS_DISTRO $ENV{ROS_DISTRO}) 52 | if(ROS_DISTRO STREQUAL "dashing") 53 | return() 54 | endif() 55 | 56 | ament_add_gtest(test_ros_transport test/test_ros_transport.cpp) 57 | orocos_configure_executable(test_ros_transport) 58 | target_link_libraries(test_ros_transport 59 | rtt_ros2::rtt_ros2 60 | rtt_ros2_node::rtt_ros2_node 61 | rtt_ros2_test_msgs::rtt_test_msgs_typekit 62 | ) 63 | target_compile_definitions(test_ros_transport 64 | PRIVATE 65 | test_msgs_VERSION_MAJOR=${test_msgs_VERSION_MAJOR} 66 | test_msgs_VERSION_MINOR=${test_msgs_VERSION_MINOR} 67 | test_msgs_VERSION_PATCH=${test_msgs_VERSION_PATCH} 68 | ) 69 | 70 | ament_add_gtest(test_topics_service test/test_topics_service.cpp) 71 | orocos_configure_executable(test_topics_service) 72 | ament_target_dependencies(test_topics_service 73 | rtt_ros2_topics 74 | ) 75 | target_link_libraries(test_topics_service 76 | rtt_ros2::rtt_ros2 77 | rtt_ros2_topics::rtt_ros2_topics 78 | ) 79 | -------------------------------------------------------------------------------- /tests/rtt_ros2_topics_tests/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2_topics_tests 5 | 0.0.0 6 | 7 | Unit tests for rtt_ros2_topics 8 | 9 | Orocos Developers 10 | Apache License 2.0 11 | 12 | ament_cmake 13 | 14 | rtt_ros2 15 | rtt_ros2_topics 16 | rtt_ros2_test_msgs 17 | 18 | ament_cmake_gtest 19 | ament_lint_auto 20 | ament_lint_common 21 | 22 | 23 | ament_cmake 24 | 25 | 26 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_action_msgs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2_action_msgs) 3 | 4 | # Default to C99 5 | if(NOT CMAKE_C_STANDARD) 6 | set(CMAKE_C_STANDARD 99) 7 | endif() 8 | 9 | # Default to C++14 10 | if(NOT CMAKE_CXX_STANDARD) 11 | set(CMAKE_CXX_STANDARD 14) 12 | endif() 13 | 14 | # if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 15 | # add_compile_options(-Wall -Wextra -Wpedantic) 16 | # endif() 17 | 18 | # find dependencies 19 | find_package(ament_cmake REQUIRED) 20 | find_package(rtt_ros2_interfaces REQUIRED) 21 | 22 | rtt_ros2_generate_interfaces_plugins(action_msgs) 23 | 24 | # linters 25 | if(BUILD_TESTING) 26 | find_package(ament_lint_auto REQUIRED) 27 | ament_lint_auto_find_test_dependencies() 28 | endif() 29 | 30 | # must be called *after* the targets to check exported libraries etc. 31 | ament_package() 32 | 33 | # orocos_generate_package() is deprecated for ROS 2. 34 | # Prefer cmake target export and import instead, in combination with 35 | # ament_export_interfaces() or ament_export_targets() when building with 36 | # ament_cmake. 37 | orocos_generate_package( 38 | DEPENDS_TARGETS rtt_ros2_interfaces 39 | ) 40 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_action_msgs/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2_action_msgs 5 | 0.0.0 6 | RTT typekit and transport plugins for action_msgs 7 | Orocos Developers 8 | Apache License 2.0 9 | 10 | ament_cmake 11 | 12 | builtin_interfaces 13 | rtt_ros2_interfaces 14 | 15 | ament_lint_auto 16 | ament_lint_common 17 | 18 | 19 | ament_cmake 20 | 21 | 22 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_builtin_interfaces/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2_builtin_interfaces CXX) 3 | 4 | # Default to C99 5 | if(NOT CMAKE_C_STANDARD) 6 | set(CMAKE_C_STANDARD 99) 7 | endif() 8 | 9 | # Default to C++14 10 | if(NOT CMAKE_CXX_STANDARD) 11 | set(CMAKE_CXX_STANDARD 14) 12 | endif() 13 | 14 | # if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 15 | # add_compile_options(-Wall -Wextra -Wpedantic) 16 | # endif() 17 | 18 | # find dependencies 19 | find_package(ament_cmake REQUIRED) 20 | find_package(rtt_ros2_idl REQUIRED) 21 | 22 | # generate typekit 23 | rtt_ros2_generate_typekit(builtin_interfaces) 24 | 25 | # linters 26 | if(BUILD_TESTING) 27 | find_package(ament_lint_auto REQUIRED) 28 | ament_lint_auto_find_test_dependencies() 29 | endif() 30 | 31 | # must be called *after* the targets to check exported libraries etc. 32 | ament_package() 33 | 34 | # orocos_generate_package() is deprecated for ROS 2. 35 | # Prefer cmake target export and import instead, in combination with 36 | # ament_export_interfaces() or ament_export_targets() when building with 37 | # ament_cmake. 38 | orocos_generate_package( 39 | DEPENDS_TARGETS rtt_ros2_idl 40 | ) 41 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_builtin_interfaces/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2_builtin_interfaces 5 | 0.0.0 6 | RTT typekit and transport plugins for builtin_interfaces 7 | Orocos Developers 8 | Apache License 2.0 9 | 10 | ament_cmake 11 | 12 | builtin_interfaces 13 | rtt_ros2_idl 14 | 15 | ament_lint_auto 16 | ament_lint_common 17 | 18 | 19 | ament_cmake 20 | 21 | 22 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_primitives_typekit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2_primitives_typekit) 3 | 4 | # Default to C99 5 | if(NOT CMAKE_C_STANDARD) 6 | set(CMAKE_C_STANDARD 99) 7 | endif() 8 | 9 | # Default to C++14 10 | if(NOT CMAKE_CXX_STANDARD) 11 | set(CMAKE_CXX_STANDARD 14) 12 | endif() 13 | 14 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 15 | add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter) 16 | endif() 17 | 18 | # find dependencies 19 | find_package(ament_cmake REQUIRED) 20 | find_package(rtt_ros2 REQUIRED) 21 | 22 | # build ros2-primitives typekit 23 | orocos_typekit(rtt_ros2_primitives_typekit 24 | src/typekit/ros2_bool_type.cpp 25 | src/typekit/ros2_float32_type.cpp 26 | src/typekit/ros2_float64_type.cpp 27 | src/typekit/ros2_int16_type.cpp 28 | src/typekit/ros2_int32_type.cpp 29 | src/typekit/ros2_int64_type.cpp 30 | src/typekit/ros2_int8_type.cpp 31 | src/typekit/ros2_primitives_typekit.cpp 32 | src/typekit/ros2_string_type.cpp 33 | src/typekit/ros2_uint16_type.cpp 34 | src/typekit/ros2_uint32_type.cpp 35 | src/typekit/ros2_uint64_type.cpp 36 | src/typekit/ros2_uint8_type.cpp 37 | src/typekit/ros2_wstring_type.cpp 38 | EXPORT ${PROJECT_NAME} 39 | INCLUDES DESTINATION include/orocos 40 | ) 41 | target_include_directories(rtt_ros2_primitives_typekit 42 | PRIVATE include/orocos 43 | ) 44 | 45 | # install 46 | install( 47 | DIRECTORY include/ 48 | DESTINATION include 49 | ) 50 | 51 | # linters 52 | if(BUILD_TESTING) 53 | find_package(ament_lint_auto REQUIRED) 54 | ament_lint_auto_find_test_dependencies() 55 | endif() 56 | 57 | # export information to downstream packages 58 | # ament_export_dependencies(rtt_ros2) 59 | ament_export_include_directories(include/orocos) 60 | if(COMMAND ament_export_targets) 61 | ament_export_targets(${PROJECT_NAME} HAS_LIBRARY_TARGET) 62 | else() 63 | ament_export_interfaces(${PROJECT_NAME} HAS_LIBRARY_TARGET) 64 | endif() 65 | 66 | # must be called *after* the targets to check exported libraries etc. 67 | ament_package() 68 | 69 | # orocos_generate_package() is deprecated for ROS 2. 70 | # Prefer cmake target export and import instead, in combination with 71 | # ament_export_interfaces() or ament_export_targets() when building with 72 | # ament_cmake. 73 | orocos_generate_package( 74 | # DEPENDS_TARGETS rtt_ros2 75 | ) 76 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_primitives_typekit/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2_primitives_typekit 5 | 0.0.0 6 | 7 | Orocos RTT typekit plugin for ROS 2 primitive types 8 | 9 | Orocos Developers 10 | Apache License 2.0 11 | 12 | ament_cmake 13 | 14 | rtt_ros2 15 | 16 | ament_lint_auto 17 | ament_lint_common 18 | 19 | 20 | ament_cmake 21 | 22 | 23 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_primitives_typekit/src/typekit/ros2_bool_type.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "rtt/types/PrimitiveSequenceTypeInfo.hpp" 18 | #include "rtt/types/CArrayTypeInfo.hpp" 19 | 20 | #include "rtt_ros2_primitives_typekit/Types.hpp" 21 | 22 | // bool 23 | template class RTT::internal::DataSource; 24 | template class RTT::internal::AssignableDataSource; 25 | template class RTT::internal::AssignCommand; 26 | template class RTT::internal::ValueDataSource; 27 | template class RTT::internal::ConstantDataSource; 28 | template class RTT::internal::ReferenceDataSource; 29 | template class RTT::OutputPort; 30 | template class RTT::InputPort; 31 | template class RTT::Property; 32 | template class RTT::Attribute; 33 | template class RTT::Constant; 34 | 35 | template class RTT::types::PrimitiveSequenceTypeInfo>; 36 | template class RTT::types::CArrayTypeInfo>; 37 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_primitives_typekit/src/typekit/ros2_float32_type.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "rtt/typekit/StdTypeInfo.hpp" 18 | #include "rtt/types/PrimitiveSequenceTypeInfo.hpp" 19 | #include "rtt/types/CArrayTypeInfo.hpp" 20 | 21 | #include "rtt_ros2_primitives_typekit/Types.hpp" 22 | 23 | // float32 24 | template class RTT::internal::DataSource; 25 | template class RTT::internal::AssignableDataSource; 26 | template class RTT::internal::AssignCommand; 27 | template class RTT::internal::ValueDataSource; 28 | template class RTT::internal::ConstantDataSource; 29 | template class RTT::internal::ReferenceDataSource; 30 | template class RTT::OutputPort; 31 | template class RTT::InputPort; 32 | template class RTT::Property; 33 | template class RTT::Attribute; 34 | template class RTT::Constant; 35 | 36 | template class RTT::types::StdTypeInfo; 37 | template class RTT::types::PrimitiveSequenceTypeInfo>; 38 | template class RTT::types::CArrayTypeInfo>; 39 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_primitives_typekit/src/typekit/ros2_float64_type.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "rtt/typekit/StdTypeInfo.hpp" 18 | #include "rtt/types/PrimitiveSequenceTypeInfo.hpp" 19 | #include "rtt/types/CArrayTypeInfo.hpp" 20 | 21 | #include "rtt_ros2_primitives_typekit/Types.hpp" 22 | 23 | // float64 24 | template class RTT::internal::DataSource; 25 | template class RTT::internal::AssignableDataSource; 26 | template class RTT::internal::AssignCommand; 27 | template class RTT::internal::ValueDataSource; 28 | template class RTT::internal::ConstantDataSource; 29 | template class RTT::internal::ReferenceDataSource; 30 | template class RTT::OutputPort; 31 | template class RTT::InputPort; 32 | template class RTT::Property; 33 | template class RTT::Attribute; 34 | template class RTT::Constant; 35 | 36 | template class RTT::types::StdTypeInfo; 37 | template class RTT::types::PrimitiveSequenceTypeInfo>; 38 | template class RTT::types::CArrayTypeInfo>; 39 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_primitives_typekit/src/typekit/ros2_int16_type.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "rtt/typekit/StdTypeInfo.hpp" 18 | #include "rtt/types/PrimitiveSequenceTypeInfo.hpp" 19 | #include "rtt/types/CArrayTypeInfo.hpp" 20 | 21 | #include "rtt_ros2_primitives_typekit/Types.hpp" 22 | 23 | // int16 24 | template class RTT::internal::DataSource; 25 | template class RTT::internal::AssignableDataSource; 26 | template class RTT::internal::AssignCommand; 27 | template class RTT::internal::ValueDataSource; 28 | template class RTT::internal::ConstantDataSource; 29 | template class RTT::internal::ReferenceDataSource; 30 | template class RTT::OutputPort; 31 | template class RTT::InputPort; 32 | template class RTT::Property; 33 | template class RTT::Attribute; 34 | template class RTT::Constant; 35 | 36 | template class RTT::types::StdTypeInfo; 37 | template class RTT::types::PrimitiveSequenceTypeInfo>; 38 | template class RTT::types::CArrayTypeInfo>; 39 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_primitives_typekit/src/typekit/ros2_int32_type.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "rtt/typekit/StdTypeInfo.hpp" 18 | #include "rtt/types/PrimitiveSequenceTypeInfo.hpp" 19 | #include "rtt/types/CArrayTypeInfo.hpp" 20 | 21 | #include "rtt_ros2_primitives_typekit/Types.hpp" 22 | 23 | // int32 24 | template class RTT::internal::DataSource; 25 | template class RTT::internal::AssignableDataSource; 26 | template class RTT::internal::AssignCommand; 27 | template class RTT::internal::ValueDataSource; 28 | template class RTT::internal::ConstantDataSource; 29 | template class RTT::internal::ReferenceDataSource; 30 | template class RTT::OutputPort; 31 | template class RTT::InputPort; 32 | template class RTT::Property; 33 | template class RTT::Attribute; 34 | template class RTT::Constant; 35 | 36 | template class RTT::types::StdTypeInfo; 37 | template class RTT::types::PrimitiveSequenceTypeInfo>; 38 | template class RTT::types::CArrayTypeInfo>; 39 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_primitives_typekit/src/typekit/ros2_int64_type.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "rtt/typekit/StdTypeInfo.hpp" 18 | #include "rtt/types/PrimitiveSequenceTypeInfo.hpp" 19 | #include "rtt/types/CArrayTypeInfo.hpp" 20 | 21 | #include "rtt_ros2_primitives_typekit/Types.hpp" 22 | 23 | // int64 24 | template class RTT::internal::DataSource; 25 | template class RTT::internal::AssignableDataSource; 26 | template class RTT::internal::AssignCommand; 27 | template class RTT::internal::ValueDataSource; 28 | template class RTT::internal::ConstantDataSource; 29 | template class RTT::internal::ReferenceDataSource; 30 | template class RTT::OutputPort; 31 | template class RTT::InputPort; 32 | template class RTT::Property; 33 | template class RTT::Attribute; 34 | template class RTT::Constant; 35 | 36 | template class RTT::types::StdTypeInfo; 37 | template class RTT::types::PrimitiveSequenceTypeInfo>; 38 | template class RTT::types::CArrayTypeInfo>; 39 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_primitives_typekit/src/typekit/ros2_int8_type.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "rtt/typekit/StdTypeInfo.hpp" 18 | #include "rtt/types/PrimitiveSequenceTypeInfo.hpp" 19 | #include "rtt/types/CArrayTypeInfo.hpp" 20 | 21 | #include "rtt_ros2_primitives_typekit/Types.hpp" 22 | 23 | // int8 24 | template class RTT::internal::DataSource; 25 | template class RTT::internal::AssignableDataSource; 26 | template class RTT::internal::AssignCommand; 27 | template class RTT::internal::ValueDataSource; 28 | template class RTT::internal::ConstantDataSource; 29 | template class RTT::internal::ReferenceDataSource; 30 | template class RTT::OutputPort; 31 | template class RTT::InputPort; 32 | template class RTT::Property; 33 | template class RTT::Attribute; 34 | template class RTT::Constant; 35 | 36 | template class RTT::types::StdTypeInfo; 37 | template class RTT::types::PrimitiveSequenceTypeInfo>; 38 | template class RTT::types::CArrayTypeInfo>; 39 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_primitives_typekit/src/typekit/ros2_string_type.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | 18 | #include "rtt/types/PrimitiveSequenceTypeInfo.hpp" 19 | #include "rtt/types/CArrayTypeInfo.hpp" 20 | 21 | #include "rtt_ros2_primitives_typekit/Types.hpp" 22 | 23 | // string 24 | template class RTT::internal::DataSource; 25 | template class RTT::internal::AssignableDataSource; 26 | template class RTT::internal::AssignCommand; 27 | template class RTT::internal::ValueDataSource; 28 | template class RTT::internal::ConstantDataSource; 29 | template class RTT::internal::ReferenceDataSource; 30 | template class RTT::OutputPort; 31 | template class RTT::InputPort; 32 | template class RTT::Property; 33 | template class RTT::Attribute; 34 | template class RTT::Constant; 35 | 36 | template class RTT::types::PrimitiveSequenceTypeInfo>; 37 | template class RTT::types::CArrayTypeInfo>; 38 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_primitives_typekit/src/typekit/ros2_uint16_type.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "rtt/typekit/StdTypeInfo.hpp" 18 | #include "rtt/types/PrimitiveSequenceTypeInfo.hpp" 19 | #include "rtt/types/CArrayTypeInfo.hpp" 20 | 21 | #include "rtt_ros2_primitives_typekit/Types.hpp" 22 | 23 | // uint16 24 | template class RTT::internal::DataSource; 25 | template class RTT::internal::AssignableDataSource; 26 | template class RTT::internal::AssignCommand; 27 | template class RTT::internal::ValueDataSource; 28 | template class RTT::internal::ConstantDataSource; 29 | template class RTT::internal::ReferenceDataSource; 30 | template class RTT::OutputPort; 31 | template class RTT::InputPort; 32 | template class RTT::Property; 33 | template class RTT::Attribute; 34 | template class RTT::Constant; 35 | 36 | template class RTT::types::StdTypeInfo; 37 | template class RTT::types::PrimitiveSequenceTypeInfo>; 38 | template class RTT::types::CArrayTypeInfo>; 39 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_primitives_typekit/src/typekit/ros2_uint32_type.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "rtt/typekit/StdTypeInfo.hpp" 18 | #include "rtt/types/PrimitiveSequenceTypeInfo.hpp" 19 | #include "rtt/types/CArrayTypeInfo.hpp" 20 | 21 | #include "rtt_ros2_primitives_typekit/Types.hpp" 22 | 23 | // uint32 24 | template class RTT::internal::DataSource; 25 | template class RTT::internal::AssignableDataSource; 26 | template class RTT::internal::AssignCommand; 27 | template class RTT::internal::ValueDataSource; 28 | template class RTT::internal::ConstantDataSource; 29 | template class RTT::internal::ReferenceDataSource; 30 | template class RTT::OutputPort; 31 | template class RTT::InputPort; 32 | template class RTT::Property; 33 | template class RTT::Attribute; 34 | template class RTT::Constant; 35 | 36 | template class RTT::types::StdTypeInfo; 37 | template class RTT::types::PrimitiveSequenceTypeInfo>; 38 | template class RTT::types::CArrayTypeInfo>; 39 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_primitives_typekit/src/typekit/ros2_uint64_type.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "rtt/typekit/StdTypeInfo.hpp" 18 | #include "rtt/types/PrimitiveSequenceTypeInfo.hpp" 19 | #include "rtt/types/CArrayTypeInfo.hpp" 20 | 21 | #include "rtt_ros2_primitives_typekit/Types.hpp" 22 | 23 | // uint64 24 | template class RTT::internal::DataSource; 25 | template class RTT::internal::AssignableDataSource; 26 | template class RTT::internal::AssignCommand; 27 | template class RTT::internal::ValueDataSource; 28 | template class RTT::internal::ConstantDataSource; 29 | template class RTT::internal::ReferenceDataSource; 30 | template class RTT::OutputPort; 31 | template class RTT::InputPort; 32 | template class RTT::Property; 33 | template class RTT::Attribute; 34 | template class RTT::Constant; 35 | 36 | template class RTT::types::StdTypeInfo; 37 | template class RTT::types::PrimitiveSequenceTypeInfo>; 38 | template class RTT::types::CArrayTypeInfo>; 39 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_primitives_typekit/src/typekit/ros2_uint8_type.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "rtt/typekit/StdTypeInfo.hpp" 18 | #include "rtt/types/PrimitiveSequenceTypeInfo.hpp" 19 | #include "rtt/types/CArrayTypeInfo.hpp" 20 | 21 | #include "rtt_ros2_primitives_typekit/Types.hpp" 22 | 23 | // byte + char + uint8 24 | template class RTT::internal::DataSource; 25 | template class RTT::internal::AssignableDataSource; 26 | template class RTT::internal::AssignCommand; 27 | template class RTT::internal::ValueDataSource; 28 | template class RTT::internal::ConstantDataSource; 29 | template class RTT::internal::ReferenceDataSource; 30 | template class RTT::OutputPort; 31 | template class RTT::InputPort; 32 | template class RTT::Property; 33 | template class RTT::Attribute; 34 | template class RTT::Constant; 35 | 36 | template class RTT::types::StdTypeInfo; 37 | template class RTT::types::PrimitiveSequenceTypeInfo>; 38 | template class RTT::types::CArrayTypeInfo>; 39 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_primitives_typekit/src/typekit/ros2_wstring_type.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include "rtt/typekit/StdStringTypeInfo.hpp" 18 | #include "rtt/types/PrimitiveSequenceTypeInfo.hpp" 19 | #include "rtt/types/CArrayTypeInfo.hpp" 20 | 21 | #include "rtt_ros2_primitives_typekit/Types.hpp" 22 | 23 | // wstring 24 | template class RTT::internal::DataSource; 25 | template class RTT::internal::AssignableDataSource; 26 | template class RTT::internal::AssignCommand; 27 | template class RTT::internal::ValueDataSource; 28 | template class RTT::internal::ConstantDataSource; 29 | template class RTT::internal::ReferenceDataSource; 30 | template class RTT::OutputPort; 31 | template class RTT::InputPort; 32 | template class RTT::Property; 33 | template class RTT::Attribute; 34 | template class RTT::Constant; 35 | 36 | template class RTT::types::StdBasicStringTypeInfo; 37 | template class RTT::types::PrimitiveSequenceTypeInfo>; 38 | template class RTT::types::CArrayTypeInfo>; 39 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_rclcpp_typekit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2_rclcpp_typekit) 3 | 4 | # Default to C99 5 | if(NOT CMAKE_C_STANDARD) 6 | set(CMAKE_C_STANDARD 99) 7 | endif() 8 | 9 | # Default to C++14 10 | if(NOT CMAKE_CXX_STANDARD) 11 | set(CMAKE_CXX_STANDARD 14) 12 | endif() 13 | 14 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 15 | add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter) 16 | endif() 17 | 18 | # find dependencies 19 | find_package(ament_cmake REQUIRED) 20 | find_package(rclcpp REQUIRED) 21 | find_package(rtt_ros2 REQUIRED) 22 | 23 | # build ros2-primitives typekit 24 | orocos_typekit(rtt_ros2_rclcpp_typekit 25 | src/ros2_duration_type.cpp 26 | src/ros2_node_options_type.cpp 27 | src/ros2_parameter_type.cpp 28 | src/ros2_parameter_value_type.cpp 29 | src/ros2_publisher_options_type.cpp 30 | src/ros2_qos_type.cpp 31 | src/ros2_time_type.cpp 32 | src/rtt_ros2_rclcpp_typekit.cpp 33 | EXPORT ${PROJECT_NAME} 34 | INCLUDES DESTINATION include/orocos 35 | ) 36 | target_include_directories(rtt_ros2_rclcpp_typekit 37 | PRIVATE include/orocos 38 | ) 39 | ament_target_dependencies(rtt_ros2_rclcpp_typekit 40 | rclcpp 41 | rtt_ros2 42 | ) 43 | 44 | # install 45 | install( 46 | DIRECTORY include/ 47 | DESTINATION include 48 | ) 49 | 50 | # linters 51 | if(BUILD_TESTING) 52 | find_package(ament_lint_auto REQUIRED) 53 | ament_lint_auto_find_test_dependencies() 54 | endif() 55 | 56 | # export information to downstream packages 57 | # ament_export_dependencies(rtt_ros2) 58 | ament_export_include_directories(include/orocos) 59 | if(COMMAND ament_export_targets) 60 | ament_export_targets(${PROJECT_NAME} HAS_LIBRARY_TARGET) 61 | else() 62 | ament_export_interfaces(${PROJECT_NAME} HAS_LIBRARY_TARGET) 63 | endif() 64 | rtt_ros2_export_plugin_depend(rtt_ros2_primitives_typekit) 65 | rtt_ros2_export_plugin_depend(rtt_ros2_builtin_interfaces) 66 | 67 | # must be called *after* the targets to check exported libraries etc. 68 | ament_package() 69 | 70 | # orocos_generate_package() is deprecated for ROS 2. 71 | # Prefer cmake target export and import instead, in combination with 72 | # ament_export_interfaces() or ament_export_targets() when building with 73 | # ament_cmake. 74 | orocos_generate_package( 75 | # DEPENDS_TARGETS rtt_ros2 76 | ) 77 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_rclcpp_typekit/include/orocos/rtt_ros2_rclcpp_typekit/ros2_duration_type.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_DURATION_TYPE_HPP_ 16 | #define OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_DURATION_TYPE_HPP_ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "rclcpp/duration.hpp" 23 | 24 | #include "rtt/types/PrimitiveTypeInfo.hpp" 25 | 26 | #include "time_io.hpp" 27 | #include "wrapped_duration.hpp" 28 | 29 | namespace rtt_ros2_rclcpp_typekit 30 | { 31 | 32 | class DurationTypeInfo 33 | : public RTT::types::PrimitiveTypeInfo 34 | { 35 | public: 36 | DurationTypeInfo(); 37 | 38 | bool installTypeInfoObject(RTT::types::TypeInfo * ti) override; 39 | }; 40 | 41 | } // namespace rtt_ros2_rclcpp_typekit 42 | 43 | #endif // OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_DURATION_TYPE_HPP_ 44 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_rclcpp_typekit/include/orocos/rtt_ros2_rclcpp_typekit/ros2_node_options_type.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_NODE_OPTIONS_TYPE_HPP_ 16 | #define OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_NODE_OPTIONS_TYPE_HPP_ 17 | 18 | #include 19 | #include 20 | 21 | #include "rclcpp/node_options.hpp" 22 | 23 | #include "rtt/types/MemberFactory.hpp" 24 | #include "rtt/types/PrimitiveTypeInfo.hpp" 25 | 26 | namespace rtt_ros2_rclcpp_typekit 27 | { 28 | 29 | class NodeOptionsTypeInfo 30 | : public RTT::types::PrimitiveTypeInfo, 31 | public RTT::types::MemberFactory 32 | { 33 | public: 34 | NodeOptionsTypeInfo(); 35 | 36 | bool installTypeInfoObject(RTT::types::TypeInfo * ti) override; 37 | 38 | std::vector getMemberNames() const override; 39 | 40 | RTT::base::DataSourceBase::shared_ptr getMember( 41 | RTT::base::DataSourceBase::shared_ptr item, 42 | const std::string & part_name) const override; 43 | }; 44 | 45 | } // namespace rtt_ros2_rclcpp_typekit 46 | 47 | #endif // OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_NODE_OPTIONS_TYPE_HPP_ 48 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_rclcpp_typekit/include/orocos/rtt_ros2_rclcpp_typekit/ros2_parameter_type.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_PARAMETER_TYPE_HPP_ 16 | #define OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_PARAMETER_TYPE_HPP_ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "rclcpp/parameter.hpp" 23 | 24 | #include "rtt/types/MemberFactory.hpp" 25 | #include "rtt/types/PrimitiveTypeInfo.hpp" 26 | 27 | namespace rtt_ros2_rclcpp_typekit 28 | { 29 | 30 | class ParameterTypeInfo 31 | : public RTT::types::PrimitiveTypeInfo, 32 | public RTT::types::MemberFactory 33 | { 34 | public: 35 | ParameterTypeInfo(); 36 | 37 | bool installTypeInfoObject(RTT::types::TypeInfo * ti) override; 38 | 39 | std::vector getMemberNames() const override; 40 | 41 | RTT::base::DataSourceBase::shared_ptr getMember( 42 | RTT::base::DataSourceBase::shared_ptr item, 43 | const std::string & part_name) const override; 44 | }; 45 | 46 | } // namespace rtt_ros2_rclcpp_typekit 47 | 48 | #endif // OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_PARAMETER_TYPE_HPP_ 49 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_rclcpp_typekit/include/orocos/rtt_ros2_rclcpp_typekit/ros2_parameter_value_type.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_PARAMETER_VALUE_TYPE_HPP_ 16 | #define OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_PARAMETER_VALUE_TYPE_HPP_ 17 | 18 | #include 19 | #include 20 | 21 | #include "rclcpp/parameter_value.hpp" 22 | 23 | #include "rtt/types/PrimitiveTypeInfo.hpp" 24 | 25 | namespace rtt_ros2_rclcpp_typekit 26 | { 27 | 28 | class ParameterValueTypeInfo 29 | : public RTT::types::PrimitiveTypeInfo 30 | { 31 | public: 32 | ParameterValueTypeInfo(); 33 | 34 | bool installTypeInfoObject(RTT::types::TypeInfo * ti) override; 35 | 36 | std::ostream & write( 37 | std::ostream & os, 38 | RTT::base::DataSourceBase::shared_ptr in) const override; 39 | 40 | std::istream & read( 41 | std::istream & is, 42 | RTT::base::DataSourceBase::shared_ptr out) const override; 43 | 44 | bool isStreamable() const override 45 | { 46 | return true; 47 | } 48 | }; 49 | 50 | } // namespace rtt_ros2_rclcpp_typekit 51 | 52 | #endif // OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_PARAMETER_VALUE_TYPE_HPP_ 53 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_rclcpp_typekit/include/orocos/rtt_ros2_rclcpp_typekit/ros2_publisher_options_type.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_PUBLISHER_OPTIONS_TYPE_HPP_ 16 | #define OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_PUBLISHER_OPTIONS_TYPE_HPP_ 17 | 18 | #include 19 | #include 20 | 21 | #include "rclcpp/publisher_options.hpp" 22 | 23 | #include "rtt/types/MemberFactory.hpp" 24 | #include "rtt/types/PrimitiveTypeInfo.hpp" 25 | 26 | namespace rtt_ros2_rclcpp_typekit 27 | { 28 | 29 | class PublisherOptionsBaseTypeInfo 30 | : public RTT::types::PrimitiveTypeInfo, 31 | public RTT::types::MemberFactory 32 | { 33 | public: 34 | PublisherOptionsBaseTypeInfo(); 35 | 36 | bool installTypeInfoObject(RTT::types::TypeInfo * ti) override; 37 | 38 | std::vector getMemberNames() const override; 39 | 40 | RTT::base::DataSourceBase::shared_ptr getMember( 41 | RTT::base::DataSourceBase::shared_ptr item, 42 | const std::string & part_name) const override; 43 | }; 44 | 45 | } // namespace rtt_ros2_rclcpp_typekit 46 | 47 | #endif // OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_PUBLISHER_OPTIONS_TYPE_HPP_ 48 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_rclcpp_typekit/include/orocos/rtt_ros2_rclcpp_typekit/ros2_qos_type.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_QOS_TYPE_HPP_ 16 | #define OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_QOS_TYPE_HPP_ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "rclcpp/qos.hpp" 23 | 24 | #include "rtt/types/MemberFactory.hpp" 25 | #include "rtt/types/PrimitiveTypeInfo.hpp" 26 | 27 | #include "wrapped_qos.hpp" 28 | 29 | namespace rtt_ros2_rclcpp_typekit 30 | { 31 | 32 | class QoSTypeInfo 33 | : public RTT::types::PrimitiveTypeInfo, 34 | public RTT::types::MemberFactory 35 | { 36 | public: 37 | QoSTypeInfo(); 38 | 39 | bool installTypeInfoObject(RTT::types::TypeInfo * ti) override; 40 | 41 | std::vector getMemberNames() const override; 42 | 43 | RTT::base::DataSourceBase::shared_ptr getMember( 44 | RTT::base::DataSourceBase::shared_ptr item, 45 | const std::string & part_name) const override; 46 | }; 47 | 48 | } // namespace rtt_ros2_rclcpp_typekit 49 | 50 | #endif // OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_QOS_TYPE_HPP_ 51 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_rclcpp_typekit/include/orocos/rtt_ros2_rclcpp_typekit/ros2_time_type.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_TIME_TYPE_HPP_ 16 | #define OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_TIME_TYPE_HPP_ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "rclcpp/time.hpp" 23 | 24 | #include "rtt/types/PrimitiveTypeInfo.hpp" 25 | 26 | #include "time_io.hpp" 27 | 28 | namespace rtt_ros2_rclcpp_typekit 29 | { 30 | 31 | class TimeTypeInfo 32 | : public RTT::types::PrimitiveTypeInfo 33 | { 34 | public: 35 | TimeTypeInfo(); 36 | 37 | bool installTypeInfoObject(RTT::types::TypeInfo * ti) override; 38 | }; 39 | 40 | } // namespace rtt_ros2_rclcpp_typekit 41 | 42 | #endif // OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__ROS2_TIME_TYPE_HPP_ 43 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_rclcpp_typekit/include/orocos/rtt_ros2_rclcpp_typekit/time_conversions.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__TIME_CONVERSIONS_HPP_ 16 | #define OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__TIME_CONVERSIONS_HPP_ 17 | 18 | #include 19 | 20 | #include "rclcpp/duration.hpp" 21 | #include "rclcpp/time.hpp" 22 | #include "rmw/types.h" 23 | 24 | #include "wrapped_duration.hpp" 25 | 26 | namespace rtt_ros2_rclcpp_typekit 27 | { 28 | 29 | static inline builtin_interfaces::msg::Time time_to_msg(const rclcpp::Time & t) 30 | { 31 | return static_cast(t); 32 | } 33 | 34 | static inline rclcpp::Time msg_to_time(const builtin_interfaces::msg::Time & msg) 35 | { 36 | return rclcpp::Time(msg); 37 | } 38 | 39 | static inline double time_to_double(const rclcpp::Time & t) 40 | { 41 | return t.seconds(); 42 | } 43 | 44 | static inline rclcpp::Time double_to_time(const double d) 45 | { 46 | return rclcpp::Time( 47 | std::chrono::duration_cast(std::chrono::duration(d)).count()); 48 | } 49 | 50 | static inline rclcpp::Time double_to_time2(const double d, rcl_clock_type_t clock) 51 | { 52 | return rclcpp::Time( 53 | std::chrono::duration_cast(std::chrono::duration(d)).count(), 54 | clock); 55 | } 56 | 57 | static inline int64_t time_to_int64(const rclcpp::Time & t) 58 | { 59 | return t.nanoseconds(); 60 | } 61 | 62 | static inline rclcpp::Time int64_to_time(const int64_t i) 63 | { 64 | return rclcpp::Time(i); 65 | } 66 | 67 | static inline rclcpp::Time int64_to_time2(const int64_t i, rcl_clock_type_t clock) 68 | { 69 | return rclcpp::Time(i, clock); 70 | } 71 | 72 | static inline builtin_interfaces::msg::Duration duration_to_msg(const WrappedDuration & t) 73 | { 74 | return static_cast(t); 75 | } 76 | 77 | static inline WrappedDuration msg_to_duration(const builtin_interfaces::msg::Duration & msg) 78 | { 79 | return WrappedDuration(msg); 80 | } 81 | 82 | static inline double duration_to_double(const WrappedDuration & t) 83 | { 84 | return t.seconds(); 85 | } 86 | 87 | static inline WrappedDuration double_to_duration(const double d) 88 | { 89 | return WrappedDuration( 90 | std::chrono::duration_cast(std::chrono::duration(d)).count()); 91 | } 92 | 93 | static inline int64_t duration_to_int64(const WrappedDuration & t) 94 | { 95 | return t.nanoseconds(); 96 | } 97 | 98 | static inline WrappedDuration int64_to_duration(const int64_t i) 99 | { 100 | return WrappedDuration(i); 101 | } 102 | 103 | static inline double rmw_time_t_to_double(const rmw_time_t & t) 104 | { 105 | return 106 | static_cast(t.sec) + static_cast(t.nsec) * 1e-9; 107 | } 108 | 109 | static inline rmw_time_t double_to_rmw_time_t(const double d) 110 | { 111 | if (d < 0) {throw std::invalid_argument("rmw_time_t cannot be negative");} 112 | rmw_time_t t; 113 | t.sec = static_cast(d); 114 | t.nsec = static_cast((d - static_cast(t.sec)) * 1e9); 115 | return t; 116 | } 117 | 118 | static inline uint64_t rmw_time_t_to_uint64(const rmw_time_t & t) 119 | { 120 | return 121 | static_cast(t.sec) * 1000000000ull + static_cast(t.nsec); 122 | } 123 | 124 | static inline rmw_time_t uint64_to_rmw_time_t(const uint64_t d) 125 | { 126 | rmw_time_t t; 127 | t.sec = static_cast(d / 1000000000L); 128 | t.nsec = static_cast(d % 1000000000L); 129 | return t; 130 | } 131 | 132 | } // namespace rtt_ros2_rclcpp_typekit 133 | 134 | #endif // OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__TIME_CONVERSIONS_HPP_ 135 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_rclcpp_typekit/include/orocos/rtt_ros2_rclcpp_typekit/time_io.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__TIME_IO_HPP_ 16 | #define OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__TIME_IO_HPP_ 17 | 18 | #include 19 | 20 | #include "rclcpp/duration.hpp" 21 | #include "rclcpp/time.hpp" 22 | #include "rmw/types.h" 23 | 24 | #include "time_conversions.hpp" 25 | #include "wrapped_duration.hpp" 26 | 27 | namespace rtt_ros2_rcpcpp_typekit 28 | { 29 | 30 | static inline std::ostream & operator<<(std::ostream & os, const rclcpp::Time & t) 31 | { 32 | return os << t.seconds(); 33 | } 34 | 35 | static inline std::istream & operator>>(std::istream & is, rclcpp::Time & t) 36 | { 37 | double d = 0.0; 38 | if (is >> d) { 39 | t = rtt_ros2_rclcpp_typekit::double_to_time(d); 40 | } 41 | return is; 42 | } 43 | 44 | static inline std::ostream & operator<<(std::ostream & os, const rclcpp::Duration & t) 45 | { 46 | return os << t.seconds(); 47 | } 48 | 49 | static inline std::istream & operator>>(std::istream & is, rclcpp::Duration & t) 50 | { 51 | double d = 0.0; 52 | if (is >> d) { 53 | t = rtt_ros2_rclcpp_typekit::double_to_duration(d); 54 | } 55 | return is; 56 | } 57 | 58 | static inline std::ostream & operator<<(std::ostream & os, const rmw_time_t & t) 59 | { 60 | return os << rtt_ros2_rclcpp_typekit::rmw_time_t_to_double(t); 61 | } 62 | 63 | static inline std::istream & operator>>(std::istream & is, rmw_time_t & t) 64 | { 65 | double d = 0.0; 66 | if (is >> d) { 67 | t = rtt_ros2_rclcpp_typekit::double_to_rmw_time_t(d); 68 | } 69 | return is; 70 | } 71 | 72 | } // namespace rtt_ros2_rcpcpp_typekit 73 | 74 | // import streaming operators in namespace RTT for RTT::types::TypeStreamSelector 75 | namespace RTT 76 | { 77 | using rtt_ros2_rcpcpp_typekit::operator<<; 78 | using rtt_ros2_rcpcpp_typekit::operator>>; 79 | } // namespace RTT 80 | 81 | #endif // OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__TIME_IO_HPP_ 82 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_rclcpp_typekit/include/orocos/rtt_ros2_rclcpp_typekit/time_operators.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__TIME_OPERATORS_HPP_ 16 | #define OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__TIME_OPERATORS_HPP_ 17 | 18 | #include 19 | 20 | #include "rclcpp/duration.hpp" 21 | #include "rclcpp/time.hpp" 22 | 23 | #include "wrapped_duration.hpp" 24 | 25 | namespace rtt_ros2_rclcpp_typekit 26 | { 27 | 28 | struct duration_plus_duration 29 | { 30 | typedef WrappedDuration first_argument_type; 31 | typedef WrappedDuration second_argument_type; 32 | typedef WrappedDuration result_type; 33 | WrappedDuration operator()(const WrappedDuration & da, const WrappedDuration & db) const 34 | { 35 | return da + db; 36 | } 37 | }; 38 | 39 | struct duration_minus_duration 40 | { 41 | typedef WrappedDuration first_argument_type; 42 | typedef WrappedDuration second_argument_type; 43 | typedef WrappedDuration result_type; 44 | WrappedDuration operator()(const WrappedDuration & da, const WrappedDuration & db) const 45 | { 46 | return da - db; 47 | } 48 | }; 49 | 50 | struct time_plus_duration 51 | { 52 | typedef rclcpp::Time first_argument_type; 53 | typedef WrappedDuration second_argument_type; 54 | typedef rclcpp::Time result_type; 55 | rclcpp::Time operator()(const rclcpp::Time & t, const WrappedDuration & d) const 56 | { 57 | return t + d; 58 | } 59 | }; 60 | 61 | struct time_minus_duration 62 | { 63 | typedef rclcpp::Time first_argument_type; 64 | typedef WrappedDuration second_argument_type; 65 | typedef rclcpp::Time result_type; 66 | rclcpp::Time operator()(const rclcpp::Time & t, const WrappedDuration & d) const 67 | { 68 | return t - d; 69 | } 70 | }; 71 | 72 | struct time_minus_time 73 | { 74 | typedef rclcpp::Time first_argument_type; 75 | typedef rclcpp::Time second_argument_type; 76 | typedef WrappedDuration result_type; 77 | WrappedDuration operator()(const rclcpp::Time & ta, const rclcpp::Time & tb) const 78 | { 79 | return ta - tb; 80 | } 81 | }; 82 | 83 | } // namespace rtt_ros2_rclcpp_typekit 84 | 85 | #endif // OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__TIME_OPERATORS_HPP_ 86 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_rclcpp_typekit/include/orocos/rtt_ros2_rclcpp_typekit/wrapped_duration.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__WRAPPED_DURATION_HPP_ 16 | #define OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__WRAPPED_DURATION_HPP_ 17 | 18 | #include 19 | 20 | #include "rclcpp/duration.hpp" 21 | 22 | namespace rtt_ros2_rclcpp_typekit 23 | { 24 | 25 | // Derived type for RTT, which is default constructible. 26 | class WrappedDuration : public rclcpp::Duration 27 | { 28 | public: 29 | WrappedDuration(); 30 | WrappedDuration(const rclcpp::Duration & duration) // NOLINT(runtime/explicit) 31 | : rclcpp::Duration(duration) {} 32 | WrappedDuration(rclcpp::Duration && duration) noexcept // NOLINT(runtime/explicit) 33 | : rclcpp::Duration(std::move(duration)) {} 34 | template 35 | WrappedDuration(Args && ... args) // NOLINT(runtime/explicit) 36 | : rclcpp::Duration(std::forward(args)...) {} 37 | WrappedDuration & operator=(const rclcpp::Duration & duration) 38 | { 39 | static_cast(*this) = duration; 40 | return *this; 41 | } 42 | WrappedDuration & operator=(rclcpp::Duration && duration) noexcept 43 | { 44 | static_cast(*this) = std::move(duration); 45 | return *this; 46 | } 47 | }; 48 | 49 | } // namespace rtt_ros2_rclcpp_typekit 50 | 51 | #endif // OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__WRAPPED_DURATION_HPP_ 52 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_rclcpp_typekit/include/orocos/rtt_ros2_rclcpp_typekit/wrapped_qos.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__WRAPPED_QOS_HPP_ 16 | #define OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__WRAPPED_QOS_HPP_ 17 | 18 | #include 19 | 20 | #include "rclcpp/qos.hpp" 21 | 22 | namespace rtt_ros2_rclcpp_typekit 23 | { 24 | 25 | // Derived type for RTT, which is default constructible. 26 | class WrappedQoS : public rclcpp::QoS 27 | { 28 | public: 29 | WrappedQoS(); 30 | WrappedQoS(const rclcpp::QoS & qos) // NOLINT(runtime/explicit) 31 | : rclcpp::QoS(qos) {} 32 | WrappedQoS(rclcpp::QoS && qos) noexcept // NOLINT(runtime/explicit) 33 | : rclcpp::QoS(std::move(qos)) {} 34 | template 35 | WrappedQoS(Args && ... args) // NOLINT(runtime/explicit) 36 | : rclcpp::QoS(std::forward(args)...) {} 37 | WrappedQoS & operator=(const rclcpp::QoS & qos) 38 | { 39 | static_cast(*this) = qos; 40 | return *this; 41 | } 42 | WrappedQoS & operator=(rclcpp::QoS && qos) noexcept 43 | { 44 | static_cast(*this) = std::move(qos); 45 | return *this; 46 | } 47 | }; 48 | 49 | } // namespace rtt_ros2_rclcpp_typekit 50 | 51 | #endif // OROCOS__RTT_ROS2_RCLCPP_TYPEKIT__WRAPPED_QOS_HPP_ 52 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_rclcpp_typekit/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2_rclcpp_typekit 5 | 0.0.0 6 | 7 | Orocos RTT typekit plugin for rclcpp types 8 | 9 | Orocos Developers 10 | Apache License 2.0 11 | 12 | ament_cmake 13 | 14 | rclcpp 15 | rtt_ros2 16 | rtt_ros2_builtin_interfaces 17 | rtt_ros2_primitives_typekit 18 | 19 | ament_lint_auto 20 | ament_lint_common 21 | 22 | 23 | ament_cmake 24 | 25 | 26 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_rclcpp_typekit/src/ros2_duration_type.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "rtt_ros2_rclcpp_typekit/ros2_duration_type.hpp" 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include "rtt/types/TemplateConstructor.hpp" 22 | 23 | #include "rtt_ros2_rclcpp_typekit/time_conversions.hpp" 24 | #include "rtt_ros2_rclcpp_typekit/time_io.hpp" 25 | 26 | using namespace RTT; // NOLINT(build/namespaces) 27 | using namespace RTT::types; // NOLINT(build/namespaces) 28 | 29 | namespace rtt_ros2_rclcpp_typekit 30 | { 31 | 32 | WrappedDuration::WrappedDuration() 33 | : rclcpp::Duration(0) {} 34 | 35 | DurationTypeInfo::DurationTypeInfo() 36 | : PrimitiveTypeInfo("/rclcpp/Duration") 37 | {} 38 | 39 | bool DurationTypeInfo::installTypeInfoObject(TypeInfo * ti) 40 | { 41 | // aquire a shared reference to the this object 42 | boost::shared_ptr mthis = 43 | boost::dynamic_pointer_cast( 44 | this->getSharedPtr()); 45 | assert(mthis); 46 | // Allow base to install first 47 | PrimitiveTypeInfo::installTypeInfoObject(ti); 48 | // ti->setStreamFactory(mthis); 49 | 50 | // Conversions 51 | const auto types = TypeInfoRepository::Instance(); 52 | { 53 | const auto built_interfaces_msg_duration_ti = 54 | types->getTypeInfo(); 55 | assert(built_interfaces_msg_duration_ti != nullptr); 56 | if (built_interfaces_msg_duration_ti != nullptr) { 57 | built_interfaces_msg_duration_ti->addConstructor(newConstructor(&duration_to_msg, true)); 58 | } 59 | ti->addConstructor(newConstructor(&msg_to_duration, true)); 60 | } 61 | { 62 | // Note: Define conversions for int64_t before double, because Orocos implicit converts from 63 | // int64_t to double, but not from double to int64_t. 64 | const auto int64_ti = types->getTypeInfo(); 65 | assert(int64_ti != nullptr); 66 | if (int64_ti != nullptr) { 67 | int64_ti->addConstructor(newConstructor(&duration_to_int64)); 68 | } 69 | ti->addConstructor(newConstructor(&int64_to_duration, true)); 70 | } 71 | { 72 | const auto double_ti = types->getTypeInfo(); 73 | assert(double_ti != nullptr); 74 | if (double_ti != nullptr) { 75 | double_ti->addConstructor(newConstructor(&duration_to_double)); 76 | } 77 | ti->addConstructor(newConstructor(&double_to_duration, true)); 78 | } 79 | 80 | // Don't delete us, we're memory-managed. 81 | return false; 82 | } 83 | 84 | } // namespace rtt_ros2_rclcpp_typekit 85 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_rclcpp_typekit/src/ros2_parameter_type.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "rtt_ros2_rclcpp_typekit/ros2_parameter_type.hpp" 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include "rtt/internal/FusedFunctorDataSource.hpp" 22 | #include "rtt/types/TemplateConstructor.hpp" 23 | 24 | using namespace RTT; // NOLINT(build/namespaces) 25 | using namespace RTT::types; // NOLINT(build/namespaces) 26 | 27 | namespace rtt_ros2_rclcpp_typekit 28 | { 29 | 30 | namespace 31 | { 32 | inline std::string get_type_name(const rclcpp::Parameter & p) 33 | { 34 | return p.get_type_name(); 35 | } 36 | 37 | inline const std::string & get_name(const rclcpp::Parameter & p) 38 | { 39 | return p.get_name(); 40 | } 41 | 42 | inline const rclcpp::ParameterValue & get_parameter_value(const rclcpp::Parameter & p) 43 | { 44 | return p.get_parameter_value(); 45 | } 46 | 47 | inline rclcpp::Parameter construct1(const std::string & name) 48 | { 49 | return rclcpp::Parameter(name); 50 | } 51 | 52 | inline rclcpp::Parameter construct2(const std::string & name, const rclcpp::ParameterValue & value) 53 | { 54 | return rclcpp::Parameter(name, value); 55 | } 56 | 57 | } // namespace 58 | 59 | ParameterTypeInfo::ParameterTypeInfo() 60 | : PrimitiveTypeInfo("/rclcpp/Parameter") 61 | {} 62 | 63 | bool ParameterTypeInfo::installTypeInfoObject(TypeInfo * ti) 64 | { 65 | // aquire a shared reference to the this object 66 | boost::shared_ptr mthis = boost::dynamic_pointer_cast( 67 | this->getSharedPtr()); 68 | assert(mthis); 69 | // Allow base to install first 70 | PrimitiveTypeInfo::installTypeInfoObject(ti); 71 | // Install the factories specific for this type 72 | ti->setMemberFactory(mthis); 73 | 74 | // Constructors 75 | ti->addConstructor(newConstructor(&construct1)); 76 | ti->addConstructor(newConstructor(&construct2)); 77 | 78 | // Don't delete us, we're memory-managed. 79 | return false; 80 | } 81 | 82 | // copied from StructTypeInfo 83 | std::vector ParameterTypeInfo::getMemberNames() const 84 | { 85 | return { 86 | "type_name", 87 | "name", 88 | "value", 89 | }; 90 | } 91 | 92 | // copied from StructTypeInfo 93 | base::DataSourceBase::shared_ptr ParameterTypeInfo::getMember( 94 | base::DataSourceBase::shared_ptr item, const std::string & name) const 95 | { 96 | typename internal::AssignableDataSource::shared_ptr adata = 97 | boost::dynamic_pointer_cast>(item); 98 | // Use a copy in case our parent is not assignable: 99 | if (!adata) { 100 | // is it non-assignable ? 101 | typename internal::DataSource::shared_ptr data = 102 | boost::dynamic_pointer_cast>(item); 103 | if (data) { 104 | // create a copy 105 | adata = new internal::ValueDataSource(data->get() ); 106 | } 107 | } 108 | if (!adata) { 109 | log(Error) << 110 | "Wrong call to type info function " + this->getTypeName() << 111 | "'s getMember() can not process " << item->getTypeName() << endlog(); 112 | return base::DataSourceBase::shared_ptr(); 113 | } 114 | 115 | if (name == "type_name") { 116 | return internal::newFunctorDataSource(&get_type_name, {adata}); 117 | } 118 | if (name == "name") { 119 | return internal::newFunctorDataSource(&get_name, {adata}); 120 | } 121 | if (name == "value") { 122 | return internal::newFunctorDataSource(&get_parameter_value, {adata}); 123 | } 124 | 125 | return base::DataSourceBase::shared_ptr(); 126 | } 127 | 128 | } // namespace rtt_ros2_rclcpp_typekit 129 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_rclcpp_typekit/src/ros2_time_type.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Intermodalics BVBA 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "rtt_ros2_rclcpp_typekit/ros2_time_type.hpp" 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include "rtt/types/TemplateConstructor.hpp" 22 | 23 | #include "rtt_ros2_rclcpp_typekit/time_conversions.hpp" 24 | #include "rtt_ros2_rclcpp_typekit/time_io.hpp" 25 | 26 | using namespace RTT; // NOLINT(build/namespaces) 27 | using namespace RTT::types; // NOLINT(build/namespaces) 28 | 29 | namespace rtt_ros2_rclcpp_typekit 30 | { 31 | 32 | TimeTypeInfo::TimeTypeInfo() 33 | : PrimitiveTypeInfo("/rclcpp/Time") 34 | {} 35 | 36 | bool TimeTypeInfo::installTypeInfoObject(TypeInfo * ti) 37 | { 38 | // aquire a shared reference to the this object 39 | boost::shared_ptr mthis = 40 | boost::dynamic_pointer_cast( 41 | this->getSharedPtr()); 42 | assert(mthis); 43 | // Allow base to install first 44 | PrimitiveTypeInfo::installTypeInfoObject(ti); 45 | // ti->setStreamFactory(mthis); 46 | 47 | // Conversions 48 | const auto types = TypeInfoRepository::Instance(); 49 | { 50 | const auto built_interfaces_msg_time_ti = 51 | types->getTypeInfo(); 52 | assert(built_interfaces_msg_time_ti != nullptr); 53 | if (built_interfaces_msg_time_ti != nullptr) { 54 | built_interfaces_msg_time_ti->addConstructor(newConstructor(&time_to_msg, true)); 55 | } 56 | ti->addConstructor(newConstructor(&msg_to_time, true)); 57 | } 58 | { 59 | // Note: Define conversions for int64_t before double, because Orocos implicit converts from 60 | // int64_t to double, but not from double to int64_t. 61 | const auto int64_ti = types->getTypeInfo(); 62 | assert(int64_ti != nullptr); 63 | if (int64_ti != nullptr) { 64 | int64_ti->addConstructor(newConstructor(&time_to_int64)); 65 | } 66 | ti->addConstructor(newConstructor(&int64_to_time, true)); 67 | ti->addConstructor(newConstructor(&int64_to_time2)); 68 | } 69 | { 70 | const auto double_ti = types->getTypeInfo(); 71 | assert(double_ti != nullptr); 72 | if (double_ti != nullptr) { 73 | double_ti->addConstructor(newConstructor(&time_to_double)); 74 | } 75 | ti->addConstructor(newConstructor(&double_to_time, true)); 76 | ti->addConstructor(newConstructor(&double_to_time2)); 77 | } 78 | 79 | // Don't delete us, we're memory-managed. 80 | return false; 81 | } 82 | 83 | } // namespace rtt_ros2_rclcpp_typekit 84 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_unique_identifier_msgs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(rtt_ros2_unique_identifier_msgs) 3 | 4 | # Default to C99 5 | if(NOT CMAKE_C_STANDARD) 6 | set(CMAKE_C_STANDARD 99) 7 | endif() 8 | 9 | # Default to C++14 10 | if(NOT CMAKE_CXX_STANDARD) 11 | set(CMAKE_CXX_STANDARD 14) 12 | endif() 13 | 14 | # if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 15 | # add_compile_options(-Wall -Wextra -Wpedantic) 16 | # endif() 17 | 18 | # find dependencies 19 | find_package(ament_cmake REQUIRED) 20 | find_package(rtt_ros2_interfaces REQUIRED) 21 | 22 | rtt_ros2_generate_interfaces_plugins(unique_identifier_msgs) 23 | 24 | # linters 25 | if(BUILD_TESTING) 26 | find_package(ament_lint_auto REQUIRED) 27 | ament_lint_auto_find_test_dependencies() 28 | endif() 29 | 30 | # must be called *after* the targets to check exported libraries etc. 31 | ament_package() 32 | 33 | # orocos_generate_package() is deprecated for ROS 2. 34 | # Prefer cmake target export and import instead, in combination with 35 | # ament_export_interfaces() or ament_export_targets() when building with 36 | # ament_cmake. 37 | orocos_generate_package( 38 | DEPENDS_TARGETS rtt_ros2_interfaces 39 | ) 40 | -------------------------------------------------------------------------------- /typekits/rtt_ros2_unique_identifier_msgs/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rtt_ros2_unique_identifier_msgs 5 | 0.0.0 6 | RTT typekit and transport plugins for unique_identifier_msgs 7 | Orocos Developers 8 | Apache License 2.0 9 | 10 | ament_cmake 11 | 12 | builtin_interfaces 13 | rtt_ros2_interfaces 14 | 15 | ament_lint_auto 16 | ament_lint_common 17 | 18 | 19 | ament_cmake 20 | 21 | 22 | --------------------------------------------------------------------------------