Software and Code
This is a quickie on how I built the Probot. This is not a technical how-to, but more like some narrative so you could have your chance to try this at home. I am not affiliated with Apple or Lego in any way, so if you have specific questions its not likely that I would be able to help. Work files, samples and required software are included below. This is how you get started...
Step One: The MacBook
You must install and configure your laptop on a wireless network, hopefully with a static IP address so that internet users can navigate to your MacBook's Personal Web Sharing. With this service running on your laptop then it becomes a quasi-server and can host simple websites without investing in expensive software. Turn on these options in your Sharing system preference tab.
Robot Controller is the software that acts as a live remote control for your Lego IR tower, when clicking the buttons on the software you will trigger the IR tower to talk to your Lego RCX computer, the big yellow thing that runs the programs.
Officially, you won't be programming your Lego brain thingy, you will be using AppleScript to control the Robot Controller software to then control the Lego RCX. Got it? AppleScript can be triggered if embedded into a web page or activated via linkage, but only if there is some intermediary service running on your server (in this case the server is your laptop).
ACGI Dispatcher is that bridge between your web visitors and your AppleScripts. Follow the instructions carefully to install this bundle, and pay attention to the versions.
Last, in order to drive you will need to install and configure iChat in order to video conference across the web with your robot. The MacBook series has its own camera installed, you may need to attach your own separately.
Step Two: Lego Mindstorms
This is the easiest and most fun part of the project. You must now build your robot chassis. Build out your robot any which way you like but this is how I did it.
In order to operate, the Lego RCX must have a line-of-sight with the IR tower as its attached to the laptop, so this was a central part of the design. I made mine so that my laptop sits on top of the chassis, and the IR tower and the Lego Brain are locked together in time, and only two motors run the bot. I chose a pair of worm-drive wheel sets, one drive and motor to each wheel, and a pair of shopping cart style casters in the back. When the wheels turn together then the bot moves forward or back, when the turn opposites then the bot rotates in place. Simple.
Step Three: Coding
Write AppleScripts to operate the Robot Controller software. My suggestion is to make one script per function. For example, I chose to write a script called Forward that moves the two wheels in the same direction. I also made a script called Stop. Using these two scripts at different times I make the bot stop and go.
These directional AppleScripts are then referenced in an HTML page, so clicking on the web page link fires off the AppleScripts that make the bot go. There is a specific place in your Library directory in which the Applescripts need to live in order to be accessible to a remote page visitor, search for the directory called CGI-Executables. Applescript files must end in .acgi in order to run remotely.
Then I can call my scripts from basic HTML pages. I made a simple index.html file that sat in my Users > Sites file so it was easy to browse to using my IP address in a browser. The Applescripts are referenced as links on the page, pointing to their CGI-Executables directory with a link similar to this: myserver/cgi-bin/myapplescript.acgi.
This part is fun for some, but for others code will make their blood run cold. Download my sample files so you don't have to start from scratch. Files are at the bottom.
Let's Review
To make your robot work, you need to
• Have a working MacBook with Mac OS X
• Launch and configure Personal File Sharing
• Have an index.html file in your Sites directory
• Have tested AppleScripts in your CGI-Executable directory
• Launch Robot Controller
• Launch ACGI Dispatcher
• Launch iChat
• Have a good Lego chassis design
• Connect the LEgo IR tower to the laptop
• Make line of sight connection with Lego RCX
• Power on RCX and check the batteries
• Finally, find another computer to browse your new robot's page
• Drive safely, exercise caution when entering traffic
And right away, you should be seeing this: Example
Enjoy the fun, report back, send me email or photos!
As promised, my AppleScripts and HTML as well as other required free or demo software are published right here:
| Attachment | Size |
|---|---|
| Probot.zip | 1.94 MB |
