Skip to content

fly4future/webrtc_ros

Repository files navigation

F4F Logo

WebRTC ROS

Package to stream ROS video topics using WebRTC, with a custom signaling server and protocol.

📌About The Project

Demo

WebRTC is a powerful technology that enables real-time communication of audio, video, and data between web browsers and other clients. The webrtc_ros package provides a custom signaling server and protocol specifically designed for streaming ROS video topics using WebRTC. This allows ROS users to easily set up real-time video streaming from their robots to web browsers or other WebRTC-enabled clients, without needing to worry about the complexities of WebRTC signaling. The package is lightweight and flexible, making it a great choice for ROS users who want to leverage the power of WebRTC for their video streaming needs.

🏁Getting Started

This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running, follow these simple example steps.

Installation

  1. Clone and move it into your ROS2 workspace

    cd ~/git # or the folder where you want to keep your git repositories (e.g., `~/Develop`)
    git clone git@github.com:fly4future/webrtc_ros.git
    
    cd ~/ros2_ws/src
    ln -sf ~/git/webrtc_ros .

    [!NOTE] Don't forget to have your SSH key added to your GitHub account. If you don't have one, you can follow this guide.

  2. Install dependencies and build the workspace

    cd ~/ros2_ws
    sudo apt update
    rosdep update
    rosdep install --from-paths src --ignore-src -r -y
  3. Build the workspace

    colcon build

Important

  • To run the av1 encoder, you need to install the rtp plugin from https://github.com/GStreamer/gst-plugins-rs
  • To run the h264 encoder with vaapi hardware acceleration, you need to have installed sudo apt install gstreamer1.0-vaapi and have a compatible Intel or AMD GPU with the necessary drivers.

🎈Usage

You have to run the signaling server first, and then the streamer node. You can use the provided launch file to start both:

  1. Run the signaling server

    python3 src/webrtc_ros/scripts/signaling_server.py

    [!NOTE] You should have the websockets Python package installed to run the signaling server.

  2. Source the workspace and run the streamer node

    source install/setup.bash
    ros2 run webrtc_ros webrtc_streamer

    [!IMPORTANT] Optionally, you can specify parameters for the streamer node, such as the signaling server URL, the encoding format, and the hardware acceleration method. For example:

    ros2 run webrtc_ros webrtc_streamer --ros-args \
     -p signaling_server_url:=ws://localhost:8173/uav124 \ # The URL of the signaling server, including the unique client ID (e.g., "uav124")
     -p encoder:=h264 \                                    # The video encoding format ("h264" or "av1")
     -p hw_acceleration:=vaapi                             # The hardware acceleration method ("cpu", "nv" for NVIDIA, "vaapi" for Intel/AMD)

About

Streaming of ROS Image Topics using WebRTC

Topics

Resources

Stars

Watchers

Forks

Contributors