Ask Your Question

how to take same variable to two different nodes in cpp ?

asked 2019-10-30 04:33:49 -0500

to_infinity_nbeyond gravatar image

hello ,

i want to take global variable one node to another without using publisher and subcriber ! can anyone give me idea ?

thanking you

edit retag flag offensive close merge delete



It looks like an xy-problem, why do you want to do this and why subscribers/publishers can't be used ? Do you also want to avoid using a service or an action server ? You should give more details about what you want to achieve and what you've tried so far.

Delb gravatar image Delb  ( 2019-10-30 05:21:30 -0500 )edit

@Delb Yes, I have same question. For example I am creating a bool flag in one node, When I am going to PAss command from one node to another node I will set and reset the flag to publish 1, sometime my data not published in another node but flag reset successfully done. That's why I don't want to go for Publisher/Subscriber. If I am creating global var How can I call from another node. It will help better usage of var and (Pub/Sub).

Mehikel gravatar image Mehikel  ( 2019-10-30 10:35:46 -0500 )edit

@Mehikel Don't hesitate to open a new question, yours might not be related with OP's question. If you do, don't forget to detail what you want, the errors you get, even some code if relevant. A new question is always better than a commentary.

Delb gravatar image Delb  ( 2019-10-30 11:11:34 -0500 )edit

@Delb I want to share multiple flags between multiple nodes, and i'm not sure if using subscribers/publishers is the valid option Is service or action server the only option? Currently I'm using multiple subscribers/publishers

to_infinity_nbeyond gravatar image to_infinity_nbeyond  ( 2019-10-30 12:33:58 -0500 )edit

Again, please expand on why you want to share those flags. With the inputs you give pub/sub, service and action server are all valid options. Why is it bothering you to use pub/sub ? We can't advise you a propper solution with that little informations.

Delb gravatar image Delb  ( 2019-10-31 03:46:14 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-10-31 03:10:57 -0500

duck-development gravatar image

The principle of node is that there are small Programms running without other nodes. So you easy reuse it.

If nodes depend on each other tightly. then you may create a bigger node with the function of those nodes.

edit flag offensive delete link more


If nodes depend on each other tightly. then you may create a bigger node with the function of those nodes.

I don't really see how this option would share the data between the nodes (without pub/sub). What you say is more the approach of creating C++ classes/libraries that you could include in your main program to use some methods, but not sharing data (unless you create an object of each class in your main program but then it would be weird to create nodes from your main node)

Delb gravatar image Delb  ( 2019-10-31 03:58:04 -0500 )edit

If you like to share data then you have in ROS topic, action, service, and parameter Server, that's it. If you like to share the data synced you use a service but this is an 1:1 dataflow.

duck-development gravatar image duck-development  ( 2019-10-31 09:25:02 -0500 )edit

Agreed but OP's question was to avoid topics.

Delb gravatar image Delb  ( 2019-10-31 09:56:05 -0500 )edit

You can use stuff not deliverd with ros. SQL data server, Mongo dB, mqtt-broker, rest server, TCP connection, udp data Gramm, but it is not ros specific

duck-development gravatar image duck-development  ( 2019-10-31 11:48:40 -0500 )edit

Thanks for the suggestions, I will try experimenting using a parameter lists and also by creating libraries

to_infinity_nbeyond gravatar image to_infinity_nbeyond  ( 2019-11-04 07:44:24 -0500 )edit

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


Asked: 2019-10-30 04:33:49 -0500

Seen: 81 times

Last updated: Oct 31 '19