Template Class CameraPublisher
Defined in File camera_publisher.hpp
Inheritance Relationships
Base Types
public fkie_message_filters::PublisherBase(Class PublisherBase)public fkie_message_filters::Sink< RosMessageSharedPtr< sensor_msgs::msg::Image >::FilterType, RosMessageSharedPtr< sensor_msgs::msg::CameraInfo >::FilterType >(Template Class Sink)
Class Documentation
-
template<template<typename> class Translate = RosMessageSharedPtr>
class CameraPublisher : public fkie_message_filters::PublisherBase, public fkie_message_filters::Sink<RosMessageSharedPtr<sensor_msgs::msg::Image>::FilterType, RosMessageSharedPtr<sensor_msgs::msg::CameraInfo>::FilterType> Publish consumed data to ROS camera topics.
This is a specialized publisher that uses image_transport to publish ROS camera topics. All messages which are received from the connected sources will be published on the corresponding advertised ROS topics. For maximum flexibility, you can choose how to receive messages from your sources:
CameraPublisher<RosMessageSharedPtr>will act as a sink ofsensor_msgs::msg::Image::ConstSharedPtrandsensor_msgs::msg::CameraInfo::ConstSharedPtrobjects (default)CameraPublisher<RosMessageUniquePtr>will act as a sink ofsensor_msgs::msg::Image::UniquePtrandsensor_msgs::msg::CameraInfo::UniquePtrobjectsCameraPublisher<RosMessage>will act as a sink of plainsensor_msgs::msg::Imageandsensor_msgs::msg::CameraInfoobjects
See also
Public Types
Public Functions
-
inline CameraPublisher() noexcept
Constructs an empty publisher.
You need to call advertise() to actually publish to a ROS topic.
Does not throw any exceptions.
-
template<class NodeT>
FKIE_MF_BEGIN_ABI_NAMESPACE CameraPublisher(NodeT &&node, const std::string &base_topic, const rclcpp::QoS &qos, const rclcpp::PublisherOptions &options)
-
template<class NodeT>
CameraPublisher(NodeT &&node, const std::string &topic, const rclcpp::QoS &qos = rclcpp::QoS(rclcpp::KeepLast(10), rmw_qos_profile_default), const rclcpp::PublisherOptions &options = rclcpp::PublisherOptions()) Constructor that advertises the given ROS camera topic.
The constructor calls advertise() for you.
Does not throw any exceptions, but will propagate exceptions from the ROS middleware layer.
-
virtual ~CameraPublisher()
Destructor.
-
template<class NodeT>
void advertise(NodeT &&node, const std::string &base_topic, const rclcpp::QoS &qos = rclcpp::QoS(rclcpp::KeepLast(10), rmw_qos_profile_default), const rclcpp::PublisherOptions &options = rclcpp::PublisherOptions()) Advertise ROS camera topic.
All arguments are passed to the image_transport library; see the ROS documentation for further information. Calling this method will automatically unadvertise any previously advertised ROS topic.
nodea node instance to handle the publishingbase_topicname of the ROS camera topic, subject to remappingqosthe ROS quality of service specificationoptionsROS publisher options
Does not throw any exceptions, but will propagate exceptions from the ROS middleware layer.
-
Connection connect_to_source(Source<Inputs...> &src) noexcept
Connect this sink to a source.
Can be called multiple times to connect multiple sources; in that case, the sink receives data from all connected sources. This function does basically the same thing as Source::connect_to_sink(), only from the opposite point of view.
srcthe source 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 sources.
The sink implementation calls disconnect_from_all_sources().
Does not throw any exceptions.
-
void disconnect_from_all_sources() noexcept
Disconnect from all connected sources.
Severs the connection to all sources. The receive() method will not be called any more.
Does not throw any exceptions.
-
virtual bool is_active() const noexcept override
Check if the ROS publisher has at least one subscriber.
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, typename std::enable_if_t< !std::is_convertible_v< NodeT, rclcpp::node_interfaces::NodeGraphInterface::SharedPtr >, bool >> FKIE_MF_BEGIN_ABI_NAMESPACE void start_monitor (NodeT &&node) noexcept
-
virtual std::string topic() const noexcept override
Return the configured ROS topic.
Does not throw any exceptions.
Public Static Attributes
-
static std::size_t NUM_INPUTS
Number of input arguments.
Protected Functions
-
std::tuple<Connection, Connection> link_with_subscriber(SubscriberBase &sub)
Add a new subscriber that will be controlled by this publisher.
subthe subscriberPropagates exceptions raised by the implementation of the abstract class methods.
- Returns:
two connection objects for the signal to enable and disable the linked subscriber
-
virtual void receive(helpers::argument_t<Inputs>... in) = 0
Process incoming data.
Derived classes need to override this method to handle all data that is to be consumed by the sink.
Depends on the implementation.
-
void shutdown_monitor() noexcept
Shutdown monitoring thread for the number of subscribers.
This function is called automatically when the publisher object is destroyed.
Start monitoring thread for the number of subscribers.
This is needed in ROS 2 because there is no longer a dedicated callback for created publishers.
Does not throw any exceptions.
Start monitoring thread for the number of subscribers.
This is needed in ROS 2 because there is no longer a dedicated callback for created publishers.
-
void update_subscriber_state()
Cause all linked subscribers to subscribe or unsubscribe to their ROS topics.
This will check the return value of is_active() to determine if the publisher is active, and then call SubscriberBase::subscribe_impl() or SubscriberBase::unsubscribe_impl() accordingly.
Propagates exceptions raised by the implementation of the abstract class methods.