Inertial#
Introduction#
The VEX IQ (2nd gen) Brain includes a built-in 3-axis gyroscope for measuring rotational movement and a 3-axis accelerometer for detecting changes in motion. These sensors allow the robot to track its orientation, heading, and acceleration.
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.
Below is a list of all available methods:
Orientation - Measure rotational movement from the Inertial Sensor.
heading – Returns the current heading.
rotation – Returns the cumulative rotation.
setHeading – Sets the Inertial Sensor’s heading to a specified value.
setRotation – Sets the Inertial Sensor’s rotation value.
calibrate – Calibrates the Inertial Sensor for stable heading tracking.
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.
Motion – Detect changes in motion.
acceleration – Returns the linear acceleration along the x, y, or z axis.
gyroRate – Returns the angular velocity around the x, y, or z axis.
orientation – Returns the roll, pitch, or yaw based on tilt and rotation.
changed – Registers a function to call when the Inertial Sensor detects change.
Constructors – Manually initialize and configure an Inertial Sensor.
inertial – Creates an Inertial Sensor.
Orientation#
heading#
heading
returns the current heading of the Inertial Sensor.
Usage:
BrainInertial.heading(units)
Parameters |
Description |
---|---|
|
Optional. The units that represent the heading:
|
// Example coming soon
rotation#
rotation
returns the current rotation of the Inertial Sensor.
Usage:
BrainInertial.rotation(units)
Parameters |
Description |
---|---|
|
Optional. The units that represent the rotation:
|
// Example coming soon
setHeading#
setHeading
sets the heading of the Inertial Sensor to a specific value.
Usage:
BrainInertial.setHeading(value, units);
Parameters |
Description |
---|---|
|
The heading value to set. |
|
The unit that represents the new heading:
|
// Example coming soon
setRotation#
setRotation
sets the rotation of the Inertial Sensor to a specific value.
Usage:
BrainInertial.setRotation(value, units);
Parameters |
Description |
---|---|
|
The rotation value to set. |
|
The unit that represents the new rotation:
|
// Example coming soon
calibrate#
calibrate
calibrates the Inertial Sensor. All subsequent lines 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 Brain must remain completely still (i.e., on a stable surface without any external movement). Movement during calibration will produce inaccurate results.
VEX brains attempt to calibrate themselves automatically at the start of every project. However, if the robot is being carried or moved during project start, the sensor may fail to calibrate properly or yield incorrect calibration.
Usage:
BrainInertial.calibrate();
Parameter |
Description |
---|---|
This method has no parameters. |
// Example coming soon
isCalibrating#
isCalibrating
checks if the Inertial Sensor is currently calibrating.
1
- The Inertial Sensor is calibrating.0
- The Inertial Sensor is not calibrating.
Usage:
isCalibrating()
Parameter |
Description |
---|---|
This method has no parameters. |
// Example coming soon
resetHeading#
resetHeading
resets the heading of the Inertial Sensor to 0.
Usage:
BrainInertial.resetHeading();
Parameters |
Description |
---|---|
This method has no parameters. |
// Example coming soon
resetRotation#
resetRotation
resets the rotation of the Inertial Sensor to 0.
Usage:
BrainInertial.resetRotation();
Parameters |
Description |
---|---|
This method has no parameters. |
// Example coming soon
Motion#
acceleration#
acceleration
returns the acceleration of the Inertial Sensor in terms of G (gravity).
Usage:
BrainInertial.acceleration(axis);
Parameters |
Description |
---|---|
|
The axis to return the acceleration from:
|
// Example coming soon
gyroRate#
gyroRate
returns the gyro rate for one axis of the Inertial Sensor.
Usage:
BrainInertial.gyroRate(axis, units);
Parameters |
Description |
---|---|
|
The axis to return the gyro rate from:
|
|
The unit used to represent the gyro rate:
|
// Example coming soon
orientation#
orientation
returns the orientation for one axis of the Inertial Sensor.
Usage:
BrainInertial.orientation(type, units);
Parameters |
Description |
---|---|
|
The axis to return the orientation from:
|
|
The unit used to represent the orientation:
|
// Example coming soon
changed#
changed
registers a callback function for when the Inertial Sensor’s heading changes.
Usage:
BrainInertial.changed(callback);
Parameters |
Description |
---|---|
|
The callback function to be called when the Inertial Sensor heading changes. |
// Example coming soon
Constructors#
inertial#
inertial
creates an Inertial Sensor.
Usage:
inertial BrainInertial = inertial();
Parameter |
Description |
---|---|
This method has no parameters. |
// Example coming soon