陀螺仪#
介绍#
陀螺仪传感器测量机器人的航向和旋转。
在“设备”窗口中,只有当陀螺仪传感器作为独立组件配置,而不是作为传动系统配置的一部分时,“陀螺仪传感器”类别才会出现。
This page uses gyro_sensor as the example Gyro Sensor name. Replace it with your own configured name as needed.
以下是可用方法列表:
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.
构造函数 - 手动初始化陀螺仪传感器。
Gyro– Create a Gyro Sensor.
校准#
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()
参数 |
描述 |
|---|---|
此方法没有参数。 |
设置标题#
set_heading sets the Gyro Sensor’s current heading to a specified value.
Usage:
gyro_sensor.set_heading(value, units)
参数 |
描述 |
|---|---|
价值 |
要分配的标题值。 |
单位 |
Optional. The units to represent the heading:
|
设置旋转#
set_rotation sets the Gyro Sensor’s current cumulative rotation value.
Usage:
gyro_sensor.set_rotation(value, units)
参数 |
描述 |
|---|---|
价值 |
要分配的累积旋转值。 |
单位 |
Optional. The units to represent the rotation:
|
标题#
heading returns the Gyro Sensor heading angle as a float from 0 to 359.99 degrees.
Usage:
gyro_sensor.heading(units)
参数 |
描述 |
|---|---|
单位 |
Optional. The units to represent the heading:
|
旋转#
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)
参数 |
描述 |
|---|---|
单位 |
Optional. The units to represent the rotation:
|
构造函数#
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)
范围 |
描述 |
|---|---|
|
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)