0% found this document useful (0 votes)
58 views5 pages

KRolog A Prolog Based Interface For The

This document describes KRolog, a Prolog-based interface for controlling simulated and real Khepera robots. The interface hides low-level communication details and provides high-level predicates. It uses the KRobot class to manage serial communication with robots. The interface has three layers: a low-level communication layer, a robot abstraction layer, and a high-level control layer accessible from Prolog. This allows developing robot control programs in a declarative manner.

Uploaded by

Simi Mar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views5 pages

KRolog A Prolog Based Interface For The

This document describes KRolog, a Prolog-based interface for controlling simulated and real Khepera robots. The interface hides low-level communication details and provides high-level predicates. It uses the KRobot class to manage serial communication with robots. The interface has three layers: a low-level communication layer, a robot abstraction layer, and a high-level control layer accessible from Prolog. This allows developing robot control programs in a declarative manner.

Uploaded by

Simi Mar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

KRolog: A Prolog based interface for the Khepera robots

Edgardo Ferretti
Laboratorio de Investigación y Desarrollo en Inteligencia Computacional (LIDIC)
Universidad Nacional de San Luis
Ejército de los Andes 950 - Local 106, (5700) - San Luis - Argentina
[email protected]

Marcelo Errecalde
Laboratorio de Investigación y Desarrollo en Inteligencia Computacional (LIDIC)
Universidad Nacional de San Luis
Ejército de los Andes 950 - Local 106, (5700) - San Luis - Argentina
[email protected]
and
Guillermo Simari
Departamento de Ciencias e Ingenierı́a de la Computación
Universidad Nacional del Sur
Av. Alem 1253, (8000) Bahı́a Blanca, Argentina
[email protected]

ABSTRACT representation language that easily reflect the deci-


In this paper we present KRolog a Prolog based inter- sion processes made by the agents. At this end, we
face to work with simulated and real Khepera robots. decided to develop an interface in Prolog, a program-
The interface hides low-level robot-computer com- ming language that has already been used to develop
munication and provides a high-order set of predi- applications in the field of cognitive robotics [3, 4].
cates to develop programs in a declarative manner. In this way, the use of this interface allow us to ig-
This paper describes the software we have developed nore the low-level details related with the robots (e.g.
to support the hardware platform we use in cognitive dealing with the size of the robot, the steering an-
robotics research at the LIDIC. gles needed, the slippage of the wheels, sensors noise,
Keywords: Khepera, Webots, Prolog, Cognitive etc.), and helps us to concentrate on the high-level
Robotics, Coordination models. problem specification.

1. INTRODUCTION 2. KHEPERA 2 ROBOT OVERVIEW


One of the main objectives of the research line “Intel- The Khepera 2 robot, is a miniature mobile robot that
ligent Agents” of the LIDIC, is the design, implemen- allows confrontation to the real world of algorithms
tation, and application of high-level multi-agent coor- developed in simulation for trajectory execution, ob-
dination models. This study is carried out through a stacle avoidance, pre-processing of sensory informa-
theoretic and practical approach. The confrontation tion, hypothesis on behaviors processing, among oth-
with the real world is done using a group of Khep- ers. Its small size (60 mm diameter, 30 mm height),
era 2 [1] mobile robots, with capabilities to pick and light weight (approx. 70 grams), and compact shape
transport objects and perform different kinds of en- are ideal for micro-world experimentation. The Khep-
vironment sensing. Moreover, before the direct ex- era 2 has eight infrared sensors to sense both ambient
perimentation with the robots we also perform robots light levels and proximity to nearby objects. It also
simulations with Webots [2], a 3D realistic profes- has two DC motors that are capable of independent
sional simulator. Furthermore, the use of this sim- variable speed motion, allowing the robot to move
ulator allows us to model situations with more than forward, backward, and complete a variety of turns
three robots, the number of robots that we have at the at different speeds.
laboratory. As can be observed in Figure 1, the Khepera 2 has
Our aim is to develop deliberative agents to con- several extension modules that can be plugged into
trol the robots coordination, and many of the aspects the top of the robot. These include an arm with a grip-
related to the robots’ behavior require an expressive per, a linear vision system, and a matrix vision cam-
era. The Khepera 2 has an on-board Motorola 68331 about the world in a declarative manner, and to de-
(25MHz) processor, 512 KB RAM, 512 KB Flash rive new representations of the world, and use them
memory programmable via serial port, and recharge- to deduce what to do.
able NiMH batteries that allows it up to 60 minutes of In Figure 2 the KRolog interface scheme is shown.
autonomy. Thus, the Khepera has sufficient sensors As can be observed it has a three layer architecture
and actuators to ensure that it can be programmed to and it is able to interact with real robots and simulated
complete a wide variety of tasks. ones. This interface has been designed to communi-
When connected to a host computer through the cate with Webots in the same way it does with the real
serial port, the SemCor control protocol is used to Khepera 2 robots.
send control messages to the robot. As the robot may Next, we describe in details this three layers that
need to send an answer message to the host, ASCII compose our interface.
messages are used to communicate between them.
The low level communication layer
Each interaction consist of:
This layer handles all the details related with se-
• A command, beginning with one or two ASCII rial communication among the robots and the high-
capital letters and followed, if necessary, by level predicates of our interface. This layer is com-
numerical or literal parameters separated by a posed by two modules, one for the real robots and
comma and terminated by a carriage return or another for interfacing the simulator.
a line feed, sent by the host computer to the
The KRobot class
Khepera 2 robot.
The KRobot class is the base building block for
• A response, beginning with the same one or the module that communicates with the robots. This
two ASCII letters of the command but in lower C++ class maintains the information of the robot’
case and followed, if necessary, by numerical state and provides a set of methods equivalent to
or literal parameters separated by a comma and the SemCor protocol commands. For instance, the
terminated by a carriage return and a line feed, command to read from the proximity sensors situated
sent by the Khepera to the host computer. around the robot is:
N
During the entire communication, the host computer where to this command the Khepera would respond
acts as a master and the robot as a slave. All commu- with the following string, if it had hit an object by its
nications are initiated by the master. front part:
Code can also be uploaded into the Khepera’s n,0,259,1023,1023,278,0,0,0
memory for a standalone execution. Programs writ- The response is returned as a C-style string and must
ten in C language or in M68000 assembly language, be parsed to determine the values of each of the prox-
can be compiled under many environments using a imity sensors.
cross compiler and uploaded in RAM or flashed in In contrast, if we want to read the proximity sen-
non volatile memory. A complete API is available, sors of a Khepera 2 robot associated with an ob-
either in C or assembly language, for programs to in- ject r of the type KRobot, we just have to invoke
terface with the robot hardware. the method r.readProxSensors(); and it saves
these values in an internal structure of the object.
3. THE KROLOG INTERFACE Then, each of these sensor values can be accessed
The KRolog interface is currently developed as a Ciao by the method r.getProxSensor(i); with 0 ≤
Prolog [5] module running under the Linux operating i ≤ 7.
system. To our view, Ciao is one of the most com- Webots interface
plete Prolog systems that allows the programmer to In Webots, the DifferentialWheels node
use sockets, multi-threads, Java and C embedded code defines any differentially wheeled robot. Thus,
in Prolog programs and vice versa, among others. In the Khepera 2 robot is an instance of the
addition, it provides a fully integrated programming DifferentialWheels node with its fields com-
environment with the text editor Emacs, that allows pleted to match its shape and functionalities.
the programmer to run, debug, compile, and syntax In this way, the module that handles the commu-
correction of Prolog programs. nication between the Prolog interpreter and the simu-
This interface uses the KRobot class [6] to man- lator translates the predicates available in the KRolog’
age the serial port communication with the robot. The API, to their respective commands of the Webots’
KRobot class developed by Harlan et al., hides low- controllers API.
level robot-computer communication and allows de-
velopers to focus on robot/environment interaction. The interconnection layer
As our interface has been programmed in Prolog, The development of this layer adheres the
it extends the functionalities provided by the KRobot paradigm of a TCP/IP connection-oriented protocol,
class in that it allows representing the knowledge using Berkeley sockets.
Figure 1: Khepera 2 robot and its accessories

Figure 2: The KRolog interface scheme

In Section 2 was mentioned that during the entire cation servers that process the images it obtains, and
communication, the host computer acts as a master generate information packets that are then made avail-
and the robot as a slave, and that all the communi- able to be used by the agents that control the robots.
cations were initiated by the master. In consequence, For instance, one alternative would be using the Do-
the robots’ control modules were programmed with raemon video server [7], the one used in the E-League
the corresponding code of a server, while the predi- competition [8].
cates available in the API are seen as clients.
The API
When the API’s predicates should sent a com-
mand to a real or simulated robot, they launch a tem- The API is composed by 24 predicates, one for
porary client (programmed in C) that communicates each KRobot class’ methods. As all the SemCor
to the server (the real or simulated robot) and waits for commands after being issued receive a result or a
its answer. This operation is repeated as many times confirmation from the Khepera robots, all the pred-
as predicates are used in the Prolog code that controls icates have a variable as parameter that matches
the robots behavior. In Figure 3, this communication this answer. Those variables named Outb matches
process is depicted. boolean values, Outint matches integer values,
As a final remark, one advantage of using TCP/IP while Outlist matches list of atoms. These pred-
sockets to develop this layer, is that it makes it pos- icates are used without distinction to communicate
sible to interact with a global camera (that covers the with a real or simulated robot. Next, we can see the
robots’ world) and its video and command communi- predicates and a brief explanation for each one:
Figure 3: Functioning of the interconnection layer

• reset(Outb): Resets the wheel counters to • getRightWheelSpeed(Outint): Reads and


zero. Sets speed and acceleration to default set- returns the speed and direction (+/-) of the right
tings. wheel/motor in mm/sec.

• moveForward(Lw,Rw,Outb): Makes the • setWheelSpeed(Ls,Rs,Outb): Sets to Ls


robot’ left and right motors to move forward in- and Rs the left and right motors’ speed and di-
definitely at speeds Lw and Rw, respectively. rection (+/-) in mm/sec.

• moveForwardDistance(D,Outb): Makes • getLeftWheelAcceleration(Outint):


robot move forward D millimeters. Reads the acceleration of left wheel/motor in
mm/sec2 .
• moveBackward(Lw,Rw,Outb): Makes the • getRightWheelAcceleration(Outin):
robot’ left and right motors to move backward Reads the acceleration of right wheel/motor
indefinitely at speeds Lw and Rw, respectively. in mm/sec2 .
• moveBackwardDistance(D,Outb): Makes • setWheelAcceleration(La,Ra,Outb):
robot move backward D millimeters. Sets to La and Ra the left and right motors’
acceleration and direction (+/-) in mm/sec2 .
• stop(Outb): Stops the robot’ movement.
• readLightSensors(Outb): Reads the val-
• turnLeft(Dg,Outb): Makes robot turn left ues of each of the eight light sensors.
Dg degrees passed as parameter.
• writeLightSensors(Outb): Displays the
• turnRight(Dg,Outb): Makes robot turn values of the eight light sensors.
right Dg degrees passed as parameter.
• getLightSensor(Ls,Outint): Gets the
• getLeftWheelCounter(Outint): Reads value of the requested light sensor Ls.
and returns the left wheel counter. • readProxSensors(Outb): Reads the values
• getRightWheelCounter(Outint): Reads of each of the eight proximity sensors.
and returns the right wheel counter. • writeProxSensors(Outb): Displays the
values of the proximity sensors.
• getLeftWheelSpeed(Outint): Reads and
returns the speed and direction (+/-) of the left • getProxSensor(Ps,Outint): Gets the
wheel/motor in mm/sec. value of the requested proximity sensor Ps.
• getAllLightSensors(Outlist): Return 7. REFERENCES
all the light sensors’ values in a list. [1] K-Team, “Khepera 2.” http://www.k-team.com.
• getAllProxSensors(Outlist): Return all A miniature mobile robot designed as a research
the proximity sensors’ values in a list. and teaching tool.
Even though this interface has not been tested un- [2] O. Michel, “Webots: Professional mobile robot
der the Windows operating system, we think that its simulation,” Journal of Advanced Robotics Sys-
code should be easily ported because Ciao and We- tems, vol. 1, no. 1, pp. 39–42, 2004.
bots versions for Windows exist. Only the serial port
definition should be changed from /dev/ttyS0 to [3] A. J. Garcı́a, G. I. Simari, and T. Delladio, “De-
COM1. signing an agent system for controlling a robotic
soccer team,” in X Congreso Argentino de Cien-
4. FUTURE DEVELOPMENTS OF cias de la Computación, 2004.
THE KROLOG INTERFACE
[4] H. J. Levesque and M. Pagnucco, “Legolog:
As further developments in the KRolog interface, we
Inexpensive experiments in cognitive robotics,”
plan to extend the interface to be able to control real
in The Second International Cognitive Robotics
and simulated robots plugged with gripper-arms and
Workshop, (Berlin, Germany), pp. 104–109, Au-
linear and matrix vision systems. In consequence, we
gust 2000.
will have to add new classes to Harlan et al. C++
interface with one class per extension module, and
[5] F. Bueno, D. Cabeza, M. Carro,
methods for each SemCor command of the k213 lin-
M. Hermenegildo, P. López-Garcı́a, and
ear vision extension turret, k6300 matrix vision ex-
G. Puebla, “The ciao prolog system. reference
tension turret, and the gripper-arm extension turret.
manual,” Tech. Rep. CLIP3/97.1, School of
In second place, we are going to extend the low-
Computer Science, Technical University of
level layer to allow the communication among the
Madrid (UPM), August 1997. Available from
robots. This is a key feature to develop coordination
http://www.clip.dia.fi.upm.es/.
models. However, as we are interested in developing
coordination models where point to point and broad- [6] R. M. Harlan, D. B. Levine, and S. McClarigan,
cast explicit communication exist, only this kind of “The khepera robot and the krobot class: a plat-
facilities will be provided. In this way, this interface form for introducing robotics in the undergradu-
would also be useful to those researchers that have the ate curriculum,” SIGCSE Bulletin, vol. 33, no. 1,
Khepera’ radio base module, because the robots could pp. 105–109, 2001.
communicate among them in a wireless mode.
Finally, as our aim is to use Defeasible Logic Pro- [7] B. Vosseteig, J. Baltes, and J. Ander-
gramming (DeLP) [9] to build applications that deal son, “Robocup e-league video server.”
with incomplete and contradictory information in dy- http://sourceforge.net/projects/robocup-video.
namic domains, we will try to interconnect an existent
DeLP interpreter [10, 11] with our interface. [8] “Oficial e-league webpage.”
http://agents.cs.columbia.edu/eleague/.
5. CONCLUSIONS
[9] A. J. Garcı́a and G. R. Simari, “Defeasi-
In this paper we have presented a flexible interface
ble logic programming: an argumentative ap-
that helps researchers, teachers, and students in the
proach,” Theory and Practice of Logic Program-
development of Prolog based applications for the
ming, vol. 4, no. 2, pp. 95–138, 2004.
Khepera robots. The interface hides low-level robot-
computer communication and provides a high-order
[10] A. J. Garcı́a and G. R. Simari, “Un compilador
set of predicates to help us to concentrate on the high-
para la programación en lógica rebatible,” in
level problem specification.
III Congreso Argentino de Ciencias de la Com-
Besides, it has the advantage of communicating
putación, 1997.
with Webots in the same way it does with the real
Khepera 2 robots. [11] A. J. Garcı́a, “La programación en lógica rebati-
ble su definición teórica y computacional,” Mas-
6. ACKNOWLEDGMENTS ter’s thesis, Departamento de Ciencias e Inge-
We thank the National University of San Luis and the nierı́a de la Computación, Universidad Nacional
ANPCYT for their unstinting support. del Sur, Bahı́a Blanca, Argentina, 1997.

You might also like