ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Best Practice for Suscriber and Publisher

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

StanSmooth gravatar image

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

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 image Airuno2L  ( 2017-12-20 07:03:28 -0500 )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 image StanSmooth  ( 2017-12-20 09:09:24 -0500 )edit

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

jayess gravatar image jayess  ( 2017-12-20 14:40:18 -0500 )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 image StanSmooth  ( 2017-12-21 03:50:03 -0500 )edit

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

StanSmooth gravatar image StanSmooth  ( 2017-12-21 03:56:48 -0500 )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 image jayess  ( 2017-12-21 04:08:32 -0500 )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 image StanSmooth  ( 2017-12-21 04:11:49 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

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

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

Question Tools

1 follower

Stats

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

Seen: 228 times

Last updated: Dec 21 '17