Modeling and Robots—on a Mac!
I’ve written a lot about the value of computational modeling and physics. To me, it’s a natural fit in the modeling physics curriculum to give students a tool that allows them to create and explore simulations using a computer, which greatly expands the scope and depth of problems that students can explore.
One of the things Matt Greenwolfe introduced me to last fall was that these simulations don’t just have to live on a computer screen—it’s not too hard to program them into robots into small, easy to use robots. Now would be a good time to go and check out some of the awesome work Matt has done with the Scribbler 2 robot in his modeling physics classes:
- The Robot Lab (formerly known as the Buggy Lab)
- Robot Coycats (or Matching Graphs)
- Turning Classic Physics Problems into Lab Practicums: Featuring the Patrolman and the Speeder
- A Living Position vs. Time Graph
He’s also given a great presentation to the Global Physics Department.
One big problem for me with all of this is that all of Matt’s work has been done on a PC, and I use a mac, and it turns out that it’s non-trivial to adapt his work to a different platform.
My idea for integrating robots into the classroom
I really like all of Matt’s creative uses for robots in his classroom, but I’d like to add one more thing. I want students to be able to take a program they’ve created to model the motion of an object in VPython, say a car moving with constant acceleration, and very simply translate that program so that a robot can physically reproduce the same motion they see on screen, with the obvious velocity and acceleration limits of the robot platform. I also want students to be able to explore some of the more typical kinematics and vector problems we do with a robot component. Could students write a program to have an robot travel a distance of 1 meter in a time of 10 seconds while the robot has a constant acceleration? Could they use the robot to trace out a series of vector displacements to help understand vector addition? Could the robot use it’s marking functions to create real ticker tapes that show a record of its motion?
The Myro library that is used to control the robots in python is very low level. It simply allows you to tell the robot basic commands of forward, backward, turnRight and turnLeft specifying the speed of the motor (on a scale of 0 to 1) and the duration of the command. Thus it’s going to require some significant work to turn this into a series of more useable commands that allow students to directly set and modify the velocity of the robot. I’m hoping that perhaps that work has already been done elsewhere, and I just need to search harder to find it.
Controlling a Scribbler2 robot using a Mac via Bluetooth
Note: Unless you are looking to setup a Scribbler2 on your a mac, you can probably skip this section, as it’s mostly for me to remember how to set up the robot.
I’m going to try to document the steps I took to get the Scribblar 2 robot working with a mac for my own future reference, and to help anyone else who might be confused by all of the different directions that are out there on the internet. As popular as these robots seem to be with intro compsci classes, the documentation is very spotty—the instructions that were mailed with my robot contained numerous errors and were impossible to get working.
First, you’ll need to order a Scribbler 2 robot and Fluke Board. Total cost is around $200 for a new robot and board, and slightly less if you are willing to buy used. The Fluke card allows for bluetooth communication with your computer, and also sports a high resolution color camera.
- Download Calico
Installing Calico on a mac running 10.8 is mostly straightforward, except that you need to manually copy a frameworks folder from the download to your /Library/Frameworks folder, which requires authentication.
- Connecting your robot
Next you’ll need to pair the robot with your computer. This involves going to your bluetooth settings, setting up a new device (the Fluke2-XXXX), and then changing the serial port (in the settings gear under the list of devices in the preference pane).
Once you do that you can rename the serial port connection something simpler, like “scribbler”.
Also note that the full name for the serial port will now be
/dev/tty.scribbler. You’ll need this in a bit.
One other handy tip: if you ever want to list all of the serial connections on your mac using the terminal, simply use the command,
If video instructions are more your thing, then this video has everything right, though you probably need to update your firmware before you can get the robot to respond.
- Connect to your robot with Calico
- Update the firmware for the Robot and Fluke Card
- Enter commands
You should now be able to run Calico, open the shell prompt and type
init("/dev/tty.scribbler") to initialize the robot. I got the following message in response:
python>>> init ("/dev/tty.scribbler")
You are using:
Fluke, version 3.0.9
Once you’ve connected for the first time, you probably won’t be able to run any commands, since the firmware on the robot and card have a tendency to be out of date.
Here’s a pro tip: naturally there’s a wonderful python library for updating the firmware of the robot. It took a lot of searching and wondering what I was doing wrong when the
upgrade("scribbler") command wasn’t being recognized. After some searching I found the following commands did the trick:
python>>> from firmwareupgrade import upgrade
Connecting to Fluke for firmware installation...
Version of fluke [3, 0, 9]
Looking for Fluke upgrade at http://www.betterbots.com/upgrade/fluke/...
Considering /fluke-upgrade-2.9.1.hex ...
Considering /fluke-upgrade-2.7.9.hex ...
Considering /fluke2-upgrade-3.0.5.hex ...
['3', '0', '5'] [3, 0, 9]
Considering /fluke2-upgrade-3.0.9.hex ...
['3', '0', '9'] [3, 0, 9]
Nothing found to upgrade!
The fluke card was already updated
using robot: SCRIBBLER-2
Looking for Scribbler upgrades at http://www.betterbots.com/upgrade/scribbler2/…
Considering scribbler2-upgrade-1.0.0.binary …
Considering scribbler2-upgrade-1.0.1.binary …
Considering scribbler2-upgrade-1.0.2.binary …
Considering scribbler2-upgrade-1.1.2.binary …
Considering scribbler2-upgrade-1.1.4.binary …
Considering scribbler2-upgrade-1.1.5.binary …
Version of fluke [3, 0, 9]
Sending magic key
Program size (bytes) = 14776; scribbler version = 2
Storing program in memory…
Programming scribbler 2…
sending magic key
Wait for the robot to reboot!
Please start myro to connect onto robot
Now that you’ve done all that, you should be able to simply issue commands either via the Calico shell, or by writing and running python scripts in Calico.