Perl Robotics: A Preview

Moshe Bar delves into the brains of an AIBO robot dog.


October 01, 2003
URL:http://www.drdobbs.com/web-development/perl-robotics-a-preview/184416053

October, 2003: Perl Robotics: A Preview

Perl Robotics: A Preview

The Perl Journal October, 2003

By Moshe Bar

Moshe is a systems administrator and operating-system researcher and has an M.Sc. and a Ph.D. in computer science. He can be contacted at [email protected].


I recently received an AIBO robotic dog for review (see http://www.aibo.com/). AIBO is a Sony product geared at the geek market as well as the upscale-toy market. It features dozens of motors to let the robotic dog move around the house, speak, take pictures, and use Wi-Fi to connect to your home network. The heart of the dog (not too literally speaking, though) is the MIPS 64-bit CPU running at 180 Mhz and a real-time, proprietary operating system.

The AIBO is a lot of fun for the first few days, as it roams the house looking for interesting objects (it takes pictures of them and emails them to you). It understands natural language (over 75 commands) and knows how to walk back to the base station to recharge its batteries.

However, all this gets boring soon enough, and it is only then that you discover the usefulness of the AIBO for robotics research and learning purposes. In fact, at least one university (the University of Pennsylvania) has a major research undertaking based on the AIBO platform. It seems they wrote a Perl interpreter to make it easy to program the AIBO, although no information about it could be found yet on the Net.

Last year, there even was an AIBO soccer tournament, called "RoboCup2002," where competing teams of AIBOs had to play a game of soccer (see http://www.openr.org/robocup/index.html). The software to control the servos had to be written in C or C++. An example of the code needed to control the joints of the AIBO is shown in Listing 1 (available from http://www.tpj.com/source/).

Developing a Perl module that uses a bit of C++ to interface with the AIBO at the lowest level shouldn't be difficult. It should be possible to use the h2xs command to convert the header files to Perl extensions, being careful to not exclude external subroutines (that is, don't use the -X switch). Then, subroutines in the .pm could serve for the various robot functions, such as:

sub get_joint {

my ($joint_name) = @_;

... ... ... ...
return $joint_number;
}

and could then be used in the Perl program.

Not much can be found on the Net when it comes to Perl and robotics. But once my geek curiosity had been awakened, I just had to walk that way all the way to the end. So, I started looking for Perl modules, software, and what have you to control robots. At first, one would assume Perl to be the perfect controlling environment for machinery. However, it seems that this is an area generally not very well covered by Perl. Part of that is certainly (sometimes, at least) due to real-time scheduling requirements.

In the CPAN you won't find anything either, but the need for a real servo/robot module is certainly there. The only real Perl system dealing with controllable motors is MisterHouse, the home automation system I use and described a few months ago in The Perl Journal (see http://misterhouse.sourceforge.net/).

MisterHouse would make a good robot-controlling framework, especially because a robot usually has a specific purpose and operates in a specific environment. Controlling the environment is easy with MisterHouse. It is already capable of doing things like these:

$fountain = new X10_Item 'B1';
   set $fountain ON if time_now '6:00 PM';
   $v_bedroom_curtain = new Voice_Cmd 
                        '[open,close] the bedroom curtains';
   curtain('bedroom', $state) if $state = said $v_bedroom_curtain;

So, adding to MisterHouse all the necessary modules to be able to do something like this should be easy:

$movement_sensor = new Serial_Item 'AIB'O, 'door';
   play(file => 'intrusion.wav') if state_now $movement_sensor eq 'door';

In other words, MisterHouse is the ideal controlling framework for robots, because all the environment data is already present. Additionally, MisterHouse is very extensible and makes it easy to drop in new modules.

I intend to start work on exactly this kind of robot module and will document its development in TPJ over the next couple of issues.

Stay tuned!

TPJ

Terms of Service | Privacy Statement | Copyright © 2024 UBM Tech, All rights reserved.