Post on 31-May-2020
Course project 4
Line following using a camera
By Alexander Audouy & Julien Leprince
Program an e-puck in
Webots so that it can
perform line following
while avoiding obstacles
placed on the top of the
line
Different type of line are
provided:
- represented by the
matrix Screen[j][i]
- Values from 0 to 256
with 0 being black color
State 0
- Turn for 29 steps
- Move forward for 11 steps
- Search for the line on each steps
- Turns if it hits an obstacle (wall)
- Adapt the speed of the wheels
depending on the distance of the
line:
- For distant line(j=[0;18]):
right_speed=initial_speed+26-a
left_speed=initial_speed-(26-a)
- Closer line (j=[18;30]) :right_speed+=initial_speed*(1-a/26)
left_speed+=initial_speed*(1-(52-a)/26)
State 1
- Close to the line (j=[18;30]) :right_speed+=initial_speed*(1-a/40)
left_speed+=initial_speed*(-(52-a)/40)
State 2
right_speed+=initial_speed*(1-a1/26)
left_speed += initial_speed*(1(-52-a2)/26)
State 22
Condition for a turn :
z<23
y<18
x>50
u>20
Lag>3 (security)
Turning:
right_speed=initial_speed
left_speed = - initial_speed
For 15 steps
State 3: Avoiding collision
Taking Braitenberg’s formula, we use the 4 front
sensors of the e-puck to detect the obstacle and
the following formula to avoid it;
left_speed+=2*(braitenberg_coefficients[j][0] * (1 - (sensor_value[j] / RANGE)));
right_speed+=2*(braitenberg_coefficients[j][1] * (1 - (sensor_value[j] / RANGE)));
With j going from 0 to 7
Braintenberg’s coefficient have been adapted after
several tests.
State 5: Wall following
The moving along the wall is computed via the following formula:
left_speed += (0.6 -sensor_value[2 or 5]/1000)*200
right_speed -= (0.6 -sensor_value[2 or 5]/1000)*200
And is corrected if the front/side values of the sensors are too high with a simple;
if(sensor_value[1 or 6] > 200){
left_speed -= or += 200;
right_speed += or -= 200; }
State4: Turning around a corner
When the side sensors 2 & 5 detect a sudden
drop of their value, a turn is made on the side
with the simple code:
It then passes back to state 5 when count_r
reaches 23.
if (cas == 1){
left_speed = 500;
right_speed = 58;
count_r++;}
State 12
Avoiding obstacle
from the right :
If (i-j) negative, the
robot needs a bigger
trajectory correction:left_speed= -1.1*initial_speed
If (i-j) positive, the
robot needs a smaller
trajectory correction:left_speed= (0.2+(i-j)/60)*
initial_speed
Avoiding obstacle
from the left :
If (i-j) positive, the
robot needs a bigger
trajectory correction:right_speed= -1.1*initial_speed
If (i-j) negative, the
robot needs a smaller
trajectory correction:right_speed= (0.2+(i-j)/60)*
initial_speed
Number of steps :
(int)(11+(i-j)/8)
Division of our work into 2 axes:
- obstacle avoidance
- line following
Complexity of the general articulation
With more time: optimized code, smoother
obstacle avoidance and line following