Running Jupyter Notebooks agains remote kernels on Lego EV3 robot bricks

257 views
Skip to first unread message

Tony Hirst

unread,
Apr 15, 2016, 10:36:31 AM4/15/16
to Project Jupyter

For an Open University residential school activity using Lego EV3 robots, we're looking at various options for programming the bricks. One possibility is that we use the Lego programming environment, a graphical UI based on Labview, another that we teach students some simple python and use the ev3dev linux environment with python-ev3.

In the version of ev3dev/python-ev3 I'm running, there is an old IPython notebook server. This works - ish, though slowly - so I can launch a notebook server on the brick then connect to it from another machine in order to programme the robot.

I've also started exploring how to set up the EV3 brick so we can launch remote kernels on it using remote-ikernel (https://bitbucket.org/tdaff/remote_ikernel) to create the connection file. I've posted a recipe of sorts here:


Has anyone else has tried setting up EV3 robot labs using Jupyter, and if so, how did it go/what route did you take?

thanks
tony

Thomas Kluyver

unread,
Apr 15, 2016, 11:14:10 AM4/15/16
to Project Jupyter
Hi Tony,

That looks amazing, thanks for documenting this!

I'm intrigued to see you're planning to use Jupyterhub - will you make a way to select which brick you're using, or will it just select one, and the first task is to figure out which brick you're controlling?

Thanks,
Thomas

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/93618fdd-25fa-4467-894b-a128530ed6d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tony Hirst

unread,
Apr 15, 2016, 11:50:15 AM4/15/16
to Project Jupyter
Hi Thomas

Re: Jupyterhub - no idea; I haven't used Jupyterhub at all so I'm trying to paint myself architectural sketches around what I think Jupyterhub does and various ways in which I can imagine the activity running!

I guess the simplest way would be to hard code IP addresses for the EV3s (no idea how to do this but I assume it can be done; only wifi router I've ever set up is my broadband one at home, but it can't be that hard, right?!), define a fixed number of users for Jupyterhub (I assume I can do this?) and hard code a kernel.json file for each user so a specific user is assigned a specific brick).

If that works, we could then think about ways of introducing bricks to the server somehow, as well as registering users, and then figuring out how to allocate a user to a brick.

Something else we're exploring is an update of a  drag and drop text editor we've been using till now with the RCX2 lego brick (an earlier Mindstorms brick) which is described in https://blog.ouseful.info/2015/12/04/pondering-new-ways-of-programming-lego-ev3-mindstorms-bricks/ .

I'm keen for this to be developed as a Jupyter client, but I have the feeling that we'll end up with a bespoke node.js client that doesn't go through Jupyter server and may interact with the brick differently. So we may not end up using Jupyter at all... we may end up with a custom client that works outside of Jupyter (but I still would like to get a solution done as proof of concept; and the more I can demonstrate, the better my chances of arguing the Jupyter route through!;-)

We also have a remote science and technology lab - https://learn5.open.ac.uk/course/view.php?id=2  - and I've started thinking about how Jupyter might fit into that. 

tony

Thomas Kluyver

unread,
Apr 15, 2016, 12:04:28 PM4/15/16
to Project Jupyter
On 15 April 2016 at 16:50, Tony Hirst <tony....@gmail.com> wrote:
I guess the simplest way would be to hard code IP addresses for the EV3s (no idea how to do this but I assume it can be done; only wifi router I've ever set up is my broadband one at home, but it can't be that hard, right?!), define a fixed number of users for Jupyterhub (I assume I can do this?) and hard code a kernel.json file for each user so a specific user is assigned a specific brick).

There is a way to have a custom form in Jupyterhub for the user to enter some information before starting their notebook server. This could probably be used to select their brick. Min can give you more info on how that works.
 
Something else we're exploring is an update of a  drag and drop text editor we've been using till now with the RCX2 lego brick (an earlier Mindstorms brick) which is described in https://blog.ouseful.info/2015/12/04/pondering-new-ways-of-programming-lego-ev3-mindstorms-bricks/ .

Neat! I actually had an RCX (Mindstorms 1.5) for years, and I did investigate alternative ways of programming it. I understand that the new EV3 is an order of magnitude more powerful, though.

Thomas

Sylvain Corlay

unread,
Apr 15, 2016, 12:16:04 PM4/15/16
to jup...@googlegroups.com
Hi Tony,

I have been experimenting with ev3dev and Jupyter.

The first thing I would recommend is to not install development versions of notebook from source on the mindstorm. The npm build takes forever on this small machine. Besides that, running the server on the robot worked well for me.

The mindstorm was my initial motivation to add the Gamepad widget in ipywidgets, so that one could wire gamepad buttons and axes to lego motors and other actions in the notebook. The `Controler` widget is part of core ipywidgets. If you are interested, I can also updated the flight attitude widgets, that can be wired to IMU sensors.

Was running the server on the robot an issue in terms of resources for you?

Best,

Sylvain

--

Tony Hirst

unread,
Apr 15, 2016, 12:58:55 PM4/15/16
to Project Jupyter
Hi Sylvain

"Was running the server on the robot an issue in terms of resources for you?"

It seemed to run very slowly on the EV3? Cell commands took a long time to execute compared to going in via ssh and executing commands directly via ipython console. 

How did you install the notebook server on the EV3?

Whilst there is a lot to be said for running all the bricks independently and having them responsible for their own programming environment exposed over http, I've also started coming round to the idea that for a class activity, having a single entry point from a jupyterhub might make sense in terms of classroom management?

The approach should also scale for remote access use if we offer remote access over the internet to the robots, though power management will be an issue there unless we can work out a way of docking the robots into a charging point or inductively charging them somehow.

One of the things I was also considering was data analysis and logging. A notebook server running on a desktop machine rather than EV3 would presumably be better able to cope with running an additional kernel loaded up with pandas, seaborn charts etc etc. I did wonder about using a cell magic to bring the EV3 kernel in eg using https://github.com/moble/remote_exec but it didn't seem to work? (More generally, is there a way to associate a notebook with two or more persistent kernels, and then activate a particular one for a given code cell, as well as supporting transfer of state between them? eg I seem to remember using an R cell magic that let me move data back and forth between a default python kernel and a magicked in R process).

The same issues about managing access etc presumably arise when developing class activities based around Raspberry Pi cards?

tony
Message has been deleted

Tony Hirst

unread,
May 18, 2016, 9:12:09 PM5/18/16
to Project Jupyter
There is a way to have a custom form in Jupyterhub for the user to enter some information before starting their notebook server. This could probably be used to select their brick. Min can give you more info on how that works.

That would be really useful.

Ideally, I'd want to define: user1...userN, with no password, or password user1..userN and then have user N be able to launch against a local py kernel or a remote kernel running via ssh on s/thing like  192.168.1.N 

MinRK

unread,
May 19, 2016, 3:05:50 AM5/19/16
to Project Jupyter

There is an example demonstrating an options form that allows specifying environment variables and command-line args for the notebook servers.

-MinRK


--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages