Inertial#
介绍#
VEX IQ(第二代)大脑内置一个用于测量旋转运动的三轴陀螺仪和一个用于检测运动变化的三轴加速度计。这些传感器使机器人能够追踪其方向、航向和加速度。
For the examples below, the configured Inertial Sensors will be named BrainInertial
, and will be used in all subsequent examples throughout this API documentation when referring to Inertial class methods.
以下是所有可用方法的列表:
方向——测量惯性传感器的旋转运动。
heading – 返回当前标题。
rotation – 返回累积旋转角度。
setHeading – Sets the Inertial Sensor’s heading to a specified value.
setRotation – Sets the Inertial Sensor’s rotation value.
calibrate – 校准惯性传感器以实现稳定的航向跟踪。
isCalibrating – Returns whether or not the Inertial Sensor is calibrating.
resetHeading – Sets the heading of the Inertial Sensor to 0.
resetRotation – Sets the rotation of the Inertial Sensor to 0.
运动——检测运动的变化。
加速度 – 返回沿 x、y 或 z 轴的线性加速度。
gyroRate – Returns the angular velocity around the x, y, or z axis.
orientation – 根据倾斜和旋转返回滚动、俯仰或偏航。
已更改 – 注册一个函数,当惯性传感器检测到变化时调用。
构造函数——手动初始化和配置惯性传感器。
inertial – Creates an Inertial Sensor.
方向#
标题#
heading
returns the current heading of the Inertial Sensor.
Usage:
BrainInertial.heading(units)
参数 |
描述 |
---|---|
|
Optional. The units that represent the heading:
|
// Example coming soon
旋转#
rotation
returns the current rotation of the Inertial Sensor.
Usage:
BrainInertial.rotation(units)
参数 |
描述 |
---|---|
|
Optional. The units that represent the rotation:
|
// Example coming soon
设置标题#
setHeading
将惯性传感器的航向设置为特定值。
Usage:
BrainInertial.setHeading(value, units);
参数 |
描述 |
---|---|
|
要设置的航向值。 |
|
表示新航向的单位:
|
// Example coming soon
设置旋转#
setRotation
将惯性传感器的旋转设置为特定值。
Usage:
BrainInertial.setRotation(value, units);
参数 |
描述 |
---|---|
|
要设置的旋转值。 |
|
表示新旋转的单位:
|
// Example coming soon
校准#
“calibrate” 用于校准惯性传感器。所有后续代码行都将等待校准完成后再执行。校准是一个内部过程,用于测量并补偿指定时间段内的传感器噪声和漂移。在此期间,Brain 必须保持完全静止(即,在稳定的表面上,没有任何外部运动)。校准期间的移动会导致结果不准确。
VEX 机器人会在每次项目开始时尝试自动校准。但是,如果在项目启动期间搬运或移动机器人,传感器可能无法正确校准或产生错误的校准结果。
Usage:
BrainInertial.calibrate();
范围 |
描述 |
---|---|
该方法没有参数。 |
// Example coming soon
正在校准#
isCalibrating
检查惯性传感器当前是否正在校准。
1
-惯性传感器正在校准。0
——惯性传感器未校准。
用法:
isCalibrating()
范围 |
描述 |
---|---|
该方法没有参数。 |
// Example coming soon
重置标题#
resetHeading
将惯性传感器的航向重置为 0。
Usage:
BrainInertial.resetHeading();
参数 |
描述 |
---|---|
该方法没有参数。 |
// Example coming soon
重置旋转#
resetRotation
将惯性传感器的旋转重置为 0。
Usage:
BrainInertial.resetRotation();
参数 |
描述 |
---|---|
该方法没有参数。 |
// Example coming soon
运动#
加速度#
acceleration
returns the acceleration of the Inertial Sensor in terms of G (gravity).
Usage:
BrainInertial.acceleration(axis);
参数 |
描述 |
---|---|
|
返回加速度的轴:
|
// Example coming soon
陀螺仪速率#
gyroRate
返回惯性传感器一个轴的陀螺仪速率。
Usage:
BrainInertial.gyroRate(axis, units);
参数 |
描述 |
---|---|
|
返回陀螺仪速率的轴:
|
|
The unit used to represent the gyro rate:
|
// Example coming soon
方向#
orientation
返回惯性传感器一个轴的方向。
Usage:
BrainInertial.orientation(type, units);
参数 |
描述 |
---|---|
|
返回方向的轴:
|
|
用于表示方向的单位:
|
// Example coming soon
改变#
当惯性传感器的航向发生变化时,changed
注册一个回调函数。
Usage:
BrainInertial.changed(callback);
参数 |
描述 |
---|---|
|
当惯性传感器航向改变时调用的回调函数。 |
// Example coming soon
构造函数#
惯性#
inertial
创建一个惯性传感器。
Usage:
inertial BrainInertial = inertial();
范围 |
描述 |
---|---|
该方法没有参数。 |
// Example coming soon