Understanding Inertial Sensor Data from the VEX IQ (2nd gen) Brain

The VEX IQ (2nd generation) Brain has an Inertial Sensor built in. The Inertial Sensor reports data about heading, rotation, orientation, and acceleration in the sensor dashboard and in VEXcode IQ. This article will review what data is presented on the sensor dashboard.

For more information about accessing the sensor dashboard, see this article. 

Brain screen is shown with the Inertial Sensor Dashboard opened from the Devices menu. The following Inertial Sensor information is shown: Heading, Rotation, Roll, Pitch, Yaw, Calibration, Acceleration on the x, y, and z axes, and Rate of rotation on the x, y, and z axes.


Heading

Top down diagram of the Brain with a circle and degree units marked around it, indicating that the heading of the Brain can range from 0 to 359.99 degrees.

Heading is the direction the Brain is facing and is reported compass-style using degrees from 0-359.99.  The 0 point can be set using commands in VEXcode IQ or by calibrating the VEX IQ (2nd generation) Brain. This information also can be used to turn your robot to face a specific location when using a Drivetrain.

Brain screen is shown with the Inertial Sensor Dashboard opened and with the Heading value highlighted.

In the sensor dashboard on the Brain's screen, heading is the first value listed. If you move the Brain while on this screen, you will see the values update in real time.

Brain is shown with the Inertial Sensor Dashboard opened and its Check button highlighted.

This is set to 0 degrees when the Brain is turned on and the Inertial Sensor calibrates. If you want to reset the heading of your Brain, select the check button on the Brain. This will reset the heading and rotation to 0 degrees, and all data on the Inertial Sensor sensor dashboard will be based on this new starting location.

VEXcode IQ Blocks VEXcode IQ Python
VEXcode IQ Turn to heading block that reads Turn to heading 90 degrees.
drivetrain.turn_to_heading(90, DEGREES)
VEXcode IQ C++
int main()
{
Drivetrain.turnToHeading(90, degrees);
}

In VEXcode IQ, the [Turn to heading] block, turn_to_heading Python command, and turnToHeading C++ command can be used to turn the robot to a specific heading.

VEXcode IQ Blocks VEXcode IQ Python
VEXcode IQ Set drive heading block that reads Set drive heading to 0 degrees.
drivetrain.set_heading(0, DEGREES)
VEXcode IQ C++
int main()
{
Drivetrain.setHeading(0, degrees);
}

Similar to the calibrate option in the sensor dashboard, the heading can be set while the project is being run using the [Set drive heading] block, set_heading Python command, or setHeading C++ command.


Rotation

Brain screen is shown with the Inertial Sensor Dashboard opened and with the Rotation value highlighted. The Rotation value reads negative 90.13.

Rotation is reported when the robot spins around the center axis of the Brain. The amount of degrees reported on the sensor dashboard indicates the direction of the turn and the degree value of the turns the Brain has completed since calibration. Unlike heading, the numeric values are not limited to the 0-359.99 degrees. The robot can rotate counter-clockwise for a negative value or clockwise for a positive value and will continue to increase the degree value to match the number of rotations the Inertial Sensor within the Brain reports. 

Brain screen is shown with the Inertial Sensor Dashboard opened and with the Rotation value highlighted. The Rotation value reads 0.47.

In the sensor dashboard on the Brain's screen, rotation is the second value listed. If you rotate the Brain while on this screen, you will see the values update in real time. 

Brain is shown with the Inertial Sensor Dashboard opened and its Check button highlighted.

This is set to 0 degrees when the Brain is turned on and the Inertial Sensor calibrates. If you want to reset the rotation of your robot, select the check button on the Brain. This will reset the heading and rotation to 0 degrees, and all data on the Inertial Sensor sensor dashboard will be based on this new starting location.

VEXcode IQ Blocks VEXcode IQ Python
VEXcode IQ Turn to rotation block that reads Turn to rotation 90 degrees.
drivetrain.turn_to_rotation(90, DEGREES)
VEXcode IQ C++
int main()
{
Drivetrain.turnToRotation(90, degrees);
}

In VEXcode IQ, the [Turn to rotation] block, turn_to_rotation Python command, and turnToRotation C++ command can be used to turn the robot for a specific number of degrees.

VEXcode IQ Blocks VEXcode IQ Python
VEXcode IQ Set drive rotation block that reads Set drive rotation to 0 degrees.
drivetrain.set_rotation(0, DEGREES)
VEXcode IQ C++
int main()
{
Drivetrain.setRotation(0, degrees);
}

Similar to the calibrate option in the sensor dashboard, the rotation value can be set while the project is being run using the [Set drive rotation] block, set_rotationPython command, or setRotation C++ command.


Pitch, Roll, and Yaw

Diagram of a BaseBot with a curved arrow indicating its Pitch. The Pitch direction can be imagined as the robot looking up or down.

Pitch, roll, and yaw are the orientation angle of the Brain along a specified axis. Pitch represents the y-axis and the angle of the robot tilting forward and backwards. Values for pitch range from -90 degrees to 90 degrees. 

Diagram of a BaseBot with a curved arrow indicating its Roll. The Roll direction can be imagined as the robot rolling over on its side.

Roll represents the x-axis and the angle of the robot tilting left and right. Values for roll range from -180 degrees to 180 degrees. 

Diagram of a BaseBot with a curved arrow indicating its Yaw. The Yaw direction can be imagined as the robot looking left and right.

Yaw represents the z-axis and the angular rotation of the robot. Values for yaw range from -180 degrees to 180 degrees.

Brain screen is shown with the Inertial Sensor Dashboard opened and with the Roll, Pitch, and Yaw values highlighted.

Pitch, roll, and yaw are shown on the sensor dashboard beneath heading and rotation.

Screenshot of the Pitch, Roll, Yaw Example Project thumbnail.

The Pitch, Roll, Yaw example project in VEXcode IQ can be used to show how to detect the orientation angle of the Brain along the y, x, and z axes. The Touch LED will be set to different colors depending on how the orientation angle of the Brain changes to indicate pitch, roll, and yaw.

For information on how to open an example project in VEXcode IQ, see one of the following articles.


Acceleration on the x, y, and z axes

Brain screen is shown with the Inertial Sensor Dashboard opened and with the Acceleration on the x, y, and z axes values highlighted. These values are labeled as ax, ay, and az in the Dashboard.

The acceleration of section on the sensor dashboard reports the acceleration value of the Inertial Sensor along a specified axis. Acceleration along the x, y, and z axes are shown on the sensor dashboard to the right using the abbreviations, "ax," "ay," and "az." Each of these reports a range from -4.0 to 4.0 Gs.

While the Brain is resting on a surface, you will see a value of roughly -1.0 Gs. this is due to the force of gravity on the Brain while at rest.

Screenshot of the Detecting Acceleration Example Project thumbnail.

The Detecting Acceleration example project in VEXcode IQ can be used to show how to detect the acceleration of the Brain along the x, y, and z axes. The Touch LED will display different colors depending on what axis the Brain is tilted.

For information on how to open an example project in VEXcode IQ, see one of the following articles.


Rate of rotation on the x, y, and z axes

Brain screen is shown with the Inertial Sensor Dashboard opened and with the Rate of rotation on the x, y, and z axes values highlighted. These values are labeled as gx, gy, and gz in the Dashboard.

The gyro rate of section on the sensor dashboard reports the rate of rotation value of the Inertial Sensor along a specified axis. The rate of rotation along the x, y, and z axes are shown on the sensor dashboard to the right using the abbreviations, "gx," "gy," and "gz." Each of these reports a range from -1000.0 to 1000.0 degrees per second.

VEXcode IQ Blocks VEXcode IQ Python
VEXcode IQ Gyro rate block that reads BrainInertial gyro rate of x axis.
brain_inertial.gyro_rate(AxisType.XAXIS, VelocityUnits.DPS)
VEXcode IQ C++
int main()
{
BrainInertial.gyroRate(xaxis, dps)
}

In VEXcode IQ, the (Gyro rate) block, gyro_rate Python command, and gyroRate C++ command can be used to report the rate of rotation of a specific axis while a project is running.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: