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

Revision history [back]

I did liveplotting in the past in two ways:

Your prefered way is the matplotlib so thats pretty easy and I explain a little bit more:

There you need a animation.FuncAnimation. It makes an animation by repeatedly calling a function/method. You can read more here.

Furter in the repeatedly called function you should do something like:

xdata.append(frame)
ydata.append(np.sin(frame))
ln.set_data(xdata, ydata)

so there you append new data and than set it. What you now need to do different is that you setup a ROS Subscriber to your data you want to publish and in the callback function/method you need to append the new data and just set in the repeatedly called function the new data. Thats only a close look about how you can do it to give you an idea.

The other way is using c++ and writing for example a rviz plugin with QT. I prefere here the QCustomPlot for live plotting. But thats a little bit tricky and needs more time when you have no idea about QT. But for me it generates better looking plots and when you are used to it its very easy too.

When you need further help please ask! It isnt too detailed. Just to give you an idea.