How to set a suitable 'architecture' for a ROS Package?

asked 2017-10-24 17:02:54 -0500

Jasmin gravatar image

updated 2017-10-24 17:19:27 -0500

Hi community!

When I first started using ROS, I was not familiar with the way it works. looking to ros_graph of existing packages was very useful and magical and do reflect the whole inner architecture of the package, its different modules, and how they exchange data.

But, when I look for the packages that I've developed so far, I feel that they are not well structured, basically it is a node reading some data from sensors and publishing something or just printing something to the screen.

So it is basically a linear code, but in some cases when complex computations and operations are done and when my node does so many tasks or steps sequentially, I think a better practice would be spliting these tasks into different blocs and create a node for each one and make sure that they communicate and cooperate together to get everything done effectively.

I was trying lately to give my packages, sort of a structured design, thinking about how many nodes to use? How many publishers and subscribers? what message types to use? and how should the code be to do what is needed etc.

Is there any recommendations regarding this topic, is there any 'norms' or 'design patterns' that can be used to create "good quality" packages?

Thanks.

edit retag flag offensive close merge delete

Comments

I don't know if there's some kind of "norm". But I understand you, I was asking this question myself some time ago. What I've learned is basically look at the work of other people (e.g. on github) and learn from their experience. But think about the code.

l4ncelot gravatar image l4ncelot  ( 2017-10-25 01:17:37 -0500 )edit
1

You need to understand why it's there and why it's been implemented that way. And if your design disagrees with theirs just figure out your own design and test it. Other advice would be to create you code functional and then decide to refactor it's design.

l4ncelot gravatar image l4ncelot  ( 2017-10-25 01:19:56 -0500 )edit
1

It's always the cycle of writing code and refactoring.

l4ncelot gravatar image l4ncelot  ( 2017-10-25 01:20:32 -0500 )edit

Thank you for your comments @l4ncelot , that's exactly what I mean. Happy I'm not the only one going through this. I 'll follow your recommendations :) .

Jasmin gravatar image Jasmin  ( 2017-10-25 02:40:57 -0500 )edit