1. Navigate alone:
-
Description
-
Pseudocode
-
Code
<
>
This program makes our robot navigate in the arena randomly, without touching the borders.
Navigate alone's pseudocode
view/hide the code
Navigate alone's code
2. Find a ball in a predefined position:
-
Description
-
Pseudocode
-
Code
<
>
This program makes the robot locate the direction of the ball, then move horizontally and vertically to grab the ball. When this is done, the robot should go back to the initial position.
Pseudocode of finding a ball in a predefined position:
view/hide the code
Code of Finding a ball in a predefined position:
3. Find a ball in a random position:
-
Description
-
Pseudocode
-
Code
<
>
This program makes the robot able to find the ball which is placed randomly in the arena. Briefly, our robot will scan the arena until it find the ball. At this moment, it return to its initial position.
Starting from the south-right corner, our robot will move a little bit, scan to find if there is a ball around it. The detection is done by comparing the current value measured by the ultrasonic sensor and the next one. A discontinuity, i.e abs( current_value - next_value ) > SEUIL ), means that we have detected a ball. If yes, our robot will go to the ball and take it back home. If no, it will again move a little bit and scan. it continue doing these two steps (moving and scanning) until it reach the border. At this moment, the robot turns left, scans and then moves horizontally a little bit. After that, the robot turns right, continues doing these steps until it finds the ball. Once the ball is found, the robot takes it back home.
The following picture explains our idea to find a ball placed randomly in the stadium:
Pseudocode of finding a ball in a random position:
view/hide the code
Code of finding a ball in a random position:
4. leader/follower in a 2-robots snake:
-
Description
-
Pseudocode
-
Code
<
>
In the stadium there are only two red/blue balls placed at a predefined locations.
Our robot have to go forward, with the follower, just before the two balls. At this moment, he make a scan to know the direction of the ball. The scan is done by turning left by an angle less than 90 degrees, then turns right by an angle less than 180 degrees. Once it detects a ball, it goes to it, grabs it, and turn to the south direction. After that, the robot will return to the initial position.
Pseudocode of LEADER in a 2-robot snake:
Pseudocode of FOLLOWER in a 2-robot snake:
view/hide the code
Navigate alone's code
5. leader/follower in a 3-robots snake:
-
Description
-
Pseudocode
-
Code
<
>
In the stadium there are four fixed balls, and other random balls may exist.
Initially, the three robots (a leader and two followers) are waiting for a START message from the server via Bluetooth. this message contains the rank. If the rank==0: we are leader, else we are follower. Thus, once we receive the START, we execute either the leader function or the follower function:
- Case 1: our robots is the leader. In this case, whenever he decides to take a step forward, he send a message (ACTION message) via Bluetooth to the first follower indicating which action it will take.
Our robot takes the green path (see picture bellow) and continuously checks if there is a ball. Once he finds a ball, he returns to its initial position (the orange path in the picture bellow).
- Case 2: our robot is a follower. If it is the first follower, whenever it receives a message it sends an ACK message, forward the message to the second follower, and follows the order. However, In case it is the second follower, it needs only to send an ACK message and follow the order.
PseudoCode of Leader/Follower in a 3-robots snake:
view/hide the code
Code of Leader/Follower in a 3-robots snake: