Aggregation
For this example, it follows the method of aggregation proposed by Gauci et al (2014) on Self-organized Aggregation without Computation, where robots would circle forward if nothing is in its line of sight and rotate on its axis if another robot is in its line of sight.
In the paper, the robots have a binary sensor that informs if another robots is in its line of sight, where I = 1
when a robot is in the line of sight and I = 0
means otherwise.
Predefined velocities of the left and right wheel are mapped to each reading of 1 and 0 in order for successful aggregation.
Aggregate()
function aggregate() { # neighbors.foreach applies the function to all robots within distance of each other neighbors.foreach(function(rid ,data) { degrees = rtod(data.azimuth) if(degrees < 2 and degrees > (-2)) { # Checks if any robot is within -2 degrees and 2 degrees of vision set_wheels(10.0, -10.0) # Sets the velocity of the wheels } else { set_wheels(7.0, 10.0) # Sets the velocity of the wheels if no robot is in range of vision } })
The function aggregate()
uses neighbors.foreach()
which applies
a function to each neighbor. data.azimuth
represents the azimuth of each neighbor in radians. The azimuth is converted from radians to degrees to reduce complexity.
if(degrees < 2 and degrees > (-2))
checks if any robot is ahead in the line of sight with a theshold of 2 degrees on each side.
set_wheels(l,r)
sets the velocity of each wheel, where l
refers to the left wheel and r
the right wheel.
Limitation
However, this approach of aggregation would only work if the robots are able to see each other. If its range and bearing sensor can only detect another robot at a short distance, this method of aggregation would not work. In order for this to work, we will need to increase the range and bearing parameters of the robots to enable them to see further.
To do this, the parameter rab_range="30"
is added to the field <foot-bot>
in <arena>
as shown:
<arena size="30, 30, 1" center="0,0,0.5"> <distribute> <position method="uniform" min="-1,-1,0" max="1,1,0" /> <orientation method="gaussian" mean="0,0,0" std_dev="360,0,0" /> <entity quantity="4" max_trials="100" base_num="0"> <foot-bot id="fb" rab_data_size="500" rab_range="30"> <controller config="fdc" /> </foot-bot> </entity> </distribute> </arena>