The motion of a robot inside a field with obstacles

Line follower

To solve the problem of robot motion inside a field with obstacles, two different philosophies can be followed. The first is to trace a predefined path to avoid obstacles, in case you know beforehand the object to avoid, the second is to probe the surrounding space through appropriate sensors and to define the better path that allows the robot to avoid the obstacles. These two different philosophies lead to two different methodologies:

  • Line follower

  • Interpolated curves.

In this paper we will analyze the two different methodologies, limiting ourself in the second case to the study of simple models within the reach of upper secondary school students.

Introduction

We propose a project of educational robotics for upper secondary school.The activity has been experimented in the scholastic field during the 2017/2018 academic year. To pursue a line is one of the typical problems of control theory: it means to obtain a desired behavior from a system (the robot) that follows a certain reference (a line). But why should a robot follow a line? Surely because in this way it could be made to move with a certain security within a space, without having to resort to other engineering concepts

Some examples from the real world of robots that work by exploiting this solution:

- Restaurants

- Industrial world

- World health care

The proposed activity has been tested with the fourth classes of the our institute Erasmo da Rotterdam Nichelino – (To) Italy

Prerequisite

What students should know before

  • Basic knowledge of the LEGO® Mindstorms EV3 Education kit , light and color sensor.

  • Basic knowledge of the LEGO® Mindstorms EV3 Home Edition Software.

  • Basic knowledge of Python.

Time constraints: 12 hrs.

Preparing For This Tutorial:

  • Instruments
    • Computers.

  • LEGO® Mindstorms EV3 Education Kit.

  • LEGO® Mindstorms EV3 Home Edition software and Python.

  • A white sheet on which a path is prepared using, for example, 2 and 5 cm black insulation tapes. Remember that the more tight the curves, the more complex it will be to program the robot and find suitable algorithms for tracking the line.

  • Methodology

The methodology adopted for the realization of the project was that of learning based on problem solving and learning: “challenge-based”. At the beginning of each lesson a problem or challenge was proposed that the students have to solve by working in a team; which also involves collaborative learning among the strategies chosen during the design phase of the activity.

image0

Effects

Outcomes:
- To construct a simple mathematical model with respect to a posed problem (to follow a line).
- Use basic programming elements (sequential, cyclic and instruction-based execution).
- Discover and use the basic elements of control theory
- Understanding the algorithms used in most of the automatic systems (industrial and otherwise).
- Increase interest in the STEM (Science Technology Engineering Maths) disciplines.
- Improve students ability to work in groups.
- Increase the students awareness of their cognitive processes (evaluation of different alternatives )

Exercise

The educational progression designed for a course of 6 meetings (12 hours) is as follows:
Meeting 1- Introduction to robotics, construction of the robot
Meeting 2- First programming tests (engine ignition, ultrasonic sensor use test to avoid obstacles)
Match 3 - Find a black line and stop (Read the values measured by the sensor on black and white)
Meeting 4 - ON-OFF algorithm
Meeting 5 - Proportional algorithm (P controller)
Meeting 6 - Final Challenge

Example solution

Part 1

The first two meeting

In the first meeting it is important:
- Forming work groups;
- Define and share project objectives with students;
- Contextualize the line follower. What is the purpose of this technique? When is it used?
The contextualization serves to make students understand that they will have to try to implement a real algorithm, really used in the engineering field, and not something exclusively educational.
After having built the robot and done the first programming tests “the rectilinear motion” we continue with the didactic progression.

Part 2

Meeting three
You can start right away with a problem. We have a white cloth, and on it a line of black scotch that forms a path. If the robot starts from a random point from the cloth, can we keep it going until it finds the black line?
A challenge of this type makes it possible to understand the functioning of the light sensor present in the kit. The sensor, in fact, positioned a few mm from the floor, detects the level of light reflected within a range from 0 to 100:
0 - No reflection -> sensor pointed on black
100 - Maximum reflection -> sensor focused on white
Example 1.

If we know that the robot is positioned on a white area, and must arrive on the black and stop the algorithm could be of this type:

I turn on the engines
I measure with the sensor and wait for a value <20

#(the initial values will be high -> the robot is on the white)

I turn off the motors
Why don’t you use a value closer to zero to detect black?
Because if you want the robot to stop quite precisely above the black, the “full” line should not be detected, but already when the sensor is partially over the black you can give the command OFF to the motors.

Part 3

The fourth meeting It is the moment when students started “banging their heads” against the main problem. Try to chase the line! Here it is always very interesting to leave time for the students to construct an algorithm hypothesis in total freedom, without influencing their choices and experiments. They will certainly ask for tips and advice. The support from the teacher could come in the form of questions: if we start from the hypothesis that the robot is above the black line, what is the desired value, what the robot would like to measure continuously (with the sensor light) during its operation? The most obvious answer is the value of black, because this would mean that the robot during all its operation would always be perfectly above the black line. From which other ideas can be born. But if the robot is precisely located with the sensor above the line, and at some point the value of reflected light detected by the sensor increases, which way do I bend the robot to correct the position and return to black? Right or left? | My be in some cases the value would increase in the same way in both directions, so it would not be possible to set a resolutive algorithm starting from this idea. We could never know what curve to impose on the robot to correct the position and return to the center of the black line! Need an alternative solution! At this point the students can work looking for a different value to follow, the “pure” black we do not like anymore. | At this stage it is essential to give them time to experiment in search of an alternative and effective solution. | The solution that we propose is to choose as desired value 50% of white and 50% of black (typical ideal situation with white = 100 and black = 0 among which we average obtaining the value 50), with the sensor positioned on the right end of the belt, This solution is called ON-OFF because the robot either turns to the right or left, always with the same curvature parameters.There are no other possibilities!

image1

Repeat indefinitely
I acquire a value from the sensor
If the value read> 50 (average value) the robot is moving towards white (which is on its right)
The robot turns to the left
If the value read <50 (average value) the robot is moving towards the black (which is on its left)
The robot turns to the right
And therefore the average value can not be 50. Students will then have

to measure these two values and then calculate the real average value between the two, before constructing the algorithm. In the scheme as average value is found 38.5 because in real conditions (in which there are variables to take into account as ambient light, the cloth of a not perfect white color), we will never have as values: | - Light reflected on black = 0 | - Light reflected on white = 100

See Appendix 1 Line follower code ON - OF

Part 4

The fifth meeting

You could start with this challenge: Improve the control algorithm! Can the robot avoid (or decrease) this oscillation? You can ask the students what is due, and why the robot behaves in this way (always leaving time to reflect, hypothesize and experiment). The robot oscillates because the ON-OFF algorithm provides only 2 states, independent of the value detected by the sensor: turn right or turn left, always the same amount! But the values found could be infinite, and therefore the corrections to be applied to the robot can become of order “infinite”. The correction i.e., should be proportional to the error that the robot is committing! A further sensor on the left edge can be inserted in the same way as the right sensor. In this case the speed of the two motors can be calibrated in a way directly proportional to the brightness of the two sensors.

image2

If the brightness of the right sensor is reduced, reduce the speed of the right motor proportionally, if the brightness of the left sensor is increased, increase proportionally the speed of the left motor, if the brightness is equal, proceed with the same speed of the two motors. Another way to control the movement of the robot is to introduce a control on the system that assesses the error compared to the optimum trajectory. The error indicated with E is nothing more than the difference between the value acquired by the sensor and the desired value (average between white and black). The correction of the robot (i.e. how much steer should be proportional to this error where Kp represents the coefficient of proportionality and is to be found empirically, it should be found by students. Depends on the speed at which the robot moves, how thick the line of the path, the white tone of the cloth, the light in the room. In short, students will have to “fiddle” a little ‘ to find the right value for this constant, which should be between 0.5 and 3 (in the case of a project of this type). It would be interesting to document the behavior of the robot according to the different Kp assigned. To find the best value it is worth advising students to initially set 1, and then proceed to modify about 0.2 the constant, until you get to the value that convinces them the most.

Insights
At this point we could think with the students about the concept of

feedback and the difference between a robot that moves in a known environment, exploiting known mathematical relationships, and their robot that moves using the sensor information. If I knew the circumference of the robot wheel, and wanted to make it go forward by 2 meters, I could calculate how many wheel revolutions it takes to cover this distance. Same if I had the exact speed and acceleration of the robot: I could take advantage of physical relationships to get the desired behavior

See Appendix 2.

Part 5

The last meeting

For the sixth and final meeting, a challenge has been proposed that the students have solved by reconfiguring the elements seen up to this point. They have been asked to move an object within a security area or warehouse (as if they were to program an industrial robot) in the shortest time possible.

With students of the fifth superior, two other topics could be addressed:

Meeting 7-Proportional derivative algorithm (PD Controller) ( 6 h )

Encounter 8-Integrative derivative proportional algorithm (PID Controller) ( 6 h )

Encounters 7- 8 - Integrative derivative proportional algorithm (PID controller)
That is a further software development also implementing the

derivative and integrative action, so as to obtain one of the most famous control strategies: the PID, in attachment you will find an algorithm of the line follower, its experimentation will be carried out next year when the students will acquire the basic skills in the differential and integral calculus.

See Appendix 3

Summary

Expected results
In this case we can talk about results achieved.
The results are closely related to the objectives previously presented:
- To construct a simple mathematical model with respect to a posed problem (to follow a line).
- Use basic programming elements (sequential, cyclic and instruction-based execution).
- Discover and use the basic elements of control theory (feedback or feedback).
- Understanding the algorithms used in most of the automatic systems (industrial and otherwise).
Regarding these first 4 objectives, we can say that:
- 100% of the students involved managed to solve the “basic” problem, that is, to chase the line, arriving to construct the proportional control algorithm.
- 25% of the students involved managed to solve the final challenge, creatively combining what they had learned during the course.
Regarding the other 3 objectives:
- Increase interest in the STEM (Science Technology Engineering Maths) disciplines.
- Improve students ability to work in groups.
- Increase the students awareness of their cognitive processes
It was decided to create a self-assessment questionnaire, characterized by the following questions:
QUESTIONS CLOSED
Q1- I understood the explanations and instructions given to me by the instructor
Q2- The instructor was available and attentive to my questions and needs
Q3- The method used by the instructor was engaging
Q4- It was easy to build the robots in groups
Q5- It was easy to use the software on the computer
Q6- I have willingly attended the laboratory activities
Q7- The climate in the classroom was clear
Q8- The work in my group has been of collaboration and support
Q9- My relationship with one or more companions has improved
Q10- I found it fun and exciting to participate in this type of alternation School-Work
Q11 - I would like to take part in other more advanced Robotics labs
OPEN QUESTIONS
What did you learn in this lab?
What is the thing that you liked the most about this workshop?
According to you there was something that did not go well?
Is there anything else you wanted to do in the lab?
We proposed a 5-point Likert scale, through which the students were able to express the level of agreement with the proposed questions:
1 = not at all
2 = a little
3 = enough
4 = a lot
5 = very much
Closed questions are organized around the 3 objectives to which they are linked in this way:
- Increase interest in the STEM (Science Technology Engineering Maths) disciplines. Q1, Q2, Q3, Q6, Q10.
- Improve students’ ability to work in groups. Q7, Q8, Q9.
- Increase the students’ awareness of their cognitive processes through the evaluation of the alternation. Q4, Q5, Q11.
The open questions were inserted to let the students express themselves freely, writing impressions, observations and criticisms about their experience.

Appendix 1

Line follower code ON - OF

#!/usr/bin/env python3

function CALIBRATE

print "WHITE?"

#Wait for Touch Sensor to change

white = Read Light Sensor

print "BLACK?"

#Wait for Touch Sensor to change

black = Read Light Sensor

done function

program LINE FOLLOWING

white = 0, black = 0

CALIBRATE()

midpoint = ( white - black ) / 2 + black

repeat

value = Read Light Sensor

if value < midpoint then

  motor B set power 50

  motor C set power 25

else

  motor B set power 25

  motor C set power 50

done if

done repeat

done program

Appendix 2

Line Follower with P controller

program LINE FOLLOWER

#!/usr/bin/env python3

white = 0, black = 0

CALIBRATE()

midpoint = ( white - black ) / 2 + black

kp = 1, ki = 1, kd = 1

lasterror=0

repeat

value = Read Light Sensor

error = midpoint - value

integral = error + integral

derivative = error - lasterror

correction = kp \* error + ki \* integral + kd \* derivative

#Turn B+C Motors by correction

lasterror = error

done repeat

done program

Appendix 3

Line Follower with PID controller

program LINE FOLLOWER

#!/usr/bin/env python3

white = 0, black = 0

CALIBRATE()

midpoint = ( white - black ) / 2 + black

kp = 1, ki = 1, kd = 1

lasterror=0

repeat

value = Read Light Sensor

error = midpoint - value

integral = error + integral

derivative = error - lasterror

correction = kp \* error + ki \* integral + kd \* derivative

#Turn B+C Motors by correction

lasterror = error

done repeat

done program
Next Section - Stirling motors