Gyro#
Introduction#
The Gyro Sensor measures the heading and the rotation of the robot.
The Gyro Sensor category will only appear when the sensor is configured independently, not as part of a drivetrain configuration, in the Devices window.
This page uses gyro_sensor as the example Gyro Sensor name. Replace it with your own configured name as needed.
Below is a list of available methods:
calibrate– Calibrates the configured Gyro Sensor.set_heading– Sets the Gyro Sensor’s current heading to a specified value.set_rotation– Sets the Gyro Sensor’s current cumulative rotation value.heading– Returns the Gyro Sensor’s heading angle as a float.rotation– Returns how much the Gyro Sensor has rotated since the project started as a float.
Constructor – Manually initialize a Gyro Sensor.
Gyro– Create a Gyro Sensor.
calibrate#
calibrate calibrates the Gyro Sensor. All subsequent methods will wait for the calibration to complete before executing. Calibration is an internal procedure that measures and compensates for sensor noise and drift over a specified period. During this time, the sensor must remain completely still (i.e., on a stable surface without any external movement). Movement during calibration will produce inaccurate results.
Usage:
gyro_sensor.calibrate()
Parameters |
Description |
|---|---|
This method has no parameters. |
set_heading#
set_heading sets the Gyro Sensor’s current heading to a specified value.
Usage:
gyro_sensor.set_heading(value, units)
Parameters |
Description |
|---|---|
value |
The heading value to assign. |
units |
Optional. The units to represent the heading:
|
set_rotation#
set_rotation sets the Gyro Sensor’s current cumulative rotation value.
Usage:
gyro_sensor.set_rotation(value, units)
Parameters |
Description |
|---|---|
value |
The cumulative rotation value to assign. |
units |
Optional. The units to represent the rotation:
|
heading#
heading returns the Gyro Sensor heading angle as a float from 0 to 359.99 degrees.
Usage:
gyro_sensor.heading(units)
Parameters |
Description |
|---|---|
units |
Optional. The units to represent the heading:
|
rotation#
rotation returns how much the Gyro Sensor has rotated since the project started as a float in degrees: positive for clockwise, negative for counterclockwise.
Usage:
gyro_sensor.rotation(units)
Parameters |
Description |
|---|---|
units |
Optional. The units to represent the rotation:
|
Constructor#
Constructors are used to manually create Gyro objects, which are necessary for configuring a Gyro Sensor outside of VEXcode.
Gyro#
Gyro creates a Gyro Sensor.
Usage:
Gyro(port)
Parameter |
Description |
|---|---|
|
The 3-Wire Port that the Gyro Sensor is connected to:
|
# Create a Gyro Sensor in Port A
gyro_sensor = Gyro(brain.three_wire_port.a)