Swarm Intelligence Simulation with NXT Robots Using Piconet and Scatternet Attila Pásztor*, Tamás Kovács,* and Zoltán Istenes** * Kecskemét College, Faculty of GAMF, Department of Information Technology, Kecskemét, Hungary **Eötvös Loránd University, Faculty of Informatics, Department of Software Technology and Methodology, Budapest Hungary
[email protected] [email protected] [email protected]
Abstract— This study deals with swarm intelligence simulation through simple Lego NXT robots using Piconet and Scatternet networks. In this research, held at the Kecskemét College faculty of GAMF, we simulated the ants’ food collecting habits, in an artificial area, with low-cost NXT robots. These autonomous robots formed groups and collected objects/foods. They communicated with each other via Bluetooth and they used several sensors, such as touch, light and ultrasonic ones, to resolve their tasks. In the first part of the research, the group consisted of one master and three slave robots, similarly to the Piconet network. Then in the second part, we improved the communication system to a better one, allowing communication in a bigger group than a Piconet network, similar to the Scatternet network. This research could be a good starting point to other practical applications, such as, for example rescuing people and values from a polluted area or for solving collective topographical tasks.
I.
INTRODUCTION
A. Swarm Intelligence researches Nowadays there is a “relatively” new scientific research field of Artificial Intelligence: the swarm intelligence [1]. Several researchers study attitudes and habits of those animals naturally living in colony and try to adopt their researches for robot groups [2][3]. Since these autonomous robot groups are multi-agent systems, they communicate and cooperate amongst themselves similarly to some animals in the nature [4]. II.
servomotors and the Bluetooth techniques, it became very popular. The main part of the robot is the programmable brick. This brick basically consists of: an Atmel® 32-bit ARM® processor AT91SAM7S256 as a main processor, an Atmel® 8-bit AVR processor ATmega48 as a coprocessor and a CSR BlueCoreTM 4 v2.0 +EDR System for the Bluetooth wireless communication. An NXT brick can be connected wirelessly to three other ones (see Fig. 1) at the same time. The communication is set up as a “master-slave” communication channel. The master can communicate only with one of the slaves at a given moment. The slaves cannot communicate directly with each other.
THE FIRST PART OF THE RESEARCH WITH FOUR
ROBOTS
A. About the Lego NXT As in our experiments we used some NXT robots it is important to describe briefly the structure of our robots regarding their communication and programmable capabilities. In 2006 the Lego Company brought out its third generation of NXT sign robot, which actually won the innovative first prize of the Nürnberg toy exhibition. Thanks to its new sensors (sound and distance), the
Figure 1. The NXT Piconet Network
The brick has three output ports and four input ports. We can connect servomotors and lamps to the output ports, and touch, light, sound and distance sensors to the input ports. Currently, several companies sell new sensors, such as for example: magnetic compass, colour or rotation sensors, etc. Furthermore, several programming languages, like NQC, NXC, NBC, LeJOS are being developed as well, and in addition to this an icon-directed Mindstorms NXT programming language developed by LEGO, which made it more popular. Nowadays the MATLAB programming environment is the one mostly applied in the NXT programming.
B. The first simulation We made a simulation, where the robots imitated some animals’ food collecting habits. In this experiment we used the food collecting habits of the African Desert Ants. The “explorer” ants, first explored the area, and then, when they found food they marked the places with “pheromone”. Finally the workers gathered the found food. In the simulation there were two types of robots, since there were two types of tasks. The first task was for the “explorer” robot, (called “master”) (see Fig. 2) to discover the artificial area ( 6m × 6m ) and to memorize the Descartes coordinates of the random spread green discs (food). This robot had three light sensors for monitoring the edges of the area and to find the green discs (food places). It also had one ultrasonic distance sensor for monitoring the other robots, so that they do not crash to each other. The master had two motors to change position and another one to move its ultrasonic distance sensor (ant’s head).
coordinate unit (the African desert ants count their steps), so these units measure the location of the robots and their discs (food). During our simulation the starting point was the origin (0;0) (ant hill) and one rotation of the wheel increased one vertical coordinate unit. At the edge of the territory the robot turned back. One turning back made one horizontal coordinate unit. food
ANTHILL
Figure 4. The anthill and the odometry method
Figure 2.
The ‘explorer’ robot
The second task was for the “worker” robots (called slaves) to gather the green discs (food). These robots had two light sensors, a distance sensor and two robotic tentacles (ant antennae) (see Fig. 3) The communication between the master and the slaves was implemented via Bluetooth.
Figure 3. The ‘workers’ robot
There are many possibilities to walk all over the territory; due to the construction of the master robot we used a method based on odometry (see Fig. 4). This method uses one rotation of the robot wheel as a
In the first step of the task, the master robot started to explore the territory. For the optimal solution of the task, when the master robot found the first disc it gave immediately its coordinates via Bluetooth to the first slave waiting at the starting point. Then the master went on exploring and gave the coordinates of the next found disc to the next free slave. The master made such little turns, that there was no opportunity to miss any of the discs. If the master found another disc, and all of the slaves were busy, it remained there until one of the slaves got free. The algorithm of the explorer can be summarised as follows: Algorithm Master while (not end_of_field()) do scan_field_using_odometry(onestep) if (object_founded) then while (not free_robot) do wait(1sec) slave=search_first_free_robot() calculate_odometry() send_coordinetes(slave) endif end broadcast(end_collecting) endalgorithm. While the master robot was working the slaves were queuing at the starting point waiting for the master’s rectangular coordinates of the newly found disc. To find the optimal way to the disc, the slaves changed the rectangular coordinates to “Polar” ones (see Fig. 5). Thanks to this change, they immediately chose the shortest way to the discs. Because of rounding errors, even the slaves need to do a local search for the discs. In that special case, when the master and a slave moved too close to each other, the master gave way to that slave. The simulation ended, when the robots carried back all the discs to the given point. In the nature, the ants gather food until sunset, unless it begins to rain or the master gives alarm for some reason, for example: an enemy appears on their territory.
Figure 5. Transferring the coordinates
Algorithm Slave while (not received(end_collecting)) do while ( not anhill_exit ) do if (robot_front_of_me ) then wait(1sec) else go_forward(onestep) endif end coordinates=received_coordinates(master) (angle,distance)=calculate_polar(coordinates) turn(angle) go_forward(distance) search_object() if (object_founded) then pick_up_object() go_back_to_anthill() if (object_founded) then put down_object() end endalgorithm. The robots, working in a group together, fulfilled the tasks rapidly and effectively. The robot controlling program was written in the NXC programming language and the programming environment was the Brixc Command Center version 3.3.17., with the firmware 1.03 running on the robots. C. The problems of the simulation During our simulation, we had two main problems to be solved. The first one was the extend safe coverage of the applied Bluetooth technology. Originally it was approximately ten meters, so the borders of the artificial territory were very limited. We had to find a new kind of communication system to increase both the size of the artificial territory and the number of robots (see Fig. 6) [5][6].
Figure 6. The NXT colony
The second problem is that the specific roles (explorer, worker) cannot be interchanged between the robots, i.e. the roles in the swarm are predefined. Thus, in case of any damages, the roles could not be passed to each other. However, such a change of the roles can be useful in many cases. For example, if the master could not work any longer, it would immediately disconnect the Bluetooth connection and the first slave would take its role in exploring the area and controlling the communication [7][8]. III. NXT SCATTERNET NETVORK STRUCTURE To solve the problem of the limited roles within the group, instead of the Piconet network we applied a “static Scatternet” network. In this new group a so called “supermaster” robot worked as the only master. The supermaster could only communicate directly with its “submaster” robots. These sub-masters worked like bridges in the network (see Fig. 7). Super-master
Sub-masters Bridges: master/slave
Slaves
Figure 7. The Scatternet network
They played two different roles: the first is a slave, while communicating with the super-master and then, after the super-master’s disconnection the second is a master role, while communicating with their slaves. The super-master could communicate with the slaves only trough its sub-masters. Still, the sub-master could play only one role at a time, either it was a slave for the supermaster or it was a master itself for the slaves. When it was playing the role of a slave for the super-master, only the super-master had the right to connect or disconnect to it. In the other case, when it was playing the role of a master, only the sub-master had the right to connect or disconnect to the slaves. The super-master could not make connection with the sub-master while it was in connection with the slaves. For this reason, it was very important to reduce the sub-master’s communication time as much as possible, to let them back to their “waiting for connection” positions. In order to implement the communication scheme above, a connector, a disconnector and a message-sender function were written in the NXC programming language. The NXC language includes Bluetooth functions: BluetoothConnect, BtDisconnect, SendRemoteMessages, which are based on the host controller interface (HCI) of the Bluetooth radio. These functions were used to write our protocols. To be able to use the HCI functions, a new firmware had to be installed into the robots. (Ims_arm_nbc_nxc_105.rfw).
Only this new firmware could use correctly the above mentioned Bluetooth functions. The programming environment also had to be changed to the latest version of the Bricx Command Center (3. 3.7.19). At the beginning, the programs did not run correctly, it only started working well, when we set the compiler into the “enhanced firmware” mode. We also had to apply a static “rooting” hierarchy to compensate the unreliability of the Bluetooth technology used in NXT robots. In this way, the number of connections and disconnections was reduced. The supermaster and the sub-masters both had a “routing table”, containing the names of all the connectable slaves, their connection numbers and the fact, whether the connection to the connectable slaves is connected or disconnected. This “routing table” could not be extended, that is, each master-robot could be connected or disconnected with only the three slaves originally assigned to it. The supermaster could be connected or disconnected with the submasters, the sub-masters could be connected or disconnected with only its slaves. The slaves in the bottom level of the hierarchy had no “routing table” at all. They could not connect any robots, they could only be connected by their own sub-masters. To reduce the unreliability of the Bluetooth communication, the connecting, disconnecting and sending messages had to be repeated with inserted timeouts and retries amongst them. IV. COLLECTING SIMULATION WITH THIRTEEN ROBOTS Thanks to the network protocol mentioned in the third part we could increase the number of our robots to thirteen. The task remained the same (gathering food) as described in the first part, but with more robots and in a bigger area. (see Fig. 8). During the simulation, the super-master robot, started first, with dividing the artificial territory into three parts and only then could the three sub-masters start to explore their own designated areas. Differently from the first simulation, the sub-masters did not send immediately the coordinates of their first found disc (food). They went on exploring their own territory, memorizing the coordinates of each of the found discs. To reduce the number of connections and disconnections, the sub-masters only send the coordinates in a package to the slaves after they have explored all of their designated territory (distributing the coordinates amongst the slaves). During the sub-masters exploration tour, each 3 groups of slaves followed its own sub-master to its designated territory, to be within the needed communication range. Once the coordinates received, first the slaves memorized them all and then, they started to take the discs, one by one, to the base. Since the slaves started their work only after the memorization of the coordinates, the sub-masters could disconnect from them quickly, so as to return to their “waiting position“. From time to time, the super-master checked on its submasters in order to control their work, and so did the submasters with their own slaves. In case of any danger, the super-master sent an “alarm broadcast message” (evacuation) to the slaves, through the sub-masters, to leave the territory.
Work-zone 3
Sub-master
Work-zone 2 Super-master
Sub-master
Work-zone 1 Slave working
Food Sub-master Slave in
Slave out Base
Figure 8. The collecting simulation with more robots and in larger area
V. GOALS, IMPROVEMENTS AND POSSIBILITIES IN THE FUTURE A. Scalability of tasks The 1-3 structured Master-Slaves group, used in the first simulation, was increased into a 1-3-9 structured group in the second simulation. This group structure, of course, could be increased in a vertical and a horizontal direction as well (width and depth scalability). As a first possibility, the colony structure of the group could be a 13-9-27 scheme, so new slaves would be connected to the original slaves (vertical increase) (see Fig. 9). Master Sub-masters Sub-masters
...... Figure 9. The depth increase of the control tree
Slaves
our testing experiments the value of t in the case of the LEGO NXT robots is in the range of 5-10 seconds, so with the help of eq. (3) we obtain that for 13 robots the minimal total broadcast time in the tree is in the range of 30-55 seconds. This relatively high value is mostly due to the poorer Bluetooth architecture of the NXT bricks, which means for example that there are no possibilities for master/slave or park/active switches in the host controller interface (see for example ref. [6]). In the other hand, our present implemented connection and acknowledged message sending algorithms can be improved yet, so that a better value for t is expected. This improvement is left to our future work.
Master
Sub-masters
Slaves Figure 10. The width increase of the control tree
As a second possibility, more sub-masters can be connected to the super-master, as the super-master disconnects its first three sub-masters and connects other three sub-masters to itself (horizontal increase) (see Fig. 10). B. Ad-hoc Scatternet network The above-mentioned static structure could be changed to a dynamical one, using dynamical routing tables. In this case, still via Bluetooth, the actual position of a robot in the network would determinate its actual role, whether the robot is a master or a slave one. Considering the rooted tree structure of the network given in Figure 9 and 10 the total time, T , needed to send a message from the root to all of the leafs can be calculated easily (for a similar calculation see for example ref. [9]). If the average number of the children for a parent node is denoted by k , the time T is given as T = t ⋅n⋅k ,
(1)
where t is the time needed for a parent to build up connection and pass an acknowledged message to a child node, and n is the number of levels in the rooted tree. The number of the nodes (robots) is calculated as
N = 1+ k + k 2 +"+ k n =
k n +1 − 1 , k −1
C. Position system for location There are a few programming languages for NXT robots (such as for example: LeJOS, NXC), which implement reliable measuring tool for the signal quality of the Bluetooth connection between two robots. A function can be created, corresponding to the measured signal quality that returns the approximate distance between two robots. Based on this function it is possible to develop an indoor location system for the robot group, since knowing the fixed positions of two robots the locations of the others can be calculated by trigonometry. D. Construction of homogenous groups of robots The three light sensors for the accurate rotating and positioning of the super-master and the sub-masters (like in our cases above) can be substituted only one magnetic compass, which is also a perfect solution to the task. In this way the masters can be equipped a new tentacle in the emptied ports, to be able to gather the discs itself. In this case the construction of the slaves and their masters would be very similar. Since the group would become homogeneous, any robot could take the role of any other robots. ACKNOWLEDGMENT We would like to thank some IT students of the KF GAMF, especially Tamás Simon who helped us a lot in building the robots. REFERENCES
(2) [1]
whence the parameter n can be expressed by k and N , so the relation (1) can be written as log[ N (k − 1) + 1] T (k ) = t ⋅ ⋅k . log k
[2] [3]
(3)
If k → 1 then T ( k ) → t ⋅ N , which is obvious, since in this case the tree is transformed into a linear chain. The other extreme case is when k ≈ N , so the number of the levels is only one. In this case T ≈ t ⋅ N , that is the same as in the previous case. By determining the minimal value of T (k ) we obtain the optimal choice for k . This value is k ≈ 2 when N is in the range of [10..100] . By means of
[4] [5]
[6]
E. Bonabeau, M. Dorigo, G. Theraulaz, „Swarm intelligence, From Natural to Artificial Systems”, Oxford University Press, 1999, ISBN13: 9780195131598, ISBN10: 0195131592 S. Rutishauser, N. Correll, A. Martinoli, “Collaborative coverage using a swarm of networked miniature robots”, Robotics and Autonomous Systems (2008), doi:10.1016/j.robot.2008.10.023 M. Kulich, J. Kout, L. Preucil, R. Mazl, J. Chudoba, J. Saarinen, J. Suomela, A. Halme, F. Driewer, H. Baier, K. Schilling, N. Ruangpayoongsak and H. Roth, „PeLoTe - a heterogeneous telematic system for cooperative search and rescue missions”, in Proc. The IEEE/RSJ International Conference on Intelligent Robots and Systems, Sendai 2004, Japani: 2004, 8 p. M. Dorigo, T. Stützle, “Ant Colony Optimization”, MIT Press, 2004, ISBN-10: 0-262-04219-3 ISBN-13: 978-0-262-04219-2 A. Weitzenfeld, L. Martínez-Gómez, J. P. Francois, A. LevinPick, K. Obraczka, J. Boice, „Beyond RoboCup: Ad-Hoc Networking for Autonomous Mobile Robots”, In proc. International Conference on Mechatronics Technology 2006 W. Song, X. Li, Y. Wang, W. Wang, „dBBlue: Low Diameter and Self-routing Bluetooth Scatternet”, DialM-POMC’03, September 19, 2003, San Diego, California, USA
[7]
[8]
G. Augusto Silva Pereira, V. Kumar, M. Fernando Montenegro Campos, “Closed loop motion planning of cooperating mobile robots using graph connectivity”, Robotics and Autonomous Systems 56 (2008) 373–384, doi:10.1016/j.robot.2007.08.003 M. J.B. Krieger, J. Billeter, „The call of duty: Self-organised task allocation in a population of up to twelve mobile robots”, Robotics and Autonomous Systems 30 (2000) 65–84, PII: S09218890(99)00065-2
[9]
E. J. Jung, “Creation and maintenance of a communication tree in wireless sensor networks,” Ph.D. thesis, Texas A & M University College Station, TX, USA, (2007)