During my last programming class I worked with a student on programming a robot to draw geometric shapes. Please excuse the weirdness of the video and note that the robot didn't work this time...
The construction of the robot itself was nothing fancy; just a Raspberry Pi, a motor shield, zumo chassis and a python code. Additionally, some tape and a fat red pen (which I normally use to fill in the hell hole of grading rubrics) and then voila!- a drawing robot. All this pales in comparison to anything truly artistic- but think of the first cave men discovering the pigments of the earth and then being able to coat the walls of their caves with images of the saber tooth tiger. It was the beginning of something special; and some would argue that a small spark leads to a grand flame; the primitive cave art flashes forward to become Michelangelo's Sistene Chapel. Revolution in thought and mainly technique; that's what I'm proposing.
Below is the link to my lesson plan:
https://drive.google.com/file/d/0B8Kb7tLLB0yzRFczUU5tdEFCU0k/view?usp=sharing
Below is a link to the worksheet I made for my student to work off of. For this lesson we have moved onto p.2 which involves the creation of buttons in Tkinter:
https://drive.google.com/file/d/0B8Kb7tLLB0yzRlZrbWt1TWgxams/view?usp=sharing
And below! Is an image of the "Turtle Bot" robot fresh from having drawn a geometric pattern. Notice the red pen attached to the front of the battery pack like Linus' beat up blanket from a Peanuts cartoon:
Thinking about the code to produce this "square" required serious trial and error/logical thinking. First off, my student and I had to figure out how many seconds it took our robotic friend to turn 90 degrees. This was with respect to the paper it's wheels rolled on and the friction it's dagger of a pen, dripping off the front like a bloody nose; produced. The outline which should have been a perfect square. But as William, my brilliant programming student pointed out, looks more like a ninja star (maybe one from the Ninja turtles? Just to keep this turtle theme going).
Here is a picture of William writing the code to produce the square image above with the turtle bot-
If you look closely at the image, you'll see that that is Python code being written; and that IS the raspberry Pi interface being mirrored to my laptop through VNC viewer.
That in itself is pretty sweet. But what really puts the sugar on this bon bon of a programming bun is the fact that a function "def square()" is outlined through the motions of the turtle bot robot. This, as I have mentioned in my previous posts, is meant to mirror the use of the Python Turtle library drawing shapes. My objective has always been to turn the representation of a trutle triangle into something which moves around in actual, physical space. Do you get it now? It looks like we came one step closer to this goal. Like CERN firing it's first electron around the particle accelerator.....
If you refer to my lesson plan link "Goal no.3" was to create a button, as a part of the control interface for the robot to execute the "square" drawing function created earlier. This activity closely follows the worksheet which directs the use to first import the appropriate libraries, then create the canvas for the buttons and then a simple button to control a function. It is then up to the student to come up with the rest of the buttons thus, an entire interface for interacting with the turtle bot remotely; if this is too easy then also a button for drawing triangles, circles and the finest mechanical rendition of Renoir's Lilly pond this part of Pennsylvania.
In all seriousness, this button creation approach was once again an attempt to teach addition programming commands by bringing the instructional sequence back to graphics through the Tkinter library. The control interface I created just to maneuver my robot around looks as follows:
But when I gave William my worksheet and set him loose with the task of creating a button for a forward, stop and square function this is what his code looked like when it was executed:
Yup, it's that blank square. As desolate as the depths of a broke heart on prom night. Oh how those roses were for nothing!
And I was just as baffled, where were the buttons! Everything was moving so smoothly but being the teacher I am this was an opportunity to see things as a teachable moment. To explain how debugging is a natural part of being in the programming game, and both of us set out trouble shooting what was missed. This being Tuesday, where literally all my classes involve programming on some level my eyes and emotions were quickly aging from code which fails to compile due to a missing "=" sign or a missing ";" at the end of a declaration. Wow, do those small details count!
Class then ended, gym class had to start at some point and we still hadn't had the satisfaction of drawing a square through the click of a button. I was desperate to see the buttons and I think that my student shared the same desire. That 40 minutes fly by! In the end we never witnessed the buttons but I was left staring at the code for another 30 minutes or so, tearing my head out for an explanation for what went wrong this time. At one point a colleague walked in and asked me if I was stressed because my hair was all messed up; that's just my disheveled motif; maybe its charming, but more than likely it oozes frustration for figuring this coding out. And then all of a sudden, like lightning striking sand, my thinking came together and I realized that William had failed to copy one essential command from the worksheet stating the unpacking of the buttons into the control panel. No wonder this thing didn't work! And shame on me for treating this exercise like a dictee in my 8th grade French class- Monsieur Wack style. I shouldn't have expected him to copy it out perfectly in the first place. I inserted a small comment in the code adding the necessary line so we can pick up with some momentum next week:
I always feel like I need more time to cover the material I design with my students in school. One time a week is certainly not enough to wrap up projects like the one I am attempting right now primarily because troubleshooting always becomes a necessity. Nonetheless, the use of Raspberry Pi for robotics has engaged my student on a new level. All of a sudden this coding thing is taking to life. Specifically, by drawing a drippy red line around paper. And while I was not able to cover the entirety of my lesson plan William and I did achieve this stunning drawing of a square using Python code which now hangs above my desk, prized and almost as bizarre, as the latest Damien Hirst painting.
Next week I'll have those dastardly Tkinter buttons settled and the majority of photos will come from the Raspberry Pi camera module.