Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions image_transport/include/image_transport/raw_subscriber.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,32 @@ class RawSubscriber : public SimpleSubscriberPlugin<sensor_msgs::msg::Image>
public:
virtual ~RawSubscriber() {}

virtual std::string getTransportName() const
std::string getTransportName() const override
{
return "raw";
}

protected:
virtual void internalCallback(const std::shared_ptr<const sensor_msgs::msg::Image>& message, const Callback& user_cb)
void internalCallback(
const std::shared_ptr<const sensor_msgs::msg::Image>& message, const Callback& user_cb) override
{
user_cb(message);
}

virtual std::string getTopicToSubscribe(const std::string& base_topic) const
std::string getTopicToSubscribe(const std::string& base_topic) const override
{
return base_topic;
}

void subscribeImpl(
rclcpp::Node * node,
const std::string & base_topic,
const Callback & callback,
rmw_qos_profile_t custom_qos,
rclcpp::SubscriptionOptions options) override
{
this->subscribeImplWithOptions(node, base_topic, callback, custom_qos, options);
}
};

} // namespace image_transport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,29 @@ class SimpleSubscriberPlugin : public SubscriberPlugin
return base_topic + "/" + getTransportName();
}

virtual void subscribeImpl(
void subscribeImpl(
rclcpp::Node * node,
const std::string & base_topic,
const Callback & callback,
rmw_qos_profile_t custom_qos) override
{
this->subscribeImpl(node, base_topic, callback, custom_qos, rclcpp::SubscriptionOptions());
impl_ = std::make_unique<Impl>();
// Push each group of transport-specific parameters into a separate sub-namespace
//ros::NodeHandle param_nh(transport_hints.getParameterNH(), getTransportName());
//
auto qos = rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(custom_qos), custom_qos);
impl_->sub_ = node->create_subscription<M>(getTopicToSubscribe(base_topic), qos,
[this, callback](const typename std::shared_ptr<const M> msg){
internalCallback(msg, callback);
});
}

void subscribeImpl(
void subscribeImplWithOptions(
rclcpp::Node * node,
const std::string & base_topic,
const Callback & callback,
rmw_qos_profile_t custom_qos,
rclcpp::SubscriptionOptions options) override
rclcpp::SubscriptionOptions options)
{
impl_ = std::make_unique<Impl>();
// Push each group of transport-specific parameters into a separate sub-namespace
Expand All @@ -136,7 +144,8 @@ class SimpleSubscriberPlugin : public SubscriberPlugin
impl_->sub_ = node->create_subscription<M>(getTopicToSubscribe(base_topic), qos,
[this, callback](const typename std::shared_ptr<const M> msg){
internalCallback(msg, callback);
}, options);
},
options);
}

private:
Expand All @@ -146,9 +155,6 @@ class SimpleSubscriberPlugin : public SubscriberPlugin
};

std::unique_ptr<Impl> impl_;



};

} // namespace image_transport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class IMAGE_TRANSPORT_PUBLIC SubscriberPlugin
node->get_logger(),
"SubscriberPlugin::subscribeImpl with five arguments has not been overridden");
this->subscribeImpl(node, base_topic, callback, custom_qos);
}
}
};

} // namespace image_transport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ class ResizedSubscriber : public image_transport::SimpleSubscriberPlugin<image_t
return "resized";
}

void subscribeImpl(
rclcpp::Node * node,
const std::string & base_topic,
const Callback & callback,
rmw_qos_profile_t custom_qos,
rclcpp::SubscriptionOptions options) override
{
this->subscribeImplWithOptions(node, base_topic, callback, custom_qos, options);
}
protected:
virtual void internalCallback(const typename image_transport_tutorial::ResizedImage::ConstPtr& message,
const Callback& user_cb);
Expand Down