Lab Report: Collective Decisions by Molly He

Plan:

In the lab, we pick a simple algorithm to simulate the behavior of “cohesion”. Steps are as follow:

1. Trigger

We have five micro:bit as operating micro:bit in a square and another one micro:bit as controller. Each operating micro:bit will join a radio group with the controller. Once the controller micro:bit gives out a trigger to all operating micro:bit, they will switch to the mode “cohesion” and begin to move to a certain point.

2. Calculate

Each operating micro:bit will stick to a different individual mark. The computer vision system will determine the coordinates of each mark. After we get the coordinates of all five micro:bit, we will calculate the coordinates of the point which is the average point to all five micro:bit. Then we will sent the current position coordinates and average point position coordinates to five operating micro:bit through controller micro:bit.

3. Display

After five operating micro:bit get the coordinates, they will calculate the direction they need to head to. Then they will show an arrow towards the place the mark is on there 5Ă—5 LED.

4. Move

Operating micro:bit will move towards or away from the marker. After each move, we will get the new location coordinates of the operating micro:bit and send them through controller micro:bit. The operating micro:bit will then automatically calculate the distance away from the average point and compare it with previous distant. If they move towards the marker (distant is smaller), they show a happy face on their screen. If they move away from the marker (distant is larger), they show a sad face. Once they are in the position they wanted to be, their screen displays something else (a square or a circle, for example).

Code:

Important Variables:

previous_distance 

current_distance

cur=(x_cur, y_cur)

des=(x_des, y_des)

Logic:

void loop{
current_distance=dist(des,cur);

if (previous_distance>current_distance){
display(HAPPY);
}else{
display(SAD);
}

previous_distance =dist(des,cur);

The logic of our algorithm is not hard to figure out. The only problem we need to solve is how to repeatedly send out coordinates (information) from the controller micro:bit. 

Reflection:

We spent much time deciding on which behavior we were going to mimic. We were also hesitant to make out a clear logic line of how to realize our idea. At last, we didn’t have time to actually tinker the code of CV and put our idea into practice.

Leave a Reply