0

I am looking for a way to share two fairly large arrays (~1 million floats) from Tensor Flow between two ROS2 nodes. I tried publishing them over a ROS topic using a custom message type containing two arrays. I only got this to work by converting it from a Device Array, to a Numpy Array, to a List, To an Array. And on the receiving side it also would have to be turned into a System Array again. This method seems really inefficient and takes about 0.15 seconds.

What is a better and more efficient way of doing this?

Edit: More info

  • I'm using ROS 2 Foxy on Ubuntu 20.04
  • The nodes are running on the same device in the same ROS environment
Thijs Hof
  • 1
  • 2
  • How are the nodes connected? – Mark Setchell Jan 24 '22 at 22:39
  • @MarkSetchell The nodes are running on Ubuntu 20.04 on the same device in the same ROS environment. One is creating a "map" of the magnetic field in a room using a gaussian process, I would like to be able to communicate this "map" to other nodes for visualization and other types of processing. – Thijs Hof Jan 25 '22 at 11:09
  • You could consider using the new-ish Python multi-processing shared memory or Redis like here https://stackoverflow.com/a/55313342/2836621 – Mark Setchell Jan 25 '22 at 12:01
  • Shared memory stuff is here https://docs.python.org/3/library/multiprocessing.shared_memory.html – Mark Setchell Jan 25 '22 at 12:29

0 Answers0