Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions image_transport_plugins/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<exec_depend>compressed_depth_image_transport</exec_depend>
<exec_depend>compressed_image_transport</exec_depend>
<exec_depend>theora_image_transport</exec_depend>
<exec_depend>zlib_image_transport</exec_depend>
<exec_depend>zstd_image_transport</exec_depend>

<export>
Expand Down
57 changes: 57 additions & 0 deletions zlib_image_transport/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
cmake_minimum_required(VERSION 3.20)

project(zlib_image_transport)

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
find_package(image_transport REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(ZLIB REQUIRED)

include_directories(include)

add_library(
${PROJECT_NAME} SHARED
src/zlib_wrapper.cpp
src/zlib_publisher.cpp
src/zlib_subscriber.cpp
src/manifest.cpp
)

target_link_libraries(${PROJECT_NAME}
ZLIB::ZLIB
image_transport::image_transport
rclcpp::rclcpp
pluginlib::pluginlib
${sensor_msgs_TARGETS}
)

install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

install(
DIRECTORY "include/"
DESTINATION include
)

pluginlib_export_plugin_description_file(image_transport zlib_plugins.xml)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()
48 changes: 48 additions & 0 deletions zlib_image_transport/include/zlib_image_transport/zlib_common.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright (c) 2026, 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 ZLIB_IMAGE_TRANSPORT__ZLIB_COMMON_HPP_
#define ZLIB_IMAGE_TRANSPORT__ZLIB_COMMON_HPP_

#include <rclcpp/parameter_value.hpp>
#include <rcl_interfaces/msg/parameter_descriptor.hpp>

namespace zlib_image_transport
{
using ParameterDescriptor = rcl_interfaces::msg::ParameterDescriptor;
using ParameterValue = rclcpp::ParameterValue;

struct ParameterDefinition
{
const ParameterValue defaultValue;
const ParameterDescriptor descriptor;
};
} // namespace zlib_image_transport

#endif // ZLIB_IMAGE_TRANSPORT__ZLIB_COMMON_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright (c) 2026, 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 ZLIB_IMAGE_TRANSPORT__ZLIB_PUBLISHER_HPP_
#define ZLIB_IMAGE_TRANSPORT__ZLIB_PUBLISHER_HPP_

#include <string>
#include <vector>
#include <unordered_set>

#include <sensor_msgs/msg/image.hpp>
#include <sensor_msgs/msg/compressed_image.hpp>
#include <image_transport/node_interfaces.hpp>
#include <image_transport/simple_publisher_plugin.hpp>

#include <rclcpp/node.hpp>

#include "zlib_image_transport/zlib_common.hpp"

namespace zlib_image_transport
{

using CompressedImage = sensor_msgs::msg::CompressedImage;
using ParameterEvent = rcl_interfaces::msg::ParameterEvent;

class ZlibPublisher : public image_transport::SimplePublisherPlugin<CompressedImage>
{
public:
ZlibPublisher();
~ZlibPublisher() override = default;

std::string getTransportName() const override;

protected:
void advertiseImpl(
image_transport::RequiredInterfaces node_interfaces,
const std::string & base_topic,
rclcpp::QoS custom_qos,
rclcpp::PublisherOptions options) final;

void publish(
const sensor_msgs::msg::Image & message,
const PublisherT & publisher) const override;

rclcpp::Logger logger_;
rclcpp::node_interfaces::NodeParametersInterface::SharedPtr node_param_interface_;
rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_base_interface_;

private:
std::vector<std::string> parameters_;
std::unordered_set<std::string> deprecated_parameters_;

rclcpp::node_interfaces::PreSetParametersCallbackHandle::SharedPtr
pre_set_parameter_callback_handle_;

void declareParameter(
const std::string & base_name,
const ParameterDefinition & definition);

void preSetParametersCallback(std::vector<rclcpp::Parameter> & parameters);
};

} // namespace zlib_image_transport

#endif // ZLIB_IMAGE_TRANSPORT__ZLIB_PUBLISHER_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright (c) 2026, 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 ZLIB_IMAGE_TRANSPORT__ZLIB_SUBSCRIBER_HPP_
#define ZLIB_IMAGE_TRANSPORT__ZLIB_SUBSCRIBER_HPP_

#include <string>
#include <vector>

#include <rclcpp/node.hpp>
#include <rclcpp/subscription_options.hpp>

#include <sensor_msgs/msg/image.hpp>
#include <sensor_msgs/msg/compressed_image.hpp>
#include <image_transport/node_interfaces.hpp>
#include <image_transport/simple_subscriber_plugin.hpp>

#include "zlib_image_transport/zlib_common.hpp"

namespace zlib_image_transport
{

using ParameterEvent = rcl_interfaces::msg::ParameterEvent;

class ZlibSubscriber final
: public image_transport::SimpleSubscriberPlugin<sensor_msgs::msg::CompressedImage>
{
public:
ZlibSubscriber();
virtual ~ZlibSubscriber() = default;

std::string getTransportName() const override;

protected:
void subscribeImpl(
image_transport::RequiredInterfaces node_interfaces,
const std::string & base_topic,
const Callback & callback,
rclcpp::QoS custom_qos,
rclcpp::SubscriptionOptions options) override;

void internalCallback(
const sensor_msgs::msg::CompressedImage::ConstSharedPtr & message,
const Callback & user_cb) override;

rclcpp::Logger logger_;
};

} // namespace zlib_image_transport

#endif // ZLIB_IMAGE_TRANSPORT__ZLIB_SUBSCRIBER_HPP_
29 changes: 29 additions & 0 deletions zlib_image_transport/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<package format="2">
<name>zlib_image_transport</name>
<version>6.2.2</version>
<description>
zlib_image_transport provides a plugin to image_transport for transparently sending images
encoded as zlib (deflate) blobs.
</description>
<maintainer email="acordero@honurobotics.com">Alejandro Hernandez Cordero</maintainer>
<license>BSD</license>

<url type="website">https://docs.ros.org/en/rolling/p/image_transport/</url>
<author>Alejandro Hernandez Cordero</author>

<buildtool_depend>ament_cmake</buildtool_depend>

<depend>image_transport</depend>
<depend>pluginlib</depend>
<depend>rclcpp</depend>
<depend>sensor_msgs</depend>
<depend>zlib</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
<image_transport plugin="${prefix}/zlib_plugins.xml" />
</export>
</package>
35 changes: 35 additions & 0 deletions zlib_image_transport/src/manifest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2026, 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 <pluginlib/class_list_macros.hpp>
#include "zlib_image_transport/zlib_publisher.hpp"
#include "zlib_image_transport/zlib_subscriber.hpp"

PLUGINLIB_EXPORT_CLASS(zlib_image_transport::ZlibPublisher, image_transport::PublisherPlugin)
PLUGINLIB_EXPORT_CLASS(zlib_image_transport::ZlibSubscriber, image_transport::SubscriberPlugin)
Loading
Loading