ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org

# Visualize or plot Float32MultiArray data field

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 close merge delete

Sort by » oldest newest most voted

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.

https://github.com/flynneva/graph_rvi...

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.

more

1

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

( 2020-11-09 13:13:10 -0600 )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. https://github.com/flynneva/graph_rvi...

( 2020-11-09 23:18:53 -0600 )edit

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.

more

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

( 2019-04-25 09:28:18 -0600 )edit

PlotJuggler has this capability now with the lua scripting feature: https://github.com/facontidavide/Plot... 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:

Global

new_series = MutableScatterXY.new("trajectory_XY")


function

 new_series:clear()

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
end


(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 = MutableScatterXY.new(series_name)
new_series:clear()

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
end
end


Global:

yaw_series = MutableScatterXY.new("yaw")


function:

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).

more