Course project 4 Line following using a camera By ... · Line following using a camera By Alexander...

17
Course project 4 Line following using a camera By Alexander Audouy & Julien Leprince

Transcript of Course project 4 Line following using a camera By ... · Line following using a camera By Alexander...

Page 1: Course project 4 Line following using a camera By ... · Line following using a camera By Alexander Audouy & Julien Leprince Program an e-puck in Webots so that it can perform line

Course project 4

Line following using a camera

By Alexander Audouy & Julien Leprince

Page 2: Course project 4 Line following using a camera By ... · Line following using a camera By Alexander Audouy & Julien Leprince Program an e-puck in Webots so that it can perform line

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:

Page 3: Course project 4 Line following using a camera By ... · Line following using a camera By Alexander Audouy & Julien Leprince Program an e-puck in Webots so that it can perform line
Page 4: Course project 4 Line following using a camera By ... · Line following using a camera By Alexander Audouy & Julien Leprince Program an e-puck in Webots so that it can perform line

- represented by the

matrix Screen[j][i]

- Values from 0 to 256

with 0 being black color

Page 5: Course project 4 Line following using a camera By ... · Line following using a camera By Alexander Audouy & Julien Leprince Program an e-puck in Webots so that it can perform line

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)

Page 6: Course project 4 Line following using a camera By ... · Line following using a camera By Alexander Audouy & Julien Leprince Program an e-puck in Webots so that it can perform line

- 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)

Page 7: Course project 4 Line following using a camera By ... · Line following using a camera By Alexander Audouy & Julien Leprince Program an e-puck in Webots so that it can perform line

State 2

right_speed+=initial_speed*(1-a1/26)

left_speed += initial_speed*(1(-52-a2)/26)

Page 8: Course project 4 Line following using a camera By ... · Line following using a camera By Alexander Audouy & Julien Leprince Program an e-puck in Webots so that it can perform line

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

Page 9: Course project 4 Line following using a camera By ... · Line following using a camera By Alexander Audouy & Julien Leprince Program an e-puck in Webots so that it can perform line

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.

Page 10: Course project 4 Line following using a camera By ... · Line following using a camera By Alexander Audouy & Julien Leprince Program an e-puck in Webots so that it can perform line

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; }

Page 11: Course project 4 Line following using a camera By ... · Line following using a camera By Alexander Audouy & Julien Leprince Program an e-puck in Webots so that it can perform line

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++;}

Page 12: Course project 4 Line following using a camera By ... · Line following using a camera By Alexander Audouy & Julien Leprince Program an e-puck in Webots so that it can perform line

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)

Page 13: Course project 4 Line following using a camera By ... · Line following using a camera By Alexander Audouy & Julien Leprince Program an e-puck in Webots so that it can perform line
Page 14: Course project 4 Line following using a camera By ... · Line following using a camera By Alexander Audouy & Julien Leprince Program an e-puck in Webots so that it can perform line
Page 15: Course project 4 Line following using a camera By ... · Line following using a camera By Alexander Audouy & Julien Leprince Program an e-puck in Webots so that it can perform line
Page 16: Course project 4 Line following using a camera By ... · Line following using a camera By Alexander Audouy & Julien Leprince Program an e-puck in Webots so that it can perform line
Page 17: Course project 4 Line following using a camera By ... · Line following using a camera By Alexander Audouy & Julien Leprince Program an e-puck in Webots so that it can perform line

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