You are on page 1of 5

Embodied Reactive Agents

The BrickPi Lego robot

Israel Lpez Vallejo


Escuela Superior de Tecnologa y Ciencias Experimentales
Universitat Jaume I
12071 - Castelln de la Plana, Spain
israel.lopez@uji.es

AbstractThis paper is a short report on the research Within the field of AI, An agent is any entity that can
done about robot interaction algorithms. To develop the perceive its environment through sensors and act upon that
activity a Raspberry Pi based Lego robot has been used. The environment through actuators (Fig. 1). The simplest agents are
aim of this research is to program the robot using python to called reactive agents, which lack an internal symbolic model
achieve behaviors, such as: and act by binding certain combinations of stimulus to certain
responses.
Following a black straight and curved line. We use Lego BrickPi robot (Fig. 2) to make programs that
permit this robot to carry out some actions in this robot. For
Go through a complex path without leaving it's path.
example: line following, line detection, random exploration,
Go through a maze until finding a candle. etc., then we acquire some important data about sensors. We
propose to program an embodied agent for extinguishing a fire
These activities must be performed by the robot with the in a four-room maze on its own.
minimum human interaction, only the programming
necessary. The aim is to let the robot interact with the
environment in order to achieve predetermined goals.

KeywordsArtificial Intelligence; Embodied Agent; Lego


robot; BrickPi; Reactive Agent; Firefighting robot; Maze;
Fire; Candle, Robot sensors.

I. INTRODUCTION
The field of Artificial Intelligence comprises the set of
intellectual and technological resources for the creation of
programs for machines that mimic human behavior. The Figure 1: Agent and environment interaction diagram
research in the field of AI is characterized by the production of
machines for automation tasks which require intelligent
behavior. AI is widely studied in various fields of science
concept, nature and society and it has been an important field of
scientific research in recent decades.
In the construction of a system, the need for some
intelligence can be predicted when it's required to adopt a
processes such as: making a decision of an unforeseen situation,
in the presence of an enormous volume and undetermined
information, much of which is inaccurate, insecure and
conjectured, taking into account constraints, goals and
objectives greatly set by the same decision-making agent which
decides, resulting in decision satisfactorily.
Thus, if the problem is well structured, the AI will obtain
great achievements, such as the ones obtained to date in games
field, automatic demonstration and scheduling. So, predictably,
the machines will exceed humans in more and more fields where
intelligence used to be considered essential. Figure 2: BrickPi robot
II. LEGOS BRICKPI ROBOT A. Exploring robot behavior
The Lego BrickPi is a kit that contains software and To start, it's necessary to calibrate the movement of the robot.
hardware to create small, customizable and programmable In our case, there was a small variance between the right and the
robots. They include a programmable brick computer that left motor, it was necessary to increase the value of the right
controls the system, a set of modular sensors and motors and motor so the robot goes straight, e.g. robot.motors(40,42), hence
LEGO parts to create the mechanical systems. The main if the robot has to go forward at a speed of 60, the right
component in the kit is a brick-shaped computer called the instruction would be robot.motors(60,62) otherwise the robot
RaspBerry Pi. would move forward but turning to the right.
Then we tested the light sensor, to know the real value when
it detects a black or white line.
Also the ultrasonic sensor had to be tested to know exactly
the range of distance it could detect obstacles. In the test we
could see that this sensor could give false values, depending on
the way that the signal was reflected to the sensor.
Once everything is set and ready, it's time to start with the
first task.
B. Environment testing
This part of the research is focused in test and observe the
behavior of the robot in several situations. All the data obtained
from these test will later be used to solve the main problem.
These are the tests from which we will acquire the data [1]:
Navigate from A point to B point.
Room exploration without touching the walls.
Simulate a sumo fight.
Figure 3: Lego sensors Follow a path without leaving the rout.
This robot uses sensors to gather information from the
environment and uses the information to plan movements. The The first task to do is to navigate from one room to other, the
Legos sensors, with which we will work, are (see Fig. 3): path we did is represented in the Fig.4 with a red line. To
The touch sensor detects physical contact with the accomplish this task, we pre-programmed the path as individual
orange trigger, and returns a value of 1 if it is pressed in, segments. So the robot just has to follow the instructions.
or 0 if it is not. It can be used as a bumper.
Ultrasonic Sensor detects distance to object in the range
[0, 250~280] mm. Allows the robot to detect obstacles
and avoid them.
The light sensor detects reflected the light, also can
detect the basic colors of objects and surfaces by aiming
directly at them at close range. The sensor gives a light
intensity reading of 0-100 value.
The programming language used to work with the BrickPi is
python, so the task of programming should not be difficult or
complex. Two libraries were provided by the teachers to start the
tests such as: candle.py and robot.py.

III. FIRST STEPS


As we mentioned before, the aim of this research is to
develop an algorithm that is able to extinguish a fire in a room
without human interaction. To reach this point first is necessary
to test in the robot.

Figure 4: Maze diagram


The next task is to write a code that allows the robot to move
inside a room without touching the walls. This task was done
using the ultrasonic sensor. The pseudo code to do this is:
while true
if distance is far enough
move forward
else
turn right

Another task is to simulate a sumo fight, in this case our


robot has to move in a circular base (delimited with a grey
circular line) without leaving the white area, looking for a pile
of coke cans, then push them out of the ring.

Figure 6: Training mat with a cycle in red

C. Braitenbergs vehicle
Braitenberg vehicle is an agent that can move in an
autonomous way by a setting. It has primitive sensors (capable
of measuring stimuli), and wheels (each driven by its own
motor) which operate as actuators or effectors. A sensor, in its
simplest form, is directly connected to an effector, so that a
signal or stimulus in such sensor produces an immediate
response in the motor (moving the wheel, for example). Our goal
is to create different algorithms which enables the robot to
produce different actions of a Braitenberg vehicle. Depending
on how the sensors are connected, the robot shows different
behaviors. Based on this idea, we define these connections in
order to bring out one certain behavior or another [2].
Both drive tasks will constantly feed the values of each light
sensor into the respective motor as a speed. So we get these
Figure 5: Sumo ring with coke cans behavior:
A. Ipsilateral relationship1 (uncrossed): Each of the two
light sensors, belonging to the robot, are connected to
the corresponding side engine (Fig. 7), the speed of
As shown in the Fig. 5, it is necessary to use the light sensor each engine is proportional to the intensity of the
to avoid the robot going out of the circle. The pseudo code to perception of these sensors, i.e., each light sensor
accomplish this goal its a variation of the previous code: stimulates the wheel on the same side.
while true When the robot detects light, it moves towards the light
if still inside ring even faster and when is very close avoids it.
move forward More light on the right, the right wheel faster
if theres any obstacle turns: Turn left, outside the light.
move forward
else More light on the left, the left wheel faster turns:
Turn right, outside the light.
turn right
else B. Contralateral relationship2 (crossed): the right light
turn 180 degrees sensor is connected to the left engine and the left light
sensor is connected to the right engine (Fig. 8).
The last task consists in following the path in a mat without When the robot detects light, it moves towards the light
leaving the rout, which is determined by a black or grey line. ever faster.
This task has a small complication with it's cycles, depending on More light on the right, the right wheel slower
the calibration of the light sensor and the navigation instructions turns: Turn right, toward the light.
we can end up in a loop (see Fig. 6).

1 2
Affecting, or referring to the same side of the body. Affecting the opposite side of the body.
More light on the left, the left wheel slower The problem resolution: The strategies to explore this
turns: Turn left, toward the light. environment can be multiple, perhaps the easiest one is to follow
one of the walls, either the left or right one.
From a known and fixed position, regarding the exploration:
The robot starts at the initial position H (Fig. 10), detects the left
wall, continues to enter to the first room (central), once inside
the robot seeks the right wall and follows it until the end of the
path.

Figure 7: Ipsilateral relationship

Figure 9: BrickPi equipped with sensors

Figure 8: Contralateral relationship

Braitenbergs Vehicle 3 In this case, the signal value is


reversed, and this means that a greater perception of light, the
speed with which the wheels turn will be lower and even zero.
When the intensity is zero, the speed of the corresponding motor
is maximum, and vice versa. As a result, the robot was going fast
because the sensor input is small, because the robot has been
relatively away from light.
IV. PROBLEM RESOLUTION Figure 10: Starting point H
The aim is to develop a code which enables the robot to find
a candle and turn it off in a four room maze (three corner rooms V. CONCLUSION
and a central one). The tasks performed in this experiment have not been
The robot is equipped with the following motors and sensors difficult to program, they are perception-action simple behaviors
(Fig. 9): in function of the sensors used for this purpose.
Left and right motors for motion. However, the following disadvantages have been noted, the
fact that the actions are based on trial and error, implies a
A fan, which is used for putting out the candle.
laborious process of experimentation. Also, the interaction
A light sensor for detecting lines in the floor. between the tasks becomes a more complicated mesh as the
A camera for detecting the candle. number of tasks increase. The robot has relatively achieved to
explore all the rooms as small changes in the engines speed
Two infrared distance sensors on each side for detecting caused the robot to avoid the walls better or worse.
the walls.
Also it was observed that the same robot behaved differently ACKNOWLEDGMENT
with the same code on different days. We deduce that such This research was supported by lab session technicians. I
behavior occurs, because the robot does not always have the thank my two class mates for the help and advice.
same accuracy to perceive the environment all times due to the
battery level. An alternative or solution is to provide the robot REFERENCES
with a memory where the maze path would be stored and would [1] A. D. (n.d.). A Fire-Fighting Embodied Agent. Retrieved May 25, 2017,
be used to complete the task immediately. from https://aulavirtual.uji.es/mod/page/view.php?id=2896504.
[2] D. (n.d.). From bricks to brains, chapter. 4.

You might also like