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. 

inertial_sensor_dashboard_blank.png


Heading

inertial_sensor_heading.png

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.

dashboard_with_heading_callout.png

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.

Screen_Shot_2021-11-04_at_12.15.49_PM.png

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
heading blocks.png
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
heading blocks 2.png
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

heading_270__rotation_-90.png

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. 

rotation_callout.png

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. 

Screen_Shot_2021-11-04_at_12.15.49_PM.png

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
blocks rotation1.png
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
blocks rotation2.png
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

IQ_Gen2_Basebot_Pitch_copy.png

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. 

IQ_Gen2_Basebot_Roll_copy.png

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. 

IQ_Gen2_Basebot_Yaw_copy.png

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

roll_pitch_yaw_callout.png

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

Screen_Shot_2021-11-04_at_2.31.36_PM.png

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

accel_x__y__z.png

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.

Screen_Shot_2021-11-04_at_2.51.22_PM.png

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

rotation_x__y__z.png

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
brain gyro.png
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: