Ask Your Question
0

Best Practice for Suscriber and Publisher

asked 2017-12-20 07:00:31 -0600

StanSmooth gravatar image

updated 2017-12-20 09:00:04 -0600

Hi everyone, I heard somewhere that the best practice for a node was to create a file receiving and publishing all the message, and then to collect these datas from another file if we need to process them.

Something like this :

process.cpp <===> SuscribeAndPublish.cpp <================================>Node 2 l___________________________________/

Node 1

Sorry for the poor schema ahaha

edit retag flag offensive close merge delete

Comments

5

I'm not sure what you're asking.

Airuno2L gravatar imageAiruno2L ( 2017-12-20 07:03:28 -0600 )edit

Sorry if i'm not clear. Someone told me, it was better to have a file supposed to collect and send message on topic, and other files suposed to process the differents algorithm we use. My question is : how do we transfer data from those different files

StanSmooth gravatar imageStanSmooth ( 2017-12-20 09:09:24 -0600 )edit

Usually, a node subscribes to the topics that it needs, processes the data, and publishes data if need be.

jayess gravatar imagejayess ( 2017-12-20 14:40:18 -0600 )edit

Yes, but will it do it on the same file ? (for instance is it possible to have multiple files per nodes ?) I'm finding a lot of examples of basic suscriber and publisher on the net, but nothing with a real processing. Do you have some examples ?

StanSmooth gravatar imageStanSmooth ( 2017-12-21 03:50:03 -0600 )edit

Moreover, is there any advice to implement a ros node, in object-oriented aspect ?

StanSmooth gravatar imageStanSmooth ( 2017-12-21 03:56:48 -0600 )edit

What do you mean by

multiple files per nodes

? Are you asking if you can have multiple nodes per file (like a *.py or *.cpp file)?

jayess gravatar imagejayess ( 2017-12-21 04:08:32 -0600 )edit

No. I know this is possible. What i'm asking is explanations (or examples) on how these nodes with multiples files are working.

StanSmooth gravatar imageStanSmooth ( 2017-12-21 04:11:49 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-12-21 08:03:41 -0600

Airuno2L gravatar image

I think you have heard wrong. You shouldn't need more than one .cpp file to fully describe a node. Most of the time when I'm making a new node, I actually go to the simple tutorial and use it as a template.

When you do have a very complex node, it is sometimes better to do everything as a class, it is still all in one .cpp file though. Here are some pointers on doing that.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-12-20 07:00:31 -0600

Seen: 86 times

Last updated: Dec 21 '17