Assignment1 LineFollowing

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

CENG488 Advanced Topics in Computer

Engineering
Assignment 1

Line Following Robot


Your objective is to implement a state machine to guide the robot along a line.

Notes:

1. The robot you should use in Webots is E-puck .

The E-puck is a compact differential-drive mobile robot. Its movement is controlled by


adjusting the speeds of its left and right wheels independently. Equipped with eight
infrared distance sensors around its body, the E-puck can detect obstacles.
Additionally, three infrared sensors are located beneath its base, aimed at the floor,
enabling the implementation of a line-following behavior. For a comprehensive guide
on the E-puck robot and its utilization in Webots, refer to the following link.
https://webots.cloud/run?version=R2023b&url=https%3A%2F%2Fgithub.com%2Fcyb
erbotics%2Fwebots%2Fblob%2Freleased%2Fprojects%2Frobots%2Fgctronic%2Fe-
puck%2Fprotos%2FE-puck.proto

2. The sample World is given in the attachments. Please save the world named
“Line_Following_2_e-puck_with_floor_sensors.wbt and line track texture named
“Line_cross_3.png” into the same directory (Webots ” projectsà Worlds)

3. I strongly recommend that you work on and complete Webots Tutorial- 4 before starting
your assignment. https://cyberbotics.com/doc/guide/tutorial-4-more-about-controllers?tab-
language=python

4. To detect the floor line, use the ground sensors, which are treated as distance sensors in
the simulator due to their infrared nature. Acces them in Python as shown below:

a. To initialize the ground sensors:


gs = []
gsNames = ['gs0', 'gs1', 'gs2']
for i in range(3):
gs.append(robot.getDevice(gsNames[i]))
gs[i].enable(timestep)

b. To read the ground sensors inside the main loop:


gsValues = []
for i in range(3):
gsValues.append(gs[i].getValue())

c. To read sensor values inside the main loop:


line_right = gsValues[0]
line_center = gsValues[1]
line_left = gsValues[2]

5. Create a new controller and implement a line following behaviour using three states, namely
forward, turn left and turn right. You may add one extra state to stop when no line is
detected.

You might also like