Robosapien-LIRC Interface

Purpose:

To allow the computer to control the robosapien in place of the provided remote control using the LIRC package. Once a simple platform can be established for controlling the robot, it can be easily and rapidly adapted for use in a variety of situations such as path planning, simple robot control demos, or more advanced robosapien programming functions.

The First Problem

The provided utility with the LIRC package, irrecord, does not correctly record remote control codes that do not repeat. (when a button is held on the remote, the code is not repeatedly sent)

A little googling turned up this: http://www.aibohack.com/robosap/ir_codes.htm (cached). Using another utility, xmode2 a graphical representation of the codes being received can be seen. This is similar to the output seen when an IR receiver is connected to an oscilloscope. Once we can determine exactly the format that robosapien expects, we can begin to mimic it so that it he will not know the difference between the remote and the computer.

The Next Problem

The codes given on aibohack.com ( here) indicate that a logical '1' is a rise to high for a specified period of time and then a fall to low for a specified period of time. This is started with a header pattern that is a long pulse drawn low. Since the header goes low with no return to high, all bits are in the pattern of "high then low" as seen here: (note, 'high' and 'low' are counter intuitively flipped)

This jives with the expected data, 0x8E for the stop command, which in binary is: 10001110.

The problem arises because of the LIRC format which expects data to be in the form of a low value followed by a high value. After much tinkering, I determined that the best solution to this would be to shift the binary data that LIRC was outputting. This is only possible since every IR code for the robosapien is greater than 0x80 which means the first binary bit is always 1. Knowing this, I was able to effectively perform a "right shift" on the code and remove the first 1 and bundle it as a piece of the header pulse. This is done by subtracting 128 (the 8th bit) and then multiplying the result by 2. For example:

The STOP code, 0x8E (pictured above) is 142 in base 10. Subtracting 128 gives us 14 and twice that is 28. Its hex representation is 0x1C or 11100 in binary, which is what we would expect when shifted:

Using this method we can create a new set of codes. This is what i have done in order to create an appropriate lircd.conf, the config file needed for LIRC to send remote codes to robosapien. Here are the important parts:

My lircd.conf file


  name          Robosapien
  frequency     39200
  header        6666 3333
  bits          8
  # the pulse and space that defines a one and zero
  one           833 3333
  zero          833 833
  gap           0
        begin codes
		# the data sent for each code
                TURN_RIGHT      0x00
                RIGHT_ARM_UP    0x02
                RIGHT_ARM_OUT   0x04
                TILT_BODY_RIGHT 0x06
		...

The full lirc config can be downloaded here.

Commanding Robosapien!

Once we have the proper config for lirc all set up, it's time to make use of it! Granted that all lirc devices drivers are set up correctly (this can be a pain - google is your friend!) you can now fire up lircd and start sending IR codes to robosapien. Before I did this, though, I tested the output on an oscilloscope to ensure the correct pattern was being outputted. This was very useful in debugging.

LIRC comes with a very simple utility called irsend which allows the user to send remote commands that are defined in lircd.conf. For example, to command robosapien to walk forward, use:

irsend SEND_ONCE Robosapien WALK_FORWARD

If all is configured correctly and the IR sensor is aligned correctly, robosapien will walk forward until you send him the STOP command.

A more advanced irsend: robowalk

irsend allows for simple testing to send one command at a time but is very cumbersome when you want to send more than one command. It can be easily scripted though with a shell script, though. A more robust method is to use a socket to send commands to lircd. Here, I have written a small program which maps WASD (common key configuration for many games) to robosapien's movements. It uses the curses library to accept key commands and is based on the irsend source for sending IR commands through a socket to lircd.

The source for robowalk can be downloaded here.

Conclusion/Problems/Things To Fix

Links/Files

Eric Buehl ebuehl@andrew.cmu.edu
(4/25/05)