From f61793f4193d6362885a225be14fb504606f3ec3 Mon Sep 17 00:00:00 2001 From: john-maidbot Date: Sun, 10 Sep 2023 18:58:23 -0500 Subject: [PATCH] Create plugin tutorial --- README.md | 2 + plugin_template/CMakeLists.txt | 58 +++++++++ plugin_template/COLCON_IGNORE | 0 plugin_template/README.md | 116 ++++++++++++++++++ .../template_publisher.hpp | 74 +++++++++++ .../template_subscriber.hpp | 71 +++++++++++ plugin_template/package.xml | 31 +++++ plugin_template/src/manifest.cpp | 46 +++++++ plugin_template/src/template_publisher.cpp | 66 ++++++++++ plugin_template/src/template_subscriber.cpp | 66 ++++++++++ plugin_template/template_plugins.xml | 19 +++ 11 files changed, 549 insertions(+) create mode 100644 plugin_template/CMakeLists.txt create mode 100644 plugin_template/COLCON_IGNORE create mode 100644 plugin_template/README.md create mode 100644 plugin_template/include/template_point_cloud_transport/template_publisher.hpp create mode 100644 plugin_template/include/template_point_cloud_transport/template_subscriber.hpp create mode 100644 plugin_template/package.xml create mode 100644 plugin_template/src/manifest.cpp create mode 100644 plugin_template/src/template_publisher.cpp create mode 100644 plugin_template/src/template_subscriber.cpp create mode 100644 plugin_template/template_plugins.xml diff --git a/README.md b/README.md index 343cf8e..75e93bb 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,5 @@ Currently provided are: - [zstd_point_cloud_transport](https://github.com/ros-perception/point_cloud_transport_plugins/tree/master/zstd_point_cloud_transport) - A library using ZSTD to compress the pointclouds. More transports can be added. Pull requests are welcome! + +If it is not clear how to write a custom transport plugin, please see the `plugin_template` directory. This provides a template as well as written instructions for writing a custom transport plugin. diff --git a/plugin_template/CMakeLists.txt b/plugin_template/CMakeLists.txt new file mode 100644 index 0000000..4d630ae --- /dev/null +++ b/plugin_template/CMakeLists.txt @@ -0,0 +1,58 @@ +# TODO (YourNameHere): This is not a working CMake Project! +# Some assembly required for your plugin. (-: + +cmake_minimum_required(VERSION 3.10.2) + +set(CMAKE_CXX_STANDARD 17) + +project(template_point_cloud_transport) + +find_package(ament_cmake REQUIRED) +find_package(pluginlib REQUIRED) +find_package(point_cloud_interfaces REQUIRED) +find_package(point_cloud_transport REQUIRED) +find_package(rclcpp REQUIRED) +# TODO (YourNameHere): You might need more dependencies + +set(dependencies + pluginlib + point_cloud_interfaces + point_cloud_transport + rclcpp +) + + +include_directories(include) + +add_library(${PROJECT_NAME} + SHARED + # TODO (YourNameHere): You might need more source files + src/manifest.cpp + src/template_publisher.cpp + src/template_subscriber.cpp +) + +ament_target_dependencies(${PROJECT_NAME} ${dependencies}) + +install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION lib/${PROJECT_NAME} +) + +install( + DIRECTORY include/${PROJECT_NAME}/ + DESTINATION include/${PROJECT_NAME} +) + +pluginlib_export_plugin_description_file(point_cloud_transport template_plugins.xml) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + ament_lint_auto_find_test_dependencies() +endif() + +ament_export_include_directories(include) +ament_export_libraries(${PROJECT_NAME}) +ament_export_dependencies(${dependencies}) +ament_package() diff --git a/plugin_template/COLCON_IGNORE b/plugin_template/COLCON_IGNORE new file mode 100644 index 0000000..e69de29 diff --git a/plugin_template/README.md b/plugin_template/README.md new file mode 100644 index 0000000..3aef063 --- /dev/null +++ b/plugin_template/README.md @@ -0,0 +1,116 @@ +# \ +**ROS2 v0.1.** + +This repository serves as a tutorial on how to create a custom plugin for . It assumes that you already have a working installation. + +This is the spiritual successor to: https://github.com/paplhjak/templateplugin_point_cloud_transport and is heavily derived from it. In the ROS2 port, we opted to migrate the plugin tutorial but move it right next to the plugin code to avoid the instructions going stale. It is worth noting that there is nothing stopping the plugin you write from existing in a separate package or repo from . + +## 1) Plugin naming +Each plugin needs its own name. It should be short and descriptive. + +For example: [draco_point_cloud_transport](https://github.com/ros-perception/point_cloud_transport_plugins/tree/rolling/draco_point_cloud_transport) is a plugin which uses Google [Draco](https://github.com/google/draco) compression, therefore the name **draco**. + +For demonstrative purposes, the plugin which we will be going through in this tutorial has used the name **template**. And we will be modifying the template to make our own plugin named **goblin**. + +## 2) Setup your plugin package + +Each transport plugin is its own ROS2 package. To create your own plugin package, let's clone the repo and make a copy of `plugin_template`: + +```bash +$ cd /point_cloud_transport_ws/src +$ git clone https://github.com/ros-perception/point_cloud_transport_plugins.git +$ cp point_cloud_transport_plugins/plugin_template point_cloud_transport_plugins/goblin_point_cloud_transport +``` + +## 3) Time for Pattern Matching + +This template uses the plugin name **template**, which is referenced repeatedly in the source files. The files and classes implemented within the plugin follow a strict naming convention, inheriting from the name of the plugin. To follow the convention, we will replace each instance of **template** with the name of our new plugin. This can be done quickly using a case-sensitive find and replace tool. Most editors can invoke this tool. Once you make sure that the find is case-sensitive, go through the files in *ONLY* the folder, and make the following replacements: + +``` +1. TEMPLATE -> GOBLIN +2. Template -> Goblin +3. template_ -> goblin_ +``` + +You can also rename the files within the folder to match this convention. i.e. +``` +1. *template_plugins.xml* +2. *src/template_publisher.cpp* +3. *src/template_subscriber.cpp* +4. *include/template_point_cloud_transport/template_publisher.hpp* +5. *include/template_point_cloud_transport/template_subscriber.hpp* +``` + +Be sure to double checkt that the CMakeLists.txt file points the expected files and that all the `#include`'s are still in order. + +## 4) Custom Message (Optional) + +Although making your own compressed message type is an option, please check first to see if any existing compressed PointCloud2 message types already meet your needs. If they do, replace any instance of `CustomMessage` in the template package with that message's name, e.g. for `CompressedPointCloud2` (do not forget to check the #include's) + +``` +CustomMessage -> CompressedPointCloud2 +``` + +If you do need a custom message, let's assume it is called **GobMessage**. See here if you are not familiar with defining a custom ROS2 message: https://docs.ros.org/en/rolling/index.html. +Once you have defined your **GobMessage**, go through the following files (do not forget to check the #include's): + +1. *goblin_publisher.h* +2. *goblin_subscriber.h* +3. *CMakeLists.txt* +4. *goblin_publisher.cpp* +5. *goblin_subscriber.cpp* + +and use the find and replace tool to replace the original name of **CustomMessage** with **GobMessage**. + +``` +CustomMessage -> GobMessage +``` + +## 5) Implementing Publisher Functionality + +Implementation of the publisher can be located in *src/goblin_publisher.cpp* within function *encodeTyped*. + +The encodeTyped function takes in a sensor_msgs::msg::PointCloud2 message, compresses it and converts the compressed data into our plugin's message format (see Step 4). You might have noticed that the plugin is only concerned with the compression / conversion process and does not call publish. This was done intentionally to separate concerns between plugin implementation and core point_cloud_transport functionality. + +## 6) Implementing Subscriber Functionality + +Implementation of the subscriber can be located in *src/goblin_subscriber.cpp* within function *decodeTyped*. + +The *decodeTyped* function takes in our plugin's message format, decompresses the data and converts it into a sensor_msgs::msg::PointCloud2. Once the point cloud message is ready, it is passed on to the subscriber callback. Just like in the publisher plugin, the subscriber plugin is only concerned with decoding and conversion. It does not actually call the subscriber callback. + +## 7) Description of Plugin + +Before we distribute our plugin, it is important that we fill in all the necessary information about it. + +In goblin_plugins.xml, make sure to provide a brief description of both the publisher and the subscriber our plugin uses. + +Then fill out the package.xml. If you are unfamiliar with how to do this, see here please: https://docs.ros.org/en/rolling/Tutorials/Beginner-Client-Libraries/Creating-Your-First-ROS2-Package.html#customize-package-xml. + +## 8) Build time! + +At this point your plugin should be able to succesfully compile, build, and be recognized by [](https://github.com/ros-perception/point_cloud_transport). + +First, delete the COLCON_IGNORE file in (otherwise your package will be ignored). + +Build the plugin. + +```bash +$ cd /point_cloud_transport_ws +$ colcon build --merge-install --event-handlers console_direct+ +``` + +Then check all plugins currently available on your system by running the command: + +``` bash +ros2 run point_cloud_transport list_transports +``` + +Do you see your plugin? If not, please look back through these instructions and through the plugin code to verify you replaced all the instances of **template** with **goblin** and that the CMakeLists.txt and package.xml files are up to date w.r.t. file naming and any dependencies you have added. + +Support +======= + +If you have found an error in these instructions, please file an issue at: [https://github.com/ros-perception/point_cloud_transport/issues]() + +Patches are encouraged, and may be submitted by forking this project and +submitting a pull request through GitHub. Any help is further development of the project is much appreciated. diff --git a/plugin_template/include/template_point_cloud_transport/template_publisher.hpp b/plugin_template/include/template_point_cloud_transport/template_publisher.hpp new file mode 100644 index 0000000..ff654d0 --- /dev/null +++ b/plugin_template/include/template_point_cloud_transport/template_publisher.hpp @@ -0,0 +1,74 @@ +/* + * Copyright (c) , (if desired) + * Copyright (c) 2023, Open Source Robotics Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TEMPLATE_POINT_CLOUD_TRANSPORT__TEMPLATE_PUBLISHER_HPP_ +#define TEMPLATE_POINT_CLOUD_TRANSPORT__TEMPLATE_PUBLISHER_HPP_ + +#include + +#include + +#include + +#include +#include + + +namespace template_point_cloud_transport +{ + +// CustomMessage could be any ROS2 message. +// e.g. point_cloud_interfaces::msg::CompressedPointCloud2, or you can make a new one. If you do, please +// add the definiton to point_cloud_interfaces. +class TemplatePublisher + : public point_cloud_transport::SimplePublisherPlugin< + point_cloud_interfaces::msg::CustomMessage> +{ +public: + std::string getTransportName() const override; + + void declareParameters(const std::string & base_topic) override; + + std::string getDataType() const override + { + // return the name of whichever message you chose as a string + return "point_cloud_interfaces/msg/CustomMessage"; + } + + TypedEncodeResult encodeTyped(const sensor_msgs::msg::PointCloud2 & raw) const override; + +private: + // good place to put any internal variables (e.g. compression algo parameters) +}; +} // namespace template_point_cloud_transport + +#endif // TEMPLATE_POINT_CLOUD_TRANSPORT__TEMPLATE_PUBLISHER_HPP_ diff --git a/plugin_template/include/template_point_cloud_transport/template_subscriber.hpp b/plugin_template/include/template_point_cloud_transport/template_subscriber.hpp new file mode 100644 index 0000000..44d57c7 --- /dev/null +++ b/plugin_template/include/template_point_cloud_transport/template_subscriber.hpp @@ -0,0 +1,71 @@ +/* + * Copyright (c) , (if desired) + * Copyright (c) 2023, Open Source Robotics Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TEMPLATE_POINT_CLOUD_TRANSPORT__TEMPLATE_SUBSCRIBER_HPP_ +#define TEMPLATE_POINT_CLOUD_TRANSPORT__TEMPLATE_SUBSCRIBER_HPP_ + +#include + +#include + +#include +#include + +namespace template_point_cloud_transport +{ + +// CustomMessage could be any ROS2 message. +// e.g. point_cloud_interfaces::msg::CompressedPointCloud2, or you can make a new one. If you do, please +// add the definiton to point_cloud_interfaces. +class TemplateSubscriber + : public point_cloud_transport::SimpleSubscriberPlugin< + point_cloud_interfaces::msg::CustomMessage> +{ +public: + std::string getTransportName() const override; + + void declareParameters() override; + + std::string getDataType() const override + { + // return the name of whichever message you chose as a string + return "point_cloud_interfaces/msg/CustomMessage"; + } + + DecodeResult decodeTyped(const point_cloud_interfaces::msg::CustomMessage & compressed) + const override; +private: + // good place to put any internal variables (e.g. decompression algo parameters) +}; +} // namespace template_point_cloud_transport + +#endif // TEMPLATE_POINT_CLOUD_TRANSPORT__TEMPLATE_SUBSCRIBER_HPP_ diff --git a/plugin_template/package.xml b/plugin_template/package.xml new file mode 100644 index 0000000..5051bec --- /dev/null +++ b/plugin_template/package.xml @@ -0,0 +1,31 @@ + + template_point_cloud_transport + 0.0.0 + + template_point_cloud_transport is not a real transport plugin. It is just a template to reference when + making new point_cloud_transport plugins. + + YourNameHere + YourNameHere + BSD + + https://github.com/rolling/point_cloud_transport_plugins + + ament_cmake + + pluginlib + + pluginlib + + + point_cloud_interfaces + point_cloud_transport + rclcpp + + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/plugin_template/src/manifest.cpp b/plugin_template/src/manifest.cpp new file mode 100644 index 0000000..ca1894a --- /dev/null +++ b/plugin_template/src/manifest.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023, Czech Technical University in Prague + * Copyright (c) 2019, paplhjak + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include +#include + +#include +#include + +PLUGINLIB_EXPORT_CLASS( + template_point_cloud_transport::TemplatePublisher, + point_cloud_transport::PublisherPlugin) +PLUGINLIB_EXPORT_CLASS( + template_point_cloud_transport::TemplateSubscriber, + point_cloud_transport::SubscriberPlugin) diff --git a/plugin_template/src/template_publisher.cpp b/plugin_template/src/template_publisher.cpp new file mode 100644 index 0000000..61b1fc3 --- /dev/null +++ b/plugin_template/src/template_publisher.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) , (if desired) + * Copyright (c) 2023, Open Source Robotics Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +namespace template_point_cloud_transport +{ + +void TemplatePublisher::declareParameters(const std::string & base_topic) +{ + // Although not required, it is often useful to expose static or dynamically configurable + // parameters to control your compression algorithm speed and output quality. +} + +std::string TemplatePublisher::getTransportName() const +{ + // This should match the name of your transport's prefix. + // e.g. for template_point_cloud_transport, the prefix is template + return "template"; +} + +TemplatePublisher::TypedEncodeResult TemplatePublisher::encodeTyped( + const sensor_msgs::msg::PointCloud2 & raw) const +{ + point_cloud_interfaces::msg::CustomMessage compressed; + + // Add your compression code here! + // turtle.compress(msg, result); + + // Although not required, it is often convenient to implement your compression + // algo in a separate file and call it here. This keeps your code + // clean and easy to read. + + return compressed; +} + +} // namespace template_point_cloud_transport diff --git a/plugin_template/src/template_subscriber.cpp b/plugin_template/src/template_subscriber.cpp new file mode 100644 index 0000000..2f7dda8 --- /dev/null +++ b/plugin_template/src/template_subscriber.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) , (if desired) + * Copyright (c) 2023, Open Source Robotics Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + +#include + +namespace template_point_cloud_transport +{ +void TemplateSubscriber::declareParameters() +{ + // Although not required, it is often useful to expose static or dynamically configurable + // parameters to control your compression algorithm speed and output quality. +} + +std::string TemplateSubscriber::getTransportName() const +{ + // This should match the name of your transport's prefix. + // e.g. for template_point_cloud_transport, the prefix is template + return "template"; +} + +TemplateSubscriber::DecodeResult TemplateSubscriber::decodeTyped( + const point_cloud_interfaces::msg::CustomMessage & msg) const +{ + auto result = std::make_shared(); + + // Add your decompression code here! + // turtle.decompress(msg, result); + + // Although not required, it is often convenient to implement your decompression + // algo in a separate file and call it here. This keeps your code + // clean and easy to read. + + return result; +} + +} // namespace template_point_cloud_transport diff --git a/plugin_template/template_plugins.xml b/plugin_template/template_plugins.xml new file mode 100644 index 0000000..55bb387 --- /dev/null +++ b/plugin_template/template_plugins.xml @@ -0,0 +1,19 @@ + + + + This plugin publishes a CustomMessage using the awesome power of turtles. + + + + + + This plugin decompresses a CustomMessage topic, also using turtles. + + +