Fun educational project you should do with your kids.
So, first off, how cool is it that we can relive our childhood passions as adults with our own kids?! And what raises the coolness factor even more is that this particular endeavor combines fun with the kids, my own passions and a unique opportunity for learning and using skills relevant to most IT professionals. Yes, you get the exhileration of a rocket launch powered by all the fly technologies: Alexa Skills Kit, AWS Lambdas, Slack integrations, and Python Raspberry Pi Slackbots using GPIO libraries.
At Tech Em we are constantly trying out new ways of teaching technology to kids — often times the ideas that garner the best results are the ones that harken back to what learning technology was like for me during the 80’s. In fact, getting Computer Science students back in touch with the bare hardware is part of the inspiration behind the Raspberry Pi, which is certainly why we love them. I learned a lot about aeronautics, circuits and making (before that was a thing) from model rocketry as a kid and that holds true today.
Rather than pushing children to think like adults, we might do better to remember that they are great learners and to try harder to be more like them. — Seymour Papert
Something Tech Em doesn’t do is shy away from utilizing the same tools that real Software Engineers use, cause I certainly wish I had Emacs on the TRS-80! Seriously, part of learning the art of programming is learning source code control, testing, continuous integration, cloud computing, design thinking, and how to coordinate with a team both virtually and in person. Not teaching the proper tools and techniques is like trying to teach a carpenter apprentice how to nail down the subfloor (and extract nails) with a plastic hammer.
Consequently, the evolution of the “Alexa, launch my rocket” project first started with an idea to build upon the Python coding projects we do on the Raspberry Pi and mix them into a Slackbot, giving the kids a user interface they understand, instant messaging. We had already setup our students on slack to correspond about classes, assignments, and allow them exposure to business text messaging. Furthermore, we had already introduced our coding classes to GitHub with at least one repo for each class and the GitHub-Slack integration so they could all watch and learn about source code control and working on development teams. The slackbot project is a great mix of 80’s style non-GUI coding using today’s technology and professional tooling.
Essentially, our slackbots run as a Python app on the Raspberry Pi. The slackbot watches for specific commands to execute custom functions. Because, we are running Python on the Pi, we can use GPIO libraries to interact with the physical world. For our student projects, the interactions are typically things like turning on/off LEDs and reading sensors/pins. The Mission Control launch sequencer actually cranks this up a notch because we are dealing with higher voltages and ultimately rocket engine igniters. We need to ensure a safe and proper sequence (state transitions) and ultimately minimize the delay for the final step in the sequence just in case the wind kicks up or a dog wanders over to the rocket. We use some on board LEDs not only to indicate state to the ground crew, but also for checking status using the GPIO libraries by the Mission Control software. Did I mention this is an awesome teaching project?
For the slackbot development, we have each class work on a repo together; using Python packages, each developer has her own custom command/function file that is combined with all the others during the automated build. For every student git push to master, we actually use Travis-CI to build the classes’ code, run our tests, and deploy the slackbot app as a library to PyPi. The class Raspberry Pi (or Pis in our studio or at my home) use cron to regularly check for updates to the slackbot (via pip install) and restart. Yes, the slackbot uses the Slack Real Time Messaging API connected to the team Slack channel firehose of messaging and runs just fine on a Pi.
These projects have been extremely fun and rewarding and, most importantly, they are the epitome of modern applied computer science. The students are contributing to a common open repo using Git, having a cloud (container-based) CI/CD build and test their changes (with each step logged in slack) and then deploy/upload to a standard python library repository. Anyone can pip install the project on his machine to run the unit tests or simply wait a few minutes and execute the code on a Pi. And they can do this directly in the GitHub editor at home — to affect the Pi in their classroom miles away! And slack is the user interface to control their custom IoT device.
Enter Alexa. I reused the Slackbot project to quickly build a proof of concept for a client that went a bit further. The slackbot for that client demo took commands to get and set data into a cloud database (AWS RDS) of topics and then monitored slack conversations to track activity on those topics. And to fully build out a compelling demo, I added an Alexa skill that read data from the same database. An exciting portion of the demo was simulating conversations in channels that mentioned topics and then asking Alexa about the trending topics. Yes, back to basics of CRUD, but within the world of instant messaging, serverless, cloud compute and store, capable IoT devices and a voice interface.
While preparing the demo I sort of created a bug. One of the things I do with lambda services is drop progress messages in a slack channel. I have slack up all the time, so may as well use it as a debugging tool, right? Anyway, this logging was also being picked up by the slackbot! Ultimately, I restricted the channels that the slackbot monitored, but I knew what this meant — I can send commands to the RPi slackbot via a simple Incoming WebHook to slack from the Alexa lambda service.
Enter Estes. I have been launching rockets with the kids for a few years cause, well, I have always loved model rockets (and really anything Aerospace Engineering related). I also had on my personal backlog to launch rockets using a RPi. However, I had always thought about having the Pi supplement a fancy led launch timer/sequencer with perhaps some other telemetry recording capabilities. I don’t remember the actual moment now, cause early this year, my kids and I simply understood — we should ask Alexa to launch our rockets. Not only would it be really cool and fun to build the rockets, the code and the wiring/circuit (transistors are a big part of Tech Em’s curriculum and this project requires a bigger TIP120 power transistor), but also it would provide additional safety since we could stand farther away, wirelessly!
The Mission Control commands that ultimately fire the rocket present a nice problem for new Python developers to solve — don’t allow just one command to launch the rocket, there must be a specific series of commands issued before the launch pin is energized. The requirements go like this: 1) the Pi must first be armed, which shall light both the red and green LEDs on the case; 2) the launch can then be commenced (iff both LEDs are on), which shall then blink and turn off the red light and leave the green LED on; 3) finally the launch command can be processed, which shall start the green LED to blink quickly and turn on the launch pin within 3 seconds; 4) the launch pin is turned on for at least 1.5 seconds to energize the transistor to allow the 6V circuit to close such that at least 600mV goes through the rocket igniter long enough to generate the spark. The recommended solution is to actually use the LEDs to manage the state, reinforcing how to turn on and off pins as well as check their status.
Likewise, the Alexa skill and lambda service is relatively straightforward, but we enforce similar safeguards. The requirement for the skill go like this: 1) A user must first request arming; 2) followed by a request within the same session to initiate the launch sequence, which starts the countdown; 3) a final check must be made before the launch command is sent to ensure the field is clear, which finishes the countdown and announces the blast off. Thus, this requires dealing with session attributes, allowing an abort up until the final roger roger. If one tries to break the sequence, alexa will scrub the launch and send the disarm command. And because the skill logic is implemented in lambda, we can continue to leverage Python that happens to be running serverlessly in the cloud.
I’m making all the code available in GitHub with the commiserate warnings about model rocket safety and the recommended process to be safe while having fun. We, of course, have several improvements in the works and will ultimately focus on Alexa, the RPi and launching rockets, but from a teaching and tech education perspective, this initial project is terrific at tying together a bunch of buzzworthy technologies, applied computer science, and maker skills into an exciting, tangible, event for all ages.
My friend calls me the Cloud Maker. I think my kids and I are more Makers of things for the Clouds using the Cloud, but that doesn’t roll off the tongue.