One of the most direct ways to talk to a Gumstix is via a serial port. Though a serial port is rather slow and is not the best for day to day operation, it comes in handy to do initial setup and repair. It’s also useful for flashing the Gumstix and installing a custom kernel and filesystem. Since I’m running a Linux host machine, I have two options for programs for connecting via serial: minicom or kermit. I started off using minicom because it was in the Arch Linux software repositories and because the configuration was very easy. However the problem is that the Gumstix cannot receive minicom file transfers, which make minicom useless for reflashing the Gumstix.
After compiling Kermit from source and starting it on the proper device, there are a number of options to be set before one can actually connect to the Gumstix. Doing this everytime is extremely tedious and error-prone so it’s easiest to create a simple script with the following:
kermit -l /dev/ttyUSB0
set speed 115200
set carrier-watch off
set flow-control none
set prefixing all
set file type bin
set rec pack 4096
set send pack 4096
set window 5
I saved this script under the name konnect and placed it directly in my
/bin directory. After marking it as executable with a
sudo chmod +x konnect, I could execute the script and have it open up Kermit with all the required configurations in place. If you want to use this script, you should change
/dev/ttyUSB0 to whatever serial device your Gumstix is actually connected. My laptop doesn’t have serial ports so I connect via a USB-serial adapter. You should also make sure that the device can be accessed by the user you run the script as or else it will keep throwing up permission denied messages. If you don’t want to mess with file permissions, you can run it as root via
The last few weeks have been rather busy, but with at least two light weeks in front of me, it’s time to get started with something serious. My first project with the Gumstix will be to use them to drive the Hemisson robots. I had thought about creating some sort of a simple “Robot Control Language” and then have the Gumstix translate that into serial commands to drive the Hemisson. However inventing a computer language, no matter how simple isn’t an easy task and I would like to have my first project be something simpler.
The point of using a Gumstix to talk to the Hemisson is so that a user can write higher-level algorithms without worrying about details such as making the wheel turn. I also want to use a programming language that has a relatively small amount of syntactical baggage and where it is easy to use function libraries without endless recompiling and linking. Luckily I know just such a language — Python. Python’s modules make it easy to create, use and distribute useful code. Being interpreted, there is no compilation needed which means that a user can easily write and debug programs on a host and then run them on the Gumstix without any change. Also important is the existence of the pySerial module which allows simple access to a machines serial ports: something which will invaluable to me.
Eventually performance might become an issue: the Gumstix is after all, somewhat limited in terms of its hardware and users might want to implement complex algorithms to determine the behavior of the robots. It may become necessary to re-implement the control library in C for the added performance edge. However since Python can easily operate with C functions, the Python programs won’t have to be rewritten (though some alterations will also be needed). You could say that in some ways the Python module will be a prototype for a more powerful and efficient C implementation sometime in the future, but I can’t guarantee that at the moment.
My first step is to brush up on Python and get used to the pySerial module and see what functionality it offers. I’m not going to be using the Gumstix for a while, but rather communicating directly from laptop to the Hemisson until I have at least a rough working implementation. But before I start working on a final implementation, I will be testing the serial connection between the Gumstix and the Hemisson and making sure that Pyserial can work with it as well. With all the preliminary steps completed I can start work on a robust, full-featured module. I’m not quite certain how much work the module should handle i.e. should it just translate movement instructions from the Python code to serial or should it have algorithms to implement things like turning through angles or rotating? These are not decisions to be taken lightly because they will have a direct effect on how users will be writing their programs, and its something that I’ll be discussing with my professor. The best idea might be to implement some higher level functions but leave the underlying simpler functions open as well.
I’m not going to venture a timeline for the project, because I have other priorities which take precedence (classes for example). But I would like to have a working version by the end of the semester (beginning of May), progressing to something which is full-featured and reasonably bug-free by the end of summer (late August). With Spring Break starting in a week, I should be able to familiarize myself with both Pyserial and the Hemisson serial interface in two weeks time. After that its just a matter of proper planning and getting things working.
The Hemissons are small semi-autonomous robots made by a Swiss company called K-Team. They began as extra-curricular projects by students at the Swiss Institute of Technology and are now widely used by teachers and hobbyists. The Hemisson has a number of features which make it ideal for small scale robotics experiments.
Each Hemisson is a small mobile robot driven by two separate motors driving its two wheels. It can sense obstacles by means of a total of 8 infra-red sensors, 6 on the sides and two on the bottom (which allow it follow marks on the ground). The brains of the Hemisson is an 8-bit Microchip PIC 16F877 microcontroller running at 20Mhz which can be programmed with a simplified 35-instruction set. It is also packaged with enough RAM and flash memory to host a simple operating system that can effectively control the robot and execute complex behaviors in response to sensor inputs. The Hemissons also come with 6 switches which can be used to turn them on, switch from a running to a programming mode and execute a number of predefined behaviors (like moving in a circle or following a line).
What makes the Hemisson attractive to robot hobbyists is that you don’t have to stick to the simple set of predefined behaviors. Each Hemisson has a serial port which can be used to directly control the robot from a host computer by sending a set of commands which the HemiOS operating system then executes. There is also an extension connector which allows hook-up of I²C compliant peripherals which can also be accessed via the serial port. K-team sells a number of sensors which come with their own microprocessors and software. In case you are feeling particularly adventurous it is possible to directly access the flash memory, thereby replacing the HemiOS operating system with your own concoction (though it seems that you need a special connector to be able to do this). Of course you can always alter the flash memory over a serial connection.
The Hemisson robots can be simulated with the Webots robot simulation package which allows you to create a virtual world with a virtual robot, program it in C, C++ or Java and then set it loose to see what happens. Though you can cross-compile a program to make it run directly on the Hemisson, actually getting it to the Hemisson’s flash memory is slightly complicated (and not covered by warranty). Bu K-Team provides a graphical programming environment it calls Bot-Studio which lets you define a behavior for the Hemisson based on the concept of finite-state machines, and these FSMs can donwloaded to the robot over the serial connection.
I will personally be making use of the serial connection to let a Gumstix essentially “drive” a Hemisson by issuing it commands over serial and listening to responses from the sensors. Because it is possible to listen to the I²C bus over the serial connection, we could attach a wide variety of sensors to the Hemisson and let the Gumstix do the thinking. While I go figure out how to do that, I’ll leave you with a nice picture (from the Hemisson website):