When to use ROS Nodes and good structure practice with ROS?

asked 2021-08-07 06:38:58 -0500

nayan gravatar image

Hi all!

I am working on a ROS project which includes subscribing to a PointCloud topic and detecting collisions. I had a question regarding the general structure of ROS projects and ROS Nodes.

I am implementing my project such that I have different nodes for different tasks. For example, my first node subscribes to the actual PointCloud data and publishes a compressed version of the cloud. My second node takes in (subscribes to) the compressed version of the cloud and publishes an array of different PointCloud segments. My next node takes in the array of PointCloud and does some tracking and publishes a PointCloud with different colors for different segments. I have other nodes for calculating the publishing the centroids for different segments, calculating and publishing the bounding box around the segments, etc.

I made the structure of the nodes like a simple pipeline such that changes could be made in a specific part of the package without affecting the other parts of the package. Eg. if I want to try another segmentation algorithm, I can just change/edit the segmentation node without affecting the other nodes and their communication.

I was wondering if this is a proper structure for ROS Nodes or not? I got a few suggestions telling me I should have everything in one node and pass data through c++ classes as it would potentially reduce some delay I am experiencing when passing data from one node to the other (specifically, I am converting pcl::PointCloud2 to sensor_msgs::PointCloud in order to publish an array of Point Clouds and re-converting sensor_msg::PointCloud to pcl::PointCloud2 after subscribing to them).

Can someone explain and clarify this for me? Which structural approach is better/standard? Any suggestions and recommendations are appreciated!

Thanks!

edit retag flag offensive close merge delete