Skip to content

CVPM buggy lab with computational modeling

August 7, 2013
tags: ,

The buggy lab is a staple of modeling and many other physics classes. Take a bunch of tumble buggys, modify a few to run slow (short one of the batteries by wrapping it in foil), and then send students off devise an experiment to measure the velocity of their particular buggy. You can read a more thorough description of this experiment on Kelly’s blog.

I want to describe a particular variation on this lab I’ve created that helps students to see the power of computational thinking. Often, I’ve concluded the buggy lab by asking students to figure out, on the basis of their whiteboards, which buggy would win a race. Then, after the class reaches agreement, we test it. This is a great question I got from Frank Noschese that really pushes students to begin to put their newfound CVPM knowledge to use. But I’d like to push this even further and get students to make their first foray into computational modeling.

I’ve written a lot of about computational thinking and modeling before, and I’ve sometimes had students modify a ready made program so that the motion of the buggy on the screen matches the motion of their actual cart. This only takes two lines of editing (the position and velocity statements), and I think it shows students that they can begin to understand a fairly complicated program just by diving in and playing around.

Still, creating a computer model a single cart doesn’t really do much to highlight the power of computational thinking. What if instead, we could somehow run a race of all of the carts together on the computer? Given that the buggies have a tendency to curve, which often makes a race impossible, being able to create a simulated race where the buggies would move in a straight line is a clear example of building a model that disregards unimportant features (the curving motion) and allows us to predict and visualize a race we might not even be able to carry out in real life.

I don’t really want to force students to learn how to make 8 objects move in their program on the second day of class when many of them have no previous exposure to programming.

What if there were a way to automate this? What if I could write a program to take the student’s changes from their individual buggy code and merge them into a single program to simulate the race? Now that would highlight computational thinking.

Here’s how I managed to get this working.

    1. Students modify their code to simulate the motion of the buggy they studied.
    2. Students then cut and paste the two lines of code they modified into a google form.

Screen Shot 2013 08 07 at 11 00 05 PM

  1. A python program running on my machine downloaded the form entries from all of the students and then writes a python program that models the race.

Here’s a video of what the merged program looks like that recreates the original experiment with all of the carts on the same table.

Here’s a video of what the race program looks like—the carts have all be turned to move int he same direction and start from the origin.

How this works

Thanks to Josh, I learned about the awesome googlecl (google command line) interface which lets you do almost anything you can do with google apps on the command line. In this case, I’d like to access and download the form data from my google form into a cdv file.

To do this you must first install googlecl, which also requires you install the Google data python client, gdata. This took a bit of fiddling, as I found some incompatibilities between various versions of googlecl and data, but eventually, I found googlecl-0.9.13 and data 2.0.14 are compatible.

With this installed you can now have python make a system call along the following lines:

os.system('/Applications/googlecl-0.9.13/build/scripts-2.7/google docs get CVPMProgramResponses --format csv /Users/jburk/Dropbox/_archive/_Teaching/_SAS\ Teaching/Courses/Honors\ Physics\ 13-14/01-CVPM/Python')

This is simply telling the os to run the googlecl app, and has it get the responses from the google doc CVPMProgramResponses in csv format and then save the on my machine.

After that, I wrote a python program to generate the two programs. I’ve put all of the necessary python files in this github repo. Be forewarned—this is mostly hacked spaghetti code I wrote to get the program working like I wanted.

A gentle introduction

My hope is that this will be a short 5-10 minute introduction to VPython. Students will see that they can modify large programs and observe how easy it is to manipulate objects in VPython. They’ll also get a taste of the real power of computing to merge all of our programs into a single program and create a more simulation that they can then play with and analyze.

2 Comments leave one →
  1. Mike Mannix permalink
    August 8, 2013 11:05 am

    I am intrigued. I used a Toshiba grant to buy Lego EV3 Mindstorm kits. The program becomes another representation/model of the motion. I have been thinking about how I will lead the students to modify and create simple programs without creating a unit dedicated to the Mindstorms programming. Thanks for the example. My long term goal is to learn Python and use it in my physics teaching.

  2. August 9, 2013 12:15 pm

    Very cool. Nothing like seeing patterns across the class. Glad that you put this together and shared it. The gdata thing is funky, I used it for the original version of Physics Gizmo before I made it a native Android app and it was always throwing errors.

    You can probably do most of this within Apps Script, here’s some links that might be helpful:,String,String)

    Good luck and keep up the awesome experiments (both in physics and pedagogy)!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: