Program Description WRO 2024 JUNIOR
Program Description WRO 2024 JUNIOR
Preface ………………………………………………………… 2
Concept ………………….…………………………………. 13
Algorithm ………………………………………………….. 19
1
Preface
The file represents methods implemented to the robot and describes
the program written in EV3G.
The instruction, the Studio 2.0 file and extra videos with more placings
are also provided.
It is important to know that the robot will not do the task perfectly
right after you build it, connect the cables and upload the program.
You will probably have to adjust it, pick up degrees, sensors’ thresholds
for scanning the lines and colors. To simplify this process you should
use motors for going with the same power and the sensors for line
following with the same values on black and white colors on the field.
The power of the motors can be checked this way:
2
The robot also uses RGB block:
You need to import this block. In EV3G open Tools -> Block Import and
import the needed block. Ev3b file with this block is provided with
other files in the Boosty post.
PD line follower
One of the most popular questions – how to make a robot follow a line
perfectly without twitching.
PD line follower is an answer.
3
e – “error”, current difference between line following sensors, e_old –
the difference on the previous iteration.
This algorithm works pretty well if you find good KP and KD. However,
sometimes the robot might stand inaccurately on the line, for example
after turning or doing any other complicated movements. In this case
PD might “save the robot”, but the further PD will be provided with
twitching. Thus the robot will arrive to the needed spot inaccurately,
which can lead to big mess.
There is a good solution of this problem, I called it “evening out”.
This means the robot will follow the line some time to stand accurately
on the line. This is like a PD with the specific speed, KP and KD to make
the further movements slight and smooth (KP and KD in this case might
be bigger than usually). As the robot evens out, we know it definitely
stands accurately on the line.
4
The robot may pass crossroads, to avoid twitching after passing we can
restrict motors’ speed.
We do not allow the speed to decrease or increase to the specific
numbers, which allows the robot to follow the line perfectly.
5
Let’s look at the PD represented in the program.
There are three main PDs – PD_Enc, PD_Cross_X and PD_Cross_T.
6
The next two are PD_Cross_X and PD_Cross_T. There are two types of
crossroads – type “X” and type “T”. It is better to separate them.
PD_Cross_T checks if the sum of the sensors’ values is less than the
specific number:
7
Let’s look at the parameters:
8
There is also a special variable s_even, which purpose is to set the
speed of the evening out:
Smooth braking
There is a term we should pay attention to - “Smooth braking”. When
the robot goes on a high speed it can slip some degrees after scanning
a crossroad. To avoid it we should decrease speed in advance – 200-
300 degrees before checking the crossroad. Let’s imagine a situation –
the robot has to go ~1000 degrees and 373 degrees after the
crossroad. It is represented in this picture:
9
out, and “0” as the fifth parameter so that the robot would keep its
speed.
10
Stable movements
To make a robot move stable several things should be comprehended.
First of all, we should understand the difference between “green” and
“blue” motors’ blocks:
Green motor blocks have some kind of a regulator inside them for
speed supporting. This means the motor will always rotate with the
needed speed.
Blue motor block does not always support the needed speed. This
block is more compromising, when meeting any obstacles the motors
will not try to rotate with the supposed speed. The speed can also
decrease with the battery level.
Blue motor blocks, for example, are usually used when a robot Is
moving along the field border.
I prefer to use blue motor blocks in the line follower, the robot seems
to move smoother than with green motor blocks.
To make movements stable there need to be a small pause (0.2-0.3
seconds) if the robot switches green motor block to blue one and vice
versa so that the robot would not bevel:
12
One more thing to make a robot stable is a pause or a delay. The
elements might be shaking after turning, so the robot should wait 0.2-
0.3 seconds so that the elements would “calm down”:
Concept
The robot starts with scanning the elements and putting the cable in
the charging area. Next, the robot takes the first three elements and
delivers them in the Park B. After, the robot takes the remaining three
elements, pushes the bikes and delivers the elements in the Park A.
Finally, the robot takes the kits and delivers them – closes the door
after putting the last kit.
Main blocks
13
Start – the elements are scanned, the cable is delivered.
Kits – the kits are taken and delivered, the door is closed.
14
Auxiliary blocks
Turning – allows the robot to revolve on its axis.
The robot rotates until the sensor which is the
closest to the line scans it.
The 1st parameter is the direction – “1” is
clockwise, “0” is not clockwise.
The 2nd is a number of degrees the robot
rotates (average of each motor) before
the closest sensor starts checking the line.
The 3rd parameter is the speed which is
supported the selected number of degree.
15
Taking – the robot takes the elements from
different positions, depending on the parameter
(will be explained in Algorithm).
16
Logic – the Algorithm procedures are carried out
here.
17
Taken from Scanning
Another place where RGB block is used is PD_Green. This block is used
when going to the Park A, this PD goes with one sensor. B-component
is used:
18
Algorithm
There are six places where the two lake elements can be:
The robot does not scan all the six elements, it just looks for the blue
ones. After finding each, the robot remembers the number of degrees
it had when the blue element was spotted. Variables enc_3 and enc_4
are responsible for that:
19
Taken from Logic
It is not necessary to check all the six intervals. To define the position
of the first blue element it is enough to check the five intervals from 6
to 2. The same logic works with the second element – only 5-1 intervals
need to be checked.
Variables dug_1 and dug_2 keep the numbers of the blue elements,
dug_1 > dug_2.
The robot takes three elements two times. Three elements must
contain two black and one blue. There are five types of taking the
elements – taking from positions 123, 234, 345, 456 and 126 or 156.
The last two takings (126 and 156) can be combined in one type. There
are two variables which keep the number of two takings – n_1 and
n_2. Variable n_1 might contain numbers 123, 234, 345 – they
correspond to the numbers of places. Variable n_2 might contain
either 456 or 404, 456 means taking from places with numbers 456,
20
404 means the robot will take elements from 126 or 156 places. The
variables are formed this way: the difference between dug_1 and
dug_2 is checked. Depending on the difference the variables n_1 and
n_2 are formed:
21