Barrier

This behavior mimics the Quorum sensing in bacteria for collective decision making. In bacteria, it works by triggering a new behavior if chemicals reach a certain threshold. In swarm robotics, this can be done using Virtual Stigmergy to create a barrier which allows the swarm to wait for a sufficient number of robots before moving to the next bahavior.

This is a simple example which shows how the barrier works in Buzz. It consists of three states, iterate, barrier_wait and rgb_red. Each robot is initialized with a random number and starts in the iterate state. While in this state, for each time step, the robot increments its random number. If the random number is a factor of 10, it goes to the barrier_wait state using barrier_set(NUM_ROBOTS, rgb_red). NUM_ROBOTS refers to the threshold set in order for the transition to the next bahavior. rgb_red is the next state of transition.

barrier.bzz (Source)

# First state, increment for every time-step
function iterate() {
  iteration = iteration + 1
  set_wheels(-10.0,10.0)
  debug(iteration)
  if(iteration % 30 == 0) {
    barrier_set(ROBOTS, rgb_red)
    barrier_ready()
  }
}

# The final state
function rgb_red() {
  setleds(255,0,0)
  set_wheels(10.0,-10.0)
  #debug("red")
}

barrier_set()

This function sets the barrier for the robot by putting it in the barrier_wait state with the threshold and the next state to transition to.

barrier.bzz (Source)

function barrier_set(threshold, transf) {
  statef = function() {
    barrier_wait(threshold, transf);
  }
}

barrier_wait()

In the barrier_wait state, it constantly checks if the size of the barrier has reached its threshold. If the size is equal to or greater than the threshold, the next state is triggered.

barrier.bzz (Source)

function barrier_wait(threshold, transf) {
  barrier.get(id)
  debug("wait ", barrier.size())
  set_wheels(0.0,0.0)
  if(barrier.size() >= threshold) {
    barrier = nil
    statef = transf
  }
}

barrier_ready()

This funciton allows the robot to be marked as ready as its ID is put into the barrier. This increases the total size of the barrier.

barrier.bzz (Source)

function barrier_ready() {
  barrier.put(id, 1)
}

Video

Back