0
$\begingroup$

Rosanswers logo

I created a node that subscribes data from 3 other nodes (2 nodes publish data in 30Hz while 1 node publishes in about 10Hz). The node I created uses a transformation matrix(4x4) from the slower node (10Hz) to transform data from other 2 faster nodes (30Hz) and publishes them. The problem is that I don't need every single transformation matrix (but occasionally) from the data stream of the slower node and I also don't want this one becomes a bottleneck of this entire process by using message filter time_sync. So, I wonder whether ROS has something similar to a global variable that sits in one place and can be read or modified so that the node I created doesn't have to wait until all data from 3 other nodes get subscribed.


Originally posted by kidpaul on ROS Answers with karma: 38 on 2021-12-09

Post score: 0


Original comments

Comment by bergercookie on 2021-12-10:
I don't think there's a global variable concept in ROS1 for this purpose. Could you perhaps limit the publishing rate of the 10Hz node itself since you want to use it at a lower rate anyway? Or you could have a wrapper node around the 10Hz node that implements that rate reduction and/or potentially caches the transform matrix.

Comment by kidpaul on 2021-12-10:
Thank you for the verification! The reason why I want to find something like global variable is to avoid the lower rate publishing.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

You tagged this rospy so I'll assume you're asking about python. Yes, python supports global variables within a single OS process. However, you should implement thread-safety if you read/write such a variable from multiple places in your code, typically by using a mutex.


Originally posted by Mike Scheutzow with karma: 4903 on 2021-12-10

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by kidpaul on 2021-12-10:
Thank you for your answer! Yeah, it seems like python global variable is the way to do what I want.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.