17 #include <boost/functional.hpp> 26 #include <topic_tools/shape_shifter.h> 51 typedef ::boost::function<void(::cras::GenericLazyPubSub::CallbackMessageType, ::ros::Publisher&)>
CallbackType;
68 const ::cras::LogHelperPtr& logHelper = ::std::make_shared<::cras::NodeLogHelper>());
82 const ::ros::NodeHandle& nhOut, const ::std::string& topicOut,
size_t queueSize, CallbackType callback,
84 const ::cras::LogHelperPtr& logHelper = ::std::make_shared<::cras::NodeLogHelper>());
97 const ::ros::NodeHandle& nhOut, const ::std::string& topicOut, CallbackType callback,
99 const ::cras::LogHelperPtr& logHelper = ::std::make_shared<::cras::NodeLogHelper>());
112 GenericLazyPubSub(const ::ros::NodeHandle& nh, const ::std::string& topicIn, const ::std::string& topicOut,
113 size_t inQueueSize,
size_t outQueueSize, CallbackType callback,
115 const ::cras::LogHelperPtr& logHelper = ::std::make_shared<::cras::NodeLogHelper>());
128 GenericLazyPubSub(const ::ros::NodeHandle& nh, const ::std::string& topicIn, const ::std::string& topicOut,
130 const ::cras::LogHelperPtr& logHelper = ::std::make_shared<::cras::NodeLogHelper>());
142 GenericLazyPubSub(const ::ros::NodeHandle& nh, const ::std::string& topicIn, const ::std::string& topicOut,
144 const ::cras::LogHelperPtr& logHelper = ::std::make_shared<::cras::NodeLogHelper>());
162 void connectCb(const ::ros::SingleSubscriberPublisher&);
168 void cb(const ::ros::MessageEvent<::topic_tools::ShapeShifter const>& event);
176 const ::ros::MessageEvent<::topic_tools::ShapeShifter const>& event);
void cb(const ::ros::MessageEvent<::topic_tools::ShapeShifter const > &event)
Callback for the received messages from subscriber. It also handles publisher creation if none exists...
void subscribe(::ros::Subscriber &sub)
Perform the subscription to the input topic.
::std::string topicIn
Input topic (relative to nh).
::ros::NodeHandle nhIn
Node handle for topic subscription.
::std::string topicOut
Output topic (relative to nh).
::ros::Publisher pub
The output publisher. It will be invalid until first message is received.
const ::ros::SubscribeOptions subscribeOptions
Options used when subscribing to the input topic.
::std::mutex pubCreateMutex
Mutex protecting pub.
A pair of lazy subscriber and publisher which use the same message type (unknown at compile time)...
virtual ::ros::AdvertiseOptions createAdvertiseOptions(const ::ros::MessageEvent<::topic_tools::ShapeShifter const > &event)
Create ros::AdvertiseOptions from a message event.
::ros::Subscriber sub
The input subscriber.
::boost::function< void(::cras::GenericLazyPubSub::CallbackMessageType, ::ros::Publisher &)> CallbackType
Type of the user callback passed to this class.
size_t outQueueSize
Queue size of the output publisher.
Lazy subscriber that subscribes only when a paired publisher has subscribers.
const ::ros::MessageEvent<::topic_tools::ShapeShifter const > & CallbackMessageType
Signature of the subscriber's callback.
::ros::NodeHandle nhOut
Node handle for topic publication.
::cras::GenericLazyPubSub::CallbackType callback
The user callback to be called when a message is received.
size_t inQueueSize
Queue size of the input subscriber.
GenericLazyPubSub(const ::ros::NodeHandle &nhIn, const ::std::string &topicIn, const ::ros::NodeHandle &nhOut, const ::std::string &topicOut, size_t inQueueSize, size_t outQueueSize, CallbackType callback, ::ros::SubscribeOptions subscribeOptions={}, const ::cras::LogHelperPtr &logHelper=::std::make_shared<::cras::NodeLogHelper >())
Create the pair of lazy subscriber and publisher.
void connectCb(const ::ros::SingleSubscriberPublisher &)
Callback that is called whenever someone (un)subscribes from the publisher.
bool shouldBeSubscribed() const override
Returns true when the subscriber should be connected - i.e. either at the start, or when pub has clie...
::cras::optional<::ros::AdvertiseOptions > advertiseOptions
The options used when the publisher was created. nullopt before the publisher is created.
A lazy subscriber that subscribes only when a condition is met.