Proportional coding: Difference between revisions
(→Theory) |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 15: | Line 15: | ||
The line follower uses color sensor and the gyroscope code uses gyroscope to drive straight. | The line follower uses color sensor and the gyroscope code uses gyroscope to drive straight. | ||
== Example | == Example Videos == | ||
We use proportionality in two examples, following a line and driving according to a given angle. | We use proportionality in two examples, following a line and driving according to a given angle. | ||
Line 31: | Line 31: | ||
<gallery> | <gallery> | ||
LinefollowerProp.png|The red and green lines do not pass origin, but show proportional relation. | LinefollowerProp.png|The red and green lines do not pass origin, but show proportional relation. | ||
Proportional.png|The | Proportional.png|The line following robot uses proportionality. | ||
GyroAngle.png|The proportionality is very important while driving to a given angle with the gyroscope. | GyroAngle.png|The proportionality is very important while driving to a given angle with the gyroscope. | ||
</gallery> | </gallery> | ||
== Exercises == | |||
Line follower: | |||
* Use the other side of the line to follow the line | |||
* Make the robot to change the side of the line during the line following: Thus, after following the line e.g. 2 wheel rotations, use the other side of the line | |||
* Make a robot with two color sensors, and use the information from the other sensor to stop the robot when the other sensor recognizes black line. | |||
* Make a robot with two color sensors, and make the robot to follow a line that is in between the two sensors. | |||
* Make a robot with two color sensors, and make the robot to follow first the line with left sensor, then after two wheel rotations use the other sensor to follow the line to the end. | |||
Gyroscope: | |||
* Make the robot to always turn the shorter distance. | |||
* Make the robot to always turn the longer distance. | |||
* Use the Modulo operator to fix the number of turns the robot makes during the drive. | |||
* Make a MyBlock that drives, and turns the robot as LEGOs steering block, but while using the gyro sensor. | |||
Back to [[Mahtavaa Matematiikkaa 2020]] | Back to [[Mahtavaa Matematiikkaa 2020]] | ||
[[File:Mahtavaa matematiikkaa.png|thumb]] | [[File:Mahtavaa matematiikkaa.png|thumb]] |
Latest revision as of 20:39, 16 October 2020
Introduction
Very often proportionality is used in robotics programming. Proportionality is an important topic on mathematics curriculum. The proportionality means a straight line (with slope, or gradient, ) passing through the origin. In robotics, the slope is first translated to pass the origin.
Aim
Slope, straight line. Multiplication.
Robot
Almost any robot will do, we use here Asimov 2/ Verne robot.
Sensors
The line follower uses color sensor and the gyroscope code uses gyroscope to drive straight.
Example Videos
We use proportionality in two examples, following a line and driving according to a given angle.
Theory
The line follower follows the line, or actually the border of the line. If the light sensor reads too small values (dark), the robot will turn to other side. If the values are higher (lighter), the robot turns to other side. The proportionality constant determines how fast the robot will steer.
Exactly the same approach is used in the gyroscope example. If the robot's direction angle differs from the decided direction, it will steer. The proportionality constant defines how fast the robot will steer.
-
The red and green lines do not pass origin, but show proportional relation.
-
The line following robot uses proportionality.
-
The proportionality is very important while driving to a given angle with the gyroscope.
Exercises
Line follower:
- Use the other side of the line to follow the line
- Make the robot to change the side of the line during the line following: Thus, after following the line e.g. 2 wheel rotations, use the other side of the line
- Make a robot with two color sensors, and use the information from the other sensor to stop the robot when the other sensor recognizes black line.
- Make a robot with two color sensors, and make the robot to follow a line that is in between the two sensors.
- Make a robot with two color sensors, and make the robot to follow first the line with left sensor, then after two wheel rotations use the other sensor to follow the line to the end.
Gyroscope:
- Make the robot to always turn the shorter distance.
- Make the robot to always turn the longer distance.
- Use the Modulo operator to fix the number of turns the robot makes during the drive.
- Make a MyBlock that drives, and turns the robot as LEGOs steering block, but while using the gyro sensor.
Back to Mahtavaa Matematiikkaa 2020