├── .github └── workflows │ ├── BuildTest.yaml │ ├── Release.yaml │ ├── Review.yaml │ └── UpdateWorkflowStatus.yaml ├── .gitignore ├── CHANGELOG.rst ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── dependency.repos ├── include └── pcl_type_adapter │ └── pcl_type_adapter.hpp ├── package.xml ├── src └── pcl_type_adapter.cpp └── test └── test_type_adapter.cpp /.github/workflows/BuildTest.yaml: -------------------------------------------------------------------------------- 1 | name: BuildTest 2 | 3 | on: 4 | schedule: 5 | - cron: 0 0 * * * 6 | pull_request: 7 | workflow_dispatch: 8 | 9 | jobs: 10 | build: 11 | name: build 12 | runs-on: ubuntu-22.04 13 | timeout-minutes: 180 14 | strategy: 15 | fail-fast: false 16 | max-parallel: 8 17 | matrix: 18 | rosdistro: [humble] 19 | include: 20 | # Galactic Geochelone (May 2021 - November 2022) 21 | # - docker_image: rostooling/setup-ros-docker:ubuntu-focal-ros-galactic-ros-base-latest 22 | # rosdistro: galactic 23 | # Humble Hawksbill (May 2022 - May 2027) 24 | - docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-humble-ros-base-latest 25 | rosdistro: humble 26 | # Rolling Ridley 27 | # - docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-rolling-ros-base-latest 28 | # rosdistro: rolling 29 | env: 30 | ROS_DISTRO: ${{ matrix.rosdistro }} 31 | container: 32 | image: ${{ matrix.docker_image }} 33 | steps: 34 | - uses: actions/checkout@v3 35 | with: 36 | fetch-depth: 0 37 | - name: workaround for jammy 38 | if: ${{ matrix.rosdistro == 'humble' }} 39 | run: | 40 | apt remove libunwind-14-dev -y 41 | apt install python3-nose -y 42 | pip uninstall nose -y 43 | - name: install ccache 44 | run: | 45 | apt install -y ccache 46 | - name: Make ccache dir 47 | run: | 48 | mkdir -p /tmp/ccache 49 | - uses: actions/cache@v3 50 | with: 51 | path: /tmp/ccache 52 | key: ccache-${{ matrix.rosdistro }} 53 | - name: Search packages in this repository 54 | id: list_packages 55 | run: | 56 | echo name=package_list::$(colcon list --names-only | sed -e ':loop; N; $!b loop; s/\n/ /g') >> "$GITHUB_OUTPUT" 57 | - name: Show target packages 58 | run: | 59 | echo "Target packages: ${{ steps.list_packages.outputs.package_list }}" 60 | - name: Check dependency-${{ matrix.rosdistro }}.repos existence 61 | id: check_rosdistro_repos_files 62 | uses: andstor/file-existence-action@v1 63 | with: 64 | files: dependency-${{ matrix.rosdistro }}.repos 65 | allow_failure: false 66 | - name: Check dependency.repos existence 67 | id: check_repos_files 68 | uses: andstor/file-existence-action@v1 69 | with: 70 | files: dependency.repos 71 | allow_failure: false 72 | - name: Run build test with dependency-${{ matrix.rosdistro }}.repos 73 | uses: ros-tooling/action-ros-ci@v0.3 74 | if: steps.check_rosdistro_repos_files.outputs.files_exists == 'true' 75 | with: 76 | package-name: ${{ steps.list_packages.outputs.package_list }} 77 | target-ros2-distro: ${{ matrix.rosdistro }} 78 | vcs-repo-file-url: dependency-${{ matrix.rosdistro }}.repos 79 | extra-cmake-args: -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache 80 | env: 81 | CCACHE_DIR: /tmp/ccache 82 | DEVELOP: true 83 | - name: Run build test with dependency.repos 84 | uses: ros-tooling/action-ros-ci@v0.3 85 | if: steps.check_rosdistro_repos_files.outputs.files_exists == 'false' && steps.check_repos_files.outputs.files_exists == 'true' 86 | with: 87 | package-name: ${{ steps.list_packages.outputs.package_list }} 88 | target-ros2-distro: ${{ matrix.rosdistro }} 89 | vcs-repo-file-url: dependency.repos 90 | extra-cmake-args: -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache 91 | env: 92 | CCACHE_DIR: /tmp/ccache 93 | DEVELOP: true 94 | - name: Run build test without .repos file 95 | uses: ros-tooling/action-ros-ci@v0.3 96 | if: steps.check_rosdistro_repos_files.outputs.files_exists == 'false' && steps.check_repos_files.outputs.files_exists == 'false' 97 | with: 98 | package-name: ${{ steps.list_packages.outputs.package_list }} 99 | target-ros2-distro: ${{ matrix.rosdistro }} 100 | extra-cmake-args: -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache 101 | env: 102 | CCACHE_DIR: /tmp/ccache 103 | DEVELOP: true 104 | - name: Notify Slack 105 | uses: 8398a7/action-slack@v2 106 | if: failure() 107 | with: 108 | status: ${{ job.status }} 109 | env: 110 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 111 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} 112 | merge: 113 | name: merge 114 | runs-on: ubuntu-22.04 115 | timeout-minutes: 180 116 | needs: build 117 | steps: 118 | - name: merge PR 119 | if : ${{ (github.event_name == 'pull_request') && (github.actor == 'wam-v-tan') }} 120 | env: 121 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 122 | run: gh pr merge ${{ github.event.pull_request.html_url }} --merge 123 | -------------------------------------------------------------------------------- /.github/workflows/Release.yaml: -------------------------------------------------------------------------------- 1 | # This file is automatically deployed from https://github.com/at-wat/.rospkg-assets. 2 | # Please don't directly edit; update at-wat/.rospkg-assets instead. 3 | 4 | name: Release 5 | on: 6 | issues: 7 | types: [opened, edited] 8 | 9 | jobs: 10 | release: 11 | runs-on: ubuntu-latest 12 | if: startsWith(github.event.issue.title, 'Release ') 13 | steps: 14 | - name: checkout 15 | uses: actions/checkout@v4 16 | - name: create release 17 | id: create_release 18 | uses: at-wat/catkin-release-action@v1 19 | with: 20 | issue_title: ${{ github.event.issue.title }} 21 | git_user: wam-v-tan 22 | git_email: ouxt.share@gmail.com 23 | github_token: ${{ secrets.GITHUB_TOKEN }} 24 | - name: open pull-request 25 | uses: repo-sync/pull-request@v2 26 | id: create_pull_request 27 | with: 28 | source_branch: ${{ steps.create_release.outputs.created_branch }} 29 | destination_branch: ${{ github.event.repository.default_branch }} 30 | pr_title: Release ${{ steps.create_release.outputs.version}} 31 | pr_body: close \#${{ github.event.issue.number }} 32 | pr_assignee: wam-v-tan 33 | github_token: ${{ secrets.WAMV_TAN_BOT_SECRET }} 34 | - name: Enable Pull Request Automerge 35 | uses: peter-evans/enable-pull-request-automerge@v1 36 | with: 37 | token: ${{ secrets.WAMV_TAN_BOT_SECRET }} 38 | pull-request-number: ${{ steps.create_pull_request.outputs.pr_number }} 39 | merge-method: squash 40 | - name: create GitHub release 41 | uses: actions/create-release@v1 42 | continue-on-error: true 43 | env: 44 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 45 | with: 46 | tag_name: ${{ steps.create_release.outputs.version}} 47 | release_name: Release ${{ steps.create_release.outputs.version}} 48 | - name: bloom release 49 | if: github.event.label.name == 'bloom' 50 | id: bloom 51 | uses: at-wat/bloom-release-action@v0 52 | with: 53 | ros_distro: foxy galactic rolling 54 | github_token_bloom: ${{ secrets.WAMV_TAN_BOT_SECRET }} 55 | github_user: wam-v-tan 56 | git_user: wam-v-tan 57 | git_email: ouxt.share@gmail.com 58 | release_repository_push_url: https://github.com/${{ github.repository }}-release.git 59 | tag_and_release: true 60 | open_pr: true 61 | - name: Notify Slack 62 | uses: 8398a7/action-slack@v2 63 | if: failure() 64 | with: 65 | status: ${{ job.status }} 66 | env: 67 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 68 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} 69 | -------------------------------------------------------------------------------- /.github/workflows/Review.yaml: -------------------------------------------------------------------------------- 1 | name: CodeReview 2 | 3 | permissions: 4 | contents: read 5 | pull-requests: write 6 | 7 | on: 8 | pull_request: 9 | types: [review_requested] 10 | 11 | jobs: 12 | review: 13 | runs-on: ubuntu-latest 14 | if: ${{ github.event.requested_reviewer.login == 'wam-v-tan' }} 15 | steps: 16 | - uses: OUXT-Polaris/chatgpt-github-actions@main 17 | with: 18 | openai_api_key: ${{ secrets.OPENAI_API_KEY }} 19 | github_token: ${{ secrets.WAMV_TAN_BOT_SECRET }} 20 | github_pr_id: ${{ github.event.number }} 21 | openai_engine: "gpt-3.5-turbo" #optional 22 | openai_temperature: 0.5 #optional 23 | openai_max_tokens: 2048 #optional 24 | mode: review 25 | -------------------------------------------------------------------------------- /.github/workflows/UpdateWorkflowStatus.yaml: -------------------------------------------------------------------------------- 1 | name: UpdateDashboard 2 | on: 3 | pull_request: 4 | paths-ignore: 5 | - ".github/workflows/UpdateWorkflowStatus.yaml" 6 | - ".github/workflows/BuildTest.yaml" 7 | - ".github/workflows/Release.yaml" 8 | - ".github/workflows/Review.yaml" 9 | workflow_dispatch: 10 | 11 | jobs: 12 | build: 13 | name: UpdateDashboard 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: benc-uk/workflow-dispatch@v1 17 | with: 18 | # You should create a personal access token and store it in your repository 19 | token: ${{ secrets.WAMV_TAN_BOT_SECRET }} 20 | repo: OUXT-Polaris/ouxt_automation 21 | workflow: document 22 | ref: master 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | -------------------------------------------------------------------------------- /CHANGELOG.rst: -------------------------------------------------------------------------------- 1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 | Changelog for package pcl_type_adapter 3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 4 | 5 | 0.1.0 (2024-04-20) 6 | ------------------ 7 | * Merge pull request `#4 `_ from OUXT-Polaris/feature/initialize_pointer 8 | Feature/initialize pointer 9 | * Merge remote-tracking branch 'origin/master' into feature/use_stl 10 | * add initialize pointer 11 | * Merge pull request `#3 `_ from OUXT-Polaris/feature/use_stl 12 | Feature/use stl 13 | * use stl 14 | * use stl 15 | * Contributors: Masaya Kataoka, hakuturu583 16 | 17 | 0.0.2 (2024-04-15) 18 | ------------------ 19 | * fix README 20 | * Merge pull request `#2 `_ from OUXT-Polaris/feature/zero_copy 21 | Feature/zero copy 22 | * change supporting pointer passing 23 | * fix compile error 24 | * fix compile error 25 | * update test code 26 | * Contributors: Masaya Kataoka, hakuturu583 27 | 28 | 0.0.1 (2024-04-15) 29 | ------------------ 30 | * add repos file 31 | * update README 32 | * update README 33 | * update README 34 | * update .gitignore 35 | * update CONTRIBUTING.md 36 | * enable zero-copy pcl point cloud 37 | * Contributors: Masaya Kataoka 38 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8) 2 | project(pcl_type_adapter) 3 | 4 | if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") 5 | add_compile_options(-Wall -Wextra -Wpedantic) 6 | endif() 7 | 8 | # find dependencies 9 | find_package(ament_cmake_auto REQUIRED) 10 | find_package(PCL REQUIRED) 11 | 12 | ament_auto_find_build_dependencies() 13 | 14 | include_directories( 15 | include 16 | ${PCL_INCLUDE_DIRS} 17 | ) 18 | 19 | link_directories( 20 | ${PCL_LIBRARY_DIRS} 21 | ) 22 | 23 | ament_auto_add_library(${PROJECT_NAME} SHARED 24 | src/pcl_type_adapter.cpp 25 | ) 26 | target_link_libraries(${PROJECT_NAME} ${PCL_LIBRARIES}) 27 | 28 | if(BUILD_TESTING) 29 | find_package(ament_lint_auto REQUIRED) 30 | ament_lint_auto_find_test_dependencies() 31 | find_package(ament_cmake_gtest REQUIRED) 32 | ament_auto_add_gtest(test_type_adapter test/test_type_adapter.cpp) 33 | target_link_libraries(test_type_adapter ${PROJECT_NAME}) 34 | endif() 35 | 36 | ament_auto_package() 37 | -------------------------------------------------------------------------------- /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 | ~~~ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pcl_type_adapter 2 | 3 | ROS 2 package of type adapter for transferring point clouds via zero-copy communication. 4 | 5 | ## How to use. 6 | 7 | ### Publish pointcloud 8 | 9 | ```cpp 10 | class PubNode : public rclcpp::Node 11 | { 12 | public: 13 | using AdaptedType = rclcpp::TypeAdapter; 14 | explicit PubNode(const rclcpp::NodeOptions & options) : Node("test", options) 15 | { 16 | publisher_ = create_publisher("pointcloud", 1); 17 | } 18 | void publish(const pcl::PointCloud::PointXYZ::Ptr & point_cloud) { publisher_->publish(point_cloud); } 19 | 20 | private: 21 | std::shared_ptr> publisher_; 22 | }; 23 | ``` 24 | 25 | ### Subscribe pointcloud 26 | 27 | ```cpp 28 | class SubNode : public rclcpp::Node 29 | { 30 | public: 31 | using AdaptedType = rclcpp::TypeAdapter; 32 | explicit SubNode( 33 | const rclcpp::NodeOptions & options) 34 | : Node("test", options) 35 | { 36 | subscriber_ = create_subscription("pointcloud", 1, [](const auto & pointcloud){}); 37 | } 38 | 39 | private: 40 | std::shared_ptr> subscriber_; 41 | }; 42 | ``` 43 | -------------------------------------------------------------------------------- /dependency.repos: -------------------------------------------------------------------------------- 1 | repositories: 2 | -------------------------------------------------------------------------------- /include/pcl_type_adapter/pcl_type_adapter.hpp: -------------------------------------------------------------------------------- 1 | // Copyright 2024 OUXT Polaris. All rights reserved. 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 PCL_TYPE_ADAPTER__PCL_TYPE_ADAPTER_HPP_ 16 | #define PCL_TYPE_ADAPTER__PCL_TYPE_ADAPTER_HPP_ 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | template 24 | struct rclcpp::TypeAdapter, sensor_msgs::msg::PointCloud2> 25 | { 26 | using is_specialized = std::true_type; 27 | using custom_type = std::shared_ptr; 28 | using ros_message_type = sensor_msgs::msg::PointCloud2; 29 | 30 | static void convert_to_ros_message(const custom_type & source, ros_message_type & destination) 31 | { 32 | pcl::toROSMsg(*source, destination); 33 | } 34 | 35 | static void convert_to_custom(const ros_message_type & source, custom_type & destination) 36 | { 37 | destination = std::shared_ptr(new PCL_POINTCLOUD_TYPE); 38 | pcl::fromROSMsg(source, *destination); 39 | } 40 | }; 41 | 42 | #endif // PCL_TYPE_ADAPTER__PCL_TYPE_ADAPTER_HPP_ 43 | -------------------------------------------------------------------------------- /package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | pcl_type_adapter 5 | 0.1.0 6 | TODO: Package description 7 | masaya 8 | Apache-2.0 9 | 10 | ament_cmake 11 | 12 | ament_cmake_auto 13 | rclcpp 14 | pcl_conversions 15 | sensor_msgs 16 | 17 | ament_lint_auto 18 | ouxt_lint_common 19 | ament_cmake_gtest 20 | 21 | 22 | ament_cmake 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/pcl_type_adapter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2024 OUXT Polaris. All rights reserved. 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 | -------------------------------------------------------------------------------- /test/test_type_adapter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2024 OUXT Polaris. All rights reserved. 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 18 | #include 19 | 20 | namespace pcl_type_adapter 21 | { 22 | template 23 | class PubNode : public rclcpp::Node 24 | { 25 | public: 26 | using AdaptedType = 27 | rclcpp::TypeAdapter, sensor_msgs::msg::PointCloud2>; 28 | explicit PubNode(const rclcpp::NodeOptions & options) : Node("test", options) 29 | { 30 | publisher_ = create_publisher("pointcloud", 1); 31 | } 32 | void publish(const std::shared_ptr & point_cloud) 33 | { 34 | publisher_->publish(point_cloud); 35 | } 36 | 37 | private: 38 | std::shared_ptr> publisher_; 39 | }; 40 | 41 | template 42 | class SubNode : public rclcpp::Node 43 | { 44 | public: 45 | using AdaptedType = 46 | rclcpp::TypeAdapter, sensor_msgs::msg::PointCloud2>; 47 | explicit SubNode( 48 | const rclcpp::NodeOptions & options, 49 | const std::function &)> function) 50 | : Node("test", options) 51 | { 52 | subscriber_ = create_subscription("pointcloud", 1, function); 53 | } 54 | 55 | private: 56 | std::shared_ptr> subscriber_; 57 | }; 58 | 59 | #define DEFINE_PUB_SUB_TEST(POINT_TYPE) \ 60 | TEST(TypeAdaptaer, POINT_TYPE) \ 61 | { \ 62 | bool point_cloud_recieved = false; \ 63 | rclcpp::init(0, nullptr); \ 64 | rclcpp::NodeOptions options; \ 65 | options.use_intra_process_comms(true); \ 66 | const auto pub_point_cloud = \ 67 | std::shared_ptr>(new pcl::PointCloud); \ 68 | auto sub_node = std::make_shared>>( \ 69 | options, [&](const std::shared_ptr> & point_cloud) { \ 70 | EXPECT_TRUE(pub_point_cloud == point_cloud); \ 71 | RCLCPP_INFO_STREAM(rclcpp::get_logger("pub : "), pub_point_cloud); \ 72 | RCLCPP_INFO_STREAM(rclcpp::get_logger("sub : "), point_cloud); \ 73 | point_cloud_recieved = true; \ 74 | }); \ 75 | auto pub_node = std::make_shared>>(options); \ 76 | pub_node->publish(pub_point_cloud); \ 77 | rclcpp::executors::SingleThreadedExecutor exec; \ 78 | exec.add_node(sub_node); \ 79 | exec.add_node(pub_node); \ 80 | exec.spin_some(); \ 81 | rclcpp::shutdown(); \ 82 | EXPECT_TRUE(point_cloud_recieved); \ 83 | } 84 | 85 | DEFINE_PUB_SUB_TEST(PointXYZ) 86 | DEFINE_PUB_SUB_TEST(PointXYZI) 87 | DEFINE_PUB_SUB_TEST(PointXYZRGB) 88 | DEFINE_PUB_SUB_TEST(PointXYZRGBA) 89 | 90 | #undef DEFINE_PUB_SUB_TEST 91 | } // namespace pcl_type_adapter 92 | 93 | int main(int argc, char ** argv) 94 | { 95 | testing::InitGoogleTest(&argc, argv); 96 | return RUN_ALL_TESTS(); 97 | } 98 | --------------------------------------------------------------------------------