Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Web Development

Perl Robotics: A Preview


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


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.