GStreamer Daemon - ROS: Difference between revisions

From RidgeRun Developer Wiki
No edit summary
No edit summary
Line 68: Line 68:
gstd-client element_set shm vtsrc pattern 18
gstd-client element_set shm vtsrc pattern 18
</syntaxhighlight>
</syntaxhighlight>
}}
* Make sure to stop the Gstd pipeline when you are done.
*Make sure to stop the Gstd pipeline when you are done.
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
gstd-client pipeline_stop shm
gstd-client pipeline_stop shm
</syntaxhighlight>
</syntaxhighlight>
}}

Revision as of 20:54, 15 March 2021


GStreamer Daemon - Digital PTZ

Home

API Examples


ROS (Robot operating system) has a big impact on the development of multimedia products, obtaining images, audio samples and data from hardware sensors all around the system. GStreamer and ROS can work together to deliver modular and optimized systems using images and audio to make decisions on actions to be performed by the robot.

GScam is a GStreamer-based ROS project with the interface to enable, configure and launch GStreamer pipelines, publishing data from any GStreamer source to a specific ROS topic.

Installing GScam

In order to use GScam, you first need to set up your ROS environment and ROS workspace. We will use official ROS documentation:

  • Install ROS Melodic. You can use another distro if you'd like.

ROS Melodic Ubuntu Installation

  • Set up your workspace:

ROS Environment and workspace setup

  • Install GSCam:
cd ~/catkin_ws/
git clone https://github.com/RidgeRun/gscam.git src/gscam
catkin_make

Using GstD with GScam

RidgeRun has modified GScam adding an example to use the Shared Memory elements shmsrc/shmsink to pass buffers from GstD to the ROS node. These elements are needed because of the GstD limitation where the GStreamer buffers (and data in general) are available within the GstD process only, and can't be accessed by the GstD Client process or any other process. Shared memory elements allow us to test the integration between GstD and ROS by using GstD as the source pipeline, and ROS handling the sink pipeline for data publishing.

Let's run the ROS + GstD example:

  • Make sure you have added the following line to your ~/.bashrc file, otherwise, run the command for each terminal opened.
source ~/catkin_ws/devel/setup.bash
  • Start roscore. Open a new terminal and run:
roscore
  • Open a new terminal and start GStreamer Daemon:
gstd
  • Create the test sender pipeline:
gstd-client pipeline_create shm videotestsrc name=vtsrc is-live=true ! "video/x-raw, format=YUY2, color-matrix=sdtv, chroma-site=mpeg2, width=(int)320, height=(int)240, framerate=(fraction)30/1"  ! perf ! queue leaky=2 max-size-buffers=5 ! shmsink socket-path=/tmp/blah shm-size=2000000
  • Start the test sender pipeline:
gstd-client pipeline_play shm
  • Run GScam node, launching the GstD demo.
roslaunch gscam gstd-demo.launch
  • Now the GScam node is publising the RAW data to the topic /gstd/camera/image_raw, you can see the available topics running:
rostopic list
  • You can check the data being published through the topic in 2 ways, using console:
rostopic echo /gstd/camera/image_raw # this will print the pixel values in the console
  • Or using the ROS node image_view:
rosrun image_view image_view image:=/gstd/camera/image_raw # this should open a window that displays the videotestsrc video
  • We can control the pipeline using GstD. For example, changing the image pattern with the following command. You will see in the image_view window the change from the color bars to the ball pattern
gstd-client element_set shm vtsrc pattern 18
  • Make sure to stop the Gstd pipeline when you are done.
gstd-client pipeline_stop shm


GStreamer Daemon - Digital PTZ

Home

API Examples