image_subscriber.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * fkie_message_filters
4  * Copyright © 2018-2020 Fraunhofer FKIE
5  * Author: Timo Röhling
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ****************************************************************************/
20 #ifndef INCLUDE_FKIE_MESSAGE_FILTERS_IMAGE_SUBSCRIBER_H_
21 #define INCLUDE_FKIE_MESSAGE_FILTERS_IMAGE_SUBSCRIBER_H_
22 
23 #include "subscriber_base.h"
24 #include "source.h"
25 #include <sensor_msgs/Image.h>
27 
28 namespace fkie_message_filters
29 {
30 
43 class ImageSubscriber : public SubscriberBase, public Source<sensor_msgs::ImageConstPtr>
44 {
45 public:
52  ImageSubscriber() noexcept {}
64  ImageSubscriber(const image_transport::ImageTransport& it, const std::string& base_topic, uint32_t queue_size, const image_transport::TransportHints& transport_hints = image_transport::TransportHints()) noexcept;
77  void set_subscribe_options(const image_transport::ImageTransport& it, const std::string& base_topic, uint32_t queue_size, const image_transport::TransportHints& transport_hints = image_transport::TransportHints()) noexcept;
90  void subscribe(const image_transport::ImageTransport& it, const std::string& base_topic, uint32_t queue_size, const image_transport::TransportHints& transport_hints = image_transport::TransportHints()) noexcept;
91  using SubscriberBase::subscribe;
92  using SubscriberBase::unsubscribe;
93  using SubscriberBase::subscribe_on_demand;
94  virtual std::string topic() const noexcept override;
95 protected:
100  virtual bool is_configured() const noexcept override;
105  virtual void subscribe_impl() noexcept override;
110  virtual void unsubscribe_impl() noexcept override;
111 private:
112  void cb(const sensor_msgs::ImageConstPtr&);
113  std::shared_ptr<image_transport::ImageTransport> it_;
114  std::string base_topic_;
115  uint32_t queue_size_;
116  image_transport::TransportHints hints_;
117  image_transport::Subscriber sub_;
118 };
119 
120 } // namespace fkie_message_filters
121 
122 #endif /* INCLUDE_FKIE_MESSAGE_FILTERS_IMAGE_SUBSCRIBER_H_ */
fkie_message_filters
Definition: buffer.h:33
fkie_message_filters::ImageSubscriber::topic
virtual std::string topic() const noexcept override
Return the subscribed topic name.
Definition: image_subscriber.cpp:64
subscriber_base.h
image_transport::ImageTransport
fkie_message_filters::ImageSubscriber::is_configured
virtual bool is_configured() const noexcept override
Check if the ROS subscriber is properly configured.
Definition: image_subscriber.cpp:69
fkie_message_filters::ImageSubscriber::set_subscribe_options
void set_subscribe_options(const image_transport::ImageTransport &it, const std::string &base_topic, uint32_t queue_size, const image_transport::TransportHints &transport_hints=image_transport::TransportHints()) noexcept
Configure ROS topic that is to be subscribed.
Definition: image_subscriber.cpp:50
fkie_message_filters::ImageSubscriber::sub_
image_transport::Subscriber sub_
Definition: image_subscriber.h:153
fkie_message_filters::SubscriberBase::unsubscribe
virtual void unsubscribe()
Unsubscribe from the configured ROS topic.
Definition: publisher_subscriber_base.cpp:70
source.h
fkie_message_filters::ImageSubscriber::subscribe_impl
virtual void subscribe_impl() noexcept override
Create a ROS subscriber.
Definition: image_subscriber.cpp:74
fkie_message_filters::ImageSubscriber::ImageSubscriber
ImageSubscriber() noexcept
Constructs an empty subscriber.
Definition: image_subscriber.h:88
fkie_message_filters::ImageSubscriber::cb
void cb(const sensor_msgs::ImageConstPtr &)
Definition: image_subscriber.cpp:94
fkie_message_filters::ImageSubscriber::unsubscribe_impl
virtual void unsubscribe_impl() noexcept override
Shut the ROS subscriber down.
Definition: image_subscriber.cpp:89
image_transport.h
std
image_transport
fkie_message_filters::SubscriberBase::subscribe
virtual void subscribe()
Subscribe to the configured ROS topic.
Definition: publisher_subscriber_base.cpp:64
fkie_message_filters::ImageSubscriber::it_
std::shared_ptr< image_transport::ImageTransport > it_
Definition: image_subscriber.h:149
image_transport::TransportHints
fkie_message_filters::ImageSubscriber::base_topic_
std::string base_topic_
Definition: image_subscriber.h:150
fkie_message_filters::SubscriberBase::subscribe_on_demand
virtual void subscribe_on_demand(PublisherBase &pub)
Subscribe to the configured ROS topic whenever the given publisher is active.
Definition: publisher_subscriber_base.cpp:76
sensor_msgs
fkie_message_filters::ImageSubscriber::hints_
image_transport::TransportHints hints_
Definition: image_subscriber.h:152
fkie_message_filters::ImageSubscriber::queue_size_
uint32_t queue_size_
Definition: image_subscriber.h:151


fkie_message_filters
Author(s): Timo Röhling
autogenerated on Wed Mar 2 2022 00:18:57