Skip to content

Commit

Permalink
Merge pull request #1 from lge-ros2/ros2
Browse files Browse the repository at this point in the history
Fix build for ROS2 Foxy (RobotWebTools#111)
  • Loading branch information
hyunseok-yang authored Jul 27, 2021
2 parents a236135 + 733a7d9 commit 9833dc6
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 18 deletions.
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ target_link_libraries(${PROJECT_NAME}
${swscale_LIBRARIES}
)

ament_package()

#############
## Install ##
#############
Expand All @@ -82,7 +80,4 @@ install(DIRECTORY include/${PROJECT_NAME}/
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
)

install(
DIRECTORY config launch
DESTINATION share/${PROJECT_NAME}
)
ament_package()
2 changes: 1 addition & 1 deletion include/web_video_server/h264_streamer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef H264_STREAMERS_H_
#define H264_STREAMERS_H_

#include <image_transport/image_transport.h>
#include <image_transport/image_transport.hpp>
#include "web_video_server/libav_streamer.h"
#include "async_web_server_cpp/http_request.hpp"
#include "async_web_server_cpp/http_connection.hpp"
Expand Down
4 changes: 2 additions & 2 deletions include/web_video_server/image_streamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#define IMAGE_STREAMER_H_

#include <rclcpp/rclcpp.hpp>
#include <image_transport/image_transport.h>
#include <image_transport/transport_hints.h>
#include <image_transport/image_transport.hpp>
#include <image_transport/transport_hints.hpp>
#include <opencv2/opencv.hpp>
#include "async_web_server_cpp/http_server.hpp"
#include "async_web_server_cpp/http_request.hpp"
Expand Down
2 changes: 1 addition & 1 deletion include/web_video_server/jpeg_streamers.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef JPEG_STREAMERS_H_
#define JPEG_STREAMERS_H_

#include <image_transport/image_transport.h>
#include <image_transport/image_transport.hpp>
#include "web_video_server/image_streamer.h"
#include "async_web_server_cpp/http_request.hpp"
#include "async_web_server_cpp/http_connection.hpp"
Expand Down
2 changes: 1 addition & 1 deletion include/web_video_server/libav_streamer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef LIBAV_STREAMERS_H_
#define LIBAV_STREAMERS_H_

#include <image_transport/image_transport.h>
#include <image_transport/image_transport.hpp>
#include "web_video_server/image_streamer.h"
#include "async_web_server_cpp/http_request.hpp"
#include "async_web_server_cpp/http_connection.hpp"
Expand Down
2 changes: 1 addition & 1 deletion include/web_video_server/png_streamers.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef PNG_STREAMERS_H_
#define PNG_STREAMERS_H_

#include <image_transport/image_transport.h>
#include <image_transport/image_transport.hpp>
#include "web_video_server/image_streamer.h"
#include "async_web_server_cpp/http_request.hpp"
#include "async_web_server_cpp/http_connection.hpp"
Expand Down
2 changes: 1 addition & 1 deletion include/web_video_server/vp8_streamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#ifndef VP8_STREAMERS_H_
#define VP8_STREAMERS_H_

#include <image_transport/image_transport.h>
#include <image_transport/image_transport.hpp>
#include "web_video_server/libav_streamer.h"
#include "async_web_server_cpp/http_request.hpp"
#include "async_web_server_cpp/http_connection.hpp"
Expand Down
2 changes: 1 addition & 1 deletion include/web_video_server/vp9_streamer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef VP9_STREAMERS_H_
#define VP9_STREAMERS_H_

#include <image_transport/image_transport.h>
#include <image_transport/image_transport.hpp>
#include "web_video_server/libav_streamer.h"
#include "async_web_server_cpp/http_request.hpp"
#include "async_web_server_cpp/http_connection.hpp"
Expand Down
4 changes: 4 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@
<exec_depend>async_web_server_cpp</exec_depend>
<exec_depend>ffmpeg</exec_depend>
<exec_depend>sensor_msgs</exec_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
4 changes: 2 additions & 2 deletions src/ros_compressed_streamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void RosCompressedStreamer::start() {
}

image_sub_ = nh_->create_subscription<sensor_msgs::msg::CompressedImage>(
compressed_topic, std::bind(&RosCompressedStreamer::imageCallback, this, std::placeholders::_1), 1);
compressed_topic, 1, std::bind(&RosCompressedStreamer::imageCallback, this, std::placeholders::_1));
}

void RosCompressedStreamer::restreamFrame(double max_age)
Expand Down Expand Up @@ -81,7 +81,7 @@ void RosCompressedStreamer::sendImage(const sensor_msgs::msg::CompressedImage::C
void RosCompressedStreamer::imageCallback(const sensor_msgs::msg::CompressedImage::ConstSharedPtr msg) {
boost::mutex::scoped_lock lock(send_mutex_); // protects last_msg and last_frame
last_msg = msg;
last_frame = rclcpp::Time(msg->header.stamp.sec, msg->header.stamp.nanosec);
last_frame = rclcpp::Time(msg->header.stamp);
sendImage(last_msg, last_frame);
}

Expand Down
5 changes: 3 additions & 2 deletions src/web_video_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void WebVideoServer::spin()
{
server_->run();
RCLCPP_INFO(nh_->get_logger(), "Waiting For connections on %s:%d", address_.c_str(), port_);
rclcpp::executors::MultiThreadedExecutor spinner(rclcpp::executor::create_default_executor_arguments(), ros_threads_);
rclcpp::executors::MultiThreadedExecutor spinner(rclcpp::ExecutorOptions(), ros_threads_);
spinner.add_node(nh_);
if ( publish_rate_ > 0 ) {
nh_->create_wall_timer(1s / publish_rate_, [this](){restreamFrames(1.0 / publish_rate_);});
Expand Down Expand Up @@ -306,8 +306,9 @@ bool WebVideoServer::handle_list_streams(const async_web_server_cpp::HttpRequest
}
auto & topic_name = topic_and_types.first;
auto & topic_type = topic_and_types.second[0]; // explicitly take the first

// TODO debugging
// fprintf(stderr, "topic_type: %s\n", topic_type.c_str());
fprintf(stderr, "topic_type: %s\n", topic_type.c_str());
if (topic_type == "sensor_msgs/msg/Image" || topic_type == "sensor_msgs/Image")
{
image_topics.push_back(topic_name);
Expand Down

0 comments on commit 9833dc6

Please sign in to comment.