Gyro sensor and geometric figures

Prerequisite

What students should know before

  • supplementary angles

  • regular polygon

  • diagonal

Time constraints:

  • starting from 45 min - single lesson

Preparing For This Tutorial:

  • The LEGO Mindstorm EV3 Robot that coincides with this tutorial comes from building specific sections found in the LEGO Mindstorm Education Core Set building instructions. You will need to build the main body for the robot (I’ll refer to use the Driving Base), plus a gyro sensor.

Effects

Mathematics - After these lessons you are able to generalize known information about the sum of the angles measured in an equilateral triangle, a square, a pentagon, and any regular n - angle. During this lesson you could observe the concept of the limit and see at least one application of conception: supplementary angles, regular polygons.

Computer science - This lesson will tell you how to create the program using a gyro sensor.

Exercise

Create a program that will make the robot run around the circumference of: an equilateral triangle, a square,a pentagon and other polygons.

Example solution

Part 1

Mathematics

In a square sign the vertices, select the internal angles and the supplementary angles and determine their measures.

Computer science

Step 1:

Check out this text to configure the gyro sensor and two servomotors.

Programme

# Import of necessary libraries

Step 2:

Create a program to make the robot move straight and then turn 90 degrees.

Programme

Run to a position relative to the current position value. The new position will be current #position + position_sp. When the new position is reached, the motor will stop using the #action specified by stop_action i.e. one rotation of wheels.

#!/usr/bin/env python3

b.run_to_rel_pos(position_sp=360,speed_sp=200,stop_action=”brake”)

c.run_to_rel_pos(position_sp=360,speed_sp=200,stop_action=”brake”)

#read the value from gyro sensor

start_angle=gy.value()

angle=0

#do the loop while condition is true

#i.e. turn the left or right (it is depend you have got b or c)

while angle-start_angle<90:

  angle=gy.value()

  #you are able to see the results on the screen

  print(str(angle)+” ”+units)

  b.runforever(speed_sp=90)

  #c.runforever(speed_sp=90)

  #the robot stop

  b.stop(stop_action=”brake”)

  #c.stop(stop_action=”brake”)

Step 3.

Create a program to make the robot plot a square.

Programme

#!/usr/bin/env python3

#set new variable to compute how many sides your robot made

counter=0

while counter<4:

  b.run_to_rel_pos(position_sp=360, speed_sp=200, stop_action="brake")

  c.run_to_rel_pos(position_sp=360, speed_sp=200, stop_action="brake")

  start_angle = gy.value()

  angle=0

while angle-start_angle<90:

  angle=gy.value()

  print(str(angle) + " " + units)

  b.run_forever(speed_sp=90)

  # c.run_forever(speed_sp=90)

  b.stop(stop_action="brake")

  #c.stop(stop_sction="brake")

  start_angle=gy.value()

  #sound information when the robot finishes rotation and starts next side.

  Sound.beep()

sleep(5)

counter=counter+1

Summary

We have just learned how to configure a motor and gyro sensor. We are able to read the value from the gyro sensor and use it to compute the angle of the robot’s rotation.

Part 2

Mathematics

In a triangle sign the vertices, select the internal angles and the supplementary angles and determine their measures.

Computer science

Step 1.

Modify a program to make the robot plot an equilateral triangle.

Programme

#!/usr/bin/env python3
counter=0
while counter<3:
b.run_to_rel_pos(position_sp=360, speed_sp=200, stop_action="brake")
c.run_to_rel_pos(position_sp=360, speed_sp=200, stop_action="brake")
start_angle = gy.value()
angle=0
while angle-start_angle<120:
  angle=gy.value()
  print(str(angle) + " " + units)
  b.run_forever(speed_sp=90)
  # c.run_forever(speed_sp=90)
  b.stop(stop_action="brake")
  #c.stop(stop_sction="brake")
  start_angle=gy.value()

  # sound information when robot finished rotation and starts next line
  segment
  Sound.beep()
  sleep(5)
  counter=counter+1

Summary

We have just created the program which makes the robot able to ,,plot” an equilateral triangle.

Part 3

Mathematics

We would like to generalize the formula for the sum of angles in the regular n - gons. Let’s start with a pentagon and let’s draw diagonals in it.

image0

We can easily determine the sum of angles in a pentagon. (180 · 3 = 540).

Then we can count the measure of one angle \(\left( \frac{540}{5} = 108{^\circ} \right)\)and the measure of supplementary angle to it (72°). We see that the measure of supplementary angle in an arbitrary regular n-gons is \(180 - \frac{180 \cdot (n - 2)}{n}\).

Computer science

Step 1.

Modify a program to make the robot plot pentagons.

Program

#!/usr/bin/env python3

counter=0
while counter<5:
b.run_to_rel_pos(position_sp=360, speed_sp=200, stop_action="brake")
c.run_to_rel_pos(position_sp=360, speed_sp=200, stop_action="brake")
start_angle = gy.value()
angle=0
while angle-start_angle<72:
  angle=gy.value()
  print(str(angle) + " " + units)
  b.run_forever(speed_sp=90)
  # c.run_forever(speed_sp=90)
  b.stop(stop_action="brake")
  #c.stop(stop_sction="brake")
  start_angle=gy.value()

  #sound information when robot finished rotation and starts next line #segment
  Sound.beep()
  sleep(5)
  counter=counter+1

Summary

We presented the method of generalizing known properties, i.e. we determined the formula for the sum of angles in the n angle. We have just created the program which makes that the robot is able to ,,plot” a pentagon and n - gone.

Part 4

Before this part students should know the limit concepts.

Mathematics

We can offer pupils, as an extension of the course, observing the concept of the limit.

Compute with your students the value of limit the following sequence \(a_{n} = 180 - \ \frac{180 \cdot (n - 2)}{n}\).

A sequence of regular polygons with an increasing number of sides approximates a circumcircle.

Computer science

Step 1.

Modify a program to make the robot plot any regular polygon (for example 100-angle).

Program

#!/usr/bin/env python3
counter=0
while counter<100:
b.run_to_rel_pos(position_sp=360, speed_sp=200, stop_action="brake")
c.run_to_rel_pos(position_sp=360, speed_sp=200, stop_action="brake")
start_angle = gy.value()
angle=0
while angle-start_angle<3.6:
  angle=gy.value()
  print(str(angle) + " " + units)
  b.run_forever(speed_sp=90)
  # c.run_forever(speed_sp=90)
  b.stop(stop_action="brake")
  #c.stop(stop_sction="brake")
  start_angle=gy.value()

  # sound information when robot finished rotation and starts next line
  #segment
  Sound.beep()
  sleep(5)
  counter=counter+1

Hint: Try to modify the length of the line segment i.e. put the value position_sp=360 less than 360.

Summary

We have presented the method allowing the students to observe the concept of the limit.

Next Section - Museum at night