Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate web_video_server into a component and an executable #168

Merged
merged 2 commits into from
Nov 2, 2024

Conversation

jwdinius
Copy link
Contributor

@jwdinius jwdinius commented Oct 27, 2024

Public API Changes

  • To support composition, web_video_server::WebVideoServer now inherits from rclcpp::Node. Previously, the WebVideoServer class had a private member variable node_ for interacting with the ROS 2 runtime.
  • The constructor for WebVideoServer was changed to accept a single input argument of type rclcpp::NodeOptions. This is required for components.
  • The spin method was removed. This separates the definition of work from the means of executing it. Instead of the WebVideoServer needing to have a public method for spinning the private node_ member, the executor that does the work is now created outside of the class.

Description

The ROS 2 (Humble) docs recommend writing applications as components:

By making the process layout a deploy-time decision the user can
choose between:

  • running multiple nodes in separate processes with the benefits
    of process/fault isolation as well as easier debugging of individual
    nodes and

  • running multiple nodes in a single process with the lower overhead
    and optionally more efficient communication.

The default deployment scheme for the web_video_server node remains the same: i.e., using
ros2 run web_video_server web_video_server {parameter-args-here}.

Having a component library available adds flexibility for users, particularly for those users looking to use intra-process memory for published camera topics and the web video server.

The [ROS 2 (Humble)
docs](https://docs.ros.org/en/humble/Concepts/Intermediate/About-Composition.html#writing-a-component)
recommend writing applications as components:

> By making the process layout a deploy-time decision the user can
> choose between:
>
> * running multiple nodes in separate processes with the benefits
> of process/fault isolation as well as easier debugging of individual
> nodes and
>
> * running multiple nodes in a single process with the lower overhead
> and optionally more efficient communication.

The default deployment scheme for the `web_video_server` node remains
the same: i.e., using
`ros2 run web_video_server web_video_server {parameter-args-here}`.

Having a component library available adds flexibility for users,
particularly for those users looking to use intra-process memory
for published camera topics and the web video server.
@bjsowa
Copy link
Collaborator

bjsowa commented Oct 29, 2024

Thanks for the contribution! I remember trying to do a similar thing but I found it problematic for WebVideoServer to inherit from rclcpp::Node. Don't remember the exact issue though and this seems to work.

CMakeLists.txt Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
src/web_video_server.cpp Show resolved Hide resolved
src/web_video_server.cpp Outdated Show resolved Hide resolved
src/web_video_server.cpp Show resolved Hide resolved
src/web_video_server_node.cpp Outdated Show resolved Hide resolved
* Rename exported library
* Move cleanup_timer_ initialization to WebVideoServer constructor
* Remove setup_cleanup_inactive_streams function and references
@jwdinius
Copy link
Contributor Author

jwdinius commented Nov 2, 2024

@bjsowa I have addressed your comments. Thanks for the suggestions!

@bjsowa bjsowa merged commit f3d5f94 into RobotWebTools:ros2 Nov 2, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants