Robotics StackExchange | Archived questions

Is there a (preferred) syntax for designing ROS applications?

Im writing a program for a robot that uses a camera to analyse its environment and determine its position using the data of the image.
I have the following sets of nodes for it;

Camera-node -(subscribed)-> imageAnalyse-node -(subscribed)-> locationDetermine-node

Is it fine if I merge the the imageAnalyse-node and locationDetermine-node to a single node since the output of the imageAnalyse will only be used for the locationDetermine-node, even thought that means it will be a single node with a lot of code in it compared to the other nodes??

It doesn't have any advantage splitting these notes and it makes the performance of my application worse (speed-wise)

Asked by HaroldVD on 2018-05-29 11:55:14 UTC

Comments

Answers

It is up to you to decide how you want to split your code. If you think that you will have some other node depending on imageAnalysis-node, it might be a good idea to make it as an independent node.

Splitting nodes and transferring images between them comes with serialization/deserialization overheads. You should consider ROS nodelets to utilize zero copy transport between your algorithms.

ROS Nodelets: http://wiki.ros.org/nodelet Porting Nodes to Nodelets: http://wiki.ros.org/nodelet/Tutorials/Porting%20nodes%20to%20nodelets

Asked by vinaykumarhs2020 on 2018-05-29 15:36:01 UTC

Comments

I assume using nodelets doesn't provide any advantages over an implementation where I put all the code in a single node since it doesn't transfer the image then?

Asked by HaroldVD on 2018-05-31 04:54:18 UTC

The advantage is on the design / software engineering side. If you don't care about that and are perfectly fine creating one big monolithic program, then there would be little difference, yes.

But then the question suggests itself: why are you using ROS?

Asked by gvdhoorn on 2018-05-31 05:24:42 UTC

I think it's perfectly fine to have both functions within the same node. You could (and should) however try to keep the implementation separated. One class each for ImageAnalysis and Localization can be used together in the node but with a well defined interface. This will be better for code quality and help you when you have to break up the node in the future.

Asked by NEngelhard on 2018-05-30 04:07:40 UTC

Comments