Skip to content
15 changes: 11 additions & 4 deletions image_transport/include/image_transport/camera_publisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,20 @@

#include <memory>
#include <string>
#include <utility>

#include "rclcpp/macros.hpp"
#include "rclcpp/node.hpp"

#include "sensor_msgs/msg/image.hpp"
#include "sensor_msgs/msg/camera_info.hpp"

#include "image_transport/single_subscriber_publisher.hpp"
#include "image_transport/visibility_control.hpp"
#include "image_transport/node_interfaces.hpp"

namespace image_transport
{

class ImageTransport;

/**
* \brief Manages advertisements for publishing camera images.
*
Expand All @@ -69,11 +68,19 @@ class CameraPublisher

IMAGE_TRANSPORT_PUBLIC
CameraPublisher(
rclcpp::Node * node,
std::shared_ptr<RequiredInterfaces> node_interfaces,
const std::string & base_topic,
rmw_qos_profile_t custom_qos = rmw_qos_profile_default,
rclcpp::PublisherOptions = rclcpp::PublisherOptions());

template<typename NodeT>
IMAGE_TRANSPORT_PUBLIC
CameraPublisher(
NodeT && node,
const std::string & base_topic,
rmw_qos_profile_t custom_qos = rmw_qos_profile_default)
: CameraPublisher(create_node_interfaces(std::forward<NodeT>(node)), base_topic, custom_qos) {}

/*!
* \brief Returns the number of subscribers that are currently connected to
* this CameraPublisher.
Expand Down
20 changes: 16 additions & 4 deletions image_transport/include/image_transport/camera_subscriber.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@
#include <functional>
#include <memory>
#include <string>
#include <utility>

#include "rclcpp/node.hpp"

#include "sensor_msgs/msg/camera_info.hpp"
#include "sensor_msgs/msg/image.hpp"

#include "image_transport/visibility_control.hpp"
#include "image_transport/node_interfaces.hpp"

namespace image_transport
{

class ImageTransport;

/**
* \brief Manages a subscription callback on synchronized Image and CameraInfo topics.
*
Expand All @@ -71,11 +71,23 @@ class CameraSubscriber

IMAGE_TRANSPORT_PUBLIC
CameraSubscriber(
rclcpp::Node * node,
std::shared_ptr<RequiredInterfaces> node_interfaces,
const std::string & base_topic,
const Callback & callback,
const std::string & transport,
rmw_qos_profile_t custom_qos = rmw_qos_profile_default);

template<typename NodeT>
IMAGE_TRANSPORT_PUBLIC
CameraSubscriber(
NodeT && node,
const std::string & base_topic,
const Callback & callback,
const std::string & transport,
rmw_qos_profile_t = rmw_qos_profile_default);
rmw_qos_profile_t custom_qos = rmw_qos_profile_default)
: CameraSubscriber(create_node_interfaces(std::forward<NodeT>(node)),
base_topic, callback, transport,
custom_qos) {}

/**
* \brief Get the base topic (on which the raw image is published).
Expand Down
70 changes: 70 additions & 0 deletions image_transport/include/image_transport/create_publisher.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright (c) 2009, Willow Garage, Inc.
//
// 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 Willow Garage 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 IMAGE_TRANSPORT__CREATE_PUBLISHER_HPP_
#define IMAGE_TRANSPORT__CREATE_PUBLISHER_HPP_

#include <functional>
#include <memory>
#include <string>
#include <utility>

#include "rclcpp/publisher_options.hpp"

#include "image_transport/camera_publisher.hpp"
#include "image_transport/publisher.hpp"
#include "image_transport/node_interfaces.hpp"
#include "image_transport/visibility_control.hpp"

namespace image_transport
{

/*!
* \brief Advertise an image topic, free function version.
*/
IMAGE_TRANSPORT_PUBLIC
Publisher create_publisher(
std::shared_ptr<RequiredInterfaces> node_interfaces,
const std::string & base_topic,
rmw_qos_profile_t custom_qos = rmw_qos_profile_default,
rclcpp::PublisherOptions options = rclcpp::PublisherOptions());

template<typename NodeT>
Publisher create_publisher(
NodeT && node,
const std::string & base_topic,
rmw_qos_profile_t custom_qos = rmw_qos_profile_default,
rclcpp::PublisherOptions options = rclcpp::PublisherOptions())
{
return create_publisher(
create_node_interfaces(std::forward<NodeT>(node)), base_topic, custom_qos, options);
}

} // namespace image_transport

#endif // IMAGE_TRANSPORT__CREATE_PUBLISHER_HPP_
74 changes: 74 additions & 0 deletions image_transport/include/image_transport/create_subscription.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Copyright (c) 2009, Willow Garage, Inc.
//
// 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 Willow Garage 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 IMAGE_TRANSPORT__CREATE_SUBSCRIPTION_HPP_
#define IMAGE_TRANSPORT__CREATE_SUBSCRIPTION_HPP_

#include <functional>
#include <memory>
#include <string>
#include <utility>

#include "rclcpp/subscription_options.hpp"

#include "image_transport/subscriber.hpp"
#include "image_transport/node_interfaces.hpp"
#include "image_transport/visibility_control.hpp"

namespace image_transport
{

/**
* \brief Subscribe to an image topic, free function version.
*/
IMAGE_TRANSPORT_PUBLIC
Subscriber create_subscription(
std::shared_ptr<RequiredInterfaces> node_interfaces,
const std::string & base_topic,
const Subscriber::Callback & callback,
const std::string & transport,
rmw_qos_profile_t custom_qos = rmw_qos_profile_default,
rclcpp::SubscriptionOptions options = rclcpp::SubscriptionOptions());

template<typename NodeT>
Subscriber create_subscription(
NodeT && node,
const std::string & base_topic,
const Subscriber::Callback & callback,
const std::string & transport,
rmw_qos_profile_t custom_qos = rmw_qos_profile_default,
rclcpp::SubscriptionOptions options = rclcpp::SubscriptionOptions())
{
return create_subscription(
create_node_interfaces(std::forward<NodeT>(node)),
base_topic, callback, transport, custom_qos, options);
}

} // namespace image_transport

#endif // IMAGE_TRANSPORT__CREATE_SUBSCRIPTION_HPP_
Loading