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

rtsp Pipeline with ROS2 humble #97

Open
Amit10311 opened this issue May 6, 2024 · 2 comments
Open

rtsp Pipeline with ROS2 humble #97

Amit10311 opened this issue May 6, 2024 · 2 comments

Comments

@Amit10311
Copy link

Amit10311 commented May 6, 2024

I am trying to get gscam working on ROS2 Humble.

Pipeline
gst-launch-1.0 -v rtspsrc location=rtsp://main:main@1xx.1xx.100.xxx:554/11 do-retransmission=false latency=0 ! queue ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! videoscale ! video/x-raw,width=640,height=480 ! autovideosink

[component_container-1] [WARN] [1714984426.616609522] [gscam_node]: [camera] does not match default in file /home/user/../../install/gscam/share/gscam/examples/uncalibrated_parameters.ini
[INFO] [launch_ros.actions.load_composable_nodes]: Loaded node '/gscam_node' in container '/gscam_container'
[component_container-1] [INFO] [1714984426.616621495] [gscam_node]: Loaded camera calibration from package://gscam/examples/uncalibrated_parameters.ini
[component_container-1] [WARN] [1714984426.616650740] [gscam_node]: No camera frame_id set, using frame "camera_frame".

Environment

ROS_DISTRO=humble RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
Can you please help me? @gitjuanr @jeremroy @KnechtNoobrecht

@nbaldy
Copy link

nbaldy commented May 9, 2024

Debugging tips:

  • See gstreamer errors and warnings
 export GST_DEBUG="*:3"
  • Run ROS node in verbose
ros2 run gscam gscam_node --ros-args --log-level DEBUG

What errors are you seeing? What's the behavior?

Another note, that I think could be a problem - if you don't set gstreamer to log errors, it could quietly have pipeline problems. For instance, I had this one:

0:00:00.008466552 587282 0x70a4cc1b7e30 WARN               structure gststructure.c:2288:priv_gst_structure_parse_name: Failed to parse structure string ''application/x-rtp, sampling=(string)YCbCr-4:2:2, width=(string)640, height=(string)480''
0:00:00.008482453 587282 0x70a4cc1b7e30 ERROR           GST_PIPELINE gst/parse/grammar.y:453:gst_parse_element_set: could not set property "caps" in element "udpsrc0" to "'application/x-rtp, sampling=(string)YCbCr-4:2:2, width=(string)640, height=(string)480'"
[ERROR] [1715286998.693376586] [gscam_publisher]: Gstreamer errors after pipeline: 4could not set property "caps" in element "udpsrc0" to "'application/x-rtp, sampling=(string)YCbCr-4:2:2, width=(string)640, height=(string)480'"
...
[DEBUG] [1715286998.696153169] [rcl]: Publisher initialized
[INFO] [1715286998.696462436] [gscam_publisher]: Publishing stream...
[INFO] [1715286998.696548809] [gscam_publisher]: Started stream.
0:00:00.013528939 587282 0x70a4cc007c60 WARN        rtpbasedepayload gstrtpbasedepayload.c:815:gst_rtp_base_depayload_handle_buffer:<rtpvrawdepay0> error: No RTP format was negotiated.
0:00:00.013538828 587282 0x70a4cc007c60 WARN        rtpbasedepayload gstrtpbasedepayload.c:815:gst_rtp_base_depayload_handle_buffer:<rtpvrawdepay0> error: Input buffers need to have RTP caps set on them. This is usually achieved by setting the 'caps' property of the upstream source element (often udpsrc or appsrc), or by putting a capsfilter element before the depayloader and setting the 'caps' property on that. Also see http://cgit.freedesktop.org/gstreamer/gst-plugins-good/tree/gst/rtp/README
0:00:00.013569232 587282 0x70a4cc007c60 WARN                 basesrc gstbasesrc.c:3127:gst_base_src_loop:<udpsrc0> error: Internal data stream error.
0:00:00.013572843 587282 0x70a4cc007c60 WARN                 basesrc gstbasesrc.c:3127:gst_base_src_loop:<udpsrc0> error: streaming stopped, reason not-negotiated (-4)
[ERROR] [1715286998.696687399] [gscam_publisher]: Could not get gstreamer sample.

However, a pipeline was still created, so the node error/exit was not triggered. I'm going to probably suggest (once I get a little more comfortable with this) adding the following after this detection so it's at least printed:

  if (error && error->code != 0)
  {
    RCLCPP_ERROR_STREAM(get_logger(), "Gstreamer errors after pipeline: [" << error->code << "] " << error->message);

  }

So that even in non-verbose mode, we'll see the errors, like in my issue:

[ERROR] [1715287940.967268950] [gscam_publisher]: Gstreamer errors after pipeline: [4] could not set property "caps" in element "udpsrc0" to "'application/x-rtp, sampling=(string)YCbCr-4:2:2, width=(string)640, height=(string)480'"

So, not a direct answer to your question because I don't really understand exactly what you're asking, but my error was that I was setting my configuration wrong:

 export GSCAM_CONFIG="udpsrc port=5000 caps='application/x-rtp, sampling=(string)YCbCr-4:2:2, width=(string)640, height=(string)480' ! rtpvrawdepay ! videoconvert"

The above fails because I'm not properly escaping my quotes

Fixed with

export GSCAM_CONFIG="udpsrc port=5000 caps=\"application/x-rtp, sampling=(string)YCbCr-4:2:2, width=(string)640, height=(string)480\" ! rtpvrawdepay ! videoconvert"

And then, I get a nice video stream with

ros2 run gscam gscam_node --ros-args --log-level DEBUG

@Amit10311
Copy link
Author

I am using a rgb camera with RTSP server. Does the pkg works with rtspsrc?

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

No branches or pull requests

2 participants