Arvont Hill: August 2008

Sunday, August 3, 2008

More iRobot Create

Virtual Wall Search: Trial 1

The goal of this project was to have the iRobot Create robot spin around until it sees an infrared signal from a "Virtual Wall". Upon seeing the virtual wall signal the Create will stop. After a quick test I had success and changed the requirements so that the Create would always try to keep the virtual wall in its sights.

I started out by writing a crude python module that would allow me to send iRobot Open Interface (OI) commands from the host computer. Not only does the module send commands but it also processes sensor data transmitted from the Create. So the host computer is actually the brains of the operation.

Another thing I did was to use my xbee 802.15.4 modules as a wireless serial connection between the host computer and the Create. So now I have remote control of the robot. Check out some pictures here and here.

Here's the function that's doing all of the work. Python syntax is pretty similar to other languages with one difference...indentations matter and they are used to mark off different blocks of code. If you can't read code there's a translation at the bottom of the post.

def spinForVirtualWall(debug):
    packetId = 13
    ir = readPacket(packetId)
    time.sleep(0.1)
    spinCw()

    while 1:
        while ir[0] != 1:
            ir = readPacket(packetId)
            if debug:
                print "ir = "+str(ir[0])
        stopDrive()

        while ir[0] == 1:
            ir = readPacket(packetId)
            if debug:
                print "ir = "+str(ir[0])
        spinCw()



First the robot looks for the virtual wall. If it doesn't see it it starts spinning clockwise and stops when (or if) it sees a virtual wall. After stopping, the robot continues looking for the virtual wall signal. If the robot loses sight of the signal then it will continue spinning clockwise until it sees the virtual wall again.