Interactive Programming: Python & RobotsAbout
From Tortoise to Finch
Robots at Work
The DARPA Robotics Challenge
November 17, 2018
Parents will be invited into the classroom for the last 15 minutes of class so you can show them what you've been working on.
If you have access to a finch after the course is over, you could continue with the Birdbrain lessons. Want to use python classes with the finch? Here's an idea for a canary module with a Canary class that inherits from the Finch class.
In the winter session, there will be a course called Microcontrollers in Action: Programming & Electronics for students in grades 6 to 8. This course will involve work with Raspberry Pi or Arduino, and looks like a good follow up for this course. Contact CTD for further details.
Try out TunePad, a tool for creating music using the Python programming language. You don't need to be a musician to create music with TunePad—you just need an interest in coding and music!
For lessons focused on improving your Python skills, see Codecademy's Learn Python 3 course.
Another great Python skill-building site is CodingBat.com.
November 10, 2018
Python and Robots Progress Survey
Take this survey to let us know how you feel about your progress and what you want to work on next. We'll try to accommodate people the best we can given the limited number of robots and student expectations. Remember, many teams of advanced programmers worked for years on robots to make it to the finals of the DARPA challenge just to have them fall over and quit before finishing. Your primary goal should be to learn as much as you can about programming and robotics, not to achieve a particular outcome with the finch.
If you finish the survey before everybody else is done, you can work on any of the turtle lessons that you haven't completed yet.
After the survey, we will play Kahoot! for a bit and then back to finch work. I'll use the survey as a guide to try to everybody taking the next steps that will work best for them.
Turtle vs. Finch
Now that you have experience with both the turtle and the finch, we can have a discussion comparing the two. We'll hold our discussion at break time.
Turtle changes position inside a loop and stops when some particular change in location or user event occurs.
Finch wheels given a certain velocity and continues at that velocity until it gets certain input from sensors or a user event.
Why are these different? What is the difference between the finch and the screen turtle? The finch and the early mechanical turtle?
The range of valid inputs for wheels is -1 to 1, for both left and right wheels. You can get a number in the range of -1 to 1 like this:
November 3, 2018
The code below makes the turtle panic when it hits the right wall of the screen.
How might you apply ideas from this code to complete Exercise 2 of Obstacles: Finch Security System? How could you make the finch's led light blink? What condition must be met for the finch to start sounding the alarm? How do you make the finch move, turn, and make noise?
After Lesson 8
Depending on your prior programming experience, some of you will need a couple more classes to finish up Lesson 8. Others will be ready to move ahead. Below are some code snippets and ideas to help roboticists who are done with Lesson 8 and want to tackle further lessons.
Lesson 9 - Functions with the Finch
If you haven't written functions yet, or would like to read more about them, see Python Functions.
Lesson 10 - Strings with Finch
Try out the snippet below. What does it do?
In the Thonny shell, try running the following statements:
Try some other characters besides 'y' and 'z'. When does the operator "in" return True? When does it return False?
For more on strings, see Python Strings.
Lesson 11 — Lists with the Finch
Lists are collections of items. The items can be strings, numbers, boolean values, or other objects. Here are examples of lists:
You can use
You can create an empty list by using the left and right square brackets with nothing in between them:
You can also add items to a list with the
For more on lists, see Python Lists.
Files and Dictionaries
Lesson 12 requires some understanding of file handling. Help is available on the following web pages:
For Lesson 13, you should know something about Python Dictionaries.
October 27, 2018
I saw some really cool programs that people wrote last week, including some great work with finch movement, finch sounds and turtle graphics.
A couple of people have started working with sensors.
To start off class today, we'll discuss questions I got from last week's reflections and programming ideas that will help with our upcoming pair programming.
You may have come across the code in the Python turtle documentation. We'll discuss how this code works and take a closer look at while loops and for loops.
Using a random number generator
The code below uses a random number generator to change the color of the turtle.
How could you write this code using a while loop? How would you modify this code to randomly change the color of the LED on the finch?
Below is a program that Ari wrote that a random number generator to control the finch.
For our pair programming time today, we'll work on Lesson 8 — Obstacle Sensors. You must complete exercises 1 through 3 before you start on the maze. Depending on time, we might not get to the maze (exercise 4 and extensions) until next week.
October 20, 2018
Jasmine got her Finch to sing Yankee Doodle Dandy!
Below is code to play the scales. You might want to modify it to create your own compositions!
The program above uses a list to keep track of frequencies. See Lesson 13 if you're interested in using a dictionary to match keys with notes.
Kupu and Neel did a nice job of compressing their maze folders.
if, elif, and else
Connor has come up with a couple of cool strategies for interactive steering. Here's one that works for both the turtle and the finch:
How could you adapt this code to work with the finch?
Below is a code fragment based on work that Connor did last week. What does it do?
What's the advantage of this strategy? Could you use this strategy with the finch?
However, in lesson 14, you'll learn how to use the tkinter module with the finch. Here's a short program that uses tkinter that will give you an idea of what you can do with it:
Could this key binding be used to steer the finch? Could the turtle screen's onkeypress method be used to steer the finch?
October 13, 2018
Individual Work Period
If you and one other person would like to team up during this time, that's fine. I can also do a random assignment of partners for people who want a random partner assigned to them.
Why do so many robots look like animals and humans?
Robots have been made to mimic all kinds of animal life, including humans, insects, birds, reptiles, mammals, fish, and even an octopus. Why do so many engineers use animals as the basis for their robot designs? We'll discuss this question and look at a short video about a robotic wild dog.
October 6, 2018
Virtual and Physical Robots
We'll watch a video about robots and discuss the difference between working with virtual and physical robots.
I'll use a Python program to pick random pairs for pair programming. During the pair programming session, you'll work through the first finch lesson from Birdbrain.
Virtual and Physical Robots
True or False?
We'll take a break by playing a game to get to know each other. You'll take turns telling us one statement about yourself that's true, and one that's false. The rest of us has to guess which statement is true.
September 29, 2018
Welcome to Interactive Programming: Python & Robots! Here's what we'll do today:
In Between Times
I sometimes make videos available on class web pages. To watch the videos, you can ask for headphones or use your own headphones or earbuds if you brought them.
Prepare for your first Finch lesson
Download the Finch Python software. Unzip the FinchPython120.zip file and open the FinchPython120 folder.
After pairs have been assigned, decide with your partner which mac you'll attach to your Finch to begin the first lesson. Hook up the Finch to the USB port on your mac. You should see the LED cycle through colors.
From the FinchPython120 folder, open dance.py with Thonny. Run the dance.py program to see your Finch dance.
Go to Birdbrain Lesson 1. Run the code shown to get the Finch to go forward a bit and then stop. Switch navigator and driver roles for Exercise 1 and for each exercise after that.
Here are some things you might want to do at home: