Ask Your Question

publish and subscribe to numpy.ndarray topic in ROS2

asked 2020-11-02 10:33:48 -0600

Kreace gravatar image


My question is quite simple is it possible to create publishers/subscriber of a numpy.ndarray topic and how? I searched on the internet and I found these two links :

I don't know if I understood them wrong but apparently it is possible to do so. I'm using ROS2 Foxy Fitztroy. I tried to create my own custom message type with numpy.ndarray but it never ended up well, and in fact i don't really know in which direction i should search. Is there already some tutorial on how to do it? Should I create a custom message type? Does ROS2 handle it without doing anything? I'm quite lost now so any help would be very much appreciate!

If you need further information to help me let me know!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-11-02 13:39:41 -0600

Create a custom message corresponding to the data you'd like to publish, then populate it with your ndarray, and publish. Or serialize it into a string field, but that's pretty hacky.

You cannot easily publish a numpy.ndarray by itself.

edit flag offensive delete link more


I have been a bit busy theses days, thanks for the clarification

Kreace gravatar image Kreace  ( 2020-11-04 08:33:31 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-11-02 10:33:48 -0600

Seen: 205 times

Last updated: Nov 02 '20