Better software design in accessing data
I would like to know a better software design utilizing ROS and object-oriented paradigm. I have written 2 nodes (say, node A and node B) in which each node comprises one class. In the node A, I have a dataset that is stored in a 2D array. In the node B, I want to access a yaw angle data (not all elements in the 2D array) from the node A. How should I realize this in a better way?
I can think of implementing it in 2 ways, either:
- I should write some lines of code that publishes yaw angle data in the node A, by which, later, I subscribe it in the node B, OR
- I should declare and define a getter(accessor) member function in the node A that returns the yaw angle data, in which later, in the node B, I will instantiate an object and access the data via the getter.
These are only my thoughts and I do not know which one is better over another or perhaps there is an elegant way of doing it.