Proportional coding

From wikiluntti
Revision as of 20:37, 16 October 2020 by Mol (talk | contribs) (→‎Exercises)

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 Video

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.


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