STEM Robotics 4 All

STEM Resources for all

Lesson 4: Going Straight with Gyro (LabView)

The RoboMentors will introduce you to the use of EV3 Gyro sensor to maintain a straight trajectory.

What You’ll Learn:

  • Calibrate the Gyro sensor
  • Apply proportional control to the Gyro sensor

Keep the Gyro Sensor and EV3 Brick steady when connecting the cable and during start-up of the EV3 Brick.

What you might want to review how to use :

  • The Gyro sensor block
  • The basic motion blocks to write a LabView program

A series of of videos from the Carnegie-Mellon curriculum can provide a useful review of how to use the Gyro sensor. Check them here.

Proportional Control: Drive straight

The gyro sensor returns a value indicating the number of degrees positive (anticlockwise) or negative (clockwise) the robot deviated from its initial heading. As long as the robot continues to go straight, the heading will be zero.

We can use to uses the gyro to keep the robot on course by modifying the turn parameter of the Drive method. 

The error gain between the desired heading and target one is multiplied by a proportional scaling constant (Kp) to scale it for the speed of the robot drive. This factor is called the proportional constant or loop gain. Increasing Kp will cause the robot to correct more quickly (but too high and it will oscillate). Decreasing the value will cause the robot correct more slowly (possibly never reaching the desired heading). This is known as proportional control.

  • In a loop do
    • read the gyro sensor value
    • compute the error
    • apply the driving correction
  • until you reach a color threshold close to a black line.

Now let’s see how it behaves on the FLL RePlay mat. As you can see how the robot can be made to stop in front of each mission.

Thanks for reading this article! Please like it and subscribe to our mailchimp newsletter to know when new articles are available!

© The Robo Mentors (Marc and Anne-Sarah)

Leave a Reply

%d bloggers like this: