Skip to content

Commit 5c60fad

Browse files
NosilleChuckEllisonbjsowa
authored
feat: Add subscriber plugins using pluginlib (#198)
Co-authored-by: ChuckEllison <charles.c.ellison@erdc.dren.mil> Co-authored-by: Błażej Sowa <bsowa123@gmail.com>
1 parent 20c30ab commit 5c60fad

30 files changed

Lines changed: 1179 additions & 306 deletions

CMakeLists.txt

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ add_library(${PROJECT_NAME} SHARED
4646
src/web_video_server.cpp
4747
src/multipart_stream.cpp
4848
src/streamer.cpp
49+
src/subscriber.cpp
4950
src/utils.cpp
5051
)
5152

@@ -61,14 +62,15 @@ target_link_libraries(${PROJECT_NAME}
6162
async_web_server_cpp::async_web_server_cpp
6263
pluginlib::pluginlib
6364
rclcpp::rclcpp
65+
${sensor_msgs_TARGETS}
6466
rmw::rmw
6567
Boost::boost
6668
PRIVATE
6769
rclcpp_components::component
6870
)
6971

7072
add_library(${PROJECT_NAME}_streamers SHARED
71-
src/streamers/image_transport_streamer.cpp
73+
src/streamers/image_streamer.cpp
7274
src/streamers/libav_streamer.cpp
7375
src/streamers/h264_streamer.cpp
7476
src/streamers/jpeg_streamers.cpp
@@ -92,7 +94,6 @@ target_link_libraries(${PROJECT_NAME}_streamers
9294
${PROJECT_NAME}
9395
async_web_server_cpp::async_web_server_cpp
9496
cv_bridge::cv_bridge
95-
image_transport::image_transport
9697
pluginlib::pluginlib
9798
rclcpp::rclcpp
9899
${sensor_msgs_TARGETS}
@@ -104,6 +105,25 @@ target_link_libraries(${PROJECT_NAME}_streamers
104105
${swscale_LIBRARIES}
105106
)
106107

108+
add_library(${PROJECT_NAME}_subscribers SHARED
109+
src/subscribers/image_transport_subscriber.cpp
110+
)
111+
112+
target_include_directories(${PROJECT_NAME}_subscribers
113+
PUBLIC
114+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
115+
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
116+
)
117+
118+
target_link_libraries(${PROJECT_NAME}_subscribers
119+
${PROJECT_NAME}
120+
async_web_server_cpp::async_web_server_cpp
121+
image_transport::image_transport
122+
pluginlib::pluginlib
123+
rclcpp::rclcpp
124+
${sensor_msgs_TARGETS}
125+
)
126+
107127
## Declare a cpp executable
108128
add_executable(${PROJECT_NAME}_node
109129
src/web_video_server_node.cpp
@@ -115,7 +135,8 @@ target_link_libraries(${PROJECT_NAME}_node
115135

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

118-
pluginlib_export_plugin_description_file(web_video_server plugins.xml)
138+
pluginlib_export_plugin_description_file(web_video_server streamer_plugins.xml)
139+
pluginlib_export_plugin_description_file(web_video_server subscriber_plugins.xml)
119140

120141
#############
121142
## Install ##
@@ -127,7 +148,7 @@ install(
127148
)
128149

129150
install(
130-
TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_streamers
151+
TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_streamers ${PROJECT_NAME}_subscribers
131152
EXPORT export_${PROJECT_NAME}
132153
LIBRARY DESTINATION lib
133154
ARCHIVE DESTINATION lib

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@ This node provides HTTP streaming of ROS topics in various formats, making it ea
44

55
## Features
66

7+
- Subscribe to ROS topics in multiple formats:
8+
- image_transport
9+
710
- Stream ROS image topics over HTTP in multiple formats:
811
- MJPEG (Motion JPEG)
912
- VP8 (WebM)
1013
- VP9 (WebM)
1114
- H264 (MP4)
1215
- PNG streams
1316
- ROS compressed image streams
17+
1418
- Query snapshots of image topics in multiple formats:
1519
- JPEG
1620
- PNG
1721
- ROS compressed image
18-
- Plugin-based architecture for easy addition of new streaming formats
22+
- Plugin-based architecture for easy addition of new subscribers or streamer formats
1923
- Adjustable quality, size, and other streaming parameters
2024
- Web interface to browse available image topics
2125
- Support for different QoS profiles in ROS 2
@@ -91,6 +95,7 @@ ros2 run web_video_server web_video_server
9195
| `server_threads` | int | 1 | 1+ | Number of server threads for handling HTTP requests |
9296
| `ros_threads` | int | 2 | 1+ | Number of threads for ROS message handling |
9397
| `verbose` | bool | false | true, false | Enable verbose logging |
98+
| `default_qos_profile` | string | "default" | "default", "system_default", "sensor_data", "services_default" | QoS profile for ROS 2 subscribers |
9499
| `default_stream_type` | string | "mjpeg" | "mjpeg", "vp8", "vp9", "h264", "png", "ros_compressed" | Default format for video streams |
95100
| `publish_rate` | double | -1.0 | -1.0 or positive value | Rate for republishing images (-1.0 means no republishing) |
96101

@@ -210,6 +215,9 @@ The response is plain text in the form `stopped=<count>`, where `<count>` is the
210215
## Creating custom streamer plugins
211216
See the [custom streamer plugin tutorial](doc/custom-streamer-plugin.md) for information on how to write your own streamer plugins.
212217

218+
## Creating custom subscriber plugins
219+
See the [custom subscriber plugin tutorial](doc/custom-subscriber-plugin.md) for information on how to write your own subscriber plugins.
220+
213221
## About
214222
This project is released as part of the [Robot Web Tools](https://robotwebtools.github.io/) effort.
215223

0 commit comments

Comments
 (0)