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

Visualize or plot Float32MultiArray data field

asked 2019-04-25 08:06:23 -0500

marinePhD gravatar image

Similar to this question, is there a way to plot the data field of a Float32MultiArray message type? I'm trying to show the FFT of a signal in real-time and I can't seem to find a straightforward method of implementing the visualization I've tried Plot juggler, rqt_plot amd rqt_multiplot and they don't seem to have the functionality

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2020-11-09 12:47:06 -0500

flynneva gravatar image

updated 2022-02-18 08:30:41 -0500

lucasw gravatar image

for anyone else who ends up here.....I did a hacky solution to this problem of visualizing uint16 multiarray topics by adding it to the already established graph_rviz_plugin.

it was relatively straight forward, and could be enhanced with the other multi-array types as well IF your use case is similiar to mine where the multi-array was only one dimension, and I wanted to just use the size of the multi-array as the x-axis.

edit flag offensive delete link more



This looks quite good actually. I basically ended up converting my data to an image using opencv and then using an image topic to view it in Rviz. I'll see if I can play around with this and let you know how I get on. My use-case is quite similar. x axis is basically each FFT bin while y axis is the amplitude of each frequency bin

marinePhD gravatar image marinePhD  ( 2020-11-09 13:13:10 -0500 )edit

i dont have a float32multiarray topic to test on but I cleaned up my code a bit and tried adding in the other multiarray types. go ahead and try it out and let me know how it goes.

flynneva gravatar image flynneva  ( 2020-11-09 23:18:53 -0500 )edit

answered 2019-04-25 08:45:21 -0500

mgruhler gravatar image

updated 2019-04-25 08:45:48 -0500

This is due the the *MultiArray data types being quite ambiguous. As you have to / can specify the MultiArrayLayout, you can put rather arbitrary data in there. The docs give an example for encoding an image using this data type. So there is no straightforward way to implement a visualization of this.

Also, all the tools you mention actually work on single value data and plot respective time series. Even though you can configure rqt_multiplot a little bit more, I don't think you are able to do that with this kind of message easily.

You'd have to create your own specific plotting display, I guess.

edit flag offensive delete link more


This is what I've come across as well. Looks like Ill have to write something it seems. Thanks.

marinePhD gravatar image marinePhD  ( 2019-04-25 09:28:18 -0500 )edit

answered 2022-02-18 08:10:06 -0500

lucasw gravatar image

updated 2022-02-18 08:47:41 -0500

PlotJuggler has this capability now with the lua scripting feature: though graph_rviz_plugin is much more straight-forward (you can add it to an .rviz file, launch that .rviz file from the command line or from a launch file and it will display though requires clicking the 'start' button on each plot, plotjuggler requires many clicks and selections to bring up a live display)

Duplicating much of the answer there:


new_series ="trajectory_XY")



  index = 0
  while(true) do
    str = string.format("/mobile_base/yaw_0/data.%d", index)
    series_yaw = TimeseriesView.find( str )
    if series_yaw == nil then break end  

    yaw = series_yaw:atTime(tracker_time)
    new_series:push_back(index, yaw)

    index = index + 1

image description

(Getting the hard-coded topic out of there is easy, turn this into one of the library functions with a topic as an argument:

function CreateSeriesFromMultiArray1D(new_series, topic, timestamp)
  -- new_series =

  index = 0
  while(true) do
    str = string.format("%s/data.%d", topic, index)
    series_y = TimeseriesView.find( str )
    if series_y == nil then break end    

    y = series_y:atTime(tracker_time)
    new_series:push_back(index, y)

    index = index + 1


yaw_series ="yaw")


CreateSeriesFromMultiArray1D(yaw_series, "/mobile_base/yaw_0", tracker_time)

But I don't see a one-step way to drag a multiarray onto the graph array and see the plot, some cut and paste and typing in various text boxes is required. )

It doesn't look hard to have additional rows of data that are plotted in parallel or become the x axis (the example library function shows that) or anything at all, so the flexibility is very high.

The scripts appear to be stuffed into ~/.config/PlotJuggler/PlotJuggler-3.ini as strings so the workflow of developing new scripts, checking them into source control and deploying them onto new systems looks awkward, and the scripts have to be worked on in the provided text box and not your text editor of choice (I'll follow up in the plotjuggler q&a about these).

edit flag offensive delete link more

Question Tools



Asked: 2019-04-25 08:06:23 -0500

Seen: 1,700 times

Last updated: Feb 18 '22