Having got a thing together that lets me use some magic to load a V-REP robot simulator scene, connect to it and control a robot contained inside it, I also started to wonder about we could build instrumentation on the Jupyter notebook client side.
The V-REP simulator itself has graph objects that can record and display logged data within the simulator:
But we can also capture data from the simulator as part of the Python control loop running via a notebook.
(I’m not sure if streaming data from the simulator is possible, or how to go about either setting that up in the simulator connection or rendering it in the notebook?)
So here’s my quick starter for 10 getting a simple data display running in a notebook using IPython widgets.
So here’s a simple text display to give a real time (ish) view of a couple of sensor values:
As the robot runs, the widget values update in real-time-ish .
I couldn’t figure out offhand how to generate a live-updating chart, and couldn’t quickly see how to return data from inside the magic cell as part of the magic function. (In fact, I’m not convinced I understand at all the scoping in there!)
But it seems as if we set a
global variable inside the magic cell, we can get data out and plot it when the simulation is stopped:
Example notebook here.
If anyone can show me how to create and update a live chart, that would be fantastic:-)
One thought on “First Attempt At Using IPywidgets in Jupyter Notebooks to Display V-REP Robot Simulator Telemetry”
Creating and updating a live plot turned out to be very tricky, considering: (1) bugs in matplotlib, and (2) the complications in the many different ways that the plot could be created (in a console, in a notebook, without a DISPLAY variable, etc.) However, we do have a working solution (ie, no known issues, but there may be some). See for example our conx Network.plot_loss_acc() function: https://github.com/Calysto/conx/blob/master/conx/network.py#L1755
Caveats: we don’t really update, but merely clear the plot (if in the console) or clear the output (if in the notebook). Also, in the notebook we generate SVG images rather than relying on matplotlib’s backends due to bugs, eg https://github.com/matplotlib/matplotlib/issues/9606
Comments are closed.