Ask Your Question
0

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

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

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

Comments

2

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 imageDelb ( 2019-10-30 05:21:30 -0600 )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 imageMehikel ( 2019-10-30 10:35:46 -0600 )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 imageDelb ( 2019-10-30 11:11:34 -0600 )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 imageto_infinity_nbeyond ( 2019-10-30 12:33:58 -0600 )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 imageDelb ( 2019-10-31 03:46:14 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

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

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

Comments

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 imageDelb ( 2019-10-31 03:58:04 -0600 )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 imageduck-development ( 2019-10-31 09:25:02 -0600 )edit

Agreed but OP's question was to avoid topics.

Delb gravatar imageDelb ( 2019-10-31 09:56:05 -0600 )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 imageduck-development ( 2019-10-31 11:48:40 -0600 )edit

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

to_infinity_nbeyond gravatar imageto_infinity_nbeyond ( 2019-11-04 07:44:24 -0600 )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

Stats

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

Seen: 28 times

Last updated: Oct 31