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 distant 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:
From my point of view, the hardest part of the lab is to figure out what type of collective decision strategy we would like to do. In other words, what simple algorithm we want to apply. We spend about almost half of our time on discussing what we want to do and finally we decide to make a cohesion behavior. Another hard point of the lab I found is that how to define the degree of simple. Sometimes when we try to add move function to the collective decision behavior, I have a feeling that it will be too complicate to call it simple. But in all, I feel the lab is an interesting topic. However, to understand it better may take a long time.