Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#include <sensor_msgs/msg/image.hpp>
#include <sensor_msgs/msg/compressed_image.hpp>
#include "image_transport/simple_publisher_plugin.h"
#include "image_transport/simple_publisher_plugin.hpp"

namespace compressed_depth_image_transport {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <rclcpp/node.hpp>
#include <sensor_msgs/msg/image.hpp>
#include <sensor_msgs/msg/compressed_image.hpp>
#include "image_transport/simple_subscriber_plugin.h"
#include "image_transport/simple_subscriber_plugin.hpp"

namespace compressed_depth_image_transport {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ class CompressedSubscriber : public image_transport::SimpleSubscriberPlugin<sens
const Callback& callback,
rmw_qos_profile_t custom_qos) override;

// Overridden to set up reconfigure server
void subscribeImpl(
rclcpp::Node * ,
const std::string& base_topic,
const Callback& callback,
rmw_qos_profile_t custom_qos,
rclcpp::SubscriptionOptions options) override;

void subscribeImplCommon(rclcpp::Node *);

void internalCallback(const sensor_msgs::msg::CompressedImage::ConstSharedPtr& message,
const Callback& user_cb) override;

Expand Down
6 changes: 3 additions & 3 deletions compressed_image_transport/src/compressed_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void CompressedPublisher::advertiseImpl(
}
else
{
RCLCPP_WARN(logger_, format_param_name + " was previously delared");
RCLCPP_WARN(logger_, "%s was previously delared", format_param_name.c_str());
}

std::string png_level_param_name = param_base_name + ".png_level";
Expand All @@ -101,7 +101,7 @@ void CompressedPublisher::advertiseImpl(
}
else
{
RCLCPP_WARN(logger_, png_level_param_name + " was previously delared");
RCLCPP_WARN(logger_, "%s was previously delared", png_level_param_name.c_str());
}

std::string jpeg_quality_param_name = param_base_name + ".jpeg_quality";
Expand All @@ -121,7 +121,7 @@ void CompressedPublisher::advertiseImpl(
}
else
{
RCLCPP_WARN(logger_, jpeg_quality_param_name + " was previously delared");
RCLCPP_WARN(logger_, "%s was previously delared", jpeg_quality_param_name.c_str());
}
}

Expand Down
56 changes: 36 additions & 20 deletions compressed_image_transport/src/compressed_subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,44 @@ void CompressedSubscriber::subscribeImpl(
const Callback& callback,
rmw_qos_profile_t custom_qos)
{
logger_ = node->get_logger();
typedef image_transport::SimpleSubscriberPlugin<CompressedImage> Base;
Base::subscribeImpl(node, base_topic, callback, custom_qos);
std::string mode;
rcl_interfaces::msg::ParameterDescriptor mode_description;
mode_description.name = "mode";
mode_description.type = rcl_interfaces::msg::ParameterType::PARAMETER_STRING;
mode_description.description = "OpenCV imdecode flags to use";
mode_description.read_only = false;
mode_description.additional_constraints = "Supported values: [unchanged, gray, color]";
mode = node->declare_parameter("mode", kDefaultMode, mode_description);

if (mode == "unchanged") {
config_.imdecode_flag = cv::IMREAD_UNCHANGED;
} else if (mode == "gray") {
config_.imdecode_flag = cv::IMREAD_GRAYSCALE;
} else if (mode == "color") {
config_.imdecode_flag = cv::IMREAD_COLOR;
} else {
RCLCPP_ERROR(logger_, "Unknown mode: %s, defaulting to 'unchanged", mode.c_str());
config_.imdecode_flag = cv::IMREAD_UNCHANGED;
}
subscribeImplCommon(node);

}
void CompressedSubscriber::subscribeImplCommon(rclcpp::Node * node){
logger_ = node->get_logger();
std::string mode;
rcl_interfaces::msg::ParameterDescriptor mode_description;
mode_description.name = "mode";
mode_description.type = rcl_interfaces::msg::ParameterType::PARAMETER_STRING;
mode_description.description = "OpenCV imdecode flags to use";
mode_description.read_only = false;
mode_description.additional_constraints = "Supported values: [unchanged, gray, color]";
mode = node->declare_parameter("mode", kDefaultMode, mode_description);

if (mode == "unchanged") {
config_.imdecode_flag = cv::IMREAD_UNCHANGED;
} else if (mode == "gray") {
config_.imdecode_flag = cv::IMREAD_GRAYSCALE;
} else if (mode == "color") {
config_.imdecode_flag = cv::IMREAD_COLOR;
} else {
RCLCPP_ERROR(logger_, "Unknown mode: %s, defaulting to 'unchanged", mode.c_str());
config_.imdecode_flag = cv::IMREAD_UNCHANGED;
}
}

void CompressedSubscriber::subscribeImpl(
rclcpp::Node * node,
const std::string& base_topic,
const Callback& callback,
rmw_qos_profile_t custom_qos,
rclcpp::SubscriptionOptions options)
{
typedef image_transport::SimpleSubscriberPlugin<CompressedImage> Base;
Base::subscribeImplWithOptions(node, base_topic, callback, custom_qos, options);
subscribeImplCommon(node);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <sensor_msgs/msg/image.hpp>
#include <sensor_msgs/msg/compressed_image.hpp>

#include <image_transport/simple_publisher_plugin.h>
#include <image_transport/simple_publisher_plugin.hpp>
#include <cv_bridge/cv_bridge.h>
#include <std_msgs/msg/header.hpp>
#include <theora_image_transport/msg/packet.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/

#include <image_transport/simple_subscriber_plugin.h>
#include <image_transport/simple_subscriber_plugin.hpp>
#include <theora_image_transport/msg/packet.hpp>

#include <theora/codec.h>
Expand Down