Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
46 changes: 43 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ find_package(rclcpp_components REQUIRED)
find_package(rmw REQUIRED)
find_package(sensor_msgs REQUIRED)

find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2_sensor_msgs REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)

find_package(OpenCV REQUIRED)
find_package(Boost REQUIRED COMPONENTS system)

Expand Down Expand Up @@ -46,6 +51,7 @@ add_library(${PROJECT_NAME} SHARED
src/web_video_server.cpp
src/multipart_stream.cpp
src/streamer.cpp
src/subscriber.cpp
src/utils.cpp
)

Expand All @@ -61,14 +67,15 @@ target_link_libraries(${PROJECT_NAME}
async_web_server_cpp::async_web_server_cpp
pluginlib::pluginlib
rclcpp::rclcpp
${sensor_msgs_TARGETS}
rmw::rmw
Boost::boost
PRIVATE
rclcpp_components::component
)

add_library(${PROJECT_NAME}_streamers SHARED
src/streamers/image_transport_streamer.cpp
src/streamers/image_streamer.cpp
src/streamers/libav_streamer.cpp
src/streamers/h264_streamer.cpp
src/streamers/jpeg_streamers.cpp
Expand All @@ -89,6 +96,38 @@ target_include_directories(${PROJECT_NAME}_streamers
)

target_link_libraries(${PROJECT_NAME}_streamers
${PROJECT_NAME}
async_web_server_cpp::async_web_server_cpp
cv_bridge::cv_bridge
pluginlib::pluginlib
rclcpp::rclcpp
${sensor_msgs_TARGETS}
Boost::boost
Boost::system
${OpenCV_LIBS}
${avcodec_LIBRARIES}
${avformat_LIBRARIES}
${avutil_LIBRARIES}
${swscale_LIBRARIES}
)

add_library(${PROJECT_NAME}_subscribers SHARED
src/subscribers/image_transport_subscriber.cpp
)

target_include_directories(${PROJECT_NAME}_subscribers
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
# ${avcodec_INCLUDE_DIRS}
# ${avformat_INCLUDE_DIRS}
# ${avutil_INCLUDE_DIRS}
# ${swscale_INCLUDE_DIRS}
)

ament_target_dependencies(${PROJECT_NAME}_subscribers rclcpp tf2 tf2_ros tf2_sensor_msgs tf2_geometry_msgs)

target_link_libraries(${PROJECT_NAME}_subscribers
${PROJECT_NAME}
async_web_server_cpp::async_web_server_cpp
cv_bridge::cv_bridge
Expand Down Expand Up @@ -116,7 +155,8 @@ target_link_libraries(${PROJECT_NAME}_node

rclcpp_components_register_nodes(${PROJECT_NAME} "web_video_server::WebVideoServer")

pluginlib_export_plugin_description_file(web_video_server plugins.xml)
pluginlib_export_plugin_description_file(web_video_server streamer_plugins.xml)
pluginlib_export_plugin_description_file(web_video_server subscriber_plugins.xml)

#############
## Install ##
Expand All @@ -128,7 +168,7 @@ install(
)

install(
TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_streamers
TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_streamers ${PROJECT_NAME}_subscribers
EXPORT export_${PROJECT_NAME}
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ This node provides HTTP streaming of ROS topics in various formats, making it ea

## Features

- Subscribe to ROS topics in multiple formats:
- image_transport

- Stream ROS image topics over HTTP in multiple formats:
- MJPEG (Motion JPEG)
- VP8 (WebM)
- VP9 (WebM)
- H264 (MP4)
- PNG streams
- ROS compressed image streams

- Query snapshots of image topics in multiple formats:
- JPEG
- PNG
- ROS compressed image
- Plugin-based architecture for easy addition of new streaming formats
- Plugin-based architecture for easy addition of new subscribers or streamer formats
- Adjustable quality, size, and other streaming parameters
- Web interface to browse available image topics
- Support for different QoS profiles in ROS 2
Expand Down Expand Up @@ -91,6 +95,7 @@ ros2 run web_video_server web_video_server
| `server_threads` | int | 1 | 1+ | Number of server threads for handling HTTP requests |
| `ros_threads` | int | 2 | 1+ | Number of threads for ROS message handling |
| `verbose` | bool | false | true, false | Enable verbose logging |
| `default_qos_profile` | string | "default" | "default", "system_default", "sensor_data", "services_default" | QoS profile for ROS 2 subscribers |
| `default_stream_type` | string | "mjpeg" | "mjpeg", "vp8", "vp9", "h264", "png", "ros_compressed" | Default format for video streams |
| `publish_rate` | double | -1.0 | -1.0 or positive value | Rate for republishing images (-1.0 means no republishing) |

Expand Down Expand Up @@ -181,6 +186,9 @@ http://localhost:8080/snapshot?topic=/camera/image_raw
## Creating custom streamer plugins
See the [custom streamer plugin tutorial](doc/custom-streamer-plugin.md) for information on how to write your own streamer plugins.

## Creating custom subscriber plugins
See the [custom subscriber plugin tutorial](doc/custom-subscriber-plugin.md) for information on how to write your own subscriber plugins.

## About
This project is released as part of the [Robot Web Tools](https://robotwebtools.github.io/) effort.

Expand Down
6 changes: 1 addition & 5 deletions doc/custom-streamer-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ This tutorial will guide you through the steps to create a simple custom streame

1. Add `TestStreamer` and `TestStreamerFactory` classes to `include/test_streamer_plugin/test_streamer_plugin.hpp` header file:
```cpp
#ifndef TEST_STREAMER_PLUGIN__TEST_STREAMER_PLUGIN_HPP_
#define TEST_STREAMER_PLUGIN__TEST_STREAMER_PLUGIN_HPP_

#include "test_streamer_plugin/visibility_control.h"
#pragma once

#include "web_video_server/streamer.hpp"

Expand Down Expand Up @@ -52,7 +49,6 @@ This tutorial will guide you through the steps to create a simple custom streame

} // namespace test_streamer_plugin

#endif // TEST_STREAMER_PLUGIN__TEST_STREAMER_PLUGIN_HPP_
```

1. Implement the `TestStreamer` and `TestStreamerFactory` classes in `src/test_streamer_plugin.cpp`:
Expand Down
Loading