Skip to content

j-dev01depot/ros2demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

 

Playing with ROS2 and GStreamer...

 
 
I made this simple demo to "get hands dirty" with code while reading ROS2 and GStreamer documentation and tutorials.

The code deals with some typical elements of a ROS2 project: publisher and subscriber nodes, service nodes, composable nodes, executors, logger, launch files.

The demo has been developed in C++ with the rclcpp ROS Client Library for C++, ROS2 Humble, GStreamer, and OpenCV libraries on Ubuntu 22.04.3 LTS.

 

Features

The workspace of this demo contains two packages: jk_demo_gst2msg (GStreamer to Message Demo) and jk_demo_msg2cv (Message to OpenCV Demo).

The jk_demo_gst2msg package contains an executable and a publisher node; the process uses the GStreamer library to play video files to simulate a streaming camera, extract video frames, and publish timed image messages to a topic.
A launcher starts two nodes to publish two topics of different streams at the same time.
The process can be configured to show the continuous streaming in the GStreamer default viewer.

The jk_demo_msg2cv executable consists of two composable nodes, a subscriber node and a service node, composed at compile time and sharing a resource.
The executable can subscribe to any number of topics published by the jk_demo_gst2msg processes, as the topics list is loaded at runtime.
A user can call the service to select one of the topics; the image messages of the selected topic are processed with OpenCV to make face recognition.
The result with the detected faces can be seen in the OpenCV default viewer.

(the descriptions of the nodes startup parameters are in the comments of the launch files)

 


A few easy coding conventions:

  • upper camel case for class names (example: ThisIsAClassName)
  • use the p_ prefix for pointer type member variables and the m_ prefix for the other class member variables, followed by lower camel case (example: std::shared_ptr<MyClass> p_myInstance, int m_myValue)
  • lower camel case name for class member functions (example: void getSomeFun(){} )
  • indentation is two spaces

How to use the code:

if not already done, activate your ROS2 system underlay; example:
$ source /opt/ros/humble/setup.bash

make the directories to set a ROS2 workspace and to store the sources; example:
$ mkdir -p my_temp_ws/src

clone the repository in the newly created src/ directory; example:
$ cd my_temp_ws/src
$ git clone https:github.com/j-dev01depot/ros2demo.git

now get back to the my_temp_ws/workspace main directory, and build the packages; example:
$ cd ../..
$ colcon build --symlink-install --packages-select jk_demo_gst2msg jk_demo_msg2cv

after building, activate the new demo workspace overlay; example:
$ source /<your-path-to>/my_temp_ws/install/setup.bash
 

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published