Template Class ImageSubscriber
Defined in File image_subscriber.hpp
Inheritance Relationships
Base Types
public fkie_message_filters::SubscriberBase(Class SubscriberBase)public fkie_message_filters::Source< RosMessageSharedPtr< sensor_msgs::msg::Image >::FilterType >(Template Class Source)
Class Documentation
-
template<template<typename> class Translate = RosMessageSharedPtr>
class ImageSubscriber : public fkie_message_filters::SubscriberBase, public fkie_message_filters::Source<RosMessageSharedPtr<sensor_msgs::msg::Image>::FilterType> Subscribe to a ROS image topic as data provider.
This is a specialized subscriber that uses image_transport to subscribe to a ROS image topic. All messages which are received on the subscribed topic will be passed to the connected sinks for further processing. For maximum flexibility, you can choose how to pass the received messages:
ImagePublisher<RosMessageSharedPtr>will act as a source ofsensor_msgs::msg::Image::ConstSharedPtrobjects (default)ImagePublisher<RosMessage>will act as a source of plainsensor_msgs::msg::Imageobjects
See also
Public Types
Public Functions
-
inline ImageSubscriber() noexcept
Constructs an empty subscriber.
You need to call set_subscribe_options() and either subscribe() or subscribe_on_demand() to actually subscribe to a ROS topic.
Does not throw any exceptions.
-
template<class NodeT>
FKIE_MF_BEGIN_ABI_NAMESPACE ImageSubscriber(NodeT &&node, const std::string &base_topic, const rclcpp::QoS &qos, const std::optional<image_transport::TransportHints> &transport_hints, const rclcpp::SubscriptionOptions &options)
-
template<class NodeT>
ImageSubscriber(NodeT &&node, const std::string &base_topic, const rclcpp::QoS &qos = rclcpp::QoS(rclcpp::KeepLast(10), rmw_qos_profile_default), const std::optional<image_transport::TransportHints> &transport_hints = std::nullopt, const rclcpp::SubscriptionOptions &options = rclcpp::SubscriptionOptions()) Constructor that subscribes to the given ROS image topic.
This constructor calls set_subscribe_options() and subscribe() for you.
nodea node instance to handle the subscriptionbase_topicname of the ROS image topic, subject to remappingqosthe ROS quality of service specificationtransport_hintstransport hints for the ROS image_transport frameworkoptionsROS subscription options
Does not throw any exceptions, but will propagate exceptions from the ROS middleware layer.
-
Connection connect_to_sink(Sink<Outputs...> &dst) noexcept
Connect this source to a sink.
Can be called multiple times to connect multiple sinks; in that case, the sinks receive data in the same order as they have been connected. This function does basically the same thing as Sink::connect_to_source(), only from the opposite point of view.
dstthe sink that is to be connected
Does not throw any exceptions.
- Returns:
a connection object that can be used to monitor or sever the created connection
-
virtual void disconnect() noexcept override
Disconnect from all connected sinks.
The source implementation calls disconnect_from_all_sinks().
Does not throw any exceptions.
-
void disconnect_from_all_sinks() noexcept
Disconnect from all connected sinks.
Severs the connection to all sinks, turning the send() method into a no-op.
Does not throw any exceptions.
-
inline virtual void reset() noexcept
Reset filter state.
For stateful filters, this method resets the internal state as if the filter had just been created. Existing connections to sources and sinks are unaffected.
The default implementation does nothing.
Does not throw any exceptions.
-
template<class NodeT>
void set_subscribe_options(NodeT &&node, const std::string &base_topic, const rclcpp::QoS &qos = rclcpp::QoS(rclcpp::KeepLast(10), rmw_qos_profile_default), const std::optional<image_transport::TransportHints> &transport_hints = std::nullopt, const rclcpp::SubscriptionOptions &options = rclcpp::SubscriptionOptions()) Configure ROS topic that is to be subscribed.
All arguments are passed to the ROS client library; see the ROS documentation for further information. Calling this method will automatically unsubscribe any previously subscribed ROS topic.
nodea node instance to handle the subscriptionbase_topicname of the ROS image topic, subject to remappingqosthe ROS quality of service specificationtransport_hintstransport hints for the ROS image_transport frameworkoptionsROS subscription options
Does not throw any exceptions, but will propagate exceptions from the ROS middleware layer.
-
virtual void subscribe()
Subscribe to the configured ROS topic.
This method does nothing if no ROS topic was configured or if the subscriber is subscribed already. Cancels the effect of subscribe_on_demand(), i.e. the subscriber will remain subscribed permanently.
Propagates exceptions raised by the implementation of the abstract class methods.
-
template<class NodeT>
void subscribe(NodeT &&node, const std::string &base_topic, const rclcpp::QoS &qos = rclcpp::QoS(rclcpp::KeepLast(10), rmw_qos_profile_default), const std::optional<image_transport::TransportHints> &transport_hints = std::nullopt, const rclcpp::SubscriptionOptions &options = rclcpp::SubscriptionOptions()) Convenience function to subscribe to a ROS topic.
This function is equivalent to calling set_subscribe_options() and then subscribe().
nodea node instance to handle the subscriptionbase_topicname of the ROS image topic, subject to remappingqosthe ROS quality of service specificationtransport_hintstransport hints for the ROS image_transport frameworkoptionsROS subscription options
Does not throw any exceptions, but will propagate exceptions from the ROS middleware layer.
-
virtual void subscribe_on_demand(PublisherBase &pub)
Subscribe to the configured ROS topic whenever the given publisher is active.
This method does nothing if no ROS topic was configured. Otherwise, it will immediately subscribe or unsubscribe depending on the publisher’s current state. If the publisher becomes active or inactive, the subscriber’s state will update accordingly.
pubpublisher
Propagates exceptions raised by the implementation of the abstract class methods.
-
virtual std::string topic() const noexcept override
Return the subscribed topic name.
Depends on the implementation.
-
virtual void unsubscribe()
Unsubscribe from the configured ROS topic.
You can call subscribe() afterwards to re-subscribe to the ROS topic. This method does nothing if the subscriber is not subscribed to any ROS topic. Cancels the effect of subscribe_on_demand(), i.e. the subscriber will remain unsubscribed permanently.
Propagates exceptions raised by the implementation of the abstract class methods.
Public Static Attributes
-
static std::size_t NUM_OUTPUTS
Number of output arguments.
Protected Functions
-
virtual bool is_configured() const noexcept override
Check if the ROS subscriber is properly configured.
Does not throw any exceptions.
-
void link_with_publisher(PublisherBase &pub)
Add self to the list of subscribers which are controlled by a publisher.
A subscriber can be linked with one publisher only. Any previously linked publisher is unlinked first.
pubpublisher
Propagates exceptions raised by the implementation of the abstract class methods.
-
void send(helpers::argument_t<Outputs>... out)
Pass data to all connected sinks.
outdata
Does not throw any exceptions, but will propagate uncaught exceptions from filter callbacks.
-
virtual void subscribe_impl() override
Create a ROS subscriber.
Does not throw any exceptions.
-
void unlink_from_publisher()
Remove self from the list of subscribers which are controlled by a publisher.
This will not affect the current subscription state. It will only prevent further updates from the previously linked publisher.
Does not throw any exceptions.
-
virtual void unsubscribe_impl() override
Shut the ROS subscriber down.
Does not throw any exceptions.