Book Image

Learning Lego Mindstorms EV3

By : Gary Garber
Book Image

Learning Lego Mindstorms EV3

By: Gary Garber

Overview of this book

Table of Contents (19 chapters)
Learning LEGO MINDSTORMS EV3
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
10
Other Programming Languages
Index

The GG My Block


The GG My Block gets Gyro Sensor feedback and calculates values to store to the Gyro rate and angular position variables. The variable block gSpd stores the current rate of rotation of the Gyro Sensor after accounting for the offset bias. The calculation is not quite as simple as subtracting the bias as we can see from the detailed equation inside the Block Text Field of the Advanced Math block. A new Gyro offset is actually calculated from 99.95 percent of the old gOS variable block and 0.05 percent of the current Gyro rate. This is to account for increased bias over time. It is this new Gyro offset that is subtracted from the current Gyro Sensor block value to return the value for the gSpd variable block.

As opposed to measuring the angle value of the Gyro Sensor directly, the value of the gAng variable block is calculated by integrating the value of the Gyro rate. The value of the gSpd variable block is multiplied by the unit of time over which it is integrated, is equivalent...