ROS @ Jupyter

Project Jupyter is a huge hit in data science, but it has not yet found widespread adoption in robotics. Today, we are releasing the first version of jupyter-ros, a collection of Jupyter interactive widgets inspired by Qt and RViz, to bring their features to the Jupyter ecosystem. This may be the right time for Jupyter-based developer tools, as cloud robotics is taking off.

This may be the right time for Jupyter-based developer tools, as cloud robotics is taking off.A PR2 robot in the browser, and making him dance through the traditional Qt interface

Historically, the ROS (Robot Operating System) community has relied on Qt for building complex user interfaces. Nowadays, the Jupyter notebook and the ipywidgets framework offer a compelling alternative for several reasons:

Code and interface are not separated — both are in the same notebook.

Complex widgets using browser technology are possible: from JavaScript sliders to 3D with WebGL, real time video streaming with WebRTC…

Works with any web browser — not bound to Linux, and no Qt applications need to be compiled.

Doesn’t need to run locally! Applications can run on a server far away, without any manual setup or installation procedure.

However, ROS does not play nicely with Jupyter. For example, rospy is inherently multi-threaded (every new ROS topic subscriber spawns a new thread). Debug printouts in callbacks result in Jupyter printing that content into the output area of the active notebook cell, quickly flooding the user interface — and there is no easy way to stop logging threads once started.

ipywidgets to the rescue: jupyter-ros

That is why jupyter-ros was created. It is a suite of plugins to the Jupyter ecosystem to make working with ROS inside Jupyter a breeze.

Subscribing with jupyter-ros produces an interactive widget

First, when you subscribe using jupyter-ros, the function returns an ipywidget with a start/stop button and a dedicated output area for debug prints. Internally this re-routes all print outs from your subscriber thread to this Jupyter cell, and gives full control over the thread (by being able to stop and restart it at any time).

The jupyros publishing sugar

If you call the publish function in jupyter-ros, a widget is automatically generated from the message specification. For example, a ROS message String field automatically becomes a text input widget, a Float32 becomes a FloatSlider...

Live plotting IMU data from a BBC micro:bit

Another interesting functionality is the live plotting, similar to rqt_plot. For this we use bqplot, a “jupyter-native” solution to plotting. With jupyter-ros, you can select a couple of fields from your message, and they will be automatically plotted to a bqplot.

Going 3-D

Most robots are three dimensional, and so should be the visualizations! The go-to tool in the ROS ecosystem at the moment is RViz, a very powerful 3-D visualization tool.

Some of RViz’s functionality has already been ported over to the web browser as part of the RobotWebTools effort. We’ve been able to piggy-back on their impressive work, and we’re releasing the first iteration of ROS3D Jupyter widgets. Currently, they allow you to programatically plug together RViz like visualizations for different data types, such as laser scans, robot trajectories, and 3D (URDF) models of the robot!

Thanks to the ipywidgetification, you can now bring complex visualizations to the web, without writing any JavaScript, and arrange those visualizations freely in JupyterLab.

Interactive widgets showing ROS data inside JupyterLab

Jupyter, Widgets, and Cloud Robotics

We hope that Jupyter, and the jupyter-ros widgets will play a big role in cloud robotics. In cloud robotics, some of the software powering one or multiple robots runs on powerful computers in data centers. For monitoring purposes, or development, Jupyter and JupyterLab are perfect candidates. Robot customers will be able to login to a single user-friendly interface, without having to install any custom software on their machine, or run a specialized operating system (ROS usually runs on Ubuntu). Exciting possibilities arise: it is already possible to run a Docker container running JupyterLab and jupyter-ros on the leading cloud robotics platforms, Rapyuta Robotics and their freshly launched platform rapyuta.io.

Installation & source

The jupyter-ros widgets can be installed from PyPI using

$ pip install jupyros

$ jupyter nbextension enable --py --sys-prefix jupyros

The examples and the source code can be found on github: https://github.com/robostack/jupyter-ros

This work is still early stages and you might find some rough edges. We look forward to collaborating with the community to polish these widgets to the highest standards!

About QuantStack

QuantStack is located in the center of Europe (Paris). We are core Jupyter developers, and love ROS, and the cloud. If you are interested in working with us on professional user interfaces for developers or clients in the cloud, do not hesitate to send us an email: wolf.vollprecht@quantstack.net