Skip to content

Fix/ros2 jazzy #72

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

Draft
wants to merge 3 commits into
base: develop-ros2
Choose a base branch
from

Conversation

EricVoll
Copy link

@EricVoll EricVoll commented Jul 12, 2024

Public API Changes
None

Description
Get build to work on Ros2 Jazzy, Ubuntu 24.04.

There are some diffs applied to the cloned webrtc source code (first two bullet points below) I'm not sure how to best apply them in this PR. Maybe apply a patch after pulling the code or something...

Open problems:

  • webrtc/build/webrtc/src/rtc_base/third_party/base64/base64.h: add #include <cstdint>
  • webrtc/build/webrtc/src/build/util/lastchange.py: replace utcfromtimestamp with fromtimestamp on L318
  • I could not find a proper replacement for the RTC_DISALLOW_COPY_AND_ASSIGN macro, so currently it's commented out. Edit: Found it and fixed.
  • Currently I cloned vision_opencv and checked out 7a47d35, and renamed a few .h to .hpp - I'm not sure if that's needed though, and I forgot where I read that this is required. Edit: yeah, seems to be needed.

#71

After launching:
The webserver launches fine and shows the available topics:
image

But when trying to establish a connection, it crashes.

[webrtc_ros_server_node-2] [INFO] [1720796065.255299670] [webrtc_server]: JSON: {"type":"configure","actions":[{"type":"add_stream","id":"webrtc_ros-stream-975963065"},{"type":"add_video_track","stream_id":"webrtc_ros-stream-975963065","id":"webrtc_ros-stream-975963065/subscribed_video","src":"ros_image:/optical_camera_rear/image_raw"}]}
[webrtc_ros_server_node-2] 
[webrtc_ros_server_node-2] 
[webrtc_ros_server_node-2] #
[webrtc_ros_server_node-2] # Fatal error in: ../../../src/webrtc_ros/webrtc/build/webrtc/src/pc/peer_connection.cc, line 816
[webrtc_ros_server_node-2] # last system error: 0
[webrtc_ros_server_node-2] # Check failed: !IsUnifiedPlan()
[ERROR] [webrtc_ros_server_node-2]: process has died [pid 382174, exit code -6, cmd '/home/er/ros2_ws/install/webrtc_ros/lib/webrtc_ros/webrtc_ros_server_node --ros-args -r __node:=webrtc_server --params-file /tmp/launch_params_y3ih5v_0'].
[webrtc_ros_server_node-2] # AddStream is not available with Unified Plan SdpSemantics. Please use AddTrack instead.

Looks like Unified Plan semantics deprecated a few of the older APIs and the webrtc client need to be rewritten...
https://webrtc.org/getting-started/unified-plan-transition-guide
There's a document on how to migrate native C++ applications to Unified Plan, but I can't access the doc...
I found this page that maybe (?) contains a copy of the document https://blog.csdn.net/dotphoenix/article/details/107480133 but no idea.

@EricVoll EricVoll changed the base branch from develop to develop-ros2 July 12, 2024 13:06
@EricVoll EricVoll marked this pull request as draft July 12, 2024 13:07
@EricVoll
Copy link
Author

Ah there it is. Found the commit that removed the macros...
https://webrtc.googlesource.com/src/+/de95329daa7175fa28a508681ab262596111cc57

@EricVoll
Copy link
Author

Ah there it is. Found the commit that removed the macros... https://webrtc.googlesource.com/src/+/de95329daa7175fa28a508681ab262596111cc57

Ah no... The macro that's being used isn't removed in that PR. Can't find the commit that removed the file.

@EricVoll
Copy link
Author

@PoommipatWat
Copy link

Is your repo(https://github.com/EricVoll/webrtc_ros/tree/fix/ros2_jazzy) works now?

@EricVoll
Copy link
Author

No, I got everything to build and it ran, but the repo is using a deprectated webrtc api which chrome doesn't support anymore. In the end I didn't have the time to update the implementation. I ended up writing a custom ros package based on aiortc in python that offers a REST endpoint for signaling and the local node publishes the streams to webrtc and ROS.

However, that code is proprietary (company) and I can't open source it.

@jp-turra
Copy link

jp-turra commented Feb 6, 2025

Hello everyone,

I've worked to find a way to build and run webrtc_ros on Ubuntu 24 with ROS Jazzy. Here are the steps that worked for me:

Steps to build webrtc_ros on Ubuntu 24 with ROS Jazzy

  1. Update the hash in the file webrtc_ros/webrtc/build/get_webrtc_source:

    src@f183d1d9966b312006e395dc4c270639b35d26de
  2. Run the build once (with the flag above) or install WebRTC using the script get_webrtc_source:

    colcon build --cmake-args -DCMAKE_CXX_FLAGS=-fpermissive --packages-select webrtc

    or

    ./webrtc_ros/webrtc/build/get_webrtc_source
  3. After encountering some errors or finishing cloning the WebRTC source code, add the following include in both webrtc_ros/webrtc/build/webrtc/src/call/rtp_demuxer.h and webrtc_ros/webrtc/build/webrtc/src/rtc_base/third_party/base64/base64.h:

    #include <cstdint>
  4. Update the CMake minimum required version if needed:

    cmake_minimum_required(VERSION 3.5)
  5. In the files webrtc_ros/webrtc_ros/src/ros_video_capturer.cpp and webrtc_ros/webrtc_ros/src/ros_video_renderer.cpp, update the header of cv_bridge to:

    #include <cv_bridge/cv_bridge.hpp>
  6. In the file webrtc_ros/webrtc_ros/CMakeLists.txt, add the following:

    find_package(ament_index_cpp REQUIRED)
    
    ament_target_dependencies(
      ${PROJECT_NAME}_server_node
        async_web_server_cpp
        cv_bridge
        image_transport
        rclcpp
        std_msgs
        webrtc_ros_msgs
        ament_index_cpp
    )

These steps allowed me to build and run the project. It worked on some devices, but there is some delay when connecting two devices using the HTTP server. I’m still investigating this issue.

@adlimited
Copy link

Screenshot 2025-04-02 at 14 53 36

Hi, I tried to colcon build the jazzy version of the commit branch, but I'm still encountering errors.
Could you please help me out?

@jp-turra
Copy link

jp-turra commented Apr 2, 2025

Screenshot 2025-04-02 at 14 53 36 Hi, I tried to colcon build the jazzy version of the commit branch, but I'm still encountering errors. Could you please help me out?

Hello @adlimited, you don't have Ninja in your system. It is not installed in the build. You can solve it by installing via apt (sudo apt install ninja-build) or by using the script under the folder webrtc/build/get_ninja.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants