how to take same variable to two different nodes in cpp ?
hello ,
i want to take global variable one node to another without using publisher and subcriber ! can anyone give me idea ?
thanking you
Asked by to_infinity_nbeyond on 2019-10-30 04:33:49 UTC
Answers
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.
Asked by duck-development on 2019-10-31 03:10:57 UTC
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)
Asked by Delb on 2019-10-31 03:58:04 UTC
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.
Asked by duck-development on 2019-10-31 09:25:02 UTC
Agreed but OP's question was to avoid topics.
Asked by Delb on 2019-10-31 09:56:05 UTC
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
Asked by duck-development on 2019-10-31 11:48:40 UTC
Thanks for the suggestions, I will try experimenting using a parameter lists and also by creating libraries
Asked by to_infinity_nbeyond on 2019-11-04 08:44:24 UTC
Comments
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.
Asked by Delb on 2019-10-30 05:21:30 UTC
@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).
Asked by Mehikel on 2019-10-30 10:35:46 UTC
@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.
Asked by Delb on 2019-10-30 11:11:34 UTC
@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
Asked by to_infinity_nbeyond on 2019-10-30 12:33:58 UTC
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.
Asked by Delb on 2019-10-31 03:46:14 UTC