I landed a gig to teach coding and robotics and I wanted to use Swift. You know that programming language that Apple created a few years back.
The place I was teaching was a green field site, it couldn’t be better. I looked into robots and of course found myself recommending Lego EV3 units. Ok it was expensive, but it ticked all the boxes for STEM project. Sure you can now get a lot of other robots. But for the most part they lack “e” as engineering. Engineering a field that is Lego’s lifeblood.
Back to Swift and I planed to use playgrounds with an EV3 extension. Playgrounds are after all what Apple was to pushing for learning to code. It was all fitting together rather well.
I got an Lego EV3, installed the playground and extension and started testing. It all looked good. Although Lego had their own environment on iPads, it was a cut-down version of their PC app. A version missing the math module among others. A module required for most exercises I would want to try with my classes potentially. The playground had a full implementation of Swift behind it, what could go wrong.
It was the line following exercise that de-railed plan. I managed to create one. But it didn’t work. I struggled for an hour or more to figure out what was happening. It was the sensor, the feedback from it seemed to be coming thru polling. Polling that was too slow. I needed real time feedback.
I logged a call with Lego to ask them for clarification. They never replied. I logged a call with Apple. They were better, although in fairness to everyone, all they did was confirm Lego wrote the app. I made no progress.
Somewhat deflated, I would have to use The Lego app, you know the “scratch” like one. I reviewed it. This wasn’t coding, it was almost impossible to create anything of any complexity. I needed a text based language.
I stumbled across ev3dev.org and looked at my options. Swift was going to have to go out of the window. I considered Java for a moment. But looking thru the code examples I started to doubt I was going to be able to pull this off.
I looked at Python. This was like Perl. I had been programming in Perl since the dawn of time, I could do this. I worked my way thru some CPython examples. I was getting back on track. But you know, in the back of my mind I still wanted iOS in there.
I needed a concept for my classes. Self driving. Autonomous driving. It was perfect. I looked into the code I would need to teach to go forward with the idea. Again cracks in the plan started to surface. The age range was 10 to 18, sure the older ones might manage, but it what about the younger kids. I started to doubt my own plans. I only had 16 hours. Again I was losing it.
I talked to colleagues for advice. I needed more time to make this work, what could I do. A peer who had run the summer camp for some years gave me the most sound advice. Set your goal to match the time available he said, don’t try and change the time you got to match your goal. The goal must be achievable.
My thoughts wondered back to that Lego “scratch” interface, good for 10 year olds. This was after all not a University, it was a summer camp. What was I thinking. The average age would be early teens I was told.
I soul searched for a few days looking on youtube and google for some inspiration. The eureka moment came when I watched a video of kids using remotes to drive their Lego EV3 bots around an arena. Attacking each other at the time. I looked at my dog and he looked back at me. Self driving. A remote. Swift. I said to him again and again. He gave me one of those, shut up and give me a biscuit looks. Wait a minute I thought. An idea started to form itself in my mind.
I could build an iOS app that would require a student to build a Python backend on their robot. A app that would be a remote. I searched for remote. Of course Lego had already built one. I tried it out, it worked well, but you needed to be running the Lego OS, not ev3dev.org version, not Python. No I needed to build my own app. The Lego OS wasn’t coding. That was it; I found my way back to Swift, ok I was going to do the coding but…
I set about doing so with earnest, I should confess to the reader, I have been coding for decades. And indeed using Swift almost since its announcement. I have as also half a dozens apps in store.
Within the month had a working version up and running. It has taken several iterations to get it right, and I hope I hit the right balance. You can down the app for yourself and try it out. You need to check the web page in the apps store too for the Python drivers you’ll need on your robot. Yes, the python code I “was” going to ask the students to write, I wrote that too.
But than things changed again. LEGO announced their support for MicroPython. I needed to redevelop the driver, sure I had a CPython version, but MP seemed to be the route I needed to take. I rewrote the driver in MicroPython and started to work on MP tutorials.
All this happened in early 2019, the summer camp is almost over as I write this and I am pleased to say the remote app worked perfectly, with all the kids; especially the younger ones, try it out if you have chance. Here is the link.
I write up another article to let you know how it worked out. Was Python the right choice. Was the app received well. Did I need to go back to the “scratch” interface. I will have some video evidence I post online assuming I can get permission to do so. Watch this space. June 2019.