Inertial#
Introduction#
The VEX GO Brain includes a built-in Inertial Sensor for measuring acceleration and detecting changes in motion.
Below is a list of all available blocks:
calibrate gyro – Calibrate the Brain’s Inertial Sensor.
set heading – Manually sets the robot’s heading value.
set rotation – Manually sets the robot’s cumulative rotation value.
heading – Returns the robot’s heading angle (0 to 359.99 degrees).
rotation – Returns how much the robot has turned since the project started.
detected crash? – Returns a Boolean indicating if a crash is detected.
acceleration – Returns the acceleration along on axis detected by the Inertial Sensor.
calibrate gyro#
The calibrate gyro block calibrates the Brain’s Inertial Sensor. All subsequent blocks 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.
Note: If a Code Base, Super Car, or Drivetrain is configured, this block becomes unavailable. This occurs because any project containing a Drivetrain block will automatically calibrate at startup.
calibrate gyro
Parameters |
Description |
|---|---|
This block has no parameters. |
set heading#
The set heading block sets the Inertial Sensor’s current heading to a specified value.
Note: If a Code Base, Super Car, or Drivetrain is configured, this turns into the set drive heading block.
set heading to [0] degrees
Parameters |
Description |
|---|---|
heading |
The heading value to assign, in degrees. |
set rotation#
The set rotation block sets the Inertial Sensor’s current cumulative rotation value.
Note: If a Code Base, Super Car, or Drivetrain is configured, this turns into the set drive rotation block.
set rotation to [0] degrees
Parameters |
Description |
|---|---|
rotation |
The cumulative rotation value to assign, in degrees. |
heading#
The heading block returns the robot’s heading angle in a range from 0 to 359.99 degrees.
Note: If a Code Base, Super Car, or Drivetrain is configured, this turns into the drive heading block.
(heading in degrees)
Parameters |
Description |
|---|---|
This block has no parameters. |
rotation#
The rotation block returns how much the robot has turned since the project started, in degrees: positive for clockwise, negative for counterclockwise.
Note: If a Code Base, Super Car, or Drivetrain is configured, this turns into the drive rotation block.
(rotation in degrees)
Parameters |
Description |
|---|---|
This block has no parameters. |
detected crash?#
The detected crash? block returns a Boolean indicating whether or not the robot crashed.
True – A crash was detected.
False – A crash was not detected
Note: This block requires a configured Code Base, Super Car, or Drivetrain.
<detected crash?>
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started :: hat events
[Build Used: Super Code Base 2.0]
[Back up and turn after crashing.]
set drive velocity to [100] %
drive [forward v]
wait until <detected crash?>
drive [reverse v] for [100] [mm v] ▶
turn [right v] for [90] degrees ▶
acceleration#
The acceleration block returns the acceleration from one of the axes (x, y, or z) of the VEX GO Brain’s Inertial Sensor as a decimal between -4.0 and 4.0 G’s.
(acceleration of [x v] axis in g)
Parameters |
Description |
|---|---|
axis |
The axis to get the acceleration from:
|
Example
when started :: hat events
[Build Used: Super Code Base 2.0]
[Display the acceleration after moving.]
set print precision to [All Digits v]
set drive velocity to [100] %
print [Resting: ] ▶
print (acceleration of [x v] axis in g) ▶
set cursor to next row
wait [1] seconds
drive [forward v] for [500] [mm v] ◀ and don't wait
wait [0.2] seconds
print [Startup: ] ▶
print (acceleration of [x v] axis in g) ▶