Ask Your Question

Revision history [back]

rostopic pub multiarray

Quick question, how do I publish a multiarray? I use rostopic a lot, and its tremendously helpful. One thing I was never able to figure out, was how publish a multiarray(I also wasn't able to find a post on it).

This is the format it provides:

rostopic pub /topic_name std_msgs/Float32MultiArray "layout:
  dim:
  - label: ''
    size: 0
    stride: 0
  data_offset: 0
data:
- 0"

That can publish a single element multiarray, but I couldn't figure out how to add another element on that array.

I've tried...

rostopic pub /topic_name std_msgs/Float32MultiArray "layout:
  dim:
  - label: ''
    size: 0
    stride: 0
  data_offset: 0
data:
- [0.0, 1.0]"

and a bunch of other variants, but nothing works. If someone can help with the syntax, that would be appreciated!