Sensor giroscópico#

Introducción#

El sensor giroscópico mide la dirección y la rotación del robot.

La categoría Sensor giroscópico solo aparecerá cuando el sensor esté configurado de forma independiente, y no como parte de una configuración de transmisión, en la ventana Dispositivos.

This page uses gyro_sensor as the example Gyro Sensor name. Replace it with your own configured name as needed.

A continuación se muestra una lista de los métodos disponibles:

  • calibrate – Calibrates the configured Gyro Sensor.

  • set_heading – Changes the Gyro Sensor’s current heading to a new heading.

  • set_rotation – Changes the Gyro Sensor’s current rotation to a new rotation.

  • 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: Inicializa manualmente un sensor giroscópico.

  • Gyro – Create a Gyro Sensor.

calibrar#

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()

Parámetros

Descripción

Este método no tiene parámetros.

establecer_encabezado#

A heading is the direction the sensor is facing, measured in degrees. set_heading changes the Gyro Sensor’s current heading to a new heading value.

For example, if the sensor has turned to face right, setting the heading to 0 degrees makes that right-facing position the new 0 degrees. Then the sensor can track other headings based on that new heading.

Usage:
gyro_sensor.set_heading(value, units)

Parámetros

Descripción

valor

The heading value, in degrees, to set for the sensor. This can be a value from 0 to 359.99.

unidades

Optional. The heading unit: DEGREES

establecer_rotación#

Rotation is how much the sensor has turned, measured in degrees. At the beginning of a project, the rotation value is set to 0 degrees. set_rotation changes the Gyro Sensor’s current rotation to a new value.

For example, if the sensor has made two full turns to the right, its rotation value will be 720 degrees. Setting the rotation to 0 degrees will reset that rotation from 720 to 0 degrees. Then the sensor can track rotations based on that new value.

Usage:
gyro_sensor.set_rotation(value, units)

Parámetros

Descripción

valor

The rotation value, in degrees, to set for the sensor. This can be an integer or a decimal (float).

unidades

Optional. The rotation unit: DEGREES

título#

A heading is the direction the sensor is facing, measured in degrees. heading returns that heading as a float from 0 to 359.99 degrees.

The starting heading is 0 degrees.

Usage:
gyro_sensor.heading(units)

Parámetros

Descripción

unidades

Optional. The heading unit: DEGREES

rotación#

Rotation is how much the sensor has turned, measured in degrees. At the beginning of a project, the rotation value is set to 0 degrees. rotation returns the Gyro Sensor’s current rotation.

Turning right increases the rotation, and turning left decreases the rotation. For example, making two full turns to the right will return a rotation of 720 degrees.

Usage:
gyro_sensor.rotation(units)

Parámetros

Descripción

unidades

Optional. The rotation unit: DEGREES

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)

Parámetro

Descripción

port

The 3-Wire Port that the Gyro Sensor is connected to:

  • On the EXP Brainbrain.three_wire_port.x where x is the number of the port.
  • On a 3-Wire Expanderexpander.a where expander is the name of the expander instance.

# Create a Gyro Sensor in Port A
gyro_sensor = Gyro(brain.three_wire_port.a)