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
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ if(${cv_bridge_VERSION} VERSION_LESS "3.3.0")
add_compile_definitions(CV_BRIDGE_USES_OLD_HEADERS)
endif()

if(${image_transport_VERSION} VERSION_LESS "6.4.0")
add_compile_definitions(IMAGE_TRANSPORT_USES_OLD_API)
endif()

## Declare a cpp library
add_library(${PROJECT_NAME} SHARED
src/web_video_server.cpp
Expand Down
6 changes: 3 additions & 3 deletions include/web_video_server/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
#include <string>
#include <optional>

#include "rmw/types.h"
#include "rclcpp/qos.hpp"

namespace web_video_server
{

/**
* @brief Gets a QoS profile given an input name, if valid.
* @param name The name of the QoS profile name.
* @param name The name of the QoS profile.
* @return An optional containing the matching QoS profile.
*/
std::optional<rmw_qos_profile_t> get_qos_profile_from_name(std::string name);
std::optional<rclcpp::QoS> get_qos_profile_from_name(const std::string & name);

} // namespace web_video_server
11 changes: 8 additions & 3 deletions src/streamers/image_transport_streamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
#include "async_web_server_cpp/http_connection.hpp"
#include "async_web_server_cpp/http_request.hpp"
#include "image_transport/image_transport.hpp"
#include "image_transport/transport_hints.hpp"
#include "rclcpp/node.hpp"
#include "rclcpp/logging.hpp"
#include "rmw/qos_profiles.h"
Expand Down Expand Up @@ -118,7 +117,6 @@ void ImageTransportStreamerBase::start()
return;
}

const image_transport::TransportHints hints(node.get(), default_transport_);
auto tnat = node->get_topic_names_and_types();
inactive_ = true;
for (auto topic_and_types : tnat) {
Expand All @@ -139,18 +137,25 @@ void ImageTransportStreamerBase::start()
qos_profile_name_.c_str());
auto qos_profile = get_qos_profile_from_name(qos_profile_name_);
if (!qos_profile) {
qos_profile = rmw_qos_profile_default;
qos_profile = rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(rmw_qos_profile_default));
RCLCPP_ERROR(
logger_,
"Invalid QoS profile %s specified. Using default profile.",
qos_profile_name_.c_str());
}

// Create subscriber
#ifdef IMAGE_TRANSPORT_USES_OLD_API
image_sub_ = image_transport::create_subscription(
node.get(), topic_,
std::bind(&ImageTransportStreamerBase::image_callback, this, std::placeholders::_1),
default_transport_, qos_profile.value().get_rmw_qos_profile());
#else
image_sub_ = image_transport::create_subscription(
*node.get(), topic_,
std::bind(&ImageTransportStreamerBase::image_callback, this, std::placeholders::_1),
default_transport_, qos_profile.value());
#endif
}

#pragma GCC diagnostic pop
Expand Down
8 changes: 4 additions & 4 deletions src/streamers/ros_compressed_streamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ rclcpp::QoS make_compressed_qos(
logger,
"Invalid QoS profile %s specified. Using default profile.",
qos_profile_name.c_str());
qos_profile = rmw_qos_profile_default;
qos_profile = rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(rmw_qos_profile_default));
}

return rclcpp::QoS(
rclcpp::QoSInitialization(qos_profile.value().history, 1),
qos_profile.value());
auto qos = qos_profile.value();
qos.keep_last(1);
return qos;
}

std::optional<std::string> resolve_content_type(
Expand Down
10 changes: 5 additions & 5 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@
#include <optional>
#include <string>

#include "rclcpp/qos.hpp"
#include "rmw/qos_profiles.h"
#include "rmw/types.h"

namespace web_video_server
{

std::optional<rmw_qos_profile_t> get_qos_profile_from_name(const std::string name)
std::optional<rclcpp::QoS> get_qos_profile_from_name(const std::string & name)
{
if (name == "default") {
return rmw_qos_profile_default;
return rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(rmw_qos_profile_default));
}
if (name == "system_default") {
return rmw_qos_profile_system_default;
return rclcpp::SystemDefaultsQoS();
}
if (name == "sensor_data") {
return rmw_qos_profile_sensor_data;
return rclcpp::SensorDataQoS();
}
return std::nullopt;
}
Expand Down
Loading