To make Gyro Sensor blocks appear in VEXcode V5, a 3-Wire Gyro Sensor must be configured in the Devices window.
For more information, refer to these articles:
Gyro Sensing#
Gyro Calibrate#
The Gyro Calibrate block is used to calibrate the Gyro/GPS/Inertial Sensor to reduce the amount of drift. It is recommended that this block is used at the start of the project.
calibrate [GyroH v]
The Brain must remain still for calibration process to succeed, which takes approximately 2 seconds.
Choose which Gyro/GPS/Inertial Sensor to use.
In this example, the Brain’s Inertial Sensor will calibrate for 2 seconds before printing the current orientation of the Inertial Sensor.
when started :: hat events
calibrate [BrainInertial v]
wait (2) seconds
print ([BrainInertial v] orientation of [roll v]) on [Brain v] ◀ and set cursor to next row
Set Heading#
The Set Heading block is used to set the Gyro/GPS/Inertial sensor’s current heading position to a set value.
set [GyroA v] heading to (0) degrees
The Set Heading block accepts a range of 0.0 to 359.99 degrees.
Choose which Gyro/GPS/Inertial Sensor to use.
In this example, the Brain’s Inertial sensor will print its starting heading, set its heading to 90 degrees, and then print the new heading.
when started :: hat events
print ([BrainInertial v] heading in degrees) on [Brain v] ◀ and set cursor to next row
set [BrainInertial v] heading to (90) degrees
print ([BrainInertial v] heading in degrees) on [Brain v] ◀ and set cursor to next row
Set Rotation#
The Set Rotation block is used to set the Gyro/GPS/Inertial sensor’s current rotation position to a set value.
set [Inertial1 v] rotation to (0) degrees
The Set Rotation block accepts any positive or negative decimal or integer number.
Choose which Gyro/GPS/Inertial Sensor to use.
In this example, the Brain’s Inertial sensor will print its starting rotation, set its rotation to -100 degrees, and then print the new rotation.
when started :: hat events
print ([BrainInertial v] rotation in degrees) on [Brain v] ◀ and set cursor to next row
set [BrainInertial v] rotation to (-100) degrees
print ([BrainInertial v] rotation in degrees) on [Brain v] ◀ and set cursor to next row
Angle of Heading#
The Angle of Heading block is used to report the 3-Wire Gyro Sensor or V5 Inertial Sensor’s current heading in degrees.
([BrainInertial v] heading in degrees)
The Angle of Heading block reports a range from 0.0 to 359.99 degrees.
Choose which Gyro/Inertial Sensor to use.
In this example, the Brain’s Inertial sensor will print its starting heading, set its heading to 90 degrees, and then print the new heading.
when started :: hat events
print ([BrainInertial v] heading in degrees) on [Brain v] ◀ and set cursor to next row
set [BrainInertial v] rotation to (90) degrees
print ([BrainInertial v] heading in degrees) on [Brain v] ◀ and set cursor to next row
Angle of Rotation#
The Angle of Rotation block is used to report the 3-Wire Gyro Sensor or V5 Inertial Sensor’s current rotation in degrees.
([BrainInertial v] rotation in degrees)
A clockwise direction is reported as a positive value, and a counterclockwise value is reported as a negative value.
Choose which Gyro/Inertial Sensor to use.
In this example, the Brain’s Inertial sensor will print its starting rotation, set its rotation to -100 degrees, and then print the new heading.
when started :: hat events
print ([BrainInertial v] rotation in degrees) on [Brain v] ◀ and set cursor to next row
set [BrainInertial v] rotation to (-100) degrees
print ([BrainInertial v] rotation in degrees) on [Brain v] ◀ and set cursor to next row