Directed Line

This behavior involves several robots to be formed up in a single line from a reference robot, in our example it will be the robot whose ID = 0. In this example, we will use a combination of neighbor communication and virtual stigmergy to achieve this behavior.

Neighbor Communication

Similar to Azimuth Coordination, a knowledge table is used in each robot to store and categorise the data in a dictionary with key pair values. An example of an entry in the knowledge table is {"x-y", data}, where x is the ID of the robot and y refers to the category of data.

Data Category

y Data
0 Own azimuth
1 Own azimuth relative to neighbor x
2 Neighbor distance
3 Visibility bit, set as 1 if neighbor is visible
4 Ready bit, set as 1 if robot is in position

Key 5-2 refers to the distance to robot whose ID is 5 and key 3-1 refers to my position relative to robot whose ID is 3.

Virtual Stigmergy

Formation of Line

The line is formed with the following steps:

  1. If robot is in line, calculate the next angle the swarm is to follow
  2. Stop movement
  3. Put data in virtual stigmergy
  4. Set as ready
  5. Set and ready the barrier

Swarm-wide consensus

line.bzz (Source)

      # Put ID and next calculated angle for the rest of the robots to follow
          vs.put("a", id)
          vs.put("b", next_angle)

      # Set robot as aligned
          write_knowledge(knowledge, id, 4, 1)

      # Ready for the next state
          barrier_set(ROBOTS, rotate)
          barrier_ready()

  } else {
    if (read_knowledge(knowledge, bot, 2) > 120.0) {  # Get closer if too far

In the example above, it shows the process of how the line is formed using virtual stigmergy to provide swarm-wide consensus. vs.put("a", id) and vs.put("b", next_angle) writes the ID of the robot and the next angle the swarm is supposed to follow into the virtual stigmergy structure. The barrier is included so that users can write their own functions and extend this behavior.

Translation of coordinates

/images/line_diagram.JPG

Figure 2: Formation of line

Since each robot has its own coordinate system, there is a need to find a common value for the robots to line up to. In figure 2, it shows two robots X and Y formed in a line. The robots are in different orientations as they will stop movement once in position. Let A and C be the reference angle and let B and D be the target angle. When robot X is lined up in position, its reference robot would be at angle A. To obtain the reciprocal angle B, we will need to add or subtract 180 degrees depending on angle A, likewise with angle C and D.

line.bzz (Source)

      # Put ID and next calculated angle for the rest of the robots to follow
          vs.put("a", id)

The function degrees_interval() enables the addition of 180 degrees without exceeding 360 degrees.

line.bzz (Source)

  inform_your_neighborhood()
  if(read_knowledge(knowledge,id,4) != 1) {
        alignNearestBot(vs.get("a"), vs.get("b"))
  }
}


#################################################

lineUp() handles the lining up of robots. In simple terms, "If a robot is not in position, align to the target angle(vs.get("b")) of the last robot(vs.get("a"))".

Video

Back