├── .clang-format ├── .github └── workflows │ └── check-copied-type-description-sources.yaml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── rosidl_adapter ├── CHANGELOG.rst ├── CMakeLists.txt ├── cmake │ └── rosidl_adapt_interfaces.cmake ├── package.xml ├── pytest.ini ├── rosidl_adapter-extras.cmake ├── rosidl_adapter │ ├── __init__.py │ ├── __main__.py │ ├── action │ │ └── __init__.py │ ├── cli.py │ ├── main.py │ ├── msg │ │ └── __init__.py │ ├── parser.py │ ├── py.typed │ ├── resource │ │ ├── __init__.py │ │ ├── action.idl.em │ │ ├── msg.idl.em │ │ ├── srv.idl.em │ │ └── struct.idl.em │ └── srv │ │ └── __init__.py ├── scripts │ ├── action2idl.py │ ├── msg2idl.py │ └── srv2idl.py ├── setup.cfg └── test │ ├── data │ ├── action │ │ ├── Test.action │ │ └── Test.expected.idl │ ├── msg │ │ ├── Test.expected.idl │ │ └── Test.msg │ └── srv │ │ ├── Test.expected.idl │ │ └── Test.srv │ ├── parse_msg_files.py │ ├── test_base_type.py │ ├── test_cli_extensions.py │ ├── test_constant.py │ ├── test_extract_message_comments.py │ ├── test_field.py │ ├── test_message_specification.py │ ├── test_parse_action_string.py │ ├── test_parse_message_file.py │ ├── test_parse_message_string.py │ ├── test_parse_primitive_value_string.py │ ├── test_parse_service_string.py │ ├── test_parse_unicode.py │ ├── test_parse_value_string.py │ ├── test_type.py │ ├── test_valid_names.py │ └── test_validate_field_types.py ├── rosidl_cli ├── CHANGELOG.rst ├── completion │ ├── rosidl-argcomplete.bash │ └── rosidl-argcomplete.zsh ├── package.xml ├── py.typed ├── pytest.ini ├── resource │ ├── package.dsv │ └── rosidl_cli ├── rosidl_cli │ ├── __init__.py │ ├── cli.py │ ├── command │ │ ├── __init__.py │ │ ├── generate │ │ │ ├── __init__.py │ │ │ ├── api.py │ │ │ └── extensions.py │ │ ├── hash │ │ │ ├── __init__.py │ │ │ ├── api.py │ │ │ └── extensions.py │ │ ├── helpers.py │ │ └── translate │ │ │ ├── __init__.py │ │ │ ├── api.py │ │ │ └── extensions.py │ ├── common.py │ ├── entry_points.py │ └── extensions.py ├── setup.py └── test │ ├── rosidl_cli │ ├── test_common.py │ ├── test_extensions.py │ ├── test_files │ │ └── bar │ │ │ └── msg │ │ │ └── Bar.idl │ └── test_helpers.py │ ├── test_copyright.py │ ├── test_flake8.py │ ├── test_mypy.py │ ├── test_pep257.py │ └── test_xmllint.py ├── rosidl_cmake ├── CHANGELOG.rst ├── CMakeLists.txt ├── cmake │ ├── rosidl_cmake-extras.cmake.in │ ├── rosidl_cmake_export_typesupport_libraries-extras.cmake.in │ ├── rosidl_cmake_export_typesupport_libraries_package_hook.cmake │ ├── rosidl_cmake_export_typesupport_targets-extras.cmake.in │ ├── rosidl_cmake_export_typesupport_targets_package_hook.cmake │ ├── rosidl_cmake_package_hook.cmake │ ├── rosidl_export_typesupport_libraries.cmake │ ├── rosidl_export_typesupport_targets.cmake │ ├── rosidl_find_package_idl.cmake │ ├── rosidl_generate_interfaces.cmake │ ├── rosidl_get_typesupport_target.cmake │ ├── rosidl_target_interfaces.cmake │ ├── rosidl_write_generator_arguments.cmake │ └── string_camel_case_to_lower_case_underscore.cmake ├── package.xml ├── rosidl_cmake-extras.cmake └── rosidl_cmake │ └── __init__.py ├── rosidl_generator_c ├── CHANGELOG.rst ├── CMakeLists.txt ├── bin │ └── rosidl_generator_c ├── cmake │ ├── register_c.cmake │ └── rosidl_generator_c_generate_interfaces.cmake ├── package.xml ├── resource │ ├── action__type_support.c.em │ ├── action__type_support.h.em │ ├── empty__description.c.em │ ├── full__description.c.em │ ├── idl.h.em │ ├── idl__description.c.em │ ├── idl__functions.c.em │ ├── idl__functions.h.em │ ├── idl__struct.h.em │ ├── idl__type_support.c.em │ ├── idl__type_support.h.em │ ├── msg__functions.c.em │ ├── msg__functions.h.em │ ├── msg__struct.h.em │ ├── msg__type_support.h.em │ ├── rosidl_generator_c__visibility_control.h.in │ ├── srv__type_support.c.em │ └── srv__type_support.h.em ├── rosidl_generator_c-extras.cmake.in ├── rosidl_generator_c │ ├── __init__.py │ └── cli.py └── setup.cfg ├── rosidl_generator_cpp ├── CHANGELOG.rst ├── CMakeLists.txt ├── bin │ └── rosidl_generator_cpp ├── cmake │ ├── register_cpp.cmake │ └── rosidl_generator_cpp_generate_interfaces.cmake ├── package.xml ├── resource │ ├── action__builder.hpp.em │ ├── action__struct.hpp.em │ ├── action__traits.hpp.em │ ├── action__type_support.hpp.em │ ├── idl.hpp.em │ ├── idl__builder.hpp.em │ ├── idl__struct.hpp.em │ ├── idl__traits.hpp.em │ ├── idl__type_support.hpp.em │ ├── msg__builder.hpp.em │ ├── msg__struct.hpp.em │ ├── msg__traits.hpp.em │ ├── msg__type_support.hpp.em │ ├── rosidl_generator_cpp__visibility_control.hpp.in │ ├── srv__builder.hpp.em │ ├── srv__struct.hpp.em │ ├── srv__traits.hpp.em │ └── srv__type_support.hpp.em ├── rosidl_generator_cpp-extras.cmake.in ├── rosidl_generator_cpp │ ├── __init__.py │ └── cli.py └── setup.cfg ├── rosidl_generator_tests ├── CHANGELOG.rst ├── CMakeLists.txt ├── LICENSE ├── msg │ ├── BasicIdl.idl │ └── SmallConstant.msg ├── package.xml └── test │ ├── rosidl_generator_c │ ├── separate_compilation.c │ ├── separate_compilation.h │ ├── test_compilation.c │ ├── test_descriptions.c │ ├── test_interfaces.c │ └── test_invalid_initialization.c │ ├── rosidl_generator_cpp │ ├── test_array_generator.hpp │ ├── test_interfaces.cpp │ ├── test_msg_builder.cpp │ ├── test_msg_datatype.cpp │ ├── test_msg_initialization.cpp │ ├── test_name.cpp │ ├── test_srv_initialization.cpp │ └── test_traits.cpp │ └── rosidl_generator_type_description │ └── test_type_hash.py ├── rosidl_generator_type_description ├── CHANGELOG.rst ├── CMakeLists.txt ├── README.md ├── bin │ └── rosidl_generator_type_description ├── cmake │ └── rosidl_generator_type_description_generate_interfaces.cmake ├── package.xml ├── resource │ └── HashedTypeDescription.schema.json ├── rosidl_generator_type_description-extras.cmake.in ├── rosidl_generator_type_description │ ├── __init__.py │ └── cli.py ├── setup.cfg └── test │ └── test_serializers.py ├── rosidl_parser ├── CHANGELOG.rst ├── CMakeLists.txt ├── bin │ └── idl2png ├── package.xml ├── pytest.ini ├── rosidl_parser │ ├── __init__.py │ ├── definition.py │ ├── grammar.lark │ ├── parser.py │ └── py.typed └── test │ ├── action │ └── MyAction.idl │ ├── msg │ └── MyMessage.idl │ ├── srv │ └── MyService.idl │ └── test_parser.py ├── rosidl_pycommon ├── CHANGELOG.rst ├── package.xml ├── py.typed ├── resource │ └── rosidl_pycommon ├── rosidl_pycommon │ └── __init__.py ├── setup.cfg ├── setup.py └── test │ ├── test_copyright.py │ ├── test_flake8.py │ ├── test_mypy.py │ ├── test_pep257.py │ └── test_xmllint.py ├── rosidl_runtime_c ├── CHANGELOG.rst ├── CMakeLists.txt ├── Doxyfile ├── QUALITY_DECLARATION.md ├── README.md ├── docs │ └── FEATURES.md ├── include │ └── rosidl_runtime_c │ │ ├── action_type_support_struct.h │ │ ├── message_initialization.h │ │ ├── message_type_support_struct.h │ │ ├── primitives_sequence.h │ │ ├── primitives_sequence_functions.h │ │ ├── sequence_bound.h │ │ ├── service_type_support_struct.h │ │ ├── string.h │ │ ├── string_bound.h │ │ ├── string_functions.h │ │ ├── type_description │ │ ├── field__functions.h │ │ ├── field__struct.h │ │ ├── field_type__functions.h │ │ ├── field_type__struct.h │ │ ├── individual_type_description__functions.h │ │ ├── individual_type_description__struct.h │ │ ├── key_value__functions.h │ │ ├── key_value__struct.h │ │ ├── type_description__functions.h │ │ ├── type_description__struct.h │ │ ├── type_source__functions.h │ │ └── type_source__struct.h │ │ ├── type_description_utils.h │ │ ├── type_hash.h │ │ ├── u16string.h │ │ ├── u16string_functions.h │ │ └── visibility_control.h ├── package.xml ├── src │ ├── message_type_support.c │ ├── primitives_sequence_functions.c │ ├── sequence_bound.c │ ├── service_type_support.c │ ├── string_functions.c │ ├── type_description │ │ ├── field__description.c │ │ ├── field__functions.c │ │ ├── field_type__description.c │ │ ├── field_type__functions.c │ │ ├── individual_type_description__description.c │ │ ├── individual_type_description__functions.c │ │ ├── key_value__description.c │ │ ├── key_value__functions.c │ │ ├── type_description__description.c │ │ ├── type_description__functions.c │ │ ├── type_source__description.c │ │ └── type_source__functions.c │ ├── type_description_utils.c │ ├── type_hash.c │ └── u16string_functions.c └── test │ ├── benchmark │ └── benchmark_string_conversion.cpp │ ├── test_message_type_support.cpp │ ├── test_primitives_sequence_functions.cpp │ ├── test_sequence_bound.cpp │ ├── test_service_type_support.cpp │ ├── test_string_functions.cpp │ ├── test_type_description_utils.cpp │ ├── test_type_hash.cpp │ └── test_u16string_functions.cpp ├── rosidl_runtime_cpp ├── CHANGELOG.rst ├── CMakeLists.txt ├── Doxyfile ├── QUALITY_DECLARATION.md ├── README.md ├── docs │ └── FEATURES.md ├── include │ ├── rosidl_runtime_cpp │ │ ├── action_type_support_decl.hpp │ │ ├── bounded_vector.hpp │ │ ├── message_initialization.hpp │ │ ├── message_type_support_decl.hpp │ │ ├── service_type_support_decl.hpp │ │ ├── traits.hpp │ │ └── type_description │ │ │ ├── field__struct.hpp │ │ │ ├── field_type__struct.hpp │ │ │ ├── individual_type_description__struct.hpp │ │ │ ├── key_value__struct.hpp │ │ │ ├── type_description__struct.hpp │ │ │ └── type_source__struct.hpp │ └── rosidl_typesupport_cpp │ │ ├── action_type_support.hpp │ │ ├── message_type_support.hpp │ │ └── service_type_support.hpp ├── package.xml └── test │ ├── benchmark │ └── benchmark_bounded_vector.cpp │ └── test_bounded_vector.cpp ├── rosidl_typesupport_interface ├── CHANGELOG.rst ├── CMakeLists.txt ├── Doxyfile ├── QUALITY_DECLARATION.md ├── README.md ├── include │ └── rosidl_typesupport_interface │ │ └── macros.h ├── package.xml └── test │ └── test_macros.cpp ├── rosidl_typesupport_introspection_c ├── CHANGELOG.rst ├── CMakeLists.txt ├── Doxyfile ├── QUALITY_DECLARATION.md ├── README.md ├── bin │ └── rosidl_typesupport_introspection_c ├── cmake │ └── rosidl_typesupport_introspection_c_generate_interfaces.cmake ├── docs │ └── FEATURES.md ├── include │ └── rosidl_typesupport_introspection_c │ │ ├── field_types.h │ │ ├── identifier.h │ │ ├── message_introspection.h │ │ ├── service_introspection.h │ │ └── visibility_control.h ├── package.xml ├── resource │ ├── idl__rosidl_typesupport_introspection_c.h.em │ ├── idl__type_support.c.em │ ├── msg__rosidl_typesupport_introspection_c.h.em │ ├── msg__type_support.c.em │ ├── rosidl_typesupport_introspection_c__visibility_control.h.in │ ├── srv__rosidl_typesupport_introspection_c.h.em │ └── srv__type_support.c.em ├── rosidl_typesupport_introspection_c-extras.cmake.in ├── rosidl_typesupport_introspection_c │ ├── __init__.py │ └── cli.py ├── setup.cfg └── src │ └── identifier.c ├── rosidl_typesupport_introspection_cpp ├── CHANGELOG.rst ├── CMakeLists.txt ├── Doxyfile ├── QUALITY_DECLARATION.md ├── README.md ├── bin │ └── rosidl_typesupport_introspection_cpp ├── cmake │ └── rosidl_typesupport_introspection_cpp_generate_interfaces.cmake ├── docs │ └── FEATURES.md ├── include │ └── rosidl_typesupport_introspection_cpp │ │ ├── field_types.hpp │ │ ├── identifier.hpp │ │ ├── message_introspection.hpp │ │ ├── message_type_support_decl.hpp │ │ ├── service_introspection.hpp │ │ ├── service_type_support_decl.hpp │ │ └── visibility_control.h ├── package.xml ├── resource │ ├── idl__rosidl_typesupport_introspection_cpp.hpp.em │ ├── idl__type_support.cpp.em │ ├── msg__rosidl_typesupport_introspection_cpp.hpp.em │ ├── msg__type_support.cpp.em │ ├── srv__rosidl_typesupport_introspection_cpp.hpp.em │ └── srv__type_support.cpp.em ├── rosidl_typesupport_introspection_cpp-extras.cmake.in ├── rosidl_typesupport_introspection_cpp │ ├── __init__.py │ └── cli.py ├── setup.cfg └── src │ └── identifier.cpp ├── rosidl_typesupport_introspection_tests ├── CHANGELOG.rst ├── CMakeLists.txt ├── include │ └── rosidl_typesupport_introspection_tests │ │ ├── api.hpp │ │ ├── fixtures.hpp │ │ ├── gtest │ │ ├── macros.hpp │ │ ├── message_introspection_test.hpp │ │ ├── service_introspection_test.hpp │ │ ├── shared_library_test.hpp │ │ └── typesupport_library_test.hpp │ │ ├── helpers.hpp │ │ ├── libraries.hpp │ │ ├── type_traits.hpp │ │ └── types.hpp ├── package.xml └── test │ ├── introspection_libraries_under_test.hpp │ ├── test_arrays_message_introspection.cpp │ ├── test_arrays_service_introspection.cpp │ ├── test_basic_types_message_introspection.cpp │ ├── test_basic_types_service_introspection.cpp │ ├── test_bounded_sequences_message_introspection.cpp │ ├── test_constants_message_introspection.cpp │ ├── test_defaults_message_introspection.cpp │ ├── test_empty_message_introspection.cpp │ ├── test_empty_service_introspection.cpp │ ├── test_multi_nested_message_introspection.cpp │ ├── test_nested_message_introspection.cpp │ ├── test_strings_message_introspection.cpp │ ├── test_typesupport_introspection_libraries.cpp │ ├── test_unbounded_sequences_message_introspection.cpp │ └── test_wstrings_message_introspection.cpp └── scripts ├── copy_type_description_generated_sources.bash └── type_description.fingerprint /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | IndentWidth: 2 3 | BreakBeforeBraces: Linux 4 | AllowShortIfStatementsOnASingleLine: false 5 | IndentCaseLabels: false 6 | PointerAlignment: Middle 7 | -------------------------------------------------------------------------------- /.github/workflows/check-copied-type-description-sources.yaml: -------------------------------------------------------------------------------- 1 | name: Check copied type description sources 2 | 3 | on: 4 | pull_request: 5 | 6 | jobs: 7 | test_copied_sources_changed_with_fingerprint: 8 | runs-on: ubuntu-latest 9 | outputs: 10 | needs_verification: ${{ steps.needs_verification.outputs.changed }} 11 | steps: 12 | - uses: actions/checkout@v4 13 | - name: Check fingerprint changed 14 | uses: tj-actions/changed-files@v46 15 | id: changed-fingerprint 16 | with: 17 | files: scripts/type_description.fingerprint 18 | - name: Check type description sources changed 19 | uses: tj-actions/changed-files@v46 20 | id: changed-copied-sources 21 | with: 22 | files: | 23 | rosidl_runtime_c/include/rosidl_runtime_c/type_description/** 24 | rosidl_runtime_c/src/type_description/** 25 | rosidl_runtime_cpp/include/rosidl_runtime_cpp/type_description/** 26 | - if: (steps.changed-fingerprint.outputs.any_changed == 'true') && (steps.changed-copied-sources.outputs.any_changed != 'true') 27 | run: | 28 | echo "Fingerprint changed but no copied sources changed" 29 | exit 1 30 | - if: (steps.changed-fingerprint.outputs.any_changed != 'true') && (steps.changed-copied-sources.outputs.any_changed == 'true') 31 | run: | 32 | echo "Copied sources changed but fingerprint not updated" 33 | exit 1 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | *.pyc 3 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Any contribution that you make to this repository will 2 | be under the Apache 2 License, as dictated by that 3 | [license](http://www.apache.org/licenses/LICENSE-2.0.html): 4 | 5 | ~~~ 6 | 5. Submission of Contributions. Unless You explicitly state otherwise, 7 | any Contribution intentionally submitted for inclusion in the Work 8 | by You to the Licensor shall be under the terms and conditions of 9 | this License, without any additional terms or conditions. 10 | Notwithstanding the above, nothing herein shall supersede or modify 11 | the terms of any separate license agreement you may have executed 12 | with Licensor regarding such Contributions. 13 | ~~~ 14 | 15 | Contributors must sign-off each commit by adding a `Signed-off-by: ...` 16 | line to commit messages to certify that they have the right to submit 17 | the code they are contributing to the project according to the 18 | [Developer Certificate of Origin (DCO)](https://developercertificate.org/). 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rosidl 2 | 3 | ```rosidl``` is one of the ros_core packages. 4 | See [documentation](https://docs.ros.org/en/rolling/Concepts/About-Internal-Interfaces.html#the-rosidl-repository) for details of this package. 5 | 6 | ## Packages 7 | 8 | * [rosidl_adapter](./rosidl_adapter) 9 | * API and scripts to parse `.msg`/`.srv`/`.action` files and convert them to `.idl` 10 | * [rosidl_cmake](./rosidl_cmake) 11 | * CMake functionality to invoke code generation for ROS interface files 12 | * [rosidl_generator_c](./rosidl_generator_c) 13 | * Generate the ROS interfaces in C 14 | * [rosidl_generator_cpp](./rosidl_generator_cpp) 15 | * Generate the ROS interfaces in C++ 16 | * [rosidl_generator_type_description](./rosidl_generator_type_desrciption) 17 | * Generate SHA256 hash values and ROS 2 interface descriptions for use by other generators 18 | * [rosidl_parser](./rosidl_parser) 19 | * Parser for `.idl` ROS interface files 20 | * [rosidl_runtime_c](./rosidl_runtime_c) 21 | * Provides definitions, initialization and finalization functions, and macros for getting and working with rosidl typesupport types in C 22 | * [rosidl_runtime_cpp](./rosidl_runtime_cpp) 23 | * Provides definitions and templated functions for getting and working with rosidl typesupport types in C++ 24 | * [rosidl_typesupport_interface](./rosidl_typesupport_interface) 25 | * Interface for rosidl typesupport packages 26 | * [rosidl_typesupport_introspection_c](./rosidl_typesupport_introspection_c) 27 | * Generate the message type support for dynamic message construction in C 28 | * [rosidl_typesupport_introspection_cpp](./rosidl_typesupport_introspection_cpp) 29 | * Generate the message type support for dynamic message construction in C++ 30 | -------------------------------------------------------------------------------- /rosidl_adapter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | project(rosidl_adapter NONE) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(ament_cmake_python REQUIRED) 7 | 8 | ament_python_install_package(${PROJECT_NAME}) 9 | 10 | if(BUILD_TESTING) 11 | find_package(ament_cmake_pytest REQUIRED) 12 | find_package(ament_lint_auto REQUIRED) 13 | find_package(ament_cmake_mypy REQUIRED) 14 | ament_lint_auto_find_test_dependencies() 15 | ament_add_pytest_test(pytest test) 16 | endif() 17 | 18 | ament_package( 19 | CONFIG_EXTRAS "rosidl_adapter-extras.cmake" 20 | ) 21 | 22 | install( 23 | DIRECTORY cmake 24 | DESTINATION share/${PROJECT_NAME} 25 | ) 26 | 27 | install(PROGRAMS 28 | scripts/msg2idl.py 29 | scripts/srv2idl.py 30 | scripts/action2idl.py 31 | DESTINATION lib/${PROJECT_NAME}) 32 | -------------------------------------------------------------------------------- /rosidl_adapter/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rosidl_adapter 5 | 4.10.0 6 | 7 | API and scripts to parse .msg/.srv/.action files and convert them to .idl. 8 | 9 | 10 | Aditya Pande 11 | Brandon Ong 12 | Dharini Dutia 13 | Shane Loretz 14 | 15 | Apache License 2.0 16 | 17 | Chris Lalancette 18 | Dirk Thomas 19 | Michel Hidalgo 20 | 21 | ament_cmake_core 22 | python3 23 | 24 | ament_cmake 25 | 26 | python3-empy 27 | rosidl_cli 28 | 29 | ament_cmake_mypy 30 | ament_cmake_pytest 31 | ament_lint_common 32 | ament_lint_auto 33 | 34 | 35 | ament_cmake 36 | 37 | 38 | -------------------------------------------------------------------------------- /rosidl_adapter/pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | junit_family=xunit2 3 | -------------------------------------------------------------------------------- /rosidl_adapter/rosidl_adapter-extras.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Open Source Robotics Foundation, Inc. 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 | # copied from rosidl_adapter/rosidl_adapter-extras.cmake 16 | 17 | include("${rosidl_adapter_DIR}/rosidl_adapt_interfaces.cmake") 18 | -------------------------------------------------------------------------------- /rosidl_adapter/rosidl_adapter/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Open Source Robotics Foundation, Inc. 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 | from pathlib import Path 16 | 17 | 18 | def convert_to_idl(package_dir: Path, package_name: str, interface_file: Path, 19 | output_dir: Path) -> Path: 20 | if interface_file.suffix == '.msg': 21 | from rosidl_adapter.msg import convert_msg_to_idl 22 | return convert_msg_to_idl( 23 | package_dir, package_name, interface_file, output_dir / 'msg') 24 | 25 | if interface_file.suffix == '.srv': 26 | from rosidl_adapter.srv import convert_srv_to_idl 27 | return convert_srv_to_idl( 28 | package_dir, package_name, interface_file, output_dir / 'srv') 29 | 30 | if interface_file.suffix == '.action': 31 | from rosidl_adapter.action import convert_action_to_idl 32 | return convert_action_to_idl( 33 | package_dir, package_name, interface_file, output_dir / 'action') 34 | 35 | assert False, f"Unsupported interface type '{interface_file.suffix}'" 36 | -------------------------------------------------------------------------------- /rosidl_adapter/rosidl_adapter/__main__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Open Source Robotics Foundation, Inc. 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 | 17 | from rosidl_adapter.main import main 18 | 19 | main() 20 | sys.exit() 21 | -------------------------------------------------------------------------------- /rosidl_adapter/rosidl_adapter/action/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018-2019 Open Source Robotics Foundation, Inc. 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 | from pathlib import Path 16 | 17 | from rosidl_adapter.parser import parse_action_string 18 | from rosidl_adapter.resource import ActionData, expand_template 19 | 20 | 21 | def convert_action_to_idl(package_dir: Path, package_name: str, input_file: Path, 22 | output_dir: Path) -> Path: 23 | assert package_dir.is_absolute() 24 | assert not input_file.is_absolute() 25 | assert input_file.suffix == '.action' 26 | 27 | abs_input_file = package_dir / input_file 28 | print(f'Reading input file: {abs_input_file}') 29 | abs_input_file = package_dir / input_file 30 | content = abs_input_file.read_text(encoding='utf-8') 31 | action = parse_action_string(package_name, input_file.stem, content) 32 | 33 | output_file = output_dir / input_file.with_suffix('.idl').name 34 | abs_output_file = output_file.absolute() 35 | print(f'Writing output file: {abs_output_file}') 36 | data: ActionData = { 37 | 'pkg_name': package_name, 38 | 'relative_input_file': input_file.as_posix(), 39 | 'action': action, 40 | } 41 | 42 | expand_template('action.idl.em', data, output_file, encoding='iso-8859-1') 43 | return output_file 44 | -------------------------------------------------------------------------------- /rosidl_adapter/rosidl_adapter/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ros2/rosidl/95fa106fce55eb62a8e4954b5f5f4004af125315/rosidl_adapter/rosidl_adapter/py.typed -------------------------------------------------------------------------------- /rosidl_adapter/rosidl_adapter/resource/action.idl.em: -------------------------------------------------------------------------------- 1 | // generated from rosidl_adapter/resource/action.idl.em 2 | // with input from @(pkg_name)/@(relative_input_file) 3 | // generated code does not contain a copyright notice 4 | 5 | @{ 6 | from rosidl_adapter.msg import get_include_file 7 | include_files = set() 8 | fields = action.goal.fields + action.result.fields + action.feedback.fields 9 | for field in fields: 10 | include_file = get_include_file(field.type) 11 | if include_file is not None: 12 | include_files.add(include_file) 13 | }@ 14 | @[for include_file in sorted(include_files)]@ 15 | #include "@(include_file)" 16 | @[end for]@ 17 | 18 | module @(pkg_name) { 19 | module action { 20 | @{ 21 | TEMPLATE( 22 | 'struct.idl.em', 23 | msg=action.goal, 24 | ) 25 | }@ 26 | @{ 27 | TEMPLATE( 28 | 'struct.idl.em', 29 | msg=action.result, 30 | ) 31 | }@ 32 | @{ 33 | TEMPLATE( 34 | 'struct.idl.em', 35 | msg=action.feedback, 36 | ) 37 | }@ 38 | }; 39 | }; 40 | -------------------------------------------------------------------------------- /rosidl_adapter/rosidl_adapter/resource/msg.idl.em: -------------------------------------------------------------------------------- 1 | // generated from rosidl_adapter/resource/msg.idl.em 2 | // with input from @(pkg_name)/@(relative_input_file) 3 | // generated code does not contain a copyright notice 4 | 5 | @{ 6 | from rosidl_adapter.msg import get_include_file 7 | include_files = set() 8 | for field in msg.fields: 9 | include_file = get_include_file(field.type) 10 | if include_file is not None: 11 | include_files.add(include_file) 12 | }@ 13 | @[for include_file in sorted(include_files)]@ 14 | #include "@(include_file)" 15 | @[end for]@ 16 | 17 | module @(pkg_name) { 18 | module msg { 19 | @{ 20 | TEMPLATE( 21 | 'struct.idl.em', 22 | msg=msg, 23 | ) 24 | }@ 25 | }; 26 | }; 27 | -------------------------------------------------------------------------------- /rosidl_adapter/rosidl_adapter/resource/srv.idl.em: -------------------------------------------------------------------------------- 1 | // generated from rosidl_adapter/resource/srv.idl.em 2 | // with input from @(pkg_name)/@(relative_input_file) 3 | // generated code does not contain a copyright notice 4 | 5 | @{ 6 | from rosidl_adapter.msg import get_include_file 7 | include_files = set() 8 | for field in srv.request.fields + srv.response.fields: 9 | include_file = get_include_file(field.type) 10 | if include_file is not None: 11 | include_files.add(include_file) 12 | }@ 13 | @[for include_file in sorted(include_files)]@ 14 | #include "@(include_file)" 15 | @[end for]@ 16 | 17 | module @(pkg_name) { 18 | module srv { 19 | @{ 20 | TEMPLATE( 21 | 'struct.idl.em', 22 | msg=srv.request, 23 | ) 24 | }@ 25 | @{ 26 | TEMPLATE( 27 | 'struct.idl.em', 28 | msg=srv.response, 29 | ) 30 | }@ 31 | }; 32 | }; 33 | -------------------------------------------------------------------------------- /rosidl_adapter/rosidl_adapter/srv/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Open Source Robotics Foundation, Inc. 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 | from pathlib import Path 16 | 17 | from rosidl_adapter.parser import parse_service_string 18 | from rosidl_adapter.resource import expand_template, SrvData 19 | 20 | 21 | def convert_srv_to_idl(package_dir: Path, package_name: str, input_file: Path, 22 | output_dir: Path) -> Path: 23 | assert package_dir.is_absolute() 24 | assert not input_file.is_absolute() 25 | assert input_file.suffix == '.srv' 26 | 27 | abs_input_file = package_dir / input_file 28 | print(f'Reading input file: {abs_input_file}') 29 | abs_input_file = package_dir / input_file 30 | content = abs_input_file.read_text(encoding='utf-8') 31 | srv = parse_service_string(package_name, input_file.stem, content) 32 | 33 | output_file = output_dir / input_file.with_suffix('.idl').name 34 | abs_output_file = output_file.absolute() 35 | print(f'Writing output file: {abs_output_file}') 36 | data: SrvData = { 37 | 'pkg_name': package_name, 38 | 'relative_input_file': input_file.as_posix(), 39 | 'srv': srv, 40 | } 41 | 42 | expand_template('srv.idl.em', data, output_file, encoding='iso-8859-1') 43 | return output_file 44 | -------------------------------------------------------------------------------- /rosidl_adapter/scripts/action2idl.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Copyright 2022 Open Source Robotics Foundation, Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | from rosidl_adapter.action import convert_action_to_idl 18 | from rosidl_adapter.cli import convert_files_to_idl 19 | 20 | 21 | if __name__ == '__main__': 22 | convert_files_to_idl('.action', convert_action_to_idl) 23 | -------------------------------------------------------------------------------- /rosidl_adapter/scripts/msg2idl.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Copyright 2018 Open Source Robotics Foundation, Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | from rosidl_adapter.cli import convert_files_to_idl 18 | from rosidl_adapter.msg import convert_msg_to_idl 19 | 20 | 21 | if __name__ == '__main__': 22 | convert_files_to_idl('.msg', convert_msg_to_idl) 23 | -------------------------------------------------------------------------------- /rosidl_adapter/scripts/srv2idl.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Copyright 2018 Open Source Robotics Foundation, Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | from rosidl_adapter.cli import convert_files_to_idl 18 | from rosidl_adapter.srv import convert_srv_to_idl 19 | 20 | 21 | if __name__ == '__main__': 22 | convert_files_to_idl('.srv', convert_srv_to_idl) 23 | -------------------------------------------------------------------------------- /rosidl_adapter/setup.cfg: -------------------------------------------------------------------------------- 1 | [options.entry_points] 2 | rosidl_cli.command.translate.extensions = 3 | msg2idl = rosidl_adapter.cli:TranslateMsgToIDL 4 | srv2idl = rosidl_adapter.cli:TranslateSrvToIDL 5 | action2idl = rosidl_adapter.cli:TranslateActionToIDL 6 | -------------------------------------------------------------------------------- /rosidl_adapter/test/data/action/Test.action: -------------------------------------------------------------------------------- 1 | # goal definition 2 | # foo 3 | 4 | # bar 5 | bool bool_value 6 | # baz 7 | byte byte_value 8 | # asd 9 | char char_value # bsd 10 | float32 float32_value 11 | float64 float64_value 12 | int8 int8_value 13 | uint8 uint8_value 14 | int16 int16_value 15 | uint16 uint16_value 16 | int32 int32_value 17 | uint32 uint32_value 18 | int64 int64_value 19 | uint64 uint64_value 20 | string string_value 21 | --- 22 | # result definition 23 | 24 | # ok docs 25 | bool ok 26 | --- 27 | # feedback definition 28 | # more 29 | 30 | # sequence docs 31 | int32[] sequence 32 | -------------------------------------------------------------------------------- /rosidl_adapter/test/data/action/Test.expected.idl: -------------------------------------------------------------------------------- 1 | // generated from rosidl_adapter/resource/action.idl.em 2 | // with input from test_msgs/action/Test.action 3 | // generated code does not contain a copyright notice 4 | 5 | 6 | module test_msgs { 7 | module action { 8 | @verbatim (language="comment", text= 9 | "goal definition" "\n" 10 | "foo") 11 | struct Test_Goal { 12 | @verbatim (language="comment", text= 13 | "bar") 14 | boolean bool_value; 15 | 16 | @verbatim (language="comment", text= 17 | "baz") 18 | octet byte_value; 19 | 20 | @verbatim (language="comment", text= 21 | "asd" "\n" 22 | "bsd") 23 | uint8 char_value; 24 | 25 | float float32_value; 26 | 27 | double float64_value; 28 | 29 | int8 int8_value; 30 | 31 | uint8 uint8_value; 32 | 33 | int16 int16_value; 34 | 35 | uint16 uint16_value; 36 | 37 | int32 int32_value; 38 | 39 | uint32 uint32_value; 40 | 41 | int64 int64_value; 42 | 43 | uint64 uint64_value; 44 | 45 | string string_value; 46 | }; 47 | @verbatim (language="comment", text= 48 | "result definition") 49 | struct Test_Result { 50 | @verbatim (language="comment", text= 51 | "ok docs") 52 | boolean ok; 53 | }; 54 | @verbatim (language="comment", text= 55 | "feedback definition" "\n" 56 | "more") 57 | struct Test_Feedback { 58 | @verbatim (language="comment", text= 59 | "sequence docs") 60 | sequence sequence; 61 | }; 62 | }; 63 | }; 64 | -------------------------------------------------------------------------------- /rosidl_adapter/test/data/msg/Test.expected.idl: -------------------------------------------------------------------------------- 1 | // generated from rosidl_adapter/resource/msg.idl.em 2 | // with input from test_msgs/msg/Test.msg 3 | // generated code does not contain a copyright notice 4 | 5 | 6 | module test_msgs { 7 | module msg { 8 | @verbatim (language="comment", text= 9 | "msg level doc") 10 | struct Test { 11 | @verbatim (language="comment", text= 12 | "field level doc") 13 | boolean bool_value; 14 | 15 | @verbatim (language="comment", text= 16 | "field level doc, style 2") 17 | octet byte_value; 18 | 19 | @verbatim (language="comment", text= 20 | "combined styles" "\n" 21 | "combined styles, part 2") 22 | uint8 char_value; 23 | 24 | float float32_value; 25 | 26 | double float64_value; 27 | 28 | int8 int8_value; 29 | 30 | uint8 uint8_value; 31 | 32 | int16 int16_value; 33 | 34 | uint16 uint16_value; 35 | 36 | int32 int32_value; 37 | 38 | uint32 uint32_value; 39 | 40 | int64 int64_value; 41 | 42 | uint64 uint64_value; 43 | }; 44 | }; 45 | }; 46 | -------------------------------------------------------------------------------- /rosidl_adapter/test/data/msg/Test.msg: -------------------------------------------------------------------------------- 1 | # msg level doc 2 | 3 | # field level doc 4 | bool bool_value 5 | byte byte_value # field level doc, style 2 6 | # combined styles 7 | char char_value # combined styles, part 2 8 | float32 float32_value 9 | float64 float64_value 10 | int8 int8_value 11 | uint8 uint8_value 12 | int16 int16_value 13 | uint16 uint16_value 14 | int32 int32_value 15 | uint32 uint32_value 16 | int64 int64_value 17 | uint64 uint64_value 18 | -------------------------------------------------------------------------------- /rosidl_adapter/test/data/srv/Test.expected.idl: -------------------------------------------------------------------------------- 1 | // generated from rosidl_adapter/resource/srv.idl.em 2 | // with input from test_msgs/srv/Test.srv 3 | // generated code does not contain a copyright notice 4 | 5 | 6 | module test_msgs { 7 | module srv { 8 | @verbatim (language="comment", text= 9 | "1" "\n" 10 | "2") 11 | struct Test_Request { 12 | @verbatim (language="comment", text= 13 | "3") 14 | boolean bool_value; 15 | 16 | @verbatim (language="comment", text= 17 | "4") 18 | octet byte_value; 19 | 20 | @verbatim (language="comment", text= 21 | "5" "\n" 22 | "6") 23 | uint8 char_value; 24 | 25 | float float32_value; 26 | 27 | double float64_value; 28 | 29 | int8 int8_value; 30 | 31 | uint8 uint8_value; 32 | 33 | int16 int16_value; 34 | 35 | uint16 uint16_value; 36 | 37 | int32 int32_value; 38 | 39 | uint32 uint32_value; 40 | 41 | int64 int64_value; 42 | 43 | uint64 uint64_value; 44 | 45 | string string_value; 46 | }; 47 | @verbatim (language="comment", text= 48 | "7") 49 | struct Test_Response { 50 | @verbatim (language="comment", text= 51 | "8") 52 | boolean ok; 53 | }; 54 | }; 55 | }; 56 | -------------------------------------------------------------------------------- /rosidl_adapter/test/data/srv/Test.srv: -------------------------------------------------------------------------------- 1 | # 1 2 | # 2 3 | 4 | # 3 5 | bool bool_value 6 | byte byte_value # 4 7 | # 5 8 | char char_value # 6 9 | float32 float32_value 10 | float64 float64_value 11 | int8 int8_value 12 | uint8 uint8_value 13 | int16 int16_value 14 | uint16 uint16_value 15 | int32 int32_value 16 | uint32 uint32_value 17 | int64 int64_value 18 | uint64 uint64_value 19 | string string_value 20 | --- 21 | # 7 22 | 23 | # 8 24 | 25 | bool ok 26 | -------------------------------------------------------------------------------- /rosidl_adapter/test/test_constant.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Open Source Robotics Foundation, Inc. 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 pytest 16 | 17 | from rosidl_adapter.parser import Constant 18 | 19 | 20 | def test_constant_constructor() -> None: 21 | value = Constant('bool', 'FOO', '1') 22 | assert value 23 | 24 | with pytest.raises(TypeError): 25 | Constant('pkg/Foo', 'FOO', '') 26 | 27 | with pytest.raises(NameError): 28 | Constant('bool', 'FOO BAR', '') 29 | 30 | with pytest.raises(ValueError): 31 | Constant('bool', 'FOO', None) # type: ignore[arg-type] 32 | 33 | 34 | def test_constant_methods() -> None: 35 | assert Constant('bool', 'FOO', '1') != 23 36 | 37 | assert Constant('bool', 'FOO', '1') == Constant('bool', 'FOO', '1') 38 | assert Constant('bool', 'FOO', '1') != Constant('bool', 'FOO', '0') 39 | assert Constant('bool', 'FOO', '1') != Constant('bool', 'BAR', '1') 40 | assert Constant('bool', 'FOO', '1') != Constant('byte', 'FOO', '1') 41 | 42 | assert str(Constant('bool', 'FOO', '1')) == 'bool FOO=True' 43 | 44 | assert str(Constant('string', 'FOO', 'foo')) == "string FOO='foo'" 45 | assert str(Constant('wstring', 'FOO', 'foo')) == "wstring FOO='foo'" 46 | -------------------------------------------------------------------------------- /rosidl_adapter/test/test_parse_message_file.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Open Source Robotics Foundation, Inc. 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 os 16 | import shutil 17 | import tempfile 18 | 19 | import pytest 20 | 21 | from rosidl_adapter.parser import parse_message_file 22 | 23 | 24 | def test_parse_message_file() -> None: 25 | path = tempfile.mkdtemp(prefix='test_parse_message_file_') 26 | try: 27 | filename = os.path.join(path, 'Foo.msg') 28 | with open(filename, 'w') as handle: 29 | handle.write('bool \tfoo') 30 | msg_spec = parse_message_file('pkg', filename) 31 | 32 | assert len(msg_spec.fields) == 1 33 | assert msg_spec.fields[0].type.type == 'bool' 34 | assert msg_spec.fields[0].name == 'foo' 35 | assert msg_spec.fields[0].default_value is None 36 | assert len(msg_spec.constants) == 0 37 | 38 | with open(filename, 'a') as handle: 39 | handle.write('\nbool foo') 40 | with pytest.raises(ValueError) as e: 41 | parse_message_file('pkg', filename) 42 | assert 'foo' in str(e.value) 43 | finally: 44 | shutil.rmtree(path) 45 | -------------------------------------------------------------------------------- /rosidl_adapter/test/test_validate_field_types.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Open Source Robotics Foundation, Inc. 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 | from typing import List 16 | 17 | import pytest 18 | from rosidl_adapter.parser import BaseType 19 | from rosidl_adapter.parser import Field 20 | from rosidl_adapter.parser import MessageSpecification 21 | from rosidl_adapter.parser import Type 22 | from rosidl_adapter.parser import UnknownMessageType 23 | from rosidl_adapter.parser import validate_field_types 24 | 25 | 26 | def test_validate_field_types() -> None: 27 | msg_spec = MessageSpecification('pkg', 'Foo', [], []) 28 | known_msg_type: List[BaseType] = [] 29 | validate_field_types(msg_spec, known_msg_type) 30 | 31 | msg_spec.fields.append(Field(Type('bool'), 'foo')) 32 | validate_field_types(msg_spec, known_msg_type) 33 | 34 | msg_spec.fields.append(Field(Type('pkg/Bar'), 'bar')) 35 | with pytest.raises(UnknownMessageType): 36 | validate_field_types(msg_spec, known_msg_type) 37 | 38 | known_msg_type.append(BaseType('pkg/Bar')) 39 | validate_field_types(msg_spec, known_msg_type) 40 | -------------------------------------------------------------------------------- /rosidl_cli/completion/rosidl-argcomplete.bash: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Open Source Robotics Foundation, Inc. 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 type register-python-argcomplete3 > /dev/null 2>&1; then 16 | eval "$(register-python-argcomplete3 rosidl)" 17 | elif type register-python-argcomplete > /dev/null 2>&1; then 18 | eval "$(register-python-argcomplete rosidl)" 19 | fi 20 | -------------------------------------------------------------------------------- /rosidl_cli/completion/rosidl-argcomplete.zsh: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Open Source Robotics Foundation, Inc. 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 | autoload -U +X compinit && compinit 16 | autoload -U +X bashcompinit && bashcompinit 17 | 18 | # Get this scripts directory 19 | __rosidl_cli_completion_dir=${0:a:h} 20 | # Just source the bash version, it works in zsh too 21 | source "$__rosidl_cli_completion_dir/rosidl-argcomplete.bash" 22 | # Cleanup 23 | unset __rosidl_cli_completion_dir 24 | -------------------------------------------------------------------------------- /rosidl_cli/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rosidl_cli 5 | 4.10.0 6 | 7 | Command line tools for ROS interface generation. 8 | 9 | 10 | Aditya Pande 11 | Brandon Ong 12 | Dharini Dutia 13 | Shane Loretz 14 | 15 | Apache License 2.0 16 | 17 | Chris Lalancette 18 | Michel Hidalgo 19 | 20 | python3-argcomplete 21 | python3-importlib-metadata 22 | 23 | ament_copyright 24 | ament_flake8 25 | ament_mypy 26 | ament_pep257 27 | ament_xmllint 28 | python3-pytest 29 | 30 | 31 | ament_python 32 | 33 | 34 | -------------------------------------------------------------------------------- /rosidl_cli/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ros2/rosidl/95fa106fce55eb62a8e4954b5f5f4004af125315/rosidl_cli/py.typed -------------------------------------------------------------------------------- /rosidl_cli/pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | junit_family=xunit2 3 | -------------------------------------------------------------------------------- /rosidl_cli/resource/package.dsv: -------------------------------------------------------------------------------- 1 | source;share/rosidl_cli/environment/rosidl-argcomplete.bash 2 | source;share/rosidl_cli/environment/rosidl-argcomplete.zsh 3 | -------------------------------------------------------------------------------- /rosidl_cli/resource/rosidl_cli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ros2/rosidl/95fa106fce55eb62a8e4954b5f5f4004af125315/rosidl_cli/resource/rosidl_cli -------------------------------------------------------------------------------- /rosidl_cli/rosidl_cli/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ros2/rosidl/95fa106fce55eb62a8e4954b5f5f4004af125315/rosidl_cli/rosidl_cli/__init__.py -------------------------------------------------------------------------------- /rosidl_cli/rosidl_cli/command/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Open Source Robotics Foundation, Inc. 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 | 17 | 18 | class Command: 19 | """ 20 | The extension point for 'command' extensions. 21 | 22 | The following methods must be defined: 23 | * `main` 24 | * `add_arguments` 25 | """ 26 | 27 | def add_arguments(self, parser: argparse.ArgumentParser) -> None: 28 | pass 29 | 30 | def main(self, *, args: argparse.Namespace) -> None: 31 | raise NotImplementedError() 32 | -------------------------------------------------------------------------------- /rosidl_cli/rosidl_cli/command/hash/extensions.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Open Source Robotics Foundation, Inc. 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 | from rosidl_cli.extensions import Extension 16 | from rosidl_cli.extensions import load_extensions 17 | 18 | 19 | class HashCommandExtension(Extension): 20 | """ 21 | The extension point for source code generation. 22 | 23 | The following methods must be defined: 24 | * `generate_type_hashes` 25 | """ 26 | 27 | def generate_type_hashes( 28 | self, 29 | package_name, 30 | interface_files, 31 | include_paths, 32 | output_path, 33 | ): 34 | """ 35 | Generate type hashes from interface definition files. 36 | 37 | Paths to interface definition files are relative paths optionally 38 | prefixed by an absolute path followed by a colon ':', in which case 39 | path resolution is to be performed against that absolute path. 40 | 41 | :param package_name: name of the package to generate source code for 42 | :param interface_files: list of paths to interface definition files 43 | :param include_paths: list of paths to include dependency interface 44 | definition files from. 45 | :param output_path: path to directory to hold generated source code files 46 | :returns: list of paths to generated source files 47 | """ 48 | raise NotImplementedError() 49 | 50 | 51 | def load_hash_extensions(**kwargs): 52 | """Load extensions for type hash generation.""" 53 | return load_extensions( 54 | 'rosidl_cli.command.hash.extensions', **kwargs 55 | ) 56 | -------------------------------------------------------------------------------- /rosidl_cli/rosidl_cli/common.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Open Source Robotics Foundation, Inc. 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 | def get_first_line_doc(any_type: object) -> str: 17 | if any_type.__doc__: 18 | for line in any_type.__doc__.splitlines(): 19 | line = line.strip() 20 | if line: 21 | return line.rstrip('.') 22 | return '' 23 | -------------------------------------------------------------------------------- /rosidl_cli/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import find_packages 2 | from setuptools import setup 3 | 4 | setup( 5 | name='rosidl_cli', 6 | version='4.10.0', 7 | packages=find_packages(exclude=['test']), 8 | extras_require={ 9 | 'completion': ['argcomplete'], 10 | }, 11 | data_files=[ 12 | ('share/ament_index/resource_index/packages', [ 13 | 'resource/rosidl_cli', 14 | ]), 15 | ('share/rosidl_cli', [ 16 | 'package.xml', 17 | 'resource/package.dsv', 18 | ]), 19 | ('share/rosidl_cli/environment', [ 20 | 'completion/rosidl-argcomplete.bash', 21 | 'completion/rosidl-argcomplete.zsh' 22 | ]), 23 | ], 24 | zip_safe=False, 25 | author='Michel Hidalgo', 26 | author_email='michel@ekumenlabs.com', 27 | maintainer='Aditya Pande, Brandon Ong, Dharini Dutia, Shane Loretz', 28 | maintainer_email='aditya.pande@openrobotics.org, brandon@openrobotics.org, dharini@openrobotics.org, sloretz@openrobotics.org', # noqa: E501 29 | url='https://github.com/ros2/rosidl/tree/master/rosidl_cli', 30 | download_url='https://github.com/ros2/rosidl/releases', 31 | keywords=[], 32 | classifiers=[ 33 | 'Environment :: Console', 34 | 'Intended Audience :: Developers', 35 | 'License :: OSI Approved :: Apache Software License', 36 | 'Programming Language :: Python', 37 | ], 38 | description='Command line tools for ROS interface generation.', 39 | long_description="""\ 40 | The tooling provides a single command line script for ROS interface source code generation.""", 41 | license='Apache License, Version 2.0', 42 | tests_require=['pytest'], 43 | entry_points={ 44 | 'console_scripts': [ 45 | 'rosidl = rosidl_cli.cli:main', 46 | ], 47 | } 48 | ) 49 | -------------------------------------------------------------------------------- /rosidl_cli/test/rosidl_cli/test_common.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Open Source Robotics Foundation, Inc. 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 | from rosidl_cli.common import get_first_line_doc 16 | 17 | 18 | def test_getting_first_line_from_no_docstring() -> None: 19 | func = test_getting_first_line_from_no_docstring 20 | line = get_first_line_doc(func) 21 | assert line == '' 22 | 23 | 24 | def test_getting_first_line_from_docstring() -> None: 25 | """Check it gets the first line.""" 26 | func = test_getting_first_line_from_docstring 27 | line = get_first_line_doc(func) 28 | assert line == 'Check it gets the first line' 29 | 30 | 31 | def test_getting_first_line_from_multiline_docstring() -> None: 32 | """ 33 | Check it really gets the first non-empty line. 34 | 35 | Additional paragraph to please flake8. 36 | """ 37 | func = test_getting_first_line_from_multiline_docstring 38 | line = get_first_line_doc(func) 39 | assert line == 'Check it really gets the first non-empty line' 40 | -------------------------------------------------------------------------------- /rosidl_cli/test/rosidl_cli/test_extensions.py: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Open Source Robotics Foundation, Inc. 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 pytest 16 | 17 | from rosidl_cli.extensions import parse_extension_specification 18 | 19 | 20 | def test_extension_specification_parsing() -> None: 21 | with pytest.raises(ValueError): 22 | parse_extension_specification('bad[') 23 | 24 | with pytest.raises(ValueError): 25 | parse_extension_specification('bad[]') 26 | 27 | with pytest.raises(ValueError): 28 | parse_extension_specification('bad[:]') 29 | 30 | name, kwargs = parse_extension_specification('no_args') 31 | assert name == 'no_args' 32 | assert kwargs == {} 33 | 34 | name, kwargs = parse_extension_specification('with_args[key: value]') 35 | assert name == 'with_args' 36 | assert kwargs == {'key': 'value'} 37 | -------------------------------------------------------------------------------- /rosidl_cli/test/rosidl_cli/test_files/bar/msg/Bar.idl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ros2/rosidl/95fa106fce55eb62a8e4954b5f5f4004af125315/rosidl_cli/test/rosidl_cli/test_files/bar/msg/Bar.idl -------------------------------------------------------------------------------- /rosidl_cli/test/test_copyright.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Open Source Robotics Foundation, Inc. 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 | from ament_copyright.main import main 16 | import pytest 17 | 18 | 19 | @pytest.mark.copyright 20 | @pytest.mark.linter 21 | def test_copyright() -> None: 22 | rc = main(argv=['.', 'test']) 23 | assert rc == 0, 'Found errors' 24 | -------------------------------------------------------------------------------- /rosidl_cli/test/test_flake8.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Open Source Robotics Foundation, Inc. 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 | from ament_flake8.main import main_with_errors 16 | import pytest 17 | 18 | 19 | @pytest.mark.flake8 20 | @pytest.mark.linter 21 | def test_flake8() -> None: 22 | rc, errors = main_with_errors(argv=[]) 23 | assert rc == 0, \ 24 | 'Found %d code style errors / warnings:\n' % len(errors) + \ 25 | '\n'.join(errors) 26 | -------------------------------------------------------------------------------- /rosidl_cli/test/test_mypy.py: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Open Source Robotics Foundation, Inc. 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 | from ament_mypy.main import main 16 | import pytest 17 | 18 | 19 | @pytest.mark.mypy 20 | @pytest.mark.linter 21 | def test_mypy() -> None: 22 | rc = main(argv=[]) 23 | assert rc == 0, 'Found type errors!' 24 | -------------------------------------------------------------------------------- /rosidl_cli/test/test_pep257.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Open Source Robotics Foundation, Inc. 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 | from ament_pep257.main import main 16 | import pytest 17 | 18 | 19 | @pytest.mark.linter 20 | @pytest.mark.pep257 21 | def test_pep257() -> None: 22 | rc = main(argv=[]) 23 | assert rc == 0, 'Found code style errors / warnings' 24 | -------------------------------------------------------------------------------- /rosidl_cli/test/test_xmllint.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Open Source Robotics Foundation, Inc. 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 | from ament_xmllint.main import main 16 | import pytest 17 | 18 | 19 | @pytest.mark.linter 20 | @pytest.mark.xmllint 21 | def test_xmllint() -> None: 22 | rc = main(argv=[]) 23 | assert rc == 0, 'Found errors' 24 | -------------------------------------------------------------------------------- /rosidl_cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(rosidl_cmake NONE) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(ament_cmake_python REQUIRED) 7 | 8 | ament_python_install_package(${PROJECT_NAME}) 9 | 10 | if(BUILD_TESTING) 11 | find_package(ament_lint_auto REQUIRED) 12 | ament_lint_auto_find_test_dependencies() 13 | endif() 14 | 15 | ament_package( 16 | CONFIG_EXTRAS "rosidl_cmake-extras.cmake" 17 | ) 18 | 19 | install( 20 | DIRECTORY cmake 21 | DESTINATION share/${PROJECT_NAME} 22 | ) 23 | -------------------------------------------------------------------------------- /rosidl_cmake/cmake/rosidl_cmake-extras.cmake.in: -------------------------------------------------------------------------------- 1 | # generated from rosidl_cmake/cmake/rosidl_cmake-extras.cmake.in 2 | 3 | set(@PROJECT_NAME@_IDL_FILES "@_rosidl_cmake_IDL_FILES@") 4 | set(@PROJECT_NAME@_INTERFACE_FILES "@_rosidl_cmake_INTERFACE_FILES@") 5 | -------------------------------------------------------------------------------- /rosidl_cmake/cmake/rosidl_cmake_export_typesupport_libraries-extras.cmake.in: -------------------------------------------------------------------------------- 1 | # generated from 2 | # rosidl_cmake/cmake/template/rosidl_cmake_export_typesupport_libraries.cmake.in 3 | 4 | set(_exported_typesupport_libraries 5 | "@_ROSIDL_CMAKE_EXPORT_TYPESUPPORT_LIBRARIES@") 6 | 7 | # populate @PROJECT_NAME@_LIBRARIES_ 8 | if(NOT _exported_typesupport_libraries STREQUAL "") 9 | # loop over typesupport libraries 10 | foreach(_tuple ${_exported_typesupport_libraries}) 11 | string(REPLACE ":" ";" _tuple "${_tuple}") 12 | list(GET _tuple 0 _suffix) 13 | list(GET _tuple 1 _library) 14 | 15 | if(NOT IS_ABSOLUTE "${_library}") 16 | # search for library target relative to this CMake file 17 | set(_lib "NOTFOUND") 18 | find_library( 19 | _lib NAMES "${_library}" 20 | PATHS "${@PROJECT_NAME@_DIR}/../../../lib" 21 | NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH 22 | ) 23 | 24 | if(NOT _lib) 25 | # the library wasn't found 26 | message(FATAL_ERROR 27 | "Package '@PROJECT_NAME@' exports the typesupport library '${_library}' which couldn't be found") 28 | elseif(NOT IS_ABSOLUTE "${_lib}") 29 | # the found library must be an absolute path 30 | message(FATAL_ERROR 31 | "Package '@PROJECT_NAME@' found the typesupport library '${_library}' at '${_lib}' " 32 | "which is not an absolute path") 33 | elseif(NOT EXISTS "${_lib}") 34 | # the found library must exist 35 | message(FATAL_ERROR "Package '@PROJECT_NAME@' found the typesupport library '${_lib}' which doesn't exist") 36 | else() 37 | list(APPEND @PROJECT_NAME@_LIBRARIES${_suffix} ${_cfg} "${_lib}") 38 | endif() 39 | 40 | else() 41 | if(NOT EXISTS "${_library}") 42 | # the found library must exist 43 | message(WARNING "Package '@PROJECT_NAME@' exports the typesupport library '${_library}' which doesn't exist") 44 | else() 45 | list(APPEND @PROJECT_NAME@_LIBRARIES${_suffix} "${_library}") 46 | endif() 47 | endif() 48 | endforeach() 49 | endif() 50 | -------------------------------------------------------------------------------- /rosidl_cmake/cmake/rosidl_cmake_export_typesupport_libraries_package_hook.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Open Source Robotics Foundation, Inc. 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 | # generate and register extra file for typesupport libraries 16 | set(_generated_extra_file 17 | "${CMAKE_CURRENT_BINARY_DIR}/rosidl_cmake/rosidl_cmake_export_typesupport_libraries-extras.cmake") 18 | configure_file( 19 | "${rosidl_cmake_DIR}/rosidl_cmake_export_typesupport_libraries-extras.cmake.in" 20 | "${_generated_extra_file}" 21 | @ONLY 22 | ) 23 | list(APPEND ${PROJECT_NAME}_CONFIG_EXTRAS "${_generated_extra_file}") 24 | -------------------------------------------------------------------------------- /rosidl_cmake/cmake/rosidl_cmake_export_typesupport_targets-extras.cmake.in: -------------------------------------------------------------------------------- 1 | # generated from 2 | # rosidl_cmake/cmake/template/rosidl_cmake_export_typesupport_targets.cmake.in 3 | 4 | set(_exported_typesupport_targets 5 | "@_ROSIDL_CMAKE_EXPORT_TYPESUPPORT_TARGETS@") 6 | 7 | # populate @PROJECT_NAME@_TARGETS_ 8 | if(NOT _exported_typesupport_targets STREQUAL "") 9 | # loop over typesupport targets 10 | foreach(_tuple ${_exported_typesupport_targets}) 11 | string(REPLACE ":" ";" _tuple "${_tuple}") 12 | list(GET _tuple 0 _suffix) 13 | list(GET _tuple 1 _target) 14 | 15 | set(_target "@PROJECT_NAME@::${_target}") 16 | if(NOT TARGET "${_target}") 17 | # the exported target must exist 18 | message(WARNING "Package '@PROJECT_NAME@' exports the typesupport target '${_target}' which doesn't exist") 19 | else() 20 | list(APPEND @PROJECT_NAME@_TARGETS${_suffix} "${_target}") 21 | endif() 22 | endforeach() 23 | endif() 24 | -------------------------------------------------------------------------------- /rosidl_cmake/cmake/rosidl_cmake_export_typesupport_targets_package_hook.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Open Source Robotics Foundation, Inc. 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 | # generate and register extra file for typesupport targets 16 | set(_generated_extra_file 17 | "${CMAKE_CURRENT_BINARY_DIR}/rosidl_cmake/rosidl_cmake_export_typesupport_targets-extras.cmake") 18 | configure_file( 19 | "${rosidl_cmake_DIR}/rosidl_cmake_export_typesupport_targets-extras.cmake.in" 20 | "${_generated_extra_file}" 21 | @ONLY 22 | ) 23 | list(APPEND ${PROJECT_NAME}_CONFIG_EXTRAS "${_generated_extra_file}") 24 | -------------------------------------------------------------------------------- /rosidl_cmake/cmake/rosidl_cmake_package_hook.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Open Source Robotics Foundation, Inc. 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 | # generate and register extra file for rosidl generation 16 | set(_generated_extra_file 17 | "${CMAKE_CURRENT_BINARY_DIR}/rosidl_cmake/rosidl_cmake-extras.cmake") 18 | configure_file( 19 | "${rosidl_cmake_DIR}/rosidl_cmake-extras.cmake.in" 20 | "${_generated_extra_file}" 21 | @ONLY 22 | ) 23 | list(APPEND ${PROJECT_NAME}_CONFIG_EXTRAS "${_generated_extra_file}") 24 | -------------------------------------------------------------------------------- /rosidl_cmake/cmake/rosidl_export_typesupport_libraries.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Open Source Robotics Foundation, Inc. 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 | # Export typesupport libraries to downstream packages. 17 | # 18 | # :param library_suffix: the suffix of the library 19 | # :param ARGN: a list of libraries. 20 | # Each element must be a CMake library target. 21 | # :type ARGN: list of strings 22 | # 23 | # @public 24 | # 25 | macro(rosidl_export_typesupport_libraries library_suffix) 26 | if(_${PROJECT_NAME}_AMENT_PACKAGE) 27 | message(FATAL_ERROR 28 | "rosidl_export_typesupport_libraries() must be called before " 29 | "ament_package()") 30 | endif() 31 | 32 | if(${ARGC} GREATER 0) 33 | _rosidl_cmake_export_typesupport_libraries_register_package_hook() 34 | # loop over libraries 35 | foreach(_lib ${ARGN}) 36 | if(NOT TARGET "${_lib}") 37 | message(FATAL_ERROR 38 | "rosidl_export_typesupport_libraries() must be called with targets") 39 | endif() 40 | 41 | get_target_property(_is_imported "${_lib}" IMPORTED) 42 | if(_is_imported) 43 | message(FATAL_ERROR 44 | "rosidl_export_typesupport_libraries() must be called with " 45 | "not-imported targets") 46 | endif() 47 | 48 | get_target_property(_lib_name "${_lib}" OUTPUT_NAME) 49 | 50 | if(NOT _lib_name) 51 | set(_lib_name ${_lib}) 52 | endif() 53 | 54 | list(APPEND _ROSIDL_CMAKE_EXPORT_TYPESUPPORT_LIBRARIES "${library_suffix}:${_lib_name}") 55 | endforeach() 56 | endif() 57 | endmacro() 58 | -------------------------------------------------------------------------------- /rosidl_cmake/cmake/rosidl_export_typesupport_targets.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Open Source Robotics Foundation, Inc. 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 | # Export typesupport targets to downstream packages. 17 | # 18 | # :param library_suffix: the suffix of the library 19 | # :type library_suffix: string 20 | # :param ARGN: a list of targets. 21 | # Each element must be an exported CMake library target. 22 | # :type ARGN: list of strings 23 | # 24 | # @public 25 | # 26 | macro(rosidl_export_typesupport_targets library_suffix) 27 | if(_${PROJECT_NAME}_AMENT_PACKAGE) 28 | message(FATAL_ERROR 29 | "rosidl_export_typesupport_targets() must be called before " 30 | "ament_package()") 31 | endif() 32 | 33 | if(${ARGC} GREATER 0) 34 | _rosidl_cmake_export_typesupport_targets_register_package_hook() 35 | # loop over targets 36 | foreach(_target ${ARGN}) 37 | if(NOT TARGET "${_target}") 38 | message(FATAL_ERROR 39 | "rosidl_export_typesupport_targets() must be called with targets") 40 | endif() 41 | 42 | get_target_property(_is_imported "${_target}" IMPORTED) 43 | if(_is_imported) 44 | message(FATAL_ERROR 45 | "rosidl_export_typesupport_targets() must be called with " 46 | "not-imported targets") 47 | endif() 48 | 49 | list(APPEND 50 | _ROSIDL_CMAKE_EXPORT_TYPESUPPORT_TARGETS 51 | "${library_suffix}:${_target}" 52 | ) 53 | endforeach() 54 | endif() 55 | endmacro() 56 | -------------------------------------------------------------------------------- /rosidl_cmake/cmake/rosidl_find_package_idl.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Open Source Robotics Foundation, Inc. 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 | # Get the absolute path of an IDL file stored in a package's share 16 | # directory, checking if the package's find module set a GNUInstallDirs 17 | # pkgname_DATADIR variable pointing to a separate location from the 18 | # default pkgname_DIR. 19 | # 20 | # :param var: A name of a variable to store the idl file absolute path. 21 | # :param pkg_name: Name of the package, assumed to have already been 22 | # find_package'd. 23 | # :type pkg_name: string 24 | # :param idl_name: The filename of the idl file to look for. 25 | # :type idl_name: string 26 | # 27 | # @public 28 | # 29 | function(rosidl_find_package_idl var pkg_name idl_file) 30 | set(_candidates 31 | "${${pkg_name}_DATADIR}/${idl_file}" 32 | "${${pkg_name}_DIR}/../${idl_file}" 33 | ) 34 | foreach(_try ${_candidates}) 35 | if(EXISTS "${_try}") 36 | normalize_path(_norm "${_try}") 37 | set("${var}" "${_norm}" PARENT_SCOPE) 38 | return() 39 | endif() 40 | endforeach() 41 | message(FATAL_ERROR "Unable to find ${idl_file} in any of ${_candidates} for ${pkg_name}.") 42 | set("${var}" "-NOTFOUND" PARENT_SCOPE) 43 | endfunction() 44 | -------------------------------------------------------------------------------- /rosidl_cmake/cmake/rosidl_get_typesupport_target.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Open Source Robotics Foundation, Inc. 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 | # Get the name of a Typesupport target so it can be used to depend on 16 | # generated messages in the same package that generated them. 17 | # 18 | # :param var: A name of a variable to store the typesupport target name 19 | # :param generate_interfaces_target: the target name passed to 20 | # rosidl_generate_interfaces 21 | # :type generate_interfaces_target: string 22 | # :param typesupport_name: the package name of the type support 23 | # :type typesupport_name: string 24 | # 25 | # @public 26 | # 27 | function(rosidl_get_typesupport_target var generate_interfaces_target typesupport_name) 28 | if(NOT TARGET ${generate_interfaces_target}) 29 | message(FATAL_ERROR 30 | "${generate_interfaces_target} is not a CMake target. Maybe rosidl_generate_interfaces was given a different target name?") 31 | endif() 32 | 33 | set(output_target "${generate_interfaces_target}__${typesupport_name}") 34 | 35 | if(NOT TARGET ${output_target}) 36 | # CMake if() evaluates strings ending in `-NOTFOUND` as false 37 | set(output_target "${output_target}-NOTFOUND") 38 | endif() 39 | 40 | set("${var}" "${output_target}" PARENT_SCOPE) 41 | endfunction() 42 | -------------------------------------------------------------------------------- /rosidl_cmake/cmake/string_camel_case_to_lower_case_underscore.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2015 Open Source Robotics Foundation, Inc. 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 | # Convert a camel case string to lower case and underscores. 17 | # 18 | # :param str: the string 19 | # :type str: string 20 | # :param var: the output variable name 21 | # :type var: bool 22 | # 23 | function(string_camel_case_to_lower_case_underscore str var) 24 | # insert an underscore before any upper case letter 25 | # which is not followed by another upper case letter 26 | string(REGEX REPLACE "(.)([A-Z][a-z]+)" "\\1_\\2" value "${str}") 27 | # insert an underscore before any upper case letter 28 | # which is preseded by a lower case letter or number 29 | string(REGEX REPLACE "([a-z0-9])([A-Z])" "\\1_\\2" value "${value}") 30 | string(TOLOWER "${value}" value) 31 | set(${var} "${value}" PARENT_SCOPE) 32 | endfunction() 33 | -------------------------------------------------------------------------------- /rosidl_cmake/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rosidl_cmake 5 | 4.10.0 6 | The CMake functionality to invoke code generation for ROS interface files. 7 | 8 | Aditya Pande 9 | Brandon Ong 10 | Dharini Dutia 11 | Shane Loretz 12 | 13 | Apache License 2.0 14 | 15 | Chris Lalancette 16 | Dirk Thomas 17 | Michel Hidalgo 18 | 19 | ament_cmake 20 | ament_cmake_python 21 | 22 | ament_cmake 23 | python3-empy 24 | 25 | 26 | rosidl_pycommon 27 | 28 | ament_lint_auto 29 | ament_lint_common 30 | 31 | 32 | ament_cmake 33 | 34 | 35 | -------------------------------------------------------------------------------- /rosidl_cmake/rosidl_cmake/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2015 Open Source Robotics Foundation, Inc. 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 warnings 16 | 17 | from rosidl_pycommon import * # noqa: F401, F403 18 | 19 | warnings.warn( 20 | "The 'rosidl_cmake' Python module is deprecated. Use 'rosidl_pycommon' instead.", 21 | UserWarning 22 | ) 23 | -------------------------------------------------------------------------------- /rosidl_generator_c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | project(rosidl_generator_c C) 4 | 5 | # Default to C11 6 | if(NOT CMAKE_C_STANDARD) 7 | set(CMAKE_C_STANDARD 11) 8 | endif() 9 | 10 | if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") 11 | add_compile_options(-Wall -Wextra -Wpedantic) 12 | endif() 13 | 14 | find_package(ament_cmake REQUIRED) 15 | find_package(ament_cmake_python REQUIRED) 16 | find_package(ament_cmake_ros_core REQUIRED) 17 | 18 | ament_export_dependencies(rosidl_typesupport_interface) 19 | ament_index_register_resource("rosidl_generator_packages") 20 | 21 | ament_python_install_package(${PROJECT_NAME}) 22 | 23 | if(BUILD_SHARED_LIBS) 24 | set(${PROJECT_NAME}_LIBRARY_TYPE "SHARED") 25 | else() 26 | set(${PROJECT_NAME}_LIBRARY_TYPE "STATIC") 27 | endif() 28 | 29 | if(BUILD_TESTING) 30 | find_package(ament_lint_auto REQUIRED) 31 | ament_lint_auto_find_test_dependencies() 32 | endif() 33 | 34 | ament_package( 35 | CONFIG_EXTRAS "rosidl_generator_c-extras.cmake.in" 36 | ) 37 | 38 | install( 39 | PROGRAMS bin/rosidl_generator_c 40 | DESTINATION lib/rosidl_generator_c 41 | ) 42 | install( 43 | DIRECTORY cmake resource 44 | DESTINATION share/${PROJECT_NAME} 45 | ) 46 | -------------------------------------------------------------------------------- /rosidl_generator_c/bin/rosidl_generator_c: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import os 5 | import sys 6 | 7 | try: 8 | from rosidl_generator_c import generate_c 9 | except ImportError: 10 | # modifying sys.path and importing the Python package with the same 11 | # name as this script does not work on Windows 12 | rosidl_generator_c_root = os.path.dirname(os.path.dirname(__file__)) 13 | rosidl_generator_c_module = os.path.join( 14 | rosidl_generator_c_root, 'rosidl_generator_c', '__init__.py') 15 | if not os.path.exists(rosidl_generator_c_module): 16 | raise 17 | from importlib.machinery import SourceFileLoader 18 | 19 | loader = SourceFileLoader('rosidl_generator_c', rosidl_generator_c_module) 20 | rosidl_generator_c = loader.load_module() 21 | generate_c = rosidl_generator_c.generate_c 22 | 23 | 24 | def main(argv=sys.argv[1:]): 25 | parser = argparse.ArgumentParser( 26 | description='Generate the C ROS interfaces.', 27 | formatter_class=argparse.ArgumentDefaultsHelpFormatter) 28 | parser.add_argument( 29 | '--generator-arguments-file', 30 | required=True, 31 | help='The location of the file containing the generator arguments') 32 | parser.add_argument( 33 | '--disable-description-codegen', action='store_true', 34 | help='If set, disable the generation of static type description ' 35 | 'code to reduce binary size.') 36 | args = parser.parse_args(argv) 37 | 38 | generate_c(args.generator_arguments_file, args.disable_description_codegen) 39 | 40 | 41 | if __name__ == '__main__': 42 | sys.exit(main()) 43 | -------------------------------------------------------------------------------- /rosidl_generator_c/cmake/register_c.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2015 Open Source Robotics Foundation, Inc. 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(rosidl_generator_c_extras BIN GENERATOR_FILES TEMPLATE_DIR) 16 | find_package(ament_cmake_core QUIET REQUIRED) 17 | find_package(rosidl_generator_type_description QUIET REQUIRED) 18 | ament_register_extension( 19 | "rosidl_generate_idl_interfaces" 20 | "rosidl_generator_c" 21 | "rosidl_generator_c_generate_interfaces.cmake") 22 | 23 | normalize_path(BIN "${BIN}") 24 | set(rosidl_generator_c_BIN "${BIN}") 25 | 26 | normalize_path(GENERATOR_FILES "${GENERATOR_FILES}") 27 | set(rosidl_generator_c_GENERATOR_FILES "${GENERATOR_FILES}") 28 | 29 | normalize_path(TEMPLATE_DIR "${TEMPLATE_DIR}") 30 | set(rosidl_generator_c_TEMPLATE_DIR "${TEMPLATE_DIR}") 31 | endmacro() 32 | -------------------------------------------------------------------------------- /rosidl_generator_c/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rosidl_generator_c 5 | 4.10.0 6 | Generate the ROS interfaces in C. 7 | 8 | Aditya Pande 9 | Brandon Ong 10 | Dharini Dutia 11 | Shane Loretz 12 | 13 | Apache License 2.0 14 | 15 | Chris Lalancette 16 | Dirk Thomas 17 | Michel Hidalgo 18 | William Woodall 19 | 20 | ament_cmake 21 | ament_cmake_python 22 | ament_cmake_ros_core 23 | 24 | ament_cmake_core 25 | python3 26 | rosidl_pycommon 27 | 28 | rosidl_cmake 29 | rosidl_generator_type_description 30 | rosidl_typesupport_interface 31 | rcutils 32 | 33 | ament_index_python 34 | rosidl_cli 35 | rosidl_parser 36 | rcutils 37 | rosidl_generator_type_description 38 | 39 | ament_lint_auto 40 | ament_lint_common 41 | 42 | rosidl_generator_packages 43 | 44 | 45 | ament_cmake 46 | 47 | 48 | -------------------------------------------------------------------------------- /rosidl_generator_c/resource/action__type_support.c.em: -------------------------------------------------------------------------------- 1 | @# Included from rosidl_generator_c/resource/idl__type_support.c.em 2 | @{ 3 | TEMPLATE( 4 | 'srv__type_support.c.em', 5 | package_name=package_name, service=action.send_goal_service, 6 | interface_path=interface_path, include_directives=include_directives) 7 | }@ 8 | 9 | @{ 10 | TEMPLATE( 11 | 'srv__type_support.c.em', 12 | package_name=package_name, service=action.get_result_service, 13 | interface_path=interface_path, include_directives=include_directives) 14 | }@ 15 | -------------------------------------------------------------------------------- /rosidl_generator_c/resource/action__type_support.h.em: -------------------------------------------------------------------------------- 1 | @# Included from rosidl_generator_c/resource/idl__type_support.h.em 2 | @{header_file = 'rosidl_runtime_c/action_type_support_struct.h'}@ 3 | @[if header_file in include_directives]@ 4 | // already included above 5 | // @ 6 | @[else]@ 7 | @{include_directives.add(header_file)}@ 8 | @[end if]@ 9 | #include "@(header_file)" 10 | 11 | // Forward declare the get type support functions for this type. 12 | ROSIDL_GENERATOR_C_PUBLIC_@(package_name) 13 | const rosidl_action_type_support_t * 14 | ROSIDL_TYPESUPPORT_INTERFACE__ACTION_SYMBOL_NAME( 15 | rosidl_typesupport_c, 16 | @(',\n '.join(action.namespaced_type.namespaced_name())) 17 | )(void); 18 | 19 | @{ 20 | TEMPLATE( 21 | 'msg__type_support.h.em', 22 | package_name=package_name, message=action.goal, 23 | include_directives=include_directives) 24 | }@ 25 | 26 | @{ 27 | TEMPLATE( 28 | 'msg__type_support.h.em', 29 | package_name=package_name, message=action.result, 30 | include_directives=include_directives) 31 | }@ 32 | 33 | @{ 34 | TEMPLATE( 35 | 'msg__type_support.h.em', 36 | package_name=package_name, message=action.feedback, 37 | include_directives=include_directives) 38 | }@ 39 | 40 | @{ 41 | TEMPLATE( 42 | 'srv__type_support.h.em', 43 | package_name=package_name, service=action.send_goal_service, 44 | include_directives=include_directives) 45 | }@ 46 | 47 | @{ 48 | TEMPLATE( 49 | 'srv__type_support.h.em', 50 | package_name=package_name, service=action.get_result_service, 51 | include_directives=include_directives) 52 | }@ 53 | 54 | @{ 55 | TEMPLATE( 56 | 'msg__type_support.h.em', 57 | package_name=package_name, message=action.feedback_message, 58 | include_directives=include_directives) 59 | }@ 60 | -------------------------------------------------------------------------------- /rosidl_generator_c/resource/empty__description.c.em: -------------------------------------------------------------------------------- 1 | @# Included from rosidl_generator_c/resource/idl__description.c.em 2 | @{ 3 | from rosidl_generator_type_description import GET_DESCRIPTION_FUNC 4 | from rosidl_generator_type_description import GET_INDIVIDUAL_SOURCE_FUNC 5 | from rosidl_generator_type_description import GET_SOURCES_FUNC 6 | 7 | def typename_to_c(typename): 8 | return typename.replace('/', '__') 9 | }@ 10 | 11 | /// Define exported TypeDescriptions and TypeSources 12 | @[for msg, interface_type in [toplevel_type_description] + implicit_type_descriptions]@ 13 | @{ 14 | td_typename = msg['type_description']['type_name'] 15 | td_c_typename = typename_to_c(td_typename) 16 | }@ 17 | 18 | const rosidl_runtime_c__type_description__TypeDescription * 19 | @(td_c_typename)__@(GET_DESCRIPTION_FUNC)( 20 | const rosidl_@(interface_type)_type_support_t * type_support) 21 | { 22 | (void)type_support; 23 | static const rosidl_runtime_c__type_description__TypeDescription description = { 24 | { 25 | {NULL, 0, 0}, 26 | {NULL, 0, 0}, 27 | }, 28 | {NULL, 0, 0}, 29 | }; 30 | return &description; 31 | } 32 | 33 | const rosidl_runtime_c__type_description__TypeSource * 34 | @(td_c_typename)__@(GET_INDIVIDUAL_SOURCE_FUNC)( 35 | const rosidl_@(interface_type)_type_support_t * type_support) 36 | { 37 | (void)type_support; 38 | static const rosidl_runtime_c__type_description__TypeSource source = { 39 | {NULL, 0, 0}, 40 | {NULL, 0, 0}, 41 | {NULL, 0, 0} 42 | }; 43 | return &source; 44 | } 45 | 46 | const rosidl_runtime_c__type_description__TypeSource__Sequence * 47 | @(td_c_typename)__@(GET_SOURCES_FUNC)( 48 | const rosidl_@(interface_type)_type_support_t * type_support) 49 | { 50 | (void)type_support; 51 | static const rosidl_runtime_c__type_description__TypeSource__Sequence sources = {NULL, 0, 0}; 52 | return &sources; 53 | } 54 | @[end for]@ 55 | -------------------------------------------------------------------------------- /rosidl_generator_c/resource/idl.h.em: -------------------------------------------------------------------------------- 1 | // generated from rosidl_generator_c/resource/idl.h.em 2 | // with input from @(package_name):@(interface_path) 3 | // generated code does not contain a copyright notice 4 | 5 | @####################################################################### 6 | @# EmPy template for generating .h files 7 | @# 8 | @# Context: 9 | @# - package_name (string) 10 | @# - interface_path (Path relative to the directory named after the package) 11 | @# - content (IdlContent, list of elements, e.g. Messages or Services) 12 | @####################################################################### 13 | @ 14 | @{ 15 | from rosidl_pycommon import convert_camel_case_to_lower_case_underscore 16 | include_parts = [package_name] + list(interface_path.parents[0].parts) + \ 17 | [convert_camel_case_to_lower_case_underscore(interface_path.stem)] 18 | include_parts_detail = [package_name] + list(interface_path.parents[0].parts) + [ 19 | 'detail', convert_camel_case_to_lower_case_underscore(interface_path.stem)] 20 | header_guard_variable = '__'.join([x.upper() for x in include_parts]) + '_H_' 21 | include_base = '/'.join(include_parts_detail) 22 | }@ 23 | #ifndef @(header_guard_variable) 24 | #define @(header_guard_variable) 25 | 26 | #include "@(include_base)__struct.h" 27 | #include "@(include_base)__functions.h" 28 | #include "@(include_base)__type_support.h" 29 | 30 | #endif // @(header_guard_variable) 31 | -------------------------------------------------------------------------------- /rosidl_generator_c/resource/msg__type_support.h.em: -------------------------------------------------------------------------------- 1 | @# Included from rosidl_generator_c/resource/idl__type_support.h.em 2 | @{header_file = 'rosidl_runtime_c/message_type_support_struct.h'}@ 3 | @[if header_file in include_directives]@ 4 | // already included above 5 | // @ 6 | @[else]@ 7 | @{include_directives.add(header_file)}@ 8 | @[end if]@ 9 | #include "@(header_file)" 10 | 11 | // Forward declare the get type support functions for this type. 12 | ROSIDL_GENERATOR_C_PUBLIC_@(package_name) 13 | const rosidl_message_type_support_t * 14 | ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME( 15 | rosidl_typesupport_c, 16 | @(',\n '.join(message.structure.namespaced_type.namespaced_name())) 17 | )(void); 18 | -------------------------------------------------------------------------------- /rosidl_generator_c/resource/rosidl_generator_c__visibility_control.h.in: -------------------------------------------------------------------------------- 1 | // generated from rosidl_generator_c/resource/rosidl_generator_c__visibility_control.h.in 2 | // generated code does not contain a copyright notice 3 | 4 | #ifndef @PROJECT_NAME_UPPER@__MSG__ROSIDL_GENERATOR_C__VISIBILITY_CONTROL_H_ 5 | #define @PROJECT_NAME_UPPER@__MSG__ROSIDL_GENERATOR_C__VISIBILITY_CONTROL_H_ 6 | 7 | #ifdef __cplusplus 8 | extern "C" 9 | { 10 | #endif 11 | 12 | // This logic was borrowed (then namespaced) from the examples on the gcc wiki: 13 | // https://gcc.gnu.org/wiki/Visibility 14 | 15 | #if defined _WIN32 || defined __CYGWIN__ 16 | #ifdef __GNUC__ 17 | #define ROSIDL_GENERATOR_C_EXPORT_@PROJECT_NAME@ __attribute__ ((dllexport)) 18 | #define ROSIDL_GENERATOR_C_IMPORT_@PROJECT_NAME@ __attribute__ ((dllimport)) 19 | #else 20 | #define ROSIDL_GENERATOR_C_EXPORT_@PROJECT_NAME@ __declspec(dllexport) 21 | #define ROSIDL_GENERATOR_C_IMPORT_@PROJECT_NAME@ __declspec(dllimport) 22 | #endif 23 | #ifdef ROSIDL_GENERATOR_C_BUILDING_DLL_@PROJECT_NAME@ 24 | #define ROSIDL_GENERATOR_C_PUBLIC_@PROJECT_NAME@ ROSIDL_GENERATOR_C_EXPORT_@PROJECT_NAME@ 25 | #else 26 | #define ROSIDL_GENERATOR_C_PUBLIC_@PROJECT_NAME@ ROSIDL_GENERATOR_C_IMPORT_@PROJECT_NAME@ 27 | #endif 28 | #else 29 | #define ROSIDL_GENERATOR_C_EXPORT_@PROJECT_NAME@ __attribute__ ((visibility("default"))) 30 | #define ROSIDL_GENERATOR_C_IMPORT_@PROJECT_NAME@ 31 | #if __GNUC__ >= 4 32 | #define ROSIDL_GENERATOR_C_PUBLIC_@PROJECT_NAME@ __attribute__ ((visibility("default"))) 33 | #else 34 | #define ROSIDL_GENERATOR_C_PUBLIC_@PROJECT_NAME@ 35 | #endif 36 | #endif 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif // @PROJECT_NAME_UPPER@__MSG__ROSIDL_GENERATOR_C__VISIBILITY_CONTROL_H_ 43 | -------------------------------------------------------------------------------- /rosidl_generator_c/resource/srv__type_support.h.em: -------------------------------------------------------------------------------- 1 | @# Included from rosidl_generator_c/resource/idl__type_support.h.em 2 | @{ 3 | TEMPLATE( 4 | 'msg__type_support.h.em', 5 | package_name=package_name, message=service.request_message, 6 | include_directives=include_directives) 7 | }@ 8 | 9 | @{ 10 | TEMPLATE( 11 | 'msg__type_support.h.em', 12 | package_name=package_name, message=service.response_message, 13 | include_directives=include_directives) 14 | }@ 15 | 16 | @{ 17 | TEMPLATE( 18 | 'msg__type_support.h.em', 19 | package_name=package_name, message=service.event_message, 20 | include_directives=include_directives) 21 | }@ 22 | 23 | @{header_file = 'rosidl_runtime_c/service_type_support_struct.h'}@ 24 | @[if header_file in include_directives]@ 25 | // already included above 26 | // @ 27 | @[else]@ 28 | @{include_directives.add(header_file)}@ 29 | @[end if]@ 30 | #include "@(header_file)" 31 | 32 | // Forward declare the get type support functions for this type. 33 | ROSIDL_GENERATOR_C_PUBLIC_@(package_name) 34 | const rosidl_service_type_support_t * 35 | ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME( 36 | rosidl_typesupport_c, 37 | @(',\n '.join(service.namespaced_type.namespaced_name())) 38 | )(void); 39 | 40 | // Forward declare the function to create a service event message for this type. 41 | ROSIDL_GENERATOR_C_PUBLIC_@(package_name) 42 | void * 43 | ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_CREATE_EVENT_MESSAGE_SYMBOL_NAME( 44 | rosidl_typesupport_c, 45 | @(',\n '.join(service.namespaced_type.namespaced_name())) 46 | )( 47 | const rosidl_service_introspection_info_t * info, 48 | rcutils_allocator_t * allocator, 49 | const void * request_message, 50 | const void * response_message); 51 | 52 | // Forward declare the function to destroy a service event message for this type. 53 | ROSIDL_GENERATOR_C_PUBLIC_@(package_name) 54 | bool 55 | ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_DESTROY_EVENT_MESSAGE_SYMBOL_NAME( 56 | rosidl_typesupport_c, 57 | @(',\n '.join(service.namespaced_type.namespaced_name())) 58 | )( 59 | void * event_msg, 60 | rcutils_allocator_t * allocator); 61 | -------------------------------------------------------------------------------- /rosidl_generator_c/rosidl_generator_c-extras.cmake.in: -------------------------------------------------------------------------------- 1 | # generated from rosidl_generator_c/rosidl_generator_c-extras.cmake 2 | 3 | # use the same type of library 4 | set(rosidl_generator_c_LIBRARY_TYPE "@rosidl_generator_c_LIBRARY_TYPE@") 5 | 6 | include("${CMAKE_CURRENT_LIST_DIR}/register_c.cmake") 7 | rosidl_generator_c_extras( 8 | "${rosidl_generator_c_DIR}/../../../lib/rosidl_generator_c/rosidl_generator_c" 9 | "${rosidl_generator_c_DIR}/../../../@PYTHON_INSTALL_DIR@/rosidl_generator_c/__init__.py" 10 | "${rosidl_generator_c_DIR}/../resource" 11 | ) 12 | -------------------------------------------------------------------------------- /rosidl_generator_c/setup.cfg: -------------------------------------------------------------------------------- 1 | [options.entry_points] 2 | rosidl_cli.command.generate.type_extensions = 3 | c = rosidl_generator_c.cli:GenerateC 4 | -------------------------------------------------------------------------------- /rosidl_generator_cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | project(rosidl_generator_cpp) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(ament_cmake_python REQUIRED) 7 | 8 | ament_index_register_resource("rosidl_generator_packages") 9 | 10 | ament_python_install_package(${PROJECT_NAME}) 11 | 12 | if(BUILD_TESTING) 13 | find_package(ament_lint_auto REQUIRED) 14 | ament_lint_auto_find_test_dependencies() 15 | endif() 16 | 17 | ament_package( 18 | CONFIG_EXTRAS "rosidl_generator_cpp-extras.cmake.in" 19 | ) 20 | 21 | install( 22 | PROGRAMS bin/rosidl_generator_cpp 23 | DESTINATION lib/rosidl_generator_cpp 24 | ) 25 | install( 26 | DIRECTORY cmake resource 27 | DESTINATION share/${PROJECT_NAME} 28 | ) 29 | -------------------------------------------------------------------------------- /rosidl_generator_cpp/bin/rosidl_generator_cpp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import os 5 | import sys 6 | 7 | try: 8 | from rosidl_generator_cpp import generate_cpp 9 | except ImportError: 10 | # modifying sys.path and importing the Python package with the same 11 | # name as this script does not work on Windows 12 | rosidl_generator_cpp_root = os.path.dirname(os.path.dirname(__file__)) 13 | rosidl_generator_cpp_module = os.path.join( 14 | rosidl_generator_cpp_root, 'rosidl_generator_cpp', '__init__.py') 15 | if not os.path.exists(rosidl_generator_cpp_module): 16 | raise 17 | from importlib.machinery import SourceFileLoader 18 | 19 | loader = SourceFileLoader('rosidl_generator_cpp', rosidl_generator_cpp_module) 20 | rosidl_generator_cpp = loader.load_module() 21 | generate_cpp = rosidl_generator_cpp.generate_cpp 22 | 23 | 24 | def main(argv=sys.argv[1:]): 25 | parser = argparse.ArgumentParser( 26 | description='Generate the C++ ROS interfaces.', 27 | formatter_class=argparse.ArgumentDefaultsHelpFormatter) 28 | parser.add_argument( 29 | '--generator-arguments-file', 30 | required=True, 31 | help='The location of the file containing the generator arguments') 32 | args = parser.parse_args(argv) 33 | 34 | generate_cpp(args.generator_arguments_file) 35 | 36 | 37 | if __name__ == '__main__': 38 | sys.exit(main()) 39 | -------------------------------------------------------------------------------- /rosidl_generator_cpp/cmake/register_cpp.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2015 Open Source Robotics Foundation, Inc. 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(rosidl_generator_cpp_extras BIN GENERATOR_FILES TEMPLATE_DIR) 16 | find_package(ament_cmake_core QUIET REQUIRED) 17 | find_package(rosidl_generator_type_description QUIET REQUIRED) 18 | ament_register_extension( 19 | "rosidl_generate_idl_interfaces" 20 | "rosidl_generator_cpp" 21 | "rosidl_generator_cpp_generate_interfaces.cmake") 22 | 23 | normalize_path(BIN "${BIN}") 24 | set(rosidl_generator_cpp_BIN "${BIN}") 25 | 26 | normalize_path(GENERATOR_FILES "${GENERATOR_FILES}") 27 | set(rosidl_generator_cpp_GENERATOR_FILES "${GENERATOR_FILES}") 28 | 29 | normalize_path(TEMPLATE_DIR "${TEMPLATE_DIR}") 30 | set(rosidl_generator_cpp_TEMPLATE_DIR "${TEMPLATE_DIR}") 31 | endmacro() 32 | -------------------------------------------------------------------------------- /rosidl_generator_cpp/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rosidl_generator_cpp 5 | 4.10.0 6 | Generate the ROS interfaces in C++. 7 | 8 | Aditya Pande 9 | Brandon Ong 10 | Dharini Dutia 11 | Shane Loretz 12 | 13 | Apache License 2.0 14 | 15 | Chris Lalancette 16 | Dirk Thomas 17 | Michel Hidalgo 18 | 19 | ament_cmake 20 | 21 | ament_cmake_core 22 | python3 23 | rosidl_pycommon 24 | 25 | rosidl_cmake 26 | 27 | rosidl_generator_c 28 | rosidl_runtime_cpp 29 | 30 | ament_index_python 31 | rosidl_cli 32 | rosidl_generator_type_description 33 | rosidl_parser 34 | 35 | ament_lint_auto 36 | ament_lint_common 37 | 38 | rosidl_generator_packages 39 | 40 | 41 | ament_cmake 42 | 43 | 44 | -------------------------------------------------------------------------------- /rosidl_generator_cpp/resource/action__builder.hpp.em: -------------------------------------------------------------------------------- 1 | @# Included from rosidl_generator_cpp/resource/idl__builder.hpp.em 2 | @{ 3 | TEMPLATE( 4 | 'msg__builder.hpp.em', 5 | package_name=package_name, interface_path=interface_path, 6 | message=action.goal, include_directives=include_directives) 7 | }@ 8 | 9 | @{ 10 | TEMPLATE( 11 | 'msg__builder.hpp.em', 12 | package_name=package_name, interface_path=interface_path, 13 | message=action.result, include_directives=include_directives) 14 | }@ 15 | 16 | @{ 17 | TEMPLATE( 18 | 'msg__builder.hpp.em', 19 | package_name=package_name, interface_path=interface_path, 20 | message=action.feedback, include_directives=include_directives) 21 | }@ 22 | 23 | @{ 24 | TEMPLATE( 25 | 'srv__builder.hpp.em', 26 | package_name=package_name, interface_path=interface_path, 27 | service=action.send_goal_service, include_directives=include_directives) 28 | }@ 29 | 30 | @{ 31 | TEMPLATE( 32 | 'srv__builder.hpp.em', 33 | package_name=package_name, interface_path=interface_path, 34 | service=action.get_result_service, include_directives=include_directives) 35 | }@ 36 | 37 | @{ 38 | TEMPLATE( 39 | 'msg__builder.hpp.em', 40 | package_name=package_name, interface_path=interface_path, 41 | message=action.feedback_message, include_directives=include_directives) 42 | }@ 43 | -------------------------------------------------------------------------------- /rosidl_generator_cpp/resource/action__type_support.hpp.em: -------------------------------------------------------------------------------- 1 | @# Included from rosidl_generator_cpp/resource/action__type_support.hpp.em 2 | @{header_file = 'rosidl_typesupport_cpp/action_type_support.hpp'}@ 3 | @[if header_file in include_directives]@ 4 | // already included above 5 | // @ 6 | @[else]@ 7 | @{include_directives.add(header_file)}@ 8 | @[end if]@ 9 | #include "@(header_file)" 10 | 11 | #ifdef __cplusplus 12 | extern "C" 13 | { 14 | #endif 15 | // Forward declare the get type support functions for this type. 16 | ROSIDL_GENERATOR_CPP_PUBLIC_@(package_name) 17 | const rosidl_action_type_support_t * 18 | ROSIDL_TYPESUPPORT_INTERFACE__ACTION_SYMBOL_NAME( 19 | rosidl_typesupport_cpp, 20 | @(',\n '.join(action.namespaced_type.namespaced_name())) 21 | )(); 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | @{ 27 | TEMPLATE( 28 | 'msg__type_support.hpp.em', 29 | package_name=package_name, message=action.goal, 30 | include_directives=include_directives) 31 | }@ 32 | 33 | @{ 34 | TEMPLATE( 35 | 'msg__type_support.hpp.em', 36 | package_name=package_name, message=action.result, 37 | include_directives=include_directives) 38 | }@ 39 | 40 | @{ 41 | TEMPLATE( 42 | 'msg__type_support.hpp.em', 43 | package_name=package_name, message=action.feedback, 44 | include_directives=include_directives) 45 | }@ 46 | 47 | @{ 48 | TEMPLATE( 49 | 'srv__type_support.hpp.em', 50 | package_name=package_name, service=action.send_goal_service, 51 | include_directives=include_directives) 52 | }@ 53 | 54 | @{ 55 | TEMPLATE( 56 | 'srv__type_support.hpp.em', 57 | package_name=package_name, service=action.get_result_service, 58 | include_directives=include_directives) 59 | }@ 60 | 61 | @{ 62 | TEMPLATE( 63 | 'msg__type_support.hpp.em', 64 | package_name=package_name, message=action.feedback_message, 65 | include_directives=include_directives) 66 | }@ 67 | -------------------------------------------------------------------------------- /rosidl_generator_cpp/resource/idl.hpp.em: -------------------------------------------------------------------------------- 1 | // generated from rosidl_generator_cpp/resource/idl.hpp.em 2 | // generated code does not contain a copyright notice 3 | 4 | @####################################################################### 5 | @# EmPy template for generating .hpp files 6 | @# 7 | @# Context: 8 | @# - package_name (string) 9 | @# - interface_path (Path relative to the directory named after the package) 10 | @# - content (IdlContent, list of elements, e.g. Messages or Services) 11 | @####################################################################### 12 | @ 13 | @{ 14 | from rosidl_pycommon import convert_camel_case_to_lower_case_underscore 15 | include_parts = [package_name] + list(interface_path.parents[0].parts) + \ 16 | [convert_camel_case_to_lower_case_underscore(interface_path.stem)] 17 | include_parts_detail = [package_name] + list(interface_path.parents[0].parts) + [ 18 | 'detail', convert_camel_case_to_lower_case_underscore(interface_path.stem)] 19 | header_guard_variable = '__'.join([x.upper() for x in include_parts]) + '_HPP_' 20 | include_base = '/'.join(include_parts_detail) 21 | }@ 22 | #ifndef @(header_guard_variable) 23 | #define @(header_guard_variable) 24 | 25 | #include "@(include_base)__struct.hpp" 26 | #include "@(include_base)__builder.hpp" 27 | #include "@(include_base)__traits.hpp" 28 | #include "@(include_base)__type_support.hpp" 29 | 30 | #endif // @(header_guard_variable) 31 | -------------------------------------------------------------------------------- /rosidl_generator_cpp/resource/msg__type_support.hpp.em: -------------------------------------------------------------------------------- 1 | @# Included from rosidl_generator_cpp/resource/msg__type_support.hpp.em 2 | @{header_file = 'rosidl_typesupport_cpp/message_type_support.hpp'}@ 3 | @[if header_file in include_directives]@ 4 | // already included above 5 | // @ 6 | @[else]@ 7 | @{include_directives.add(header_file)}@ 8 | @[end if]@ 9 | #include "@(header_file)" 10 | 11 | #ifdef __cplusplus 12 | extern "C" 13 | { 14 | #endif 15 | // Forward declare the get type support functions for this type. 16 | ROSIDL_GENERATOR_CPP_PUBLIC_@(package_name) 17 | const rosidl_message_type_support_t * 18 | ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME( 19 | rosidl_typesupport_cpp, 20 | @(',\n '.join(message.structure.namespaced_type.namespaced_name())) 21 | )(); 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | -------------------------------------------------------------------------------- /rosidl_generator_cpp/resource/rosidl_generator_cpp__visibility_control.hpp.in: -------------------------------------------------------------------------------- 1 | // generated from rosidl_generator_cpp/resource/rosidl_generator_cpp__visibility_control.hpp.in 2 | // generated code does not contain a copyright notice 3 | 4 | #ifndef @PROJECT_NAME_UPPER@__MSG__ROSIDL_GENERATOR_CPP__VISIBILITY_CONTROL_HPP_ 5 | #define @PROJECT_NAME_UPPER@__MSG__ROSIDL_GENERATOR_CPP__VISIBILITY_CONTROL_HPP_ 6 | 7 | #ifdef __cplusplus 8 | extern "C" 9 | { 10 | #endif 11 | 12 | // This logic was borrowed (then namespaced) from the examples on the gcc wiki: 13 | // https://gcc.gnu.org/wiki/Visibility 14 | 15 | #if defined _WIN32 || defined __CYGWIN__ 16 | #ifdef __GNUC__ 17 | #define ROSIDL_GENERATOR_CPP_EXPORT_@PROJECT_NAME@ __attribute__ ((dllexport)) 18 | #define ROSIDL_GENERATOR_CPP_IMPORT_@PROJECT_NAME@ __attribute__ ((dllimport)) 19 | #else 20 | #define ROSIDL_GENERATOR_CPP_EXPORT_@PROJECT_NAME@ __declspec(dllexport) 21 | #define ROSIDL_GENERATOR_CPP_IMPORT_@PROJECT_NAME@ __declspec(dllimport) 22 | #endif 23 | #ifdef ROSIDL_GENERATOR_CPP_BUILDING_DLL_@PROJECT_NAME@ 24 | #define ROSIDL_GENERATOR_CPP_PUBLIC_@PROJECT_NAME@ ROSIDL_GENERATOR_CPP_EXPORT_@PROJECT_NAME@ 25 | #else 26 | #define ROSIDL_GENERATOR_CPP_PUBLIC_@PROJECT_NAME@ ROSIDL_GENERATOR_CPP_IMPORT_@PROJECT_NAME@ 27 | #endif 28 | #else 29 | #define ROSIDL_GENERATOR_CPP_EXPORT_@PROJECT_NAME@ __attribute__ ((visibility("default"))) 30 | #define ROSIDL_GENERATOR_CPP_IMPORT_@PROJECT_NAME@ 31 | #if __GNUC__ >= 4 32 | #define ROSIDL_GENERATOR_CPP_PUBLIC_@PROJECT_NAME@ __attribute__ ((visibility("default"))) 33 | #else 34 | #define ROSIDL_GENERATOR_CPP_PUBLIC_@PROJECT_NAME@ 35 | #endif 36 | #endif 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif // @PROJECT_NAME_UPPER@__MSG__ROSIDL_GENERATOR_CPP__VISIBILITY_CONTROL_HPP_ 43 | -------------------------------------------------------------------------------- /rosidl_generator_cpp/resource/srv__builder.hpp.em: -------------------------------------------------------------------------------- 1 | @# Included from rosidl_generator_cpp/resource/idl__builder.hpp.em 2 | @{ 3 | TEMPLATE( 4 | 'msg__builder.hpp.em', 5 | package_name=package_name, interface_path=interface_path, 6 | message=service.request_message, include_directives=include_directives) 7 | }@ 8 | 9 | @{ 10 | TEMPLATE( 11 | 'msg__builder.hpp.em', 12 | package_name=package_name, interface_path=interface_path, 13 | message=service.response_message, include_directives=include_directives) 14 | }@ 15 | 16 | @{ 17 | TEMPLATE( 18 | 'msg__builder.hpp.em', 19 | package_name=package_name, interface_path=interface_path, 20 | message=service.event_message, include_directives=include_directives) 21 | }@ 22 | -------------------------------------------------------------------------------- /rosidl_generator_cpp/resource/srv__struct.hpp.em: -------------------------------------------------------------------------------- 1 | @# Included from rosidl_generator_cpp/resource/idl__struct.hpp.em 2 | @{ 3 | from rosidl_generator_c import type_hash_to_c_definition 4 | from rosidl_parser.definition import SERVICE_EVENT_MESSAGE_SUFFIX 5 | from rosidl_parser.definition import SERVICE_REQUEST_MESSAGE_SUFFIX 6 | from rosidl_parser.definition import SERVICE_RESPONSE_MESSAGE_SUFFIX 7 | }@ 8 | @{ 9 | TEMPLATE( 10 | 'msg__struct.hpp.em', 11 | package_name=package_name, interface_path=interface_path, 12 | message=service.request_message, include_directives=include_directives) 13 | }@ 14 | 15 | @{ 16 | TEMPLATE( 17 | 'msg__struct.hpp.em', 18 | package_name=package_name, interface_path=interface_path, 19 | message=service.response_message, include_directives=include_directives) 20 | }@ 21 | 22 | @{ 23 | TEMPLATE( 24 | 'msg__struct.hpp.em', 25 | package_name=package_name, interface_path=interface_path, 26 | message=service.event_message, include_directives=include_directives) 27 | }@ 28 | 29 | @[for ns in service.namespaced_type.namespaces]@ 30 | namespace @(ns) 31 | { 32 | 33 | @[end for]@ 34 | @ 35 | struct @(service.namespaced_type.name) 36 | { 37 | @{ 38 | service_typename = '::'.join(service.namespaced_type.namespaced_name()) 39 | }@ 40 | using Request = @(service_typename)@(SERVICE_REQUEST_MESSAGE_SUFFIX); 41 | using Response = @(service_typename)@(SERVICE_RESPONSE_MESSAGE_SUFFIX); 42 | using Event = @(service_typename)@(SERVICE_EVENT_MESSAGE_SUFFIX); 43 | }; 44 | @ 45 | @[for ns in reversed(service.namespaced_type.namespaces)]@ 46 | 47 | } // namespace @(ns) 48 | @[end for]@ 49 | -------------------------------------------------------------------------------- /rosidl_generator_cpp/resource/srv__traits.hpp.em: -------------------------------------------------------------------------------- 1 | @# Included from rosidl_generator_cpp/resource/idl__traits.hpp.em 2 | @{ 3 | TEMPLATE( 4 | 'msg__traits.hpp.em', 5 | package_name=package_name, interface_path=interface_path, 6 | message=service.request_message, include_directives=include_directives) 7 | }@ 8 | 9 | @{ 10 | TEMPLATE( 11 | 'msg__traits.hpp.em', 12 | package_name=package_name, interface_path=interface_path, 13 | message=service.response_message, include_directives=include_directives) 14 | }@ 15 | 16 | @{ 17 | TEMPLATE( 18 | 'msg__traits.hpp.em', 19 | package_name=package_name, interface_path=interface_path, 20 | message=service.event_message, include_directives=include_directives) 21 | }@ 22 | 23 | @{ 24 | service_typename = '::'.join(service.namespaced_type.namespaced_name()) 25 | service_fully_qualified_name = '/'.join(service.namespaced_type.namespaced_name()) 26 | }@ 27 | @ 28 | namespace rosidl_generator_traits 29 | { 30 | 31 | template<> 32 | inline const char * data_type<@(service_typename)>() 33 | { 34 | return "@(service_typename)"; 35 | } 36 | 37 | template<> 38 | inline const char * name<@(service_typename)>() 39 | { 40 | return "@(service_fully_qualified_name)"; 41 | } 42 | 43 | template<> 44 | struct has_fixed_size<@(service_typename)> 45 | : std::integral_constant< 46 | bool, 47 | has_fixed_size<@(service_typename)_Request>::value && 48 | has_fixed_size<@(service_typename)_Response>::value 49 | > 50 | { 51 | }; 52 | 53 | template<> 54 | struct has_bounded_size<@(service_typename)> 55 | : std::integral_constant< 56 | bool, 57 | has_bounded_size<@(service_typename)_Request>::value && 58 | has_bounded_size<@(service_typename)_Response>::value 59 | > 60 | { 61 | }; 62 | 63 | template<> 64 | struct is_service<@(service_typename)> 65 | : std::true_type 66 | { 67 | }; 68 | 69 | template<> 70 | struct is_service_request<@(service_typename)_Request> 71 | : std::true_type 72 | { 73 | }; 74 | 75 | template<> 76 | struct is_service_response<@(service_typename)_Response> 77 | : std::true_type 78 | { 79 | }; 80 | 81 | } // namespace rosidl_generator_traits 82 | -------------------------------------------------------------------------------- /rosidl_generator_cpp/resource/srv__type_support.hpp.em: -------------------------------------------------------------------------------- 1 | @# Included from rosidl_generator_cpp/resource/srv__type_support.hpp.em 2 | @{header_file = 'rosidl_typesupport_cpp/service_type_support.hpp'}@ 3 | @[if header_file in include_directives]@ 4 | // already included above 5 | // @ 6 | @[else]@ 7 | @{include_directives.add(header_file)}@ 8 | @[end if]@ 9 | #include "@(header_file)" 10 | 11 | #ifdef __cplusplus 12 | extern "C" 13 | { 14 | #endif 15 | // Forward declare the get type support functions for this type. 16 | ROSIDL_GENERATOR_CPP_PUBLIC_@(package_name) 17 | const rosidl_service_type_support_t * 18 | ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME( 19 | rosidl_typesupport_cpp, 20 | @(',\n '.join(service.namespaced_type.namespaced_name())) 21 | )(); 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | @{ 27 | TEMPLATE( 28 | 'msg__type_support.hpp.em', 29 | package_name=package_name, message=service.request_message, 30 | include_directives=include_directives) 31 | }@ 32 | 33 | @{ 34 | TEMPLATE( 35 | 'msg__type_support.hpp.em', 36 | package_name=package_name, message=service.response_message, 37 | include_directives=include_directives) 38 | }@ 39 | 40 | -------------------------------------------------------------------------------- /rosidl_generator_cpp/rosidl_generator_cpp-extras.cmake.in: -------------------------------------------------------------------------------- 1 | # generated from rosidl_generator_cpp/rosidl_generator_cpp-extras.cmake 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/register_cpp.cmake") 4 | rosidl_generator_cpp_extras( 5 | "${rosidl_generator_cpp_DIR}/../../../lib/rosidl_generator_cpp/rosidl_generator_cpp" 6 | "${rosidl_generator_cpp_DIR}/../../../@PYTHON_INSTALL_DIR@/rosidl_generator_cpp/__init__.py" 7 | "${rosidl_generator_cpp_DIR}/../resource" 8 | ) 9 | -------------------------------------------------------------------------------- /rosidl_generator_cpp/setup.cfg: -------------------------------------------------------------------------------- 1 | [options.entry_points] 2 | rosidl_cli.command.generate.type_extensions = 3 | cpp = rosidl_generator_cpp.cli:GenerateCpp 4 | -------------------------------------------------------------------------------- /rosidl_generator_tests/msg/BasicIdl.idl: -------------------------------------------------------------------------------- 1 | module rosidl_generator_tests { 2 | module msg { 3 | struct BasicIdl { 4 | float x; 5 | }; 6 | }; 7 | }; 8 | -------------------------------------------------------------------------------- /rosidl_generator_tests/msg/SmallConstant.msg: -------------------------------------------------------------------------------- 1 | float32 FLOAT32_CONST=0.05 2 | -------------------------------------------------------------------------------- /rosidl_generator_tests/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rosidl_generator_tests 5 | 4.10.0 6 | Integration tests for rosidl_generator_c and rosidl_generator_cpp packages. 7 | 8 | Aditya Pande 9 | Brandon Ong 10 | Dharini Dutia 11 | Shane Loretz 12 | 13 | Apache-2.0 14 | 15 | Geoffrey Biggs 16 | Jacob Perron 17 | Michel Hidalgo 18 | 19 | ament_cmake 20 | 21 | action_msgs 22 | ament_cmake_gtest 23 | ament_cmake_pytest 24 | ament_lint_auto 25 | ament_lint_common 26 | ament_index_python 27 | python3-fastjsonschema 28 | rosidl_cmake 29 | rosidl_generator_c 30 | rosidl_generator_cpp 31 | rosidl_generator_type_description 32 | rosidl_runtime_c 33 | rosidl_runtime_cpp 34 | service_msgs 35 | test_interface_files 36 | type_description_interfaces 37 | 38 | 39 | ament_cmake 40 | 41 | 42 | -------------------------------------------------------------------------------- /rosidl_generator_tests/test/rosidl_generator_c/separate_compilation.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Open Source Robotics Foundation, Inc. 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 ROSIDL_GENERATOR_C__SEPARATE_COMPILATION_H_ 16 | #define ROSIDL_GENERATOR_C__SEPARATE_COMPILATION_H_ 17 | 18 | int func(void); 19 | 20 | #endif // ROSIDL_GENERATOR_C__SEPARATE_COMPILATION_H_ 21 | -------------------------------------------------------------------------------- /rosidl_generator_tests/test/rosidl_generator_c/test_compilation.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Open Source Robotics Foundation, Inc. 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 "rosidl_generator_tests/msg/detail/constants__struct.h" 19 | #include "rosidl_generator_tests/msg/detail/constants__functions.h" 20 | 21 | #include "./separate_compilation.h" 22 | 23 | int main(int argc, char ** argv) 24 | { 25 | (void)argc; 26 | (void)argv; 27 | 28 | if (!rosidl_generator_tests__msg__Constants__BOOL_CONST) { 29 | fprintf(stderr, "wrong boolean constant\n"); 30 | return 1; 31 | } 32 | 33 | if (rosidl_generator_tests__msg__Constants__UINT8_CONST != 200) { 34 | fprintf(stderr, "wrong integer constant\n"); 35 | return 1; 36 | } 37 | 38 | int rc = func(); 39 | 40 | if (!rc) { 41 | printf("all checks passed\n"); 42 | } 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /rosidl_generator_tests/test/rosidl_generator_cpp/test_msg_datatype.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Open Source Robotics Foundation, Inc. 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 "rosidl_generator_tests/msg/empty.hpp" 17 | #include "rosidl_generator_tests/msg/strings.hpp" 18 | 19 | 20 | TEST(Test_rosidl_generator_traits, check_data_type) { 21 | ASSERT_STREQ( 22 | "rosidl_generator_tests::msg::Strings", 23 | rosidl_generator_traits::data_type()); 24 | ASSERT_STREQ( 25 | "rosidl_generator_tests::msg::Empty", 26 | rosidl_generator_traits::data_type()); 27 | } 28 | -------------------------------------------------------------------------------- /rosidl_generator_tests/test/rosidl_generator_type_description/test_type_hash.py: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Open Source Robotics Foundation, Inc. 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 json 16 | import os 17 | from pathlib import Path 18 | 19 | from ament_index_python import get_package_share_directory 20 | import fastjsonschema 21 | 22 | 23 | def test_type_hash(): 24 | """Test all rosidl_generator_type_description output files against defined schemas.""" 25 | schema_path = ( 26 | Path(get_package_share_directory('rosidl_generator_type_description')) / 'resource' / 27 | 'HashedTypeDescription.schema.json') 28 | 29 | with schema_path.open('r') as schema_file: 30 | schema = json.load(schema_file) 31 | validator = fastjsonschema.compile(schema) 32 | 33 | generated_files_dir = Path(os.environ['GENERATED_TEST_FILE_DIR']) 34 | validated_files = 0 35 | for namespace in generated_files_dir.iterdir(): 36 | for p in namespace.iterdir(): 37 | assert p.is_file() 38 | assert p.suffix == '.json' 39 | with p.open('r') as f: 40 | instance = json.load(f) 41 | validator(instance) 42 | validated_files += 1 43 | assert validated_files, 'Needed to validate at least one JSON output.' 44 | -------------------------------------------------------------------------------- /rosidl_generator_type_description/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | project(rosidl_generator_type_description) 4 | 5 | find_package(ament_cmake_python REQUIRED) 6 | find_package(ament_cmake_ros_core REQUIRED) 7 | 8 | ament_index_register_resource("rosidl_generator_packages") 9 | ament_python_install_package(${PROJECT_NAME}) 10 | 11 | if(BUILD_TESTING) 12 | find_package(ament_lint_auto REQUIRED) 13 | find_package(ament_cmake_pytest REQUIRED) 14 | ament_lint_auto_find_test_dependencies() 15 | ament_add_pytest_test(pytest_type_hash_generator test) 16 | endif() 17 | 18 | ament_package( 19 | CONFIG_EXTRAS "${PROJECT_NAME}-extras.cmake.in" 20 | ) 21 | 22 | install( 23 | PROGRAMS bin/${PROJECT_NAME} 24 | DESTINATION lib/${PROJECT_NAME} 25 | ) 26 | install( 27 | DIRECTORY cmake resource 28 | DESTINATION share/${PROJECT_NAME} 29 | ) 30 | -------------------------------------------------------------------------------- /rosidl_generator_type_description/README.md: -------------------------------------------------------------------------------- 1 | # rosidl_generator_type_description 2 | 3 | This generator serializes ROS 2 interface descriptions (message, service, action) to a common format and uses SHA256 to hash that representation into a unique hash for each type. 4 | 5 | The SHA256 hashes generated by this package must match those generated by `rcl_calculate_type_hash`. The `.json` files generated must, therefore, match the result of `rcl_type_description_to_hashable_json`. 6 | 7 | ## Generated files 8 | 9 | This generator creates one output file per interface, `interface_name.json`. 10 | 11 | This file follows the schema [`HashedTypedDescription`](./resource/HashedTypeDescription.schema.json). 12 | It contains a tree of hashes for the top-level interface and any of its generated subinterfaces (such as request and response messages for a service), as well as fully-expanded descriptions of the interface type. 13 | This description is a representation of `type_description_interfaces/msg/TypeDescription`, including all recursively-referenced types. 14 | This way, dependent descriptions may use this interface and recurse no further to know the full set of referenced types it needs to know about. 15 | -------------------------------------------------------------------------------- /rosidl_generator_type_description/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rosidl_generator_type_description 5 | 4.10.0 6 | Generate hashes and descriptions of ROS 2 interface types, per REP-2011. 7 | 8 | Emerson Knapp 9 | 10 | Apache License 2.0 11 | 12 | Emerson Knapp 13 | 14 | ament_cmake_python 15 | ament_cmake_ros_core 16 | 17 | ament_cmake_core 18 | python3 19 | 20 | ament_index_python 21 | rosidl_cli 22 | rosidl_parser 23 | 24 | ament_lint_auto 25 | ament_lint_common 26 | 27 | rosidl_generator_packages 28 | 29 | 30 | ament_cmake 31 | 32 | 33 | -------------------------------------------------------------------------------- /rosidl_generator_type_description/rosidl_generator_type_description-extras.cmake.in: -------------------------------------------------------------------------------- 1 | find_package(ament_cmake_core QUIET REQUIRED) 2 | 3 | ament_register_extension( 4 | "rosidl_generate_idl_interfaces" 5 | "rosidl_generator_type_description" 6 | "rosidl_generator_type_description_generate_interfaces.cmake") 7 | 8 | set(rosidl_generator_type_description_BIN 9 | "${rosidl_generator_type_description_DIR}/../../../lib/rosidl_generator_type_description/rosidl_generator_type_description") 10 | normalize_path(rosidl_generator_type_description_BIN 11 | "${rosidl_generator_type_description_BIN}") 12 | 13 | set(rosidl_generator_type_description_GENERATOR_FILES 14 | "${rosidl_generator_type_description_DIR}/../../../@PYTHON_INSTALL_DIR@/rosidl_generator_type_description/__init__.py") 15 | normalize_path(rosidl_generator_type_description_GENERATOR_FILES 16 | "${rosidl_generator_type_description_GENERATOR_FILES}") 17 | -------------------------------------------------------------------------------- /rosidl_generator_type_description/setup.cfg: -------------------------------------------------------------------------------- 1 | [options.entry_points] 2 | rosidl_cli.command.hash.extensions = 3 | type_description = rosidl_generator_type_description.cli:HashTypeDescription 4 | -------------------------------------------------------------------------------- /rosidl_parser/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(rosidl_parser NONE) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | find_package(ament_cmake_python REQUIRED) 7 | 8 | ament_python_install_package(${PROJECT_NAME}) 9 | 10 | if(BUILD_TESTING) 11 | find_package(ament_lint_auto REQUIRED) 12 | find_package(ament_cmake_mypy REQUIRED) 13 | ament_lint_auto_find_test_dependencies() 14 | endif() 15 | 16 | ament_package() 17 | 18 | if(BUILD_TESTING) 19 | find_package(ament_cmake_pytest REQUIRED) 20 | ament_add_pytest_test(pytest test) 21 | endif() 22 | 23 | install( 24 | PROGRAMS bin/idl2png 25 | DESTINATION lib/${PROJECT_NAME}) 26 | -------------------------------------------------------------------------------- /rosidl_parser/bin/idl2png: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Copyright 2018 Open Source Robotics Foundation, Inc. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | import argparse 18 | import pathlib 19 | import sys 20 | 21 | from lark.tree import pydot__tree_to_png 22 | 23 | from rosidl_parser.parser import get_ast_from_idl_string 24 | 25 | 26 | def main(argv=sys.argv[1:]): 27 | parser = argparse.ArgumentParser( 28 | description='Generate a .png file with the AST of an .idl file.', 29 | formatter_class=argparse.ArgumentDefaultsHelpFormatter) 30 | parser.add_argument( 31 | 'idl_files', nargs='+', 32 | help='The path of the .idl files') 33 | args = parser.parse_args(argv) 34 | 35 | for idl_file in args.idl_files: 36 | print('idl_file', idl_file) 37 | idl_file = pathlib.Path(idl_file) 38 | if not idl_file.exists(): 39 | print(f"File '{idl_file} not found", file=sys.stderr) 40 | continue 41 | 42 | string = idl_file.read_text() 43 | try: 44 | tree = get_ast_from_idl_string(string) 45 | except Exception as e: # noqa: F841 46 | print(f"Failed to parse '{idl_file}': {e}", file=sys.stderr) 47 | continue 48 | 49 | png_file = idl_file.with_suffix('.png') 50 | try: 51 | pydot__tree_to_png(tree, png_file) 52 | except ImportError as e: # noqa: F841 53 | print(f'Failed to generate png files: {e}', file=sys.stderr) 54 | return 1 55 | print(f"Generated '{png_file}'") 56 | 57 | 58 | if __name__ == '__main__': 59 | sys.exit(main()) 60 | -------------------------------------------------------------------------------- /rosidl_parser/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rosidl_parser 5 | 4.10.0 6 | The parser for `.idl` ROS interface files. 7 | 8 | Aditya Pande 9 | Brandon Ong 10 | Dharini Dutia 11 | Shane Loretz 12 | 13 | Apache License 2.0 14 | 15 | Chris Lalancette 16 | Dirk Thomas 17 | Michel Hidalgo 18 | 19 | ament_cmake 20 | 21 | python3-lark-parser 22 | rosidl_adapter 23 | 24 | ament_cmake_mypy 25 | ament_cmake_pytest 26 | ament_lint_auto 27 | ament_lint_common 28 | python3-pytest 29 | 30 | 31 | ament_cmake 32 | 33 | 34 | -------------------------------------------------------------------------------- /rosidl_parser/pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | junit_family=xunit2 3 | -------------------------------------------------------------------------------- /rosidl_parser/rosidl_parser/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ros2/rosidl/95fa106fce55eb62a8e4954b5f5f4004af125315/rosidl_parser/rosidl_parser/__init__.py -------------------------------------------------------------------------------- /rosidl_parser/rosidl_parser/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ros2/rosidl/95fa106fce55eb62a8e4954b5f5f4004af125315/rosidl_parser/rosidl_parser/py.typed -------------------------------------------------------------------------------- /rosidl_parser/test/action/MyAction.idl: -------------------------------------------------------------------------------- 1 | module rosidl_parser { 2 | module action { 3 | module MyAction_Goal_Constants { 4 | const short SHORT_CONSTANT = -23; 5 | }; 6 | struct MyAction_Goal { 7 | int32 input_value; 8 | }; 9 | module MyAction_Result_Constants { 10 | const unsigned long UNSIGNED_LONG_CONSTANT = 42; 11 | }; 12 | struct MyAction_Result { 13 | uint32 output_value; 14 | }; 15 | module MyAction_Feedback_Constants { 16 | const float FLOAT_CONSTANT = 1.25; 17 | }; 18 | struct MyAction_Feedback { 19 | float progress_value; 20 | }; 21 | }; 22 | }; 23 | -------------------------------------------------------------------------------- /rosidl_parser/test/srv/MyService.idl: -------------------------------------------------------------------------------- 1 | module rosidl_parser { 2 | module srv { 3 | module MyService_Request_Constants { 4 | const short SHORT_CONSTANT = -23; 5 | }; 6 | struct MyService_Request { 7 | short short_value; 8 | string string_value; 9 | }; 10 | module MyService_Response_Constants { 11 | const unsigned long UNSIGNED_LONG_CONSTANT = 42; 12 | }; 13 | struct MyService_Response { 14 | boolean boolean_value; 15 | }; 16 | }; 17 | }; 18 | -------------------------------------------------------------------------------- /rosidl_pycommon/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rosidl_pycommon 5 | 4.10.0 6 | Common Python functions used by rosidl packages. 7 | 8 | Aditya Pande 9 | Brandon Ong 10 | Dharini Dutia 11 | Shane Loretz 12 | 13 | Apache License 2.0 14 | 15 | Jacob Perron 16 | Michel Hidalgo 17 | 18 | rosidl_parser 19 | 20 | ament_copyright 21 | ament_flake8 22 | ament_pep257 23 | ament_mypy 24 | ament_xmllint 25 | python3-pytest 26 | 27 | 28 | ament_python 29 | 30 | 31 | -------------------------------------------------------------------------------- /rosidl_pycommon/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ros2/rosidl/95fa106fce55eb62a8e4954b5f5f4004af125315/rosidl_pycommon/py.typed -------------------------------------------------------------------------------- /rosidl_pycommon/resource/rosidl_pycommon: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ros2/rosidl/95fa106fce55eb62a8e4954b5f5f4004af125315/rosidl_pycommon/resource/rosidl_pycommon -------------------------------------------------------------------------------- /rosidl_pycommon/setup.cfg: -------------------------------------------------------------------------------- 1 | [develop] 2 | script_dir=$base/lib/rosidl_pycommon 3 | [install] 4 | install_scripts=$base/lib/rosidl_pycommon 5 | -------------------------------------------------------------------------------- /rosidl_pycommon/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import find_packages 2 | from setuptools import setup 3 | 4 | package_name = 'rosidl_pycommon' 5 | 6 | setup( 7 | name=package_name, 8 | version='4.10.0', 9 | packages=find_packages(exclude=['test']), 10 | data_files=[ 11 | ('share/ament_index/resource_index/packages', 12 | ['resource/' + package_name]), 13 | ('share/' + package_name, ['package.xml']), 14 | ], 15 | install_requires=['setuptools'], 16 | zip_safe=True, 17 | author='Jacob Perron', 18 | author_email='jacob@openrobotics.org', 19 | maintainer='Aditya Pande, Brandon Ong, Dharini Dutia, Shane Loretz', 20 | maintainer_email='aditya.pande@openrobotics.org, brandon@openrobotics.org, dharini@openrobotics.org, sloretz@openrobotics.org', # noqa: E501 21 | description='Common Python functions used by rosidl packages.', 22 | license='Apache License, Version 2.0', 23 | tests_require=['pytest'], 24 | entry_points={ 25 | 'console_scripts': [ 26 | ], 27 | }, 28 | ) 29 | -------------------------------------------------------------------------------- /rosidl_pycommon/test/test_copyright.py: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Open Source Robotics Foundation, Inc. 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 | from ament_copyright.main import main 16 | import pytest 17 | 18 | 19 | @pytest.mark.copyright 20 | @pytest.mark.linter 21 | def test_copyright() -> None: 22 | rc = main(argv=['.', 'test']) 23 | assert rc == 0, 'Found errors' 24 | -------------------------------------------------------------------------------- /rosidl_pycommon/test/test_flake8.py: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Open Source Robotics Foundation, Inc. 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 | from ament_flake8.main import main_with_errors 16 | import pytest 17 | 18 | 19 | @pytest.mark.flake8 20 | @pytest.mark.linter 21 | def test_flake8() -> None: 22 | rc, errors = main_with_errors(argv=[]) 23 | assert rc == 0, \ 24 | 'Found %d code style errors / warnings:\n' % len(errors) + \ 25 | '\n'.join(errors) 26 | -------------------------------------------------------------------------------- /rosidl_pycommon/test/test_mypy.py: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Open Source Robotics Foundation, Inc. 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 | from ament_mypy.main import main 16 | import pytest 17 | 18 | 19 | @pytest.mark.mypy 20 | @pytest.mark.linter 21 | def test_mypy() -> None: 22 | rc = main(argv=[]) 23 | assert rc == 0, 'Found type errors!' 24 | -------------------------------------------------------------------------------- /rosidl_pycommon/test/test_pep257.py: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Open Source Robotics Foundation, Inc. 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 | from ament_pep257.main import main 16 | import pytest 17 | 18 | 19 | @pytest.mark.linter 20 | @pytest.mark.pep257 21 | def test_pep257() -> None: 22 | rc = main(argv=['.', 'test']) 23 | assert rc == 0, 'Found code style errors / warnings' 24 | -------------------------------------------------------------------------------- /rosidl_pycommon/test/test_xmllint.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Open Source Robotics Foundation, Inc. 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 | from ament_xmllint.main import main 16 | import pytest 17 | 18 | 19 | @pytest.mark.linter 20 | @pytest.mark.xmllint 21 | def test_xmllint() -> None: 22 | rc = main(argv=[]) 23 | assert rc == 0, 'Found errors' 24 | -------------------------------------------------------------------------------- /rosidl_runtime_c/Doxyfile: -------------------------------------------------------------------------------- 1 | # All settings not listed here will use the Doxygen default values. 2 | 3 | PROJECT_NAME = "rosidl_runtime_c" 4 | PROJECT_NUMBER = master 5 | PROJECT_BRIEF = "Generate the rosidl interfaces in C." 6 | 7 | INPUT = README.md ./include ./docs ./QUALITY_DECLARATION.md 8 | USE_MDFILE_AS_MAINPAGE = README.md 9 | RECURSIVE = YES 10 | OUTPUT_DIRECTORY = doc_output 11 | 12 | EXTRACT_ALL = YES 13 | SORT_MEMBER_DOCS = NO 14 | 15 | GENERATE_LATEX = NO 16 | 17 | ENABLE_PREPROCESSING = YES 18 | MACRO_EXPANSION = YES 19 | EXPAND_ONLY_PREDEF = YES 20 | PREDEFINED += ROSIDL_GENERATOR_C_PUBLIC= 21 | 22 | # Tag files that do not exist will produce a warning and cross-project linking will not work. 23 | TAGFILES += "../../../../doxygen_tag_files/cppreference-doxygen-web.tag.xml=http://en.cppreference.com/w/" 24 | # Uncomment to generate tag files for cross-project linking. 25 | GENERATE_TAGFILE = "../../../../doxygen_tag_files/rosidl_runtime_c.tag" 26 | -------------------------------------------------------------------------------- /rosidl_runtime_c/README.md: -------------------------------------------------------------------------------- 1 | # rosidl_generator_c 2 | 3 | `rosidl_runtime_c` is a package and provides runtime ROSIDL functionality in C. 4 | 5 | ## Features 6 | 7 | A list of features provided by `rosidl_runtime_c` is available in its [feature documentation](docs/FEATURES.md). 8 | 9 | ## Quality Declaration 10 | 11 | See the [Quality Declaration](QUALITY_DECLARATION.md) for more details. 12 | -------------------------------------------------------------------------------- /rosidl_runtime_c/include/rosidl_runtime_c/message_initialization.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Open Source Robotics Foundation, Inc. 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 ROSIDL_RUNTIME_C__MESSAGE_INITIALIZATION_H_ 16 | #define ROSIDL_RUNTIME_C__MESSAGE_INITIALIZATION_H_ 17 | 18 | enum rosidl_runtime_c__message_initialization 19 | { 20 | // Initialize all fields of the message, either with the default value 21 | // (if the field has one), or with an empty value (generally 0 or an 22 | // empty string). 23 | ROSIDL_RUNTIME_C_MSG_INIT_ALL, 24 | // Skip initialization of all fields of the message. It is up to the user to 25 | // ensure that all fields are initialized before use. 26 | ROSIDL_RUNTIME_C_MSG_INIT_SKIP, 27 | // Initialize all fields of the message to an empty value (generally 0 or an 28 | // empty string). 29 | ROSIDL_RUNTIME_C_MSG_INIT_ZERO, 30 | // Initialize all fields of the message that have defaults; all other fields 31 | // are left untouched. 32 | ROSIDL_RUNTIME_C_MSG_INIT_DEFAULTS_ONLY, 33 | }; 34 | 35 | #endif // ROSIDL_RUNTIME_C__MESSAGE_INITIALIZATION_H_ 36 | -------------------------------------------------------------------------------- /rosidl_runtime_c/include/rosidl_runtime_c/string.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Open Source Robotics Foundation, Inc. 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 ROSIDL_RUNTIME_C__STRING_H_ 16 | #define ROSIDL_RUNTIME_C__STRING_H_ 17 | 18 | #include 19 | 20 | #include "rosidl_runtime_c/primitives_sequence.h" 21 | 22 | /// An array of 8-bit characters terminated by a null byte. 23 | typedef struct rosidl_runtime_c__String 24 | { 25 | /// The pointer to the first character, the sequence ends with a null byte. 26 | char * data; 27 | /// The length of the string (excluding the null byte). 28 | size_t size; 29 | /// The capacity represents the number of allocated bytes (including the null byte). 30 | size_t capacity; 31 | } rosidl_runtime_c__String; 32 | 33 | ROSIDL_RUNTIME_C__PRIMITIVE_SEQUENCE(String, rosidl_runtime_c__String) 34 | 35 | #endif // ROSIDL_RUNTIME_C__STRING_H_ 36 | -------------------------------------------------------------------------------- /rosidl_runtime_c/include/rosidl_runtime_c/string_bound.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Open Source Robotics Foundation, Inc. 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 ROSIDL_RUNTIME_C__STRING_BOUND_H_ 16 | #define ROSIDL_RUNTIME_C__STRING_BOUND_H_ 17 | 18 | #include 19 | 20 | /// Upper boundary for #rosidl_runtime_c__String or #rosidl_runtime_c__U16String. 21 | typedef struct rosidl_runtime_c__String__bound 22 | { 23 | /// The number of characters in the string (excluding the null character). 24 | size_t bound; 25 | } rosidl_runtime_c__String__bound; 26 | 27 | #endif // ROSIDL_RUNTIME_C__STRING_BOUND_H_ 28 | -------------------------------------------------------------------------------- /rosidl_runtime_c/include/rosidl_runtime_c/type_description/field__struct.h: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT MANUALLY - this copied file managed by copy_type_description_generated_sources.bash 2 | // generated from rosidl_generator_c/resource/idl__struct.h.em 3 | // with input from type_description_interfaces:msg/Field.idl 4 | // generated code does not contain a copyright notice 5 | 6 | #ifndef ROSIDL_RUNTIME_C__TYPE_DESCRIPTION__FIELD__STRUCT_H_ 7 | #define ROSIDL_RUNTIME_C__TYPE_DESCRIPTION__FIELD__STRUCT_H_ 8 | 9 | #ifdef __cplusplus 10 | extern "C" 11 | { 12 | #endif 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | // Constants defined in the message 19 | 20 | // Include directives for member types 21 | // Member 'name' 22 | // Member 'default_value' 23 | #include "rosidl_runtime_c/string.h" 24 | // Member 'type' 25 | #include "rosidl_runtime_c/type_description/field_type__struct.h" 26 | 27 | /// Struct defined in msg/Field in the package type_description_interfaces. 28 | /** 29 | * Represents a single field in a type. 30 | */ 31 | typedef struct rosidl_runtime_c__type_description__Field 32 | { 33 | /// Name of the field. 34 | rosidl_runtime_c__String name; 35 | /// Type of the field, including details about the type like length, nested name, etc. 36 | rosidl_runtime_c__type_description__FieldType type; 37 | /// Literal default value of the field as a string, as it appeared in the original 38 | /// message description file, whether that be .msg/.srv/.action or .idl. 39 | rosidl_runtime_c__String default_value; 40 | } rosidl_runtime_c__type_description__Field; 41 | 42 | // Struct for a sequence of rosidl_runtime_c__type_description__Field. 43 | typedef struct rosidl_runtime_c__type_description__Field__Sequence 44 | { 45 | rosidl_runtime_c__type_description__Field * data; 46 | /// The number of valid items in data 47 | size_t size; 48 | /// The number of allocated items in data 49 | size_t capacity; 50 | } rosidl_runtime_c__type_description__Field__Sequence; 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif // ROSIDL_RUNTIME_C__TYPE_DESCRIPTION__FIELD__STRUCT_H_ 57 | -------------------------------------------------------------------------------- /rosidl_runtime_c/include/rosidl_runtime_c/type_description/key_value__struct.h: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT MANUALLY - this copied file managed by copy_type_description_generated_sources.bash 2 | // generated from rosidl_generator_c/resource/idl__struct.h.em 3 | // with input from type_description_interfaces:msg/KeyValue.idl 4 | // generated code does not contain a copyright notice 5 | 6 | #ifndef ROSIDL_RUNTIME_C__TYPE_DESCRIPTION__KEY_VALUE__STRUCT_H_ 7 | #define ROSIDL_RUNTIME_C__TYPE_DESCRIPTION__KEY_VALUE__STRUCT_H_ 8 | 9 | #ifdef __cplusplus 10 | extern "C" 11 | { 12 | #endif 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | // Constants defined in the message 19 | 20 | // Include directives for member types 21 | // Member 'key' 22 | // Member 'value' 23 | #include "rosidl_runtime_c/string.h" 24 | 25 | /// Struct defined in msg/KeyValue in the package type_description_interfaces. 26 | /** 27 | * Represents an arbitrary key-value pair for application-specific information. 28 | */ 29 | typedef struct rosidl_runtime_c__type_description__KeyValue 30 | { 31 | rosidl_runtime_c__String key; 32 | rosidl_runtime_c__String value; 33 | } rosidl_runtime_c__type_description__KeyValue; 34 | 35 | // Struct for a sequence of rosidl_runtime_c__type_description__KeyValue. 36 | typedef struct rosidl_runtime_c__type_description__KeyValue__Sequence 37 | { 38 | rosidl_runtime_c__type_description__KeyValue * data; 39 | /// The number of valid items in data 40 | size_t size; 41 | /// The number of allocated items in data 42 | size_t capacity; 43 | } rosidl_runtime_c__type_description__KeyValue__Sequence; 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif // ROSIDL_RUNTIME_C__TYPE_DESCRIPTION__KEY_VALUE__STRUCT_H_ 50 | -------------------------------------------------------------------------------- /rosidl_runtime_c/include/rosidl_runtime_c/type_description/type_description__struct.h: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT MANUALLY - this copied file managed by copy_type_description_generated_sources.bash 2 | // generated from rosidl_generator_c/resource/idl__struct.h.em 3 | // with input from type_description_interfaces:msg/TypeDescription.idl 4 | // generated code does not contain a copyright notice 5 | 6 | #ifndef ROSIDL_RUNTIME_C__TYPE_DESCRIPTION__TYPE_DESCRIPTION__STRUCT_H_ 7 | #define ROSIDL_RUNTIME_C__TYPE_DESCRIPTION__TYPE_DESCRIPTION__STRUCT_H_ 8 | 9 | #ifdef __cplusplus 10 | extern "C" 11 | { 12 | #endif 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | // Constants defined in the message 19 | 20 | // Include directives for member types 21 | // Member 'type_description' 22 | // Member 'referenced_type_descriptions' 23 | #include "rosidl_runtime_c/type_description/individual_type_description__struct.h" 24 | 25 | /// Struct defined in msg/TypeDescription in the package type_description_interfaces. 26 | /** 27 | * Represents a complete type description, including the type itself as well as the types it references. 28 | */ 29 | typedef struct rosidl_runtime_c__type_description__TypeDescription 30 | { 31 | /// Description of the type. 32 | rosidl_runtime_c__type_description__IndividualTypeDescription type_description; 33 | /// Descriptions of all referenced types, recursively. 34 | rosidl_runtime_c__type_description__IndividualTypeDescription__Sequence referenced_type_descriptions; 35 | } rosidl_runtime_c__type_description__TypeDescription; 36 | 37 | // Struct for a sequence of rosidl_runtime_c__type_description__TypeDescription. 38 | typedef struct rosidl_runtime_c__type_description__TypeDescription__Sequence 39 | { 40 | rosidl_runtime_c__type_description__TypeDescription * data; 41 | /// The number of valid items in data 42 | size_t size; 43 | /// The number of allocated items in data 44 | size_t capacity; 45 | } rosidl_runtime_c__type_description__TypeDescription__Sequence; 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif // ROSIDL_RUNTIME_C__TYPE_DESCRIPTION__TYPE_DESCRIPTION__STRUCT_H_ 52 | -------------------------------------------------------------------------------- /rosidl_runtime_c/include/rosidl_runtime_c/u16string.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2018 Open Source Robotics Foundation, Inc. 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 ROSIDL_RUNTIME_C__U16STRING_H_ 16 | #define ROSIDL_RUNTIME_C__U16STRING_H_ 17 | 18 | #include 19 | 20 | #include "rosidl_runtime_c/primitives_sequence.h" 21 | 22 | /// An array of 16-bit characters terminated by a null character. 23 | typedef struct rosidl_runtime_c__U16String 24 | { 25 | /// The pointer to the first character, the sequence ends with a null character. 26 | uint_least16_t * data; // using uint_least16_t to match a C++ std::u16string 27 | /// The length of the u16string (excluding the null character). 28 | size_t size; 29 | /// The capacity represents the number of allocated characters (including the null character). 30 | size_t capacity; 31 | } rosidl_runtime_c__U16String; 32 | 33 | ROSIDL_RUNTIME_C__PRIMITIVE_SEQUENCE(U16String, rosidl_runtime_c__U16String) 34 | 35 | #endif // ROSIDL_RUNTIME_C__U16STRING_H_ 36 | -------------------------------------------------------------------------------- /rosidl_runtime_c/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rosidl_runtime_c 5 | 4.10.0 6 | Provides definitions, initialization and finalization functions, and macros for getting and working with rosidl typesupport types in C. 7 | 8 | Aditya Pande 9 | Brandon Ong 10 | Dharini Dutia 11 | Shane Loretz 12 | 13 | Apache License 2.0 14 | 15 | Chris Lalancette 16 | Dirk Thomas 17 | Michel Hidalgo 18 | William Woodall 19 | 20 | ament_cmake 21 | ament_cmake_ros_core 22 | 23 | rosidl_typesupport_interface 24 | 25 | ament_cmake 26 | 27 | rosidl_typesupport_interface 28 | 29 | rcutils 30 | 31 | ament_cmake_gtest 32 | ament_lint_auto 33 | ament_lint_common 34 | performance_test_fixture 35 | 36 | rosidl_runtime_packages 37 | 38 | 39 | ament_cmake 40 | 41 | 42 | -------------------------------------------------------------------------------- /rosidl_runtime_c/src/message_type_support.c: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Open Source Robotics Foundation, Inc. 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 "rosidl_runtime_c/message_type_support_struct.h" 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | rosidl_message_type_support_t rosidl_get_zero_initialized_message_type_support_handle(void) 22 | { 23 | static rosidl_message_type_support_t null_message_type_support = { 24 | .typesupport_identifier = NULL, 25 | .data = NULL, 26 | .func = NULL, 27 | .get_type_hash_func = NULL, 28 | .get_type_description_func = NULL, 29 | .get_type_description_sources_func = NULL 30 | }; 31 | return null_message_type_support; 32 | } 33 | 34 | const rosidl_message_type_support_t * get_message_typesupport_handle( 35 | const rosidl_message_type_support_t * handle, const char * identifier) 36 | { 37 | assert(handle); 38 | assert(handle->func); 39 | rosidl_message_typesupport_handle_function func = 40 | (rosidl_message_typesupport_handle_function)(handle->func); 41 | return func(handle, identifier); 42 | } 43 | 44 | const rosidl_message_type_support_t * get_message_typesupport_handle_function( 45 | const rosidl_message_type_support_t * handle, const char * identifier) 46 | { 47 | assert(handle); 48 | assert(handle->typesupport_identifier); 49 | assert(identifier); 50 | if (strcmp(handle->typesupport_identifier, identifier) == 0) { 51 | return handle; 52 | } 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /rosidl_runtime_c/src/sequence_bound.c: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Open Source Robotics Foundation, Inc. 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 "rosidl_runtime_c/sequence_bound.h" 16 | 17 | #include 18 | #include 19 | 20 | const rosidl_runtime_c__Sequence__bound * get_sequence_bound_handle( 21 | const rosidl_runtime_c__Sequence__bound * handle, const char * identifier) 22 | { 23 | assert(handle); 24 | assert(handle->func); 25 | rosidl_runtime_c__bound_handle_function func = 26 | (rosidl_runtime_c__bound_handle_function)(handle->func); 27 | return func(handle, identifier); 28 | } 29 | 30 | const rosidl_runtime_c__Sequence__bound * get_sequence_bound_handle_function( 31 | const rosidl_runtime_c__Sequence__bound * handle, const char * identifier) 32 | { 33 | assert(handle); 34 | assert(handle->typesupport_identifier); 35 | assert(identifier); 36 | if (strcmp(handle->typesupport_identifier, identifier) == 0) { 37 | return handle; 38 | } 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /rosidl_runtime_c/src/service_type_support.c: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Open Source Robotics Foundation, Inc. 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 "rosidl_runtime_c/service_type_support_struct.h" 16 | 17 | #include 18 | #include 19 | 20 | const rosidl_service_type_support_t * get_service_typesupport_handle( 21 | const rosidl_service_type_support_t * handle, const char * identifier) 22 | { 23 | assert(handle); 24 | assert(handle->func); 25 | rosidl_service_typesupport_handle_function func = 26 | (rosidl_service_typesupport_handle_function)(handle->func); 27 | return func(handle, identifier); 28 | } 29 | 30 | const rosidl_service_type_support_t * get_service_typesupport_handle_function( 31 | const rosidl_service_type_support_t * handle, const char * identifier) 32 | { 33 | assert(handle); 34 | assert(handle->typesupport_identifier); 35 | assert(identifier); 36 | if (strcmp(handle->typesupport_identifier, identifier) == 0) { 37 | return handle; 38 | } 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /rosidl_runtime_c/test/test_message_type_support.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Open Source Robotics Foundation, Inc. 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 "gtest/gtest.h" 16 | #include "rosidl_runtime_c/message_type_support_struct.h" 17 | 18 | const rosidl_message_type_support_t * dummy_message_typesupport_handle_function( 19 | const rosidl_message_type_support_t * handle, const char *) {return handle;} 20 | 21 | TEST(message_typesupport, get_message_typesupport_handle) { 22 | rosidl_message_type_support_t message_typesupport; 23 | 24 | constexpr char identifier[] = "identifier"; 25 | message_typesupport.typesupport_identifier = &identifier[0]; 26 | message_typesupport.func = dummy_message_typesupport_handle_function; 27 | 28 | EXPECT_EQ( 29 | get_message_typesupport_handle( 30 | &message_typesupport, 31 | &identifier[0]), &message_typesupport); 32 | EXPECT_EQ( 33 | get_message_typesupport_handle_function( 34 | &message_typesupport, 35 | &identifier[0]), &message_typesupport); 36 | EXPECT_EQ( 37 | get_message_typesupport_handle_function( 38 | &message_typesupport, 39 | "different identifier"), nullptr); 40 | } 41 | -------------------------------------------------------------------------------- /rosidl_runtime_c/test/test_sequence_bound.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Open Source Robotics Foundation, Inc. 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 "gtest/gtest.h" 16 | #include "rosidl_runtime_c/sequence_bound.h" 17 | 18 | const rosidl_runtime_c__Sequence__bound * dummy_sequence_bound_handle_function( 19 | const rosidl_runtime_c__Sequence__bound * handle, const char *) {return handle;} 20 | 21 | TEST(sequence_bound, get_sequence_bound_handle) { 22 | rosidl_runtime_c__Sequence__bound sequence_bound; 23 | 24 | constexpr char identifier[] = "identifier"; 25 | sequence_bound.typesupport_identifier = &identifier[0]; 26 | sequence_bound.func = dummy_sequence_bound_handle_function; 27 | 28 | EXPECT_EQ(get_sequence_bound_handle(&sequence_bound, &identifier[0]), &sequence_bound); 29 | EXPECT_EQ(get_sequence_bound_handle_function(&sequence_bound, &identifier[0]), &sequence_bound); 30 | EXPECT_EQ(get_sequence_bound_handle_function(&sequence_bound, "different identifier"), nullptr); 31 | } 32 | -------------------------------------------------------------------------------- /rosidl_runtime_c/test/test_service_type_support.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Open Source Robotics Foundation, Inc. 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 "gtest/gtest.h" 16 | #include "rosidl_runtime_c/service_type_support_struct.h" 17 | 18 | const rosidl_service_type_support_t * dummy_service_typesupport_handle_function( 19 | const rosidl_service_type_support_t * handle, const char *) {return handle;} 20 | 21 | TEST(service_typesupport, get_service_typesupport_handle) { 22 | rosidl_service_type_support_t service_typesupport; 23 | 24 | constexpr char identifier[] = "identifier"; 25 | service_typesupport.typesupport_identifier = &identifier[0]; 26 | service_typesupport.func = dummy_service_typesupport_handle_function; 27 | 28 | EXPECT_EQ( 29 | get_service_typesupport_handle( 30 | &service_typesupport, 31 | &identifier[0]), &service_typesupport); 32 | EXPECT_EQ( 33 | get_service_typesupport_handle_function( 34 | &service_typesupport, 35 | &identifier[0]), &service_typesupport); 36 | EXPECT_EQ( 37 | get_service_typesupport_handle_function( 38 | &service_typesupport, 39 | "different identifier"), nullptr); 40 | } 41 | -------------------------------------------------------------------------------- /rosidl_runtime_cpp/Doxyfile: -------------------------------------------------------------------------------- 1 | # All settings not listed here will use the Doxygen default values. 2 | 3 | PROJECT_NAME = "rosidl_runtime_cpp" 4 | PROJECT_NUMBER = master 5 | PROJECT_BRIEF = "Generate the rosidl interfaces in C++." 6 | 7 | INPUT = README.md ./include ./docs ./QUALITY_DECLARATION.md 8 | USE_MDFILE_AS_MAINPAGE = README.md 9 | RECURSIVE = YES 10 | OUTPUT_DIRECTORY = doc_output 11 | 12 | EXTRACT_ALL = YES 13 | SORT_MEMBER_DOCS = NO 14 | 15 | GENERATE_LATEX = NO 16 | 17 | ENABLE_PREPROCESSING = YES 18 | MACRO_EXPANSION = YES 19 | EXPAND_ONLY_PREDEF = YES 20 | 21 | # Tag files that do not exist will produce a warning and cross-project linking will not work. 22 | TAGFILES += "../../../../doxygen_tag_files/cppreference-doxygen-web.tag.xml=http://en.cppreference.com/w/" 23 | TAGFILES += "../../../../doxygen_tag_files/rosidl_runtime_c.tag" 24 | # Uncomment to generate tag files for cross-project linking. 25 | GENERATE_TAGFILE = "../../../../doxygen_tag_files/rosidl_runtime_cpp.tag" 26 | -------------------------------------------------------------------------------- /rosidl_runtime_cpp/README.md: -------------------------------------------------------------------------------- 1 | # rosidl_runtime_cpp 2 | 3 | `rosidl_runtime_cpp` is a package generates and provides runtime ROSIDL interfaces files in C++. 4 | 5 | ## Features 6 | 7 | The features provided by `rosidl_runtime_cpp` are documented in its [feature documentation](docs/FEATURES.md). 8 | 9 | ## Quality Declaration 10 | 11 | See the [Quality Declaration](QUALITY_DECLARATION.md) for more details. 12 | -------------------------------------------------------------------------------- /rosidl_runtime_cpp/include/rosidl_runtime_cpp/action_type_support_decl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Open Source Robotics Foundation, Inc. 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 ROSIDL_RUNTIME_CPP__ACTION_TYPE_SUPPORT_DECL_HPP_ 16 | #define ROSIDL_RUNTIME_CPP__ACTION_TYPE_SUPPORT_DECL_HPP_ 17 | 18 | #include 19 | #include 20 | 21 | namespace rosidl_runtime_cpp 22 | { 23 | 24 | /// Get the action type support handle. 25 | /** 26 | * Note: this is implemented by generated sources of rosidl packages. 27 | * \return Function handler for the action's typesupport. 28 | */ 29 | template 30 | [[nodiscard]] 31 | const rosidl_action_type_support_t * get_action_type_support_handle(); 32 | 33 | } // namespace rosidl_runtime_cpp 34 | 35 | #endif // ROSIDL_RUNTIME_CPP__ACTION_TYPE_SUPPORT_DECL_HPP_ 36 | -------------------------------------------------------------------------------- /rosidl_runtime_cpp/include/rosidl_runtime_cpp/message_initialization.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Open Source Robotics Foundation, Inc. 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 ROSIDL_RUNTIME_CPP__MESSAGE_INITIALIZATION_HPP_ 16 | #define ROSIDL_RUNTIME_CPP__MESSAGE_INITIALIZATION_HPP_ 17 | 18 | #include 19 | 20 | namespace rosidl_runtime_cpp 21 | { 22 | 23 | /// Enum utilized in rosidl generated sources for describing how members are initialized. 24 | /** 25 | * See the documentation for the `rosidl_runtime_c__message_initialization` enum for more information. 26 | */ 27 | enum class MessageInitialization 28 | { 29 | ALL = ROSIDL_RUNTIME_C_MSG_INIT_ALL, 30 | SKIP = ROSIDL_RUNTIME_C_MSG_INIT_SKIP, 31 | ZERO = ROSIDL_RUNTIME_C_MSG_INIT_ZERO, 32 | DEFAULTS_ONLY = ROSIDL_RUNTIME_C_MSG_INIT_DEFAULTS_ONLY, 33 | }; 34 | 35 | } // namespace rosidl_runtime_cpp 36 | 37 | #endif // ROSIDL_RUNTIME_CPP__MESSAGE_INITIALIZATION_HPP_ 38 | -------------------------------------------------------------------------------- /rosidl_runtime_cpp/include/rosidl_runtime_cpp/message_type_support_decl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2015 Open Source Robotics Foundation, Inc. 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 ROSIDL_RUNTIME_CPP__MESSAGE_TYPE_SUPPORT_DECL_HPP_ 16 | #define ROSIDL_RUNTIME_CPP__MESSAGE_TYPE_SUPPORT_DECL_HPP_ 17 | 18 | #include 19 | #include 20 | 21 | namespace rosidl_runtime_cpp 22 | { 23 | 24 | /// Get the message type support handle. 25 | /** 26 | * Note: this is implemented by generated sources of rosidl packages. 27 | * \return Function handler for the message's typesupport. 28 | */ 29 | template 30 | [[nodiscard]] 31 | const rosidl_message_type_support_t * get_message_type_support_handle(); 32 | 33 | } // namespace rosidl_runtime_cpp 34 | 35 | #endif // ROSIDL_RUNTIME_CPP__MESSAGE_TYPE_SUPPORT_DECL_HPP_ 36 | -------------------------------------------------------------------------------- /rosidl_runtime_cpp/include/rosidl_runtime_cpp/service_type_support_decl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2015 Open Source Robotics Foundation, Inc. 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 ROSIDL_RUNTIME_CPP__SERVICE_TYPE_SUPPORT_DECL_HPP_ 16 | #define ROSIDL_RUNTIME_CPP__SERVICE_TYPE_SUPPORT_DECL_HPP_ 17 | 18 | #include 19 | #include 20 | 21 | namespace rosidl_runtime_cpp 22 | { 23 | 24 | /// Get the service type support handle. 25 | /** 26 | * Note: this is implemented by generated sources of rosidl packages. 27 | * \return Function handler for the service's typesupport. 28 | */ 29 | template 30 | [[nodiscard]] 31 | const rosidl_service_type_support_t * get_service_type_support_handle(); 32 | 33 | } // namespace rosidl_runtime_cpp 34 | 35 | #endif // ROSIDL_RUNTIME_CPP__SERVICE_TYPE_SUPPORT_DECL_HPP_ 36 | -------------------------------------------------------------------------------- /rosidl_runtime_cpp/include/rosidl_typesupport_cpp/action_type_support.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Open Source Robotics Foundation, Inc. 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 ROSIDL_TYPESUPPORT_CPP__ACTION_TYPE_SUPPORT_HPP_ 16 | #define ROSIDL_TYPESUPPORT_CPP__ACTION_TYPE_SUPPORT_HPP_ 17 | 18 | #include 19 | #include 20 | 21 | namespace rosidl_typesupport_cpp 22 | { 23 | 24 | template 25 | [[nodiscard]] 26 | const rosidl_action_type_support_t * get_action_type_support_handle(); 27 | 28 | } // namespace rosidl_typesupport_cpp 29 | 30 | #endif // ROSIDL_TYPESUPPORT_CPP__ACTION_TYPE_SUPPORT_HPP_ 31 | -------------------------------------------------------------------------------- /rosidl_runtime_cpp/include/rosidl_typesupport_cpp/message_type_support.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Open Source Robotics Foundation, Inc. 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 ROSIDL_TYPESUPPORT_CPP__MESSAGE_TYPE_SUPPORT_HPP_ 16 | #define ROSIDL_TYPESUPPORT_CPP__MESSAGE_TYPE_SUPPORT_HPP_ 17 | 18 | #include 19 | #include 20 | 21 | namespace rosidl_typesupport_cpp 22 | { 23 | 24 | template 25 | [[nodiscard]] 26 | const rosidl_message_type_support_t * get_message_type_support_handle(); 27 | 28 | } // namespace rosidl_typesupport_cpp 29 | 30 | #endif // ROSIDL_TYPESUPPORT_CPP__MESSAGE_TYPE_SUPPORT_HPP_ 31 | -------------------------------------------------------------------------------- /rosidl_runtime_cpp/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rosidl_runtime_cpp 5 | 4.10.0 6 | Provides definitions and templated functions for getting and working with rosidl typesupport types in C++. 7 | 8 | Aditya Pande 9 | Brandon Ong 10 | Dharini Dutia 11 | Shane Loretz 12 | 13 | Apache License 2.0 14 | 15 | Chris Lalancette 16 | Dirk Thomas 17 | Michel Hidalgo 18 | 19 | ament_cmake 20 | 21 | ament_cmake 22 | 23 | rosidl_runtime_c 24 | 25 | ament_cmake_gtest 26 | ament_lint_auto 27 | ament_lint_common 28 | performance_test_fixture 29 | 30 | rosidl_runtime_packages 31 | 32 | 33 | ament_cmake 34 | 35 | 36 | -------------------------------------------------------------------------------- /rosidl_typesupport_interface/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(rosidl_typesupport_interface NONE) 4 | 5 | find_package(ament_cmake REQUIRED) 6 | 7 | add_library(${PROJECT_NAME} INTERFACE) 8 | target_include_directories(${PROJECT_NAME} INTERFACE 9 | "$" 10 | "$") 11 | 12 | # Export old-style CMake variables 13 | ament_export_include_directories("include/${PROJECT_NAME}") 14 | 15 | # Export modern CMake targets 16 | ament_export_targets(${PROJECT_NAME}) 17 | 18 | if(BUILD_TESTING) 19 | find_package(ament_lint_auto REQUIRED) 20 | ament_lint_auto_find_test_dependencies() 21 | 22 | # For gtest 23 | enable_language(C CXX) 24 | # Default to C11 25 | if(NOT CMAKE_C_STANDARD) 26 | set(CMAKE_C_STANDARD 11) 27 | endif() 28 | # Default to C++17 29 | if(NOT CMAKE_CXX_STANDARD) 30 | set(CMAKE_CXX_STANDARD 17) 31 | endif() 32 | 33 | find_package(ament_cmake_gtest REQUIRED) 34 | 35 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 36 | add_compile_options(-Wall -Wextra -Wpedantic) 37 | endif() 38 | 39 | ament_add_gtest(test_macros test/test_macros.cpp) 40 | if(TARGET test_macros) 41 | target_link_libraries(test_macros ${PROJECT_NAME}) 42 | endif() 43 | 44 | endif() 45 | 46 | ament_package() 47 | 48 | install( 49 | DIRECTORY include/ 50 | DESTINATION include/${PROJECT_NAME} 51 | ) 52 | install( 53 | TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME} 54 | ) 55 | -------------------------------------------------------------------------------- /rosidl_typesupport_interface/Doxyfile: -------------------------------------------------------------------------------- 1 | # All settings not listed here will use the Doxygen default values. 2 | 3 | PROJECT_NAME = "rosidl_typesupport_interface" 4 | PROJECT_NUMBER = master 5 | PROJECT_BRIEF = "The C/C++ interface for rosidl typesupport packages." 6 | 7 | INPUT = README.md ./include ./QUALITY_DECLARATION.md 8 | USE_MDFILE_AS_MAINPAGE = README.md 9 | RECURSIVE = YES 10 | OUTPUT_DIRECTORY = doc_output 11 | 12 | EXTRACT_ALL = YES 13 | SORT_MEMBER_DOCS = NO 14 | 15 | GENERATE_LATEX = NO 16 | 17 | ENABLE_PREPROCESSING = YES 18 | MACRO_EXPANSION = YES 19 | EXPAND_ONLY_PREDEF = YES 20 | 21 | # Tag files that do not exist will produce a warning and cross-project linking will not work. 22 | TAGFILES += "../../../../doxygen_tag_files/cppreference-doxygen-web.tag.xml=http://en.cppreference.com/w/" 23 | # Uncomment to generate tag files for cross-project linking. 24 | GENERATE_TAGFILE = "../../../../doxygen_tag_files/rosidl_runtime_cpp.tag" 25 | -------------------------------------------------------------------------------- /rosidl_typesupport_interface/README.md: -------------------------------------------------------------------------------- 1 | # rosidl_typesupport_interface 2 | 3 | `rosidl_typesupport_interface` is a package that provides macros that define the rosidl typesupport interface. 4 | 5 | ## Features 6 | 7 | `rosidl_typesupport_interface` provides an interface of C/C++ macros for rosidl typesupport packages. 8 | They are available in the `macros.h` header. 9 | 10 | ## Quality Declaration 11 | 12 | See the [Quality Declaration](QUALITY_DECLARATION.md) for more details. 13 | -------------------------------------------------------------------------------- /rosidl_typesupport_interface/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rosidl_typesupport_interface 5 | 4.10.0 6 | 7 | The interface for rosidl typesupport packages. 8 | 9 | 10 | Aditya Pande 11 | Brandon Ong 12 | Dharini Dutia 13 | Shane Loretz 14 | 15 | Apache License 2.0 16 | 17 | Chris Lalancette 18 | Dirk Thomas 19 | Michel Hidalgo 20 | 21 | ament_cmake 22 | 23 | ament_lint_auto 24 | ament_lint_common 25 | ament_cmake_gtest 26 | 27 | 28 | ament_cmake 29 | 30 | 31 | -------------------------------------------------------------------------------- /rosidl_typesupport_interface/test/test_macros.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Open Source Robotics Foundation, Inc. 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 "gtest/gtest.h" 16 | 17 | #include "rosidl_typesupport_interface/macros.h" 18 | 19 | #define a__get_message_type_support_handle__b__c__d SUCCEED(); return; 20 | #define a__get_service_type_support_handle__b__c__d SUCCEED(); return; 21 | #define a__get_action_type_support_handle__b__c__d SUCCEED(); return; 22 | 23 | TEST(rosidl_typesupport_interface, message_symbol_name) { 24 | ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(a, b, c, d); 25 | FAIL() << "This line should not be reached"; 26 | } 27 | 28 | TEST(rosidl_typesupport_interface, service_symbol_name) { 29 | ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME(a, b, c, d); 30 | FAIL() << "This line should not be reached"; 31 | } 32 | 33 | TEST(rosidl_typesupport_interface, action_symbol_name) { 34 | ROSIDL_TYPESUPPORT_INTERFACE__ACTION_SYMBOL_NAME(a, b, c, d); 35 | FAIL() << "This line should not be reached"; 36 | } 37 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_c/Doxyfile: -------------------------------------------------------------------------------- 1 | # All settings not listed here will use the Doxygen default values. 2 | 3 | PROJECT_NAME = "rosidl_typesupport_introspection_c" 4 | PROJECT_NUMBER = master 5 | PROJECT_BRIEF = "Generate the message type support for dynamic message construction in C." 6 | 7 | INPUT = README.md QUALITY_DECLARATION.md ./include ./docs 8 | USE_MDFILE_AS_MAINPAGE = README.md 9 | RECURSIVE = YES 10 | OUTPUT_DIRECTORY = docs_output 11 | 12 | EXTRACT_ALL = YES 13 | SORT_MEMBER_DOCS = NO 14 | 15 | GENERATE_LATEX = NO 16 | GENERATE_XML = YES 17 | EXCLUDE_SYMBOLS = detail details 18 | 19 | ENABLE_PREPROCESSING = YES 20 | MACRO_EXPANSION = YES 21 | EXPAND_ONLY_PREDEF = YES 22 | PREDEFINED += ROSIDL_TYPESUPPORT_INTROSPECTION_C_PUBLIC 23 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_c/README.md: -------------------------------------------------------------------------------- 1 | # rosidl_typesupport_introspection_c 2 | 3 | `rosidl_typesupport_introspection_c` provides functionality for getting the associated message or service C typesupport handler functions and dynamically accessing or manipulating messages. 4 | 5 | ## Features 6 | 7 | The features provided by `rosidl_typesupport_introspection_c` are described in [FEATURES](docs/FEATURES.md). 8 | 9 | ## Quality Declaration 10 | 11 | See the [Quality Declaration](./QUALITY_DECLARATION.md) for more details. 12 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_c/bin/rosidl_typesupport_introspection_c: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import sys 5 | 6 | from rosidl_typesupport_introspection_c import generate_c 7 | from typing import List 8 | 9 | 10 | def main(argv: List[str] = sys.argv[1:]): 11 | """ 12 | Generate the C introspection type support for ROS interfaces. 13 | 14 | :param argv: The command-line arguments to be parsed. Defaults to 15 | sys.argv[1:]. 16 | :type argv: List[str] 17 | """ 18 | parser = argparse.ArgumentParser( 19 | description='Generate the C type support to dynamically handle ROS messages.', 20 | formatter_class=argparse.ArgumentDefaultsHelpFormatter) 21 | parser.add_argument( 22 | '--generator-arguments-file', 23 | required=True, 24 | help='The location of the file containing the generator arguments') 25 | args = parser.parse_args(argv) 26 | 27 | generate_c(args.generator_arguments_file) 28 | 29 | 30 | if __name__ == '__main__': 31 | sys.exit(main()) 32 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_c/docs/FEATURES.md: -------------------------------------------------------------------------------- 1 | # rosidl_typesupport_introspection_c features 2 | 3 | `rosidl_typesupport_introspection_c` provides a Python generator executable, `rosidl_typesupport_introspection_c`, based on Empy to create C source files that describes the type of a ROS 2 C message and provides interfaces to construct and interpret such messages. 4 | 5 | The templates utilized by this generator executable are located in the `resource` directory and generate source files for messages, services and actions. 6 | 7 | `rosidl_typesupport_introspection_c` defines a typesupport identifier, which is declared in `identifier.h`. 8 | 9 | `rosidl_typesupport_introspection_c` provides the following functionality for incorporation into generated typesupport source files. 10 | 11 | * `message_type_support_decl.h`: Look up message type support handle functions from available libraries. 12 | * `service_type_support_decl.h`: Look up service type support handle functions from available libraries. 13 | * `message_introspection.h`: Defines the representation of message members and functions to construct or destruct messages and members and to compute member addresses. 14 | * `service_introspection.h`: Provides access to service name, namespace and message types. 15 | * `field_types.h`: Defines the codes used to identify a members' types. 16 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_c/include/rosidl_typesupport_introspection_c/identifier.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014-2015 Open Source Robotics Foundation, Inc. 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 ROSIDL_TYPESUPPORT_INTROSPECTION_C__IDENTIFIER_H_ 16 | #define ROSIDL_TYPESUPPORT_INTROSPECTION_C__IDENTIFIER_H_ 17 | 18 | #include "rosidl_typesupport_introspection_c/visibility_control.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" 22 | { 23 | #endif 24 | 25 | /// String identifying the typesupport introspection implementation in use. 26 | ROSIDL_TYPESUPPORT_INTROSPECTION_C_PUBLIC 27 | extern const char * rosidl_typesupport_introspection_c__identifier; 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif // ROSIDL_TYPESUPPORT_INTROSPECTION_C__IDENTIFIER_H_ 34 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_c/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rosidl_typesupport_introspection_c 5 | 4.10.0 6 | 7 | Generate the message type support for dynamic message construction in C. 8 | 9 | 10 | Aditya Pande 11 | Brandon Ong 12 | Dharini Dutia 13 | Shane Loretz 14 | 15 | Apache License 2.0 16 | 17 | Chris Lalancette 18 | Dirk Thomas 19 | Michel Hidalgo 20 | 21 | ament_cmake 22 | ament_cmake_ros_core 23 | 24 | ament_cmake 25 | python3 26 | rosidl_generator_c 27 | rosidl_pycommon 28 | 29 | rosidl_cmake 30 | rosidl_runtime_c 31 | rosidl_typesupport_interface 32 | 33 | ament_index_python 34 | rosidl_cli 35 | rosidl_generator_c 36 | rosidl_parser 37 | rosidl_pycommon 38 | 39 | ament_lint_auto 40 | ament_lint_common 41 | 42 | rosidl_typesupport_c_packages 43 | 44 | 45 | ament_cmake 46 | 47 | 48 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_c/resource/msg__rosidl_typesupport_introspection_c.h.em: -------------------------------------------------------------------------------- 1 | @# Included from rosidl_typesupport_introspection_c/resource/idl__rosidl_typesupport_introspection_c.h.em 2 | @{ 3 | header_files = [ 4 | 'rosidl_runtime_c/message_type_support_struct.h', 5 | 'rosidl_typesupport_interface/macros.h', 6 | package_name + '/msg/rosidl_typesupport_introspection_c__visibility_control.h', 7 | ] 8 | }@ 9 | @[for header_file in header_files]@ 10 | @[ if header_file in include_directives]@ 11 | // already included above 12 | // @ 13 | @[ else]@ 14 | @{include_directives.add(header_file)}@ 15 | @[ end if]@ 16 | #include "@(header_file)" 17 | @[end for]@ 18 | 19 | ROSIDL_TYPESUPPORT_INTROSPECTION_C_PUBLIC_@(package_name) 20 | const rosidl_message_type_support_t * 21 | ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(message.structure.namespaced_type.name))(); 22 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_c/resource/rosidl_typesupport_introspection_c__visibility_control.h.in: -------------------------------------------------------------------------------- 1 | // generated from 2 | // rosidl_typesupport_introspection_c/resource/rosidl_typesupport_introspection_c__visibility_control.h.in 3 | // generated code does not contain a copyright notice 4 | 5 | #ifndef @PROJECT_NAME_UPPER@__MSG__ROSIDL_TYPESUPPORT_INTROSPECTION_C__VISIBILITY_CONTROL_H_ 6 | #define @PROJECT_NAME_UPPER@__MSG__ROSIDL_TYPESUPPORT_INTROSPECTION_C__VISIBILITY_CONTROL_H_ 7 | 8 | #ifdef __cplusplus 9 | extern "C" 10 | { 11 | #endif 12 | 13 | // This logic was borrowed (then namespaced) from the examples on the gcc wiki: 14 | // https://gcc.gnu.org/wiki/Visibility 15 | 16 | #if defined _WIN32 || defined __CYGWIN__ 17 | #ifdef __GNUC__ 18 | #define ROSIDL_TYPESUPPORT_INTROSPECTION_C_EXPORT_@PROJECT_NAME@ __attribute__ ((dllexport)) 19 | #define ROSIDL_TYPESUPPORT_INTROSPECTION_C_IMPORT_@PROJECT_NAME@ __attribute__ ((dllimport)) 20 | #else 21 | #define ROSIDL_TYPESUPPORT_INTROSPECTION_C_EXPORT_@PROJECT_NAME@ __declspec(dllexport) 22 | #define ROSIDL_TYPESUPPORT_INTROSPECTION_C_IMPORT_@PROJECT_NAME@ __declspec(dllimport) 23 | #endif 24 | #ifdef ROSIDL_TYPESUPPORT_INTROSPECTION_C_BUILDING_DLL_@PROJECT_NAME@ 25 | #define ROSIDL_TYPESUPPORT_INTROSPECTION_C_PUBLIC_@PROJECT_NAME@ ROSIDL_TYPESUPPORT_INTROSPECTION_C_EXPORT_@PROJECT_NAME@ 26 | #else 27 | #define ROSIDL_TYPESUPPORT_INTROSPECTION_C_PUBLIC_@PROJECT_NAME@ ROSIDL_TYPESUPPORT_INTROSPECTION_C_IMPORT_@PROJECT_NAME@ 28 | #endif 29 | #else 30 | #define ROSIDL_TYPESUPPORT_INTROSPECTION_C_EXPORT_@PROJECT_NAME@ __attribute__ ((visibility("default"))) 31 | #define ROSIDL_TYPESUPPORT_INTROSPECTION_C_IMPORT_@PROJECT_NAME@ 32 | #if __GNUC__ >= 4 33 | #define ROSIDL_TYPESUPPORT_INTROSPECTION_C_PUBLIC_@PROJECT_NAME@ __attribute__ ((visibility("default"))) 34 | #else 35 | #define ROSIDL_TYPESUPPORT_INTROSPECTION_C_PUBLIC_@PROJECT_NAME@ 36 | #endif 37 | #endif 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif // @PROJECT_NAME_UPPER@__MSG__ROSIDL_TYPESUPPORT_INTROSPECTION_C__VISIBILITY_CONTROL_H_ 44 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_c/resource/srv__rosidl_typesupport_introspection_c.h.em: -------------------------------------------------------------------------------- 1 | @# Included from rosidl_typesupport_introspection_c/resource/idl__rosidl_typesupport_introspection_c.h.em 2 | @{ 3 | TEMPLATE( 4 | 'msg__rosidl_typesupport_introspection_c.h.em', 5 | package_name=package_name, interface_path=interface_path, message=service.request_message, 6 | include_directives=include_directives) 7 | }@ 8 | 9 | @{ 10 | TEMPLATE( 11 | 'msg__rosidl_typesupport_introspection_c.h.em', 12 | package_name=package_name, interface_path=interface_path, message=service.response_message, 13 | include_directives=include_directives) 14 | }@ 15 | 16 | @{ 17 | TEMPLATE( 18 | 'msg__rosidl_typesupport_introspection_c.h.em', 19 | package_name=package_name, interface_path=interface_path, message=service.event_message, 20 | include_directives=include_directives) 21 | }@ 22 | 23 | @{ 24 | header_files = [ 25 | 'rosidl_runtime_c/service_type_support_struct.h', 26 | 'rosidl_typesupport_interface/macros.h', 27 | package_name + '/msg/rosidl_typesupport_introspection_c__visibility_control.h', 28 | ] 29 | }@ 30 | @[for header_file in header_files]@ 31 | @[ if header_file in include_directives]@ 32 | // already included above 33 | // @ 34 | @[ else]@ 35 | @{include_directives.add(header_file)}@ 36 | @[ end if]@ 37 | #include "@(header_file)" 38 | @[end for]@ 39 | 40 | ROSIDL_TYPESUPPORT_INTROSPECTION_C_PUBLIC_@(package_name) 41 | const rosidl_service_type_support_t * 42 | ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME(rosidl_typesupport_introspection_c, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name))(); 43 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_c/rosidl_typesupport_introspection_c-extras.cmake.in: -------------------------------------------------------------------------------- 1 | # generated from 2 | # rosidl_typesupport_introspection_c/ 3 | # rosidl_typesupport_introspection_c-extras.cmake.in 4 | 5 | # use the same type of library 6 | set(rosidl_typesupport_introspection_c_LIBRARY_TYPE 7 | "@rosidl_typesupport_introspection_c_LIBRARY_TYPE@") 8 | 9 | # Make sure rosidl_generator_c extension point is registered first 10 | find_package(rosidl_generator_c QUIET) 11 | 12 | find_package(ament_cmake_core QUIET REQUIRED) 13 | ament_register_extension( 14 | "rosidl_generate_idl_interfaces" 15 | "rosidl_typesupport_introspection_c" 16 | "rosidl_typesupport_introspection_c_generate_interfaces.cmake") 17 | 18 | set(rosidl_typesupport_introspection_c_BIN 19 | "${rosidl_typesupport_introspection_c_DIR}/../../../lib/rosidl_typesupport_introspection_c/rosidl_typesupport_introspection_c") 20 | normalize_path(rosidl_typesupport_introspection_c_BIN 21 | "${rosidl_typesupport_introspection_c_BIN}") 22 | 23 | set(rosidl_typesupport_introspection_c_GENERATOR_FILES 24 | "${rosidl_typesupport_introspection_c_DIR}/../../../@PYTHON_INSTALL_DIR@/rosidl_typesupport_introspection_c/__init__.py") 25 | normalize_path(rosidl_typesupport_introspection_c_GENERATOR_FILES 26 | "${rosidl_typesupport_introspection_c_GENERATOR_FILES}") 27 | 28 | set(rosidl_typesupport_introspection_c_TEMPLATE_DIR 29 | "${rosidl_typesupport_introspection_c_DIR}/../resource") 30 | normalize_path(rosidl_typesupport_introspection_c_TEMPLATE_DIR 31 | "${rosidl_typesupport_introspection_c_TEMPLATE_DIR}") 32 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_c/rosidl_typesupport_introspection_c/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014-2021 Open Source Robotics Foundation, Inc. 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 | from typing import List 16 | 17 | from rosidl_pycommon import generate_files 18 | 19 | 20 | def generate_c(generator_arguments_file: str) -> List[str]: 21 | """ 22 | Generate the C implementation of the type support. 23 | 24 | :param generator_arguments_file: The path to the file containing the 25 | arguments for the generator. 26 | :type generator_arguments_file: str 27 | """ 28 | mapping = { 29 | 'idl__rosidl_typesupport_introspection_c.h.em': 30 | 'detail/%s__rosidl_typesupport_introspection_c.h', 31 | 'idl__type_support.c.em': 'detail/%s__type_support.c', 32 | } 33 | return generate_files(generator_arguments_file, mapping) 34 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_c/setup.cfg: -------------------------------------------------------------------------------- 1 | [options.entry_points] 2 | rosidl_cli.command.generate.typesupport_extensions = 3 | introspection_c = rosidl_typesupport_introspection_c.cli:GenerateIntrospectionCTypesupport 4 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_c/src/identifier.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Open Source Robotics Foundation, Inc. 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 "rosidl_typesupport_introspection_c/identifier.h" 16 | 17 | const char * rosidl_typesupport_introspection_c__identifier = "rosidl_typesupport_introspection_c"; 18 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_cpp/Doxyfile: -------------------------------------------------------------------------------- 1 | # All settings not listed here will use the Doxygen default values. 2 | 3 | PROJECT_NAME = "rosidl_typesupport_introspection_cpp" 4 | PROJECT_NUMBER = master 5 | PROJECT_BRIEF = "Generate the message type support for dynamic message construction in C++." 6 | 7 | INPUT = README.md QUALITY_DECLARATION.md ./include ./docs 8 | USE_MDFILE_AS_MAINPAGE = README.md 9 | RECURSIVE = YES 10 | OUTPUT_DIRECTORY = docs_output 11 | 12 | EXTRACT_ALL = YES 13 | SORT_MEMBER_DOCS = NO 14 | 15 | GENERATE_LATEX = NO 16 | GENERATE_XML = YES 17 | EXCLUDE_SYMBOLS = detail details 18 | 19 | ENABLE_PREPROCESSING = YES 20 | MACRO_EXPANSION = YES 21 | EXPAND_ONLY_PREDEF = YES 22 | PREDEFINED += ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_PUBLIC 23 | PREDEFINED += ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_IMPORT 24 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_cpp/README.md: -------------------------------------------------------------------------------- 1 | # rosidl_typesupport_introspection_cpp 2 | 3 | `rosidl_typesupport_introspection_cpp` provides functionality for getting the associated message or service C++ typesupport handler functions and dynamically accessing or manipulating messages. 4 | 5 | ## Features 6 | 7 | The features provided by `rosidl_typesupport_introspection_cpp` are described in [FEATURES](docs/FEATURES.md). 8 | 9 | ## Quality Declaration 10 | 11 | See the [Quality Declaration](./QUALITY_DECLARATION.md) for more details. 12 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_cpp/bin/rosidl_typesupport_introspection_cpp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import argparse 4 | import sys 5 | 6 | from rosidl_typesupport_introspection_cpp import generate_cpp 7 | from typing import List 8 | 9 | 10 | def main(argv: List[str] = sys.argv[1:]): 11 | """ 12 | Generate the C++ introspection type support for ROS interfaces. 13 | 14 | :param argv: The command-line arguments to be parsed. Defaults to 15 | sys.argv[1:]. 16 | :type argv: List[str] 17 | """ 18 | parser = argparse.ArgumentParser( 19 | description='Generate the C++ type support to dynamically handle ROS messages.', 20 | formatter_class=argparse.ArgumentDefaultsHelpFormatter) 21 | parser.add_argument( 22 | '--generator-arguments-file', 23 | required=True, 24 | help='The location of the file containing the generator arguments') 25 | args = parser.parse_args(argv) 26 | 27 | generate_cpp(args.generator_arguments_file) 28 | 29 | 30 | if __name__ == '__main__': 31 | sys.exit(main()) 32 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_cpp/docs/FEATURES.md: -------------------------------------------------------------------------------- 1 | # rosidl_typesupport_introspection_cpp features 2 | 3 | `rosidl_typesupport_introspection_cpp` provides a Python generator executable, `rosidl_typesupport_introspection_cpp`, based on Empy to create C++ source files that describes the type of a ROS 2 C++ message and provides interfaces to construct and interpret such messages. 4 | 5 | The templates utilized by this generator executable are located in the `resource` directory and generate source files for messages, services and actions. 6 | 7 | `rosidl_typesupport_introspection_cpp` defines a typesupport identifier, which is declared in `identifier.hpp`. 8 | 9 | `rosidl_typesupport_introspection_cpp` provides the following functionality for incorporation into generated typesupport source files. 10 | 11 | * `message_type_support_decl.hpp`: Look up message type support handle functions from available libraries. 12 | * `service_type_support_decl.hpp`: Look up service type support handle functions from available libraries. 13 | * `message_introspection.hpp`: Defines the representation of message members and functions to construct or destruct messages and members and to compute member addresses. 14 | * `service_introspection.hpp`: Provides access to service name, namespace and message types. 15 | * `field_types.hpp`: Defines the codes used to identify a members' types. 16 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/identifier.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Open Source Robotics Foundation, Inc. 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 ROSIDL_TYPESUPPORT_INTROSPECTION_CPP__IDENTIFIER_HPP_ 16 | #define ROSIDL_TYPESUPPORT_INTROSPECTION_CPP__IDENTIFIER_HPP_ 17 | 18 | #include "rosidl_typesupport_introspection_cpp/visibility_control.h" 19 | 20 | namespace rosidl_typesupport_introspection_cpp 21 | { 22 | 23 | /// String identifying the typesupport introspection implementation in use. 24 | ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_IMPORT 25 | extern const char * typesupport_identifier; 26 | 27 | } // namespace rosidl_typesupport_introspection_cpp 28 | 29 | #endif // ROSIDL_TYPESUPPORT_INTROSPECTION_CPP__IDENTIFIER_HPP_ 30 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/message_type_support_decl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Open Source Robotics Foundation, Inc. 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 ROSIDL_TYPESUPPORT_INTROSPECTION_CPP__MESSAGE_TYPE_SUPPORT_DECL_HPP_ 16 | #define ROSIDL_TYPESUPPORT_INTROSPECTION_CPP__MESSAGE_TYPE_SUPPORT_DECL_HPP_ 17 | 18 | // Provides the definition of the rosidl_message_type_support_t struct. 19 | #include "rosidl_runtime_c/message_type_support_struct.h" 20 | // Provides visibility macros like ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_PUBLIC. 21 | #include "rosidl_typesupport_introspection_cpp/visibility_control.h" 22 | 23 | namespace rosidl_typesupport_introspection_cpp 24 | { 25 | 26 | /// Returns a pointer to the type support structure provided by the 27 | /// downstream libraries for introspecting interfaces generated by 28 | /// the rosidl_generate_interfaces() macro. 29 | /// This is implemented in the shared library provided by this package. 30 | template 31 | [[nodiscard]] 32 | ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_PUBLIC 33 | const rosidl_message_type_support_t * get_message_type_support_handle(); 34 | 35 | } // namespace rosidl_typesupport_introspection_cpp 36 | 37 | #endif // ROSIDL_TYPESUPPORT_INTROSPECTION_CPP__MESSAGE_TYPE_SUPPORT_DECL_HPP_ 38 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_cpp/include/rosidl_typesupport_introspection_cpp/service_type_support_decl.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Open Source Robotics Foundation, Inc. 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 ROSIDL_TYPESUPPORT_INTROSPECTION_CPP__SERVICE_TYPE_SUPPORT_DECL_HPP_ 16 | #define ROSIDL_TYPESUPPORT_INTROSPECTION_CPP__SERVICE_TYPE_SUPPORT_DECL_HPP_ 17 | 18 | // Provides the definition of the rosidl_service_type_support_t struct. 19 | #include "rosidl_runtime_c/service_type_support_struct.h" 20 | // Provides visibility macros like ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_PUBLIC. 21 | #include "rosidl_typesupport_introspection_cpp/visibility_control.h" 22 | 23 | namespace rosidl_typesupport_introspection_cpp 24 | { 25 | 26 | /// Returns a pointer to the type support structure provided by this library for introspecting 27 | /// services. 28 | /// This is implemented in the shared library provided by this package. 29 | template 30 | [[nodiscard]] 31 | ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_PUBLIC 32 | const rosidl_service_type_support_t * get_service_type_support_handle(); 33 | 34 | } // namespace rosidl_typesupport_introspection_cpp 35 | 36 | #endif // ROSIDL_TYPESUPPORT_INTROSPECTION_CPP__SERVICE_TYPE_SUPPORT_DECL_HPP_ 37 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_cpp/resource/msg__rosidl_typesupport_introspection_cpp.hpp.em: -------------------------------------------------------------------------------- 1 | @# Included from rosidl_typesupport_introspection_cpp/resource/idl__rosidl_typesupport_introspection_cpp.hpp.em 2 | @{ 3 | header_files = [ 4 | 'rosidl_runtime_c/message_type_support_struct.h', 5 | 'rosidl_typesupport_interface/macros.h', 6 | 'rosidl_typesupport_introspection_cpp/visibility_control.h', 7 | ] 8 | }@ 9 | @[for header_file in header_files]@ 10 | @[ if header_file in include_directives]@ 11 | // already included above 12 | // @ 13 | @[ else]@ 14 | @{include_directives.add(header_file)}@ 15 | @[ end if]@ 16 | #include "@(header_file)" 17 | @[end for]@ 18 | 19 | #ifdef __cplusplus 20 | extern "C" 21 | { 22 | #endif 23 | 24 | // TODO(dirk-thomas) these visibility macros should be message package specific 25 | ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_PUBLIC 26 | const rosidl_message_type_support_t * 27 | ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_introspection_cpp, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(message.structure.namespaced_type.name))(); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_cpp/resource/srv__rosidl_typesupport_introspection_cpp.hpp.em: -------------------------------------------------------------------------------- 1 | @# Included from rosidl_typesupport_introspection_cpp/resource/idl__rosidl_typesupport_introspection_cpp.hpp.em 2 | @{ 3 | TEMPLATE( 4 | 'msg__rosidl_typesupport_introspection_cpp.hpp.em', 5 | package_name=package_name, interface_path=interface_path, message=service.request_message, 6 | include_directives=include_directives) 7 | }@ 8 | 9 | @{ 10 | TEMPLATE( 11 | 'msg__rosidl_typesupport_introspection_cpp.hpp.em', 12 | package_name=package_name, interface_path=interface_path, message=service.response_message, 13 | include_directives=include_directives) 14 | }@ 15 | 16 | @{ 17 | TEMPLATE( 18 | 'msg__rosidl_typesupport_introspection_cpp.hpp.em', 19 | package_name=package_name, interface_path=interface_path, message=service.event_message, 20 | include_directives=include_directives) 21 | }@ 22 | 23 | @{ 24 | header_files = [ 25 | 'rosidl_runtime_c/service_type_support_struct.h', 26 | 'rosidl_typesupport_interface/macros.h', 27 | 'rosidl_typesupport_introspection_cpp/visibility_control.h', 28 | ] 29 | }@ 30 | @[for header_file in header_files]@ 31 | @[ if header_file in include_directives]@ 32 | // already included above 33 | // @ 34 | @[ else]@ 35 | @{include_directives.add(header_file)}@ 36 | @[ end if]@ 37 | #include "@(header_file)" 38 | @[end for]@ 39 | 40 | #ifdef __cplusplus 41 | extern "C" 42 | { 43 | #endif 44 | 45 | ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_PUBLIC 46 | const rosidl_service_type_support_t * 47 | ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME(rosidl_typesupport_introspection_cpp, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name))(); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_cpp/rosidl_typesupport_introspection_cpp-extras.cmake.in: -------------------------------------------------------------------------------- 1 | # generated from 2 | # rosidl_typesupport_introspection_cpp/ 3 | # rosidl_typesupport_introspection_cpp-extras.cmake.in 4 | 5 | # use the same type of library 6 | set(rosidl_typesupport_introspection_cpp_LIBRARY_TYPE 7 | "@rosidl_typesupport_introspection_cpp_LIBRARY_TYPE@") 8 | 9 | # Make sure extension points are registered in order 10 | find_package(rosidl_generator_cpp QUIET) 11 | 12 | find_package(ament_cmake_core QUIET REQUIRED) 13 | ament_register_extension( 14 | "rosidl_generate_idl_interfaces" 15 | "rosidl_typesupport_introspection_cpp" 16 | "rosidl_typesupport_introspection_cpp_generate_interfaces.cmake") 17 | 18 | set(rosidl_typesupport_introspection_cpp_BIN 19 | "${rosidl_typesupport_introspection_cpp_DIR}/../../../lib/rosidl_typesupport_introspection_cpp/rosidl_typesupport_introspection_cpp") 20 | normalize_path(rosidl_typesupport_introspection_cpp_BIN 21 | "${rosidl_typesupport_introspection_cpp_BIN}") 22 | 23 | set(rosidl_typesupport_introspection_cpp_GENERATOR_FILES 24 | "${rosidl_typesupport_introspection_cpp_DIR}/../../../@PYTHON_INSTALL_DIR@/rosidl_typesupport_introspection_cpp/__init__.py") 25 | normalize_path(rosidl_typesupport_introspection_cpp_GENERATOR_FILES 26 | "${rosidl_typesupport_introspection_cpp_GENERATOR_FILES}") 27 | 28 | set(rosidl_typesupport_introspection_cpp_TEMPLATE_DIR 29 | "${rosidl_typesupport_introspection_cpp_DIR}/../resource") 30 | normalize_path(rosidl_typesupport_introspection_cpp_TEMPLATE_DIR 31 | "${rosidl_typesupport_introspection_cpp_TEMPLATE_DIR}") 32 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_cpp/rosidl_typesupport_introspection_cpp/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014-2018 Open Source Robotics Foundation, Inc. 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 | from typing import List 16 | 17 | from rosidl_pycommon import generate_files 18 | 19 | 20 | def generate_cpp(generator_arguments_file: str) -> List[str]: 21 | """ 22 | Generate the C++ implementation of the type support. 23 | 24 | :param generator_arguments_file: The path to the file containing the 25 | arguments for the generator. 26 | :type generator_arguments_file: str 27 | """ 28 | mapping = { 29 | 'idl__rosidl_typesupport_introspection_cpp.hpp.em': 30 | 'detail/%s__rosidl_typesupport_introspection_cpp.hpp', 31 | 'idl__type_support.cpp.em': 'detail/%s__type_support.cpp', 32 | } 33 | return generate_files(generator_arguments_file, mapping) 34 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_cpp/setup.cfg: -------------------------------------------------------------------------------- 1 | [options.entry_points] 2 | rosidl_cli.command.generate.typesupport_extensions = 3 | introspection_cpp = rosidl_typesupport_introspection_cpp.cli:GenerateIntrospectionCppTypesupport 4 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_cpp/src/identifier.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Open Source Robotics Foundation, Inc. 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 "rosidl_typesupport_introspection_cpp/visibility_control.h" 16 | 17 | namespace rosidl_typesupport_introspection_cpp 18 | { 19 | 20 | ROSIDL_TYPESUPPORT_INTROSPECTION_CPP_EXPORT 21 | const char * typesupport_identifier = "rosidl_typesupport_introspection_cpp"; 22 | 23 | } // namespace rosidl_typesupport_introspection_cpp 24 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_tests/include/rosidl_typesupport_introspection_tests/fixtures.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2022 Open Source Robotics Foundation, Inc. 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 ROSIDL_TYPESUPPORT_INTROSPECTION_TESTS__FIXTURES_HPP_ 16 | #define ROSIDL_TYPESUPPORT_INTROSPECTION_TESTS__FIXTURES_HPP_ 17 | 18 | #include 19 | 20 | namespace rosidl_typesupport_introspection_tests 21 | { 22 | 23 | // Base definition, to be specialized 24 | template 25 | struct Example; 26 | 27 | } // namespace rosidl_typesupport_introspection_tests 28 | 29 | #endif // ROSIDL_TYPESUPPORT_INTROSPECTION_TESTS__FIXTURES_HPP_ 30 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_tests/include/rosidl_typesupport_introspection_tests/gtest/shared_library_test.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2022 Open Source Robotics Foundation, Inc. 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 ROSIDL_TYPESUPPORT_INTROSPECTION_TESTS__GTEST__SHARED_LIBRARY_TEST_HPP_ 16 | #define ROSIDL_TYPESUPPORT_INTROSPECTION_TESTS__GTEST__SHARED_LIBRARY_TEST_HPP_ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | 24 | namespace rosidl_typesupport_introspection_tests 25 | { 26 | namespace testing 27 | { 28 | 29 | /// A GTest fixture for tests that involve a 30 | /// dynamically loaded shared library. 31 | class SharedLibraryTest : public ::testing::Test 32 | { 33 | public: 34 | explicit SharedLibraryTest(const std::string & name) 35 | : library_(rcpputils::get_platform_library_name(name)) 36 | { 37 | } 38 | 39 | rcpputils::SharedLibrary & GetSharedLibrary() {return library_;} 40 | 41 | private: 42 | rcpputils::SharedLibrary library_; 43 | }; 44 | 45 | } // namespace testing 46 | } // namespace rosidl_typesupport_introspection_tests 47 | 48 | #endif // ROSIDL_TYPESUPPORT_INTROSPECTION_TESTS__GTEST__SHARED_LIBRARY_TEST_HPP_ 49 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_tests/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | rosidl_typesupport_introspection_tests 5 | 4.10.0 6 | Integration tests of the rosidl_typesupport_introspection_c/cpp packages. 7 | 8 | Aditya Pande 9 | Brandon Ong 10 | Dharini Dutia 11 | Shane Loretz 12 | 13 | Apache 2.0 License 14 | 15 | Geoffrey Biggs 16 | Michel Hidalgo 17 | 18 | ament_cmake 19 | 20 | ament_cmake_gtest 21 | ament_lint_auto 22 | ament_lint_common 23 | rcutils 24 | rcpputils 25 | rosidl_cmake 26 | rosidl_generator_c 27 | rosidl_generator_cpp 28 | rosidl_typesupport_introspection_c 29 | rosidl_typesupport_introspection_cpp 30 | rosidl_typesupport_interface 31 | test_interface_files 32 | service_msgs 33 | 34 | 35 | ament_cmake 36 | 37 | 38 | -------------------------------------------------------------------------------- /rosidl_typesupport_introspection_tests/test/test_typesupport_introspection_libraries.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2022 Open Source Robotics Foundation, Inc. 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 "rosidl_typesupport_introspection_tests/gtest/typesupport_library_test.hpp" 18 | 19 | #include "introspection_libraries_under_test.hpp" 20 | 21 | namespace rosidl_typesupport_introspection_tests 22 | { 23 | namespace testing 24 | { 25 | namespace 26 | { 27 | 28 | using IntrospectionTypeSupportLibraries = ::testing::Types< 29 | IntrospectionCTypeSupportTestLibrary, 30 | IntrospectionCppTypeSupportTestLibrary>; 31 | 32 | INSTANTIATE_TYPED_TEST_SUITE_P( 33 | Introspection, TypeSupportLibraryTest, 34 | IntrospectionTypeSupportLibraries); 35 | 36 | } // namespace 37 | } // namespace testing 38 | } // namespace rosidl_typesupport_introspection_tests 39 | --------------------------------------------------------------------------------