ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Better software design in accessing data

asked 2011-12-25 23:41:06 -0500

alfa_80 gravatar image

updated 2014-01-28 17:11:03 -0500

ngrennan gravatar image

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:

  1. 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
  2. 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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2011-12-26 12:38:06 -0500

dornhege gravatar image

As you describe it 1. and 2. are two different things.

  1. uses ROS to (continuously) transfer information between nodes.
  2. uses a getter, which means that B will need to have an instance of A from somewhere (i.e. they can't be in different nodes). The ROS equivalent of this will be to use a service call that B can use to get specific information from A.

Which one you need depends on the use case. If it is a lot of data and you only need part of the data in specific situations a service seems good.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-12-25 23:41:06 -0500

Seen: 233 times

Last updated: Dec 26 '11