Preparation of Papers in Two-Column Format



An Inexpensive LISP-Based Educational Platform to Teach Humanoid Robotics and Artificial Intelligence

Authors:

Tze-wen Wang, Portland State University, Oregon, USA, tzewen@ee.pdx.edu

Marek A. Perkowski, Portland State University, Oregon, USA, mperkows@ee.pdx.edu

Maciej Sajkowski, Silesian University of Technology, Gliwice, Poland, maciej.sajkowski@polsl.pl

Tomasz Stenzel, Silesian University of Technology, Gliwice, Poland, tomasz.stenzel@.pl

Abstract ( Due to simplicity and ease of writing advanced software using functional language, LISP – the language of artificial intelligence – has been recommended as a language to teach fundamentals of programming in conjunction with Basic and Logo. LISP has been widely used in both undergraduate and high school education. We had taught selected high school students and used LISP in various simple projects. Curriculums include: control of servo-motors, simple sensors, mechanical design of robot heads, robot animals, robot hands and arms, simple robot vision and pattern recognition, obstacle avoidance, and labyrinth exploration. Robosapien is an eighty-dollar infrared remote-controllable humanoid walking robot that has an amazing power of programmable behaviors stored in its tiny chip. The latest design has a new type of analog control called digital nervous network (in contrast to neural). Robosapien hit the 2004 United States robot hobby market. We add a radio frequency device on top of the infrared autonomous on-board microcontroller. The robot is then driven by LISP programs under a public Common LISP environment on a PC with abundant software resources such as OpenCV from Intel for image processing, SAPI from Microsoft for speech processing, and many other libraries. The robot is able to dance, sing, talk and move. In this paper, we briefly discuss foreign function facility of the Common LISP implementation and usage of the facility and its applications. Furthermore, we successfully control a humanoid robot using a LISP program collaborating with several C standard libraries including image recognition and operating system routines. We believe this environment will attract more high school students to learn LISP and increase their potential interests in autonomous systems, artificial intelligence programming and other engineering disciplines.

Index Terms ( AI programming, Common LISP, humanoid robot, inexpensive platform.

1. Introduction

FOR PAST FEW YEARS, WITH GENEROUS SUPPORTS FROM INTEL SEMICONDUCTOR, STATE OF OREGON, AND PORTLAND PUBLIC SCHOOL DISTRICT, THE INTELLIGENT ROBOTICS LABORATORY AT PORTLAND STATE UNIVERSITY EXPERIMENTS WITH INEXPENSIVE, HIGHLY ENTERTAINING AND EDUCATIONAL PLATFORMS TO TEACH WIDELY UNDERSTOOD ROBOTICS TO HIGH SCHOOL AND UNDERGRADUATE STUDENTS. FOR MANY REASONS, OUR ROBOTS SO FAR HAVE BEEN ANIMAL-LIKE: DOGS, SPIDERS, SNAKES, ETC. WE USE BOTH HOME-BUILT ROBOTS AND KITS FROM US, JAPANESE, AND KOREAN COMPANIES, AND A COMPLETE HEXAPOD ROBOT HEXOR DEVELOPED BY STENZEL COMPANY IN POLAND [15], WHICH HAVE BEEN ALL UPGRADED, MODIFIED AND PROGRAMMED BY US. WE BELIEVE THAT MORE HIGH-SCHOOL STUDENTS SHOULD BE ATTRACTED TO STUDY ENGINEERING. BUILDING AND PROGRAMMING SMALL ROBOTS IS ONE OF THE BEST WAYS TO ENTHUSE THEM. WINTER PROGRAMS AND SUMMER CAMPS HAVE BEEN ORGANIZED AT PSU, WHERE STUDENTS BUILT THEIR OWN EITHER AUTONOMOUS OR RADIO CONTROLLED ROBOTIC ANIMALS SUCH AS HEXAPODS, QUADRUPEDS, AND BIPEDS EQUIPPED WITH COMPUTER VISION, SONAR AND OTHER SENSORS FOR LIGHT FOLLOWING AND OBSTACLE AVOIDANCE. HIGH SCHOOL STUDENTS ALSO LEARN LISP – THE LANGUAGE OF ARTIFICIAL INTELLIGENCE – TO DO VARIOUS SIMPLE PROJECTS SUCH AS INTERACTIVE GAMES AND ELIZA-LIKE LANGUAGE-BASED DIALOGS. THE CURRICULUMS INCLUDE: CONTROL OF SERVO-MOTORS, SIMPLE SENSORS, MECHANICAL DESIGN OF ROBOT HEADS, ROBOT ANIMALS, ROBOT HANDS AND ARMS, SIMPLE ROBOT VISION AND PATTERN RECOGNITION, OBSTACLE AVOIDANCE, LABYRINTHS EXPLORATION, AND DIALOG WITH ROBOT.

In spite of our teaching made students successfully winning several awards in Oregon’s robot design competitions in the past, we believed that these young students should use a more sophisticated and user-friendly system to implement their software components. Recently, in order to aid the development of such systems, we created a PC LISP-based robot controller in our Intelligent Robotics Laboratory at PSU to interface with Robosapien, a walking biped, through radio devices. Robosapien is an eighty-dollar infrared remote-controllable humanoid walking robot with amazing power of programmable behaviors stored in its tiny chip. It hits 2004 U.S. robot hobby market. As far as we know, it has not been used for education yet. The original Robosapien design is to be controlled through an infrared remote controller. This certainly places physical constraints and technical difficulties on the robot to receive control signals from a PC although it is possible to have an infrared transmitter installed on the PC. To overcome this, we add an extra radio communication device in parallel with its original infrared controller on top of the autonomous on-board microcontroller. PC-based programs are able to control the modified robot with powerful libraries such as OpenCV [6] from Intel for image processing, SAPI [10] from Microsoft for speech processing, graphical components from Visual Studio for user interface. The robot can dance, sing, talk and move controlled from a remote personal computer.

According to our more than 20-year robotic teaching experience, it is much easier to integrate a large AI system in LISP than it is in other languages. LISP or its variants are taught in top Universities [7]-[8][12] as the first programming language, and it teaches good programming habits like recursions, backtracking, searching on tree structures, rule-based programming, data-driven programming, and object oriented programming. We accumulated much LISP software for AI, evolutionary programming, natural language processing and other intelligent robotics applications. With the cost of desktops and laptops reduced dramatically today, we believe that using PIC-based such as BasicStamp platform [5] to build autonomous robots is no longer reasonable, which is still a standard world-wide in robotic education. In fact, we do keep these processors on our robots, but they are now staying at system-level rather than application-level in the system. Students are now able to completely observe walking humanoid robot control and perception through LISP environment. The ones do not have to bother with details of radio communication or servo programming. We found that this property is also important to high school teachers who teach robotics. They prefer to work with familiar PC programming environment rather than using new and exotic microcontroller platforms. They are familiar with programming but most are afraid of hardware, which in our opinion is the predominant obstacle in teaching high school robotics in most countries that we visited or live in.

|[pic] |[pic] |

FIGURE 1

LEFT-Hand Side: Hexor, KHR-1, And Robosapien (From Left To Right); Right-Hand Side: Robosapien And The CLISP Environment.

A desktop, laptop computer, or even a handheld device today is powerful enough to run moderately complex AI programs including all textbook famous programs like natural language conversation, building pyramids, and avoiding moving obstacles at reasonably speed. We believed that these factors would motivate high-school students to build up and program robots. Nevertheless, learning how to write intelligent robot programs in C or Basic is a barrier for most students. Traditionally, people use LISP to write AI programs, especially robotic programs [1][3][11]. LISP provides a great environment for AI programming in spite of the performance of programs written in LISP is somehow inefficient. LISP’s interactive environment, uniform syntax, loose data type, and special constructs offer the ease of programming and rapid prototyping capability. However, it is not recommended to do everything in this great language. For instance, writing complex functions such as communication and GUI routines using LISP is a difficult task and may discourage students from learning the language. Our system is based on a Common LISP implementation that features an interface connecting LISP functions and libraries written in other languages. The Common LISP implementation is available in the public domain and free for academic use. Hence, every school is likely to afford such inexpensive educational platform. Only a few hundred dollars is needed for radio controller, camera and the humanoid robot, Robosapien. It is possible to experiment remotely controlled autonomous robots with vision, speech and AI control with this affordable platform, an environment similar to those that only few top universities were able to afford a couple of years ago. We are hoping that these kinds of robots will dramatically advance the state of the art in robot research and education worldwide in the coming years.

The rest of the paper is structured as follows: in section 2, we give an overview of our robot platform including software and hardware implementations. In section 3, we briefly discuss the Common LISP environment and its foreign function interface. In section 4, we demonstrate some LISP programs to achieve hardware operations such as driving of the robot, and accessing cameras. The paper concludes and discusses future work in section 5.

2. System Overview

2-1. SYSTEM MODEL

There are two issues with building autonomous: expandability and power. Today’s technology allows a humanoid robot driven by a dedicated and portable computer such as handheld devices. Handheld device often comes with less storage capacity and communication capability. This immediately becomes a bottleneck that limits the size of the control program. The autonomous can only perform a certain number of behaviors. Second, a well-design autonomous should have an internal power system to have free movement. It could be as simple as a battery, for example. Placing a handheld device on top of the autonomous likely consumes more energy.

2-2. Software Implementation

One possible way two fix these problems is to reduce number of devices on the system. We may place a piece communication device on the robot and let it take commands from computers wirelessly. This offers greater flexibility on the system programming and results in saving of energy to keep the autonomous alive longer. Our platform relies on a computer system, a camera, and a set of communication devices on both sides shown in the figure 2. We separate “the brain” of the autonomous from its body. A pair of wireless communication devices takes the place in between the brain and the body. The brain now can be any computer system from a single laptop or PC up to a cluster or a group of computers. With great contemporary technology, a computer is capable to handle high-speed and multiple I/O at one time. Hence, feedback can be a video stream collected by a camera as well as sensors installed on the body. There are several wireless such as radio frequency (RF), IEEE 802.3g, and blue-tooth, well developed and matured communication protocols. System developers may get this in form of kits and thus does not have to study on protocol details. These devices usually can be easily hooked with PC through dedicated standard I/O ports such as Serial I/O Port, Parallel I/O Port and Universal Serial Bus.

|[pic] |[pic] |

FIGURE 2

An Autonomous Control System Model With A Separated “Brain” And Its Software Architecture.

A robot control program is a complex piece. Computers in this platform play an extremely important role. Figure 2 also illustrates the platform from a programmer’s view. It is responsible for collecting feedback, generating responses accordingly, and communicating with robots. Although the workload is heavily placed on the computer, the computer technology today offers tremendous computation powers that can in fact control multiple robots at a time. It is even possible to have a distributed system to perform Artificial Intelligence analysis across a cluster of computers in parallel. To achieve this, we have to have a programming language and environment that can accommodate diverse programs and models. We discovered a Common LISP implementation that is available in the public domain. It is free for academic use under GNU/GPL license.

It is known that LISP programs are system independent and thus can be run under any operating system without modifications. The downside is that the language itself is entirely isolated from hardware architecture. Hence, the CLISP environment has a special package to exchange data with other programs called foreign function interface (FFI). This package is a powerful tool that allows low-level program sequence to be embedded within high-level LISP programs. This allows a LISP program capable to be a major control routine of a robot program. For example, many data transmissions such as device I/O transactions are handled at operating system level. A LISP program only needs to properly invoke relevant routines to transmit and receive data without touching hardware abstraction level. The program also can coordinate between libraries and hardware devices. For instance, a video stream is collected from a camera and processed by a set of image processing functions. These operations can be done efficiently and relatively easily. In other words, a LISP program can extract information from a video stream by utilizing a set of library functions, which is the core of this platform. The CLISP environment and FFI package is discussed in section 3.

2-3. Hardware Realization

In this platform, the robot is no more a piece of hardware device to the computer. There are many commercial robots available on the market. We use an eighty-dollar humanoid robot, Robospaien, to be part of the system. Robosapien has its own on-board microcontroller to make movements, sounds, and effects. It attaches an infrared receiver to its microprocessor to take commands from a remote controller. Although it is possible to install an infrared transmitter on a PC and control it with PC-based software, infrared places physical constraints that increase difficulty to communicate with each other. Hence, we perform a little hardware modification on Robosapien. Based on the fact that all commands are generated by the remote controller and received through infrared receiver, we add an extra radio frequency receiver. Robosapien is now equipped with two communication devices that can take commands both from infrared and RF receivers. Nevertheless, the RF receiver can not be directly interfaced with Robosapien’s microcontroller due to serial protocol incompatibility. The receiver runs at 9600 BPS baud rate and this is not the baud rate the IR receiver runs at. For simplicity, we insert a BasicStamp microcontroller in to overcome this problem. The BasicStamp receives commands from computer through a RF receiver and generates proper serial signal for Robosapien’s internal microcontroller. We used some work done by people who are interesting on hacking Robosapien’s protocol [13]-[14]. On the other hand, we hook up a RF transmitter with standard serial I/O port, say COM1, on a PC. It works perfectly fine because the UART in PC is highly programmable and the baud rates are matched. However, we still need a microcontroller interfacing between PC’s UART and RF transmitter due to different signal levels. This is a possible to be improved by having a signal converter such MAX232 instead.

3. The CLISP Environment

3-1. OVERVIEW

Many commercial and public LISP environments are available. In commercial domain, there are Allegro CL, LispWorks, and Digitool. In public domain, there are CMUCL, CLISP, ILISP and OpenMCL. Commercial LISP environments often come with powerful package such as XML parser and some hardware control routines but they are expensive and unaffordable for academic and research use, particularly, for high-schools. On the other hand, publicly available LISP environments often lack maintenance and key routines for crafting a real robot control program. GNU CLISP implementation [2] is a public-domain ANSI Common LISP environment. The environment is bound to GNU/GPL license. It requires only 2MB RAM to run and provides many useful packages. More importantly, this environment has been already ported to UNIX, Linux, and Windows platforms. Precompiled binary executables are also available. This is an extremely low-cost to get a LISP programming environment to programming a robot using LISP. The CLISP implementation offers many useful packages. In this paper, we will focus on the most important package among all – Foreign Function Interface.

3-2. A Quick Example

|[pic] |(SHBrowseForFolder |

| |(make-LBPI_T |

| |:hwndOwner 0 |

| |:pidlRoot 0 |

| |:pszDisplayName "Called From Lisp" |

| |:lpszTitle "Called From Lisp" |

| |:ulFlags 0 |

| |:lpfn 0 |

| |:lParam 0 |

| |:iImage 0)) |

FIGURE 3

A LISP Code Snippet To Open A GUI Dialog Using FFI And The Screenshot.

The best way to illustrate how FFI in CLISP is able to help on robot programming is to start with a short example. We give an example of LISP code using FFI package to make foreign function calls. This example runs on Windows system and opens a path browse dialog using Win32 GUI API. The name of the system call is called SHBrowseForFolder [9] located in file shell32.dll. Figure 3 shows a running snapshot of SHBrowseForFolder with its LISP code, respectively. A LISP-C symbol can refer to either a foreign function or foreign type. We specifically call them LISP-C because these symbols are in the same form of LISP symbols but they have special meaning and can not be used with native LISP functions. We need to define at least two symbols before we make the call. The symbols are SHBrowseForFolder, and LBPI_T. The former is a LISP-C-FUNCTION symbol and the latter is a LISP-C-TYPE symbol. SHBrowseForFolder is a call-out function because it is invoked from CLISP which program control flow is transferred from CLISP to the function. Note that we directly instantiate the structure right before the function call with using make-LBPI_T primitive, a LISP standard to create a record object. The intermediate pointer return by make-LBPI_T is automatically passed to the function. Figure 4 shows how to define the structs for the call.

|(def-call-out SHBROWSEFORFOLDER |(def-c-struct LBPI_T |

|(:language :stdc) |(hwndOwner INT) |

|(:name "SHBrowseForFolder") |(pidlRoot INT) |

|(:library "SHELL32.DLL") |(pszDisplayName C-STRING) |

|(:arguments (LBPI (c-ptr LBPI_T))) |(lpszTitle C-STRING) |

| |(ulFlags UINT) |

| |(lpfn UINT) |

| |(lParam UINT) |

| |(iImage INT)) |

FIGURE 4

A LISP Code Snippet To Define Structs For System Call Shbrowseforfolder.

3-3. FFI Package

FFI or Foreign Function Interface package is a set of LISP definitions to deal with foreign functions. A foreign function refers to a function that is not physically in CLISP environment. In some sense, this interface acts as a gateway between functions inside and outside CLISP environment. FFI consists of a set of LISP primitives that are necessary to convert LISP data types to foreign data types such as C data structures. The primitives are also used to define presences of foreign functions in CLISP environment as LISP-C-FUNCTION symbols. The package comes with symbols, macros, and functions to interfacing with foreign functions. Current package implementation only supports C type libraries. Therefore, we will only focus on the issues between C and LISP types. The package can be roughly classified in four categories: LISP-C-FUNCTION symbol declaration, LISP-C-TYPE declaration, variable instantiation and operations. All related functions and predefined LISP-C-TYPE symbols are stored in a package called FFI.

3-4. LISP-C-FUNCTION Symbol Declaration

LISP symbols are in contrast to symbols written in C. All LISP symbols are case insensitive. This is an immediate problem for calling the function outside LISP environment. Thus, we need to use some FFI primitives to define symbols representing foreign functions. A foreign function symbols has to consist of the following information: foreign function type, function name in string type, language type, argument types, and function return type. Recall that program control flow can be passed back and forth between native and foreign functions. As a consequence, we need to first specify what type of foreign function is. The type is either a call-out function or call-in function. A call-out function passes control flow from LISP to foreign functions. A call-in function passes control flow from foreign to LISP functions. We use def-call-out and def-call-in to declare call-out and call-in functions respectively. Options are NAME, ARGUMENTS, RETURN-TYPE, LANGUAGE, and LIBRARY. Figure 5 shows synopsis of def-call-out and def-call-in declarations:

|(def-call-out LISP-C-FUNC |(def-call-in LISP-NAME |

|:LANGUAGE {:C | :STDC | :STDC-CALL} |:LANGUAGE {:C | :STDC | :STDC-CALL} |

|:NAME C-FUNC-NAME |:NAME C-FUNC-NAME |

|:LIBRARY LIB-PATH |:ARGUMENTS ((ARG LISP-C-TYPE [PMODE] [ALLOC]) |

|:ARGUMENTS ((ARG LISP-C-TYPE [PMODE] [ALLOC]) |(ARG LISP-C-TYPE [PMODE] [ALLOC]) |

|(ARG LISP-C-TYPE [PMODE] [ALLOC]) |…) |

|…) |:RETURN-TYPE LISP-C-TYPE [ALLOC]) |

|:RETURN-TYPE LISP-C-TYPE [ALLOC]) | |

FIGURE 5

Synopsis Of DEF-CALL-OUT And DEF-CALL-IN

Option :LANGUAGE is used to describe what calling convention is used for that particular foreign function. Calling methods slightly differ from language compilers. “:C” denotes K&R C, “:STDC” denotes ANSI C, and “STDC-STDCALL” denotes ANSI C with stdcall calling convention. Option :NAME simply describes the name of the foreign function with a double quoted string. For instance, “SHBrowseForFolder”, a shell function used in section 3-2. Option :LIBRARY is used to specify the location of the foreign function. It must be a valid path to a DLL file containing the function, “C:\Windows\System32\Shell32.dll” or “/lib/libmp.so”, for example. The path type depends on platform on which CLISP runs. Option :ARGUMENT specifies a list of arguments for the function. Each argument is also a list with a LISP symbol as the first element and LISP-C-TYPE symbol as second element. A LISP-C-TYPE can be either one of C basic types which are predefined in FFI package or a user-defined LISP-C-TYPE symbol. Please refer to section 3-5 for details of predefined LISP-C-TYPE symbols. Note that each argument has an optional specifier to indicate storage allocation type and an optional specifier to indicate access mode. Access mode is either :IN or :OUT or :INOUT for read-only, write-only, and read-write, respectively. Storage allocation type is extremely important when passing a structure from LISP to a foreign function. It is possible that the storage is allocated in the LISP and freed by the foreign function or vice versa, especially for the case of a pointer to a structure. Failed to maintain storage integrity could result in unexpected errors such as application crash. The options are :MALLOC-FREE, :ALLOCA, and :NONE. The first option is that storage is allocated in the LISP and freed by foreign function. Second option is that storage will be allocated in the LISP prior to the call and be freed as soon as the call returns. Option :NONE does not allocate any storage. Lastly, option :RETURN-TYPE is used to describe returning type of the foreign function. This must be either a predefined or user-defined LISP-C-TYPE symbol.

3-5. LISP-C-TYPE Declaration

|LISP-C-TYPE |C Type Equivalent |LISP Type Equivalent |Comment |

|NIL |void |NIL |As a result type only |

|BOOLEAN |int |BOOLEAN | |

|CHARACTER |char |CHARACTER | |

|char |signed char |INTEGER | |

|uchar |unsigned char |INTEGER | |

|short |short |INTEGER | |

|ushort |unsigned short |INTEGER | |

|int |int |INTEGER | |

|uint |unsigned int |INTEGER | |

|long |long |INTEGER | |

|ulong |unsigned long |INTEGER | |

|uint8 |uint8 |(UNSIGNED-BYTE 8) | |

|sint8 |sint8 |(SIGNED-BYTE 8) | |

|uint16 |uint16 |(UNSIGNED-BYTE 16) | |

|sint16 |sint16 |(SIGNED-BYTE 16) | |

|uint32 |uint32 |(UNSIGNED-BYTE 32) | |

|sint32 |sint32 |(SIGNED-BYTE 32) | |

|uint64 |uint64 |(UNSIGNED-BYTE 64) |Does not work on all platforms |

|sint64 |sint64 |(SIGNED-BYTE 64) |Does not work on all platforms |

|SINGLE-FLOAT |float |SINGLE-FLOAT | |

|DOUBLE-FLOAT |double |DOUBLE-FLOAT | |

TABLE 1

Predefined LISP-C-TYPE Symbols And Corresponding C Data Types (Source: ).

The C language is a strong typed language which requires exact type information on variables at compile time and disregard type checking during runtime. In CLISP, programmers can also define their own LISP-C-TYPE symbol such as structure, union, and enumeration in additional to predefined ones. Table 1 is a summary of predefined LISP-C-TYPE symbols and their corresponding C equivalent data types.

|LISP-C-TYPE |C Types |Synopsis |

|c-string |null-terminated string |c-string |

|c-pointer |pointer (to any type) |c-pointer |

|c-ptr |pointer to TYPE |(c-ptr LIST-C-TYPE) |

|c-ptr-null | |(c-ptr-null LISP-C-TYPE) |

|c-array-ptr |array of pointer to TYPE |(c-array-ptr LISP-C-TYPE) |

|c-array |array of TYPE |(c-array LISP-C-TYPE (DIM1 DIM2 …)) |

|c-struct |structure |(c-struct LISP-NAME |

| | |(ID LISP-C-TYPE) |

| | |(ID LISP-C-TYPE) …) |

|c-union |union |(c-union |

| | |(ID LISP-C-TYPE) |

| | |(ID LISP-C-TYPE)…) |

|c-function |function |(c-function |

| | |(:arguments |

| | |(ARG LISP-C-TYPE [PMODE] [ALLOC]) |

| | |(ARG LISP-C-TYPE [PMODE] [ALLOC]) …) |

| | |(:return-type LISP-C-TYPE [ALLOC]) |

TABLE 2

Special LISP-C-TYPE Symbols And Their Synopsis (Source: ).

Another distinct data type is pointer. Pointers are widely used in C programs. FFI package also provides several c-pointer primitives. c-ptr is pointer wrapper used in conjunction with LISP-C-TYPE symbols. For example, an argument or variable declared as (c-ptr int) refers to a pointer to integer. This is equivalent to a C declaration int*. In many cases, variables are declared as generic pointers and type casted to other types according to program behavior at runtime. A generic pointer type in C is known as void*. FFI package also provides such special LISP-C-TYPE symbol known as c-pointer. Moreover, struct and union are also supported known as c-struct and c-union, respectively. Table 2 summarizes LISP-C-TYPE symbols and primitives for special data types.

3-6. Variable Instantiation and Operation

All arguments or parameters to be passed to a foreign function must be allocated a special stack in CLISP environment prior to the call. Thus, variables have to be created using special LISP functions prior to pass to foreign functions. FFI package provides with-c-var macro to create a foreign variable. The synopsis is (with-c-var (C-TYPE [INIT]) BODY) where C-TYPE is an either backquoted predefined or user-defined LIST-C-TYPE symbol and BODY is code accessing the variables. Option :INIT is initial value for the variable. In regular C language, there are many special operators such as & and * used to obtain a variable address and dereference a variable. FFI package provides to c-var-address and deref to incorporate with the operations. In addition, slot is used to access members in a structure and cast is used to perform type casting with a foreign variable. Please refer to [4] for further details.

4. Put It All Together

WE DEVELOPED A ROBOSAPIEN TEXTUAL TERMINAL PROGRAM TO SEND CONTROL COMMANDS THROUGH A SERIAL PORT ON A PC OVER A RADIO FREQUENCY DEVICE. THE ROBOT IS OPERATED BY THE COMMANDS INTERPRETED BY ROBOSAPIEN’S INTERNAL MICROCONTROLLER. USED SYSTEM ROUTINES ARE COMMUNICATION APIS PROVIDED BY WINDOWS OPERATION SYSTEM. WE USED LISP’S MACRO EXPANSION CAPABILITY TO REDUCE THE COMPLEXITY OF INVOKING SYSTEM CALLS. SOME OF THE PARAMETERS IN SYSTEM CALLS ARE LIKELY TO BE FIXED. FOR INSTANCE, UART PARAMETERS CAN BE DETERMINED BY THE TIME WHEN HARDWARE COMMUNICATION PROTOCOL IS KNOWN. EVEN MORE, ONE CAN LIMIT THE PROGRAM TO USE A SPECIFIC PORT. ALTHOUGH THIS SOMEHOW REDUCES THE USABILITY OF THE FUNCTION, THE PROGRAM LOOKS VERY SIMPLE.

|(defun robosapien () |(defun opencv () |

|(with-open-com1 (com1) |(setf i (get-internal-real-time)) |

|;Local varaible declaration. |(with-open-cam (image) |

|(let ((input) (parsedInput)) |(if (> (- (get-internal-real-time) i) 0) |

|;Robot initialization |(write |

|;*** BasicStamp takes 1000ms to initialize. |(float |

|(pause 1000) |(/ 10000000 |

|(write-byte 177 com1) |(- (get-internal-real-time) i))))) |

|;Loop body. |(write-string " fps ") |

|(loop |(write-char #\Return) |

|(write-string "ROBOSAPIEN> " *terminal-io*) |(setf i (get-internal-real-time)))) |

|(setf input (read-line-no-punct)) | |

|(cond ((equal input `quit) | |

|;Exit program. | |

|(write-byte 163 com1) | |

|(return `bye))) | |

|(setf parsedInput (lookup input commandSet)) | |

|(cond ((null parsedInput) | |

|;Send unknown comamnd. | |

|(write-byte 194 com1)) | |

|;Send command. | |

|(T (write-byte parsedInput com1))))))) | |

FIGURE 6

Left-Hand Side: Code Snippet Of Robosapien Terminal Control Program; Right-Hand Side: Code Snippet Of A Simple Lisp Program That Accesses An USB Camera.

Figure 6 only shows the main function of two LISP programs. The one on the left-hand side is the Robosapien terminal. The program is essentially no more than a control loop of a serial of operations: wait for user command, lookup the corresponding control code, and write the control code to the port. Some subroutines such as with-open-com1, pause, and lookup can be defined somewhere else as long as they are loaded prior to the execution. It is even possible to create memory image to reduce CLISP’s startup time. On the other hand, we developed a simple LISP program as it is also shown in figure 6, which accesses to an USB camera and calculates frame rate. This program relies on subroutine with-open-cam. This subroutine opens the first camera in the camera list and callback on the programs written in the body upon each captured image frame. Line 4 to 10 performs the calculation of frame rate per second. with-open-cam takes the advantage of LISP’s macro expansion capability. The first argument is a variable in which each incoming image frame is stored. The rest of the arguments known as form are the body of the callback function. This suggests that the complexity of programming on image I/O can be extremely low. The macro expansion entirely compensates the learning process of hardware access. Furthermore, OpenCV provides abundant image processing routines that allows programmer to perform image recognition without rewriting the functions in LISP.

5. Conclusion and Future Work

WE HAVE DEMONSTRATED OUR ROBOT PLATFORM AND A BRIEF DISCUSSION HOW TO USE A PUBLICLY AVAILABLE COMMON LISP ENVIRONMENT TO COOPERATE WITH LIBRARIES – FUNCTIONS WRITTEN IN THE LANGUAGES OTHER THAN LISP. WITH FFI PACKAGE, LISP IS EVEN CAPABLE TO DO LOW-LEVEL PROGRAMMING. DOING LOW-LEVEL PROGRAMMING SUCH AS SENDING ROBOT CONTROL CODE AND ACCESSING A CAMERA AND OTHER DEVICES IS AN ESSENTIAL FOR ROBOT CONTROL PROGRAMS. FURTHERMORE, A COMPLETE ROBOT PROGRAM NOW CAN BE DEVISED INTO PARTS USING DIFFERENT LANGUAGES. FFI PACKAGE ALLOWS PROGRAMMER TO CALL LISP FUNCTIONS FROM OTHER LANGUAGES. THIS SUGGESTS THAT LISP PROGRAMS MAY BE EITHER CONTROL OR ASSISTIVE PROGRAMS. IT IS KNOWN THAT LISP IS ALSO CAPABLE FOR MACRO EXPANSION, WHICH ALLOWS A SERIAL OF LOW-LEVEL OPERATIONS TO BE PARAMETERIZED. THIS ALSO SUGGESTS SIMPLER APPROACHES TO CONSTRUCT ROBOT CONTROL PROGRAMS.

Hexor is a hexapod robot that will perform in teams with Robosapien and KHR-1 humanoids. It is a very solid robot in design, compared to other hexapod kits now available. Moreover, its architecture can be extended on both hardware and software levels. Recently, Faculty at Electrical Engineering Silesian University of Technology and Intelligent Robotics Laboratory at Portland State University formed a partnership to execute a project that uses Hexor robot control board in conjuction with dedicated servo controller to control a humanoid robot’s head. Simple behaviors such as reactions are programmed at microcontroller level. Complex and sophiticated behaviors are programmed on PCs using high level languages such as LISP, C, and Pascal.

[pic]

FIGURE 7

The Hexor Robot Control System Schematic Diagram.

Figure 7 presents the hardware architecture of Hexor robot. Major control components consist of a PC or personal computer and a robot’s on-board control unit. A radio interface operated in range of 300-1000 Megahertz takes a place of digital transmission between the PC and the robot. A Transceiver, Base Radio Module (BRM), is the an USB communication deivce on the PC. On the robot side, the communication device uses serial interface (UART) to transmitt and retrieve commands and data. The central processing unit is an ATMEL AVR M128 microcontroller. Although AVR M128 is an 8-bit microprocessor, the chip has enough capacity to handle all on-board peripheralssuch as digital thermometer, EEPROM, RTC, and other sensors and actuators using I2C bus. Not only DC servos but also DC motors with enoders can be directly controlled by the control board. The board is also equipped with watchdog chip (WD) and voltage regulators providing stable 5 and 12 Volts DC power with input in range from 4.5 to 9 Volts. Independent power channels as 6 and 12 Volts for servos and others can be controlled by the microprocessor program through Power Management and Control unit (PMC). The central processor also cooperates with some sensors such as ultrasonic distance meter (SONAR), infrared proximity detectors with regulated range (IRPD), tactile sensors (TS) and any type of analog sensors (AS) which can be connected to in-chip analog to digital converter (ADC). Voice recognition (VR) and voice memory module is also possible to be installed on the board through suitable sockets. Hence, it is likely to accomplish voice recognition and synthesis for commands in any language. Voice recognition unit is handled by a co-processor (AUX) which is connected to the central microprocessor with Serial Peripheral Interface (SPI). This solution allows programs to be executed on both microcontrollers in paraller to obtain the highest possible system performance. All three microcontrollers: central processor, co-processor, and data transmission processor can be programmed using Flash Memory Programming Interface (FMPI) in conjunction with Base Radio Module (BRM) or a separate flash programmer on a PC through a parallel port. In addition, Hexor has an on-board color camera controlled by central processor. Images and sound, from the camera and a microphome, respectively, are transmitted to the computer and processed by applications using publicly available software resouces such as Intel’s OpenCV to locate and inspect robot’s surroundings.

Due to bi-directional data transmission capability between PC and Hexor, it is now possible to create sophisticated software using any high level programming language communicating with the robot with ActiveX interface on various abstraction levels. Alternatively, all Hexor commands and routines, which provides access to all on-board components, can be stored in dynamic link libraries that encapsulates all low-level operations. We may take existing work and make little modification to meet current project requirements. For instance, we have a set of robot control routines written in BASIC as well as C built with GCC compiler consisting of control functions for a mobile wheeled robot. This can be done by extending the instructions list stored in on-board microcontroller flash memory.

The operational system presented here is only the first step. With such easy to use system, we will soon organize new summer camps for high school and use this system in undergraduate classes. The first task is to organize regular exercises for students, which should be always the initial step of building their own applications. The exercises will include: visual feedback for obstacle avoidance, finding a red item and grabbing it, navigating recursively defined paths, coordination of few robots with loose interaction through vision. The software can be shared with interested parties and we hope more Universities will be soon developing our platform and interfacing it to not only Robosapien, but also Hexor, KHR-1 and other new animal-like and humanoid robots that appear every month in the toy and hobbyist markets.

6. References

[1] BEETZ, M., “STRUCTURED REACTIVE CONTROLLERS: CONTROLLING ROBOTS THAT PERFORM EVERYDAY ACTIVITY”, PROCEEDINGS OF THE THIRD ANNUAL CONFERENCE ON AUTONOMOUS AGENTS, 1999, P228-235.

[2] “CLISP – An ANSI Common LISP Implementation”, Worldwide Web, .

[3] Cutting, D., Kupiec, J., Perdersen, and Sibun, P., “A Practical Part-of-speech Tagger”, Proceedings of the Third Conference on Applied Natural Language Processing, 1992, p133-140.

[4] “The Foreign Function Call Facility”, Worldwide Web, .

[5] Hamrita, T. K., Potter, W. D., and Bishop, B., “Robotics, Microcontroller, and Embedded Systems Education Initiatives at the University of Georgia: An Interdisciplinary Approach”, International Journal of Engineering Education, 2005, to appear.

[6] Intel Corp., “Open Source Computer Vision Library”, Worldwide Web, .

[7] Kumar, D. and Meeden, L., “A Robot Laboratory for Teaching Artificial Intelligence”, ACM SIGCSE Bulletin, Vol.30, No.1, 1998, p341-344.

[8] Kumar, D. and Wyatt, R., “Undergraduate AI and Its Non-imperative Prerequisite”, ACM SIGART Bulletin, Vol. 6, No.2, 1995, p11-13.

[9] Microsoft Corp., “Description of SHBroseForFolder”, Worldwide Web, /platform/shell/reference/functions/shbrowseforfolder.asp.

[10] Microsoft Corp., “SAPI 5.0 Overview”, Worldwide Web, /ceconsapi50overview.asp.

[11] Norvig, P. “Paradigms of Artificial Intelligence Programming: Case Studies in Common LISP”, Morgan Kaufmann, 1992.

[12] Papert, S., “Mindstorms: Children, Computers, and Powerful Ideas”, Basic Books, 1993.

[13] “Robosapien”, Worldwide Web, .

[14] “Robosapien IR Codes”, Worldwide Web, .

[15] “Roboty”, Worldwide Web, .

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download