Inertial#
Introduction#
The VEX AIM Coding Robot’s Inertial Sensor 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. Below is a list of all available blocks, grouped by functionality:
Values - Return orientation and movement data.
heading – Returns the robot’s heading angle (0 to 359.99 degrees).
rotation – Returns how much the robot has turned since it started.
acceleration – Returns acceleration along the forward, rightward, or downward axis.
get turn rate – Returns the robot’s current rotation speed in degrees per second (dps).
orientation – Returns the robot’s roll, pitch, or yaw (–180.00 to 180.00 degrees).
Actions – Detect and respond to changes in acceleration or reset heading/orientation.
when crashed – Triggers an event when the robot detects a sudden impact.
set crash sensitivity – Adjusts how sensitive the crash detection is to impacts.
reset heading – Resets the heading value to zero.
reset rotation – Resets the rotation value to zero.
Values#
heading#
The heading block returns the robot’s heading angle as a decimal number, in the range 0 to 359.99 degrees.
heading in degrees
Parameters |
Description |
---|---|
This block has no parameters. |
Examples
when started :: hat events
[Turn right until the heading reaches 90 degrees.]
turn [right v]
wait [0.05] seconds
wait until <(heading in degrees) [math_greater_than v] [90]>
stop all movement
when started :: hat events
[Display the robot's heading as it is rotated by hand.]
forever
clear row [1] on screen
set cursor to row [1] column [1] on screen
print (heading in degrees) on screen ▶
wait [0.05] seconds
rotation#
The rotation block returns how much the robot has turned since it started, in degrees: positive for clockwise, negative for counterclockwise.
(rotation in degrees)
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Print the rotation value as the robot turns.]
turn [right v] for [480] degrees ◀ and don't wait
forever
clear screen
set cursor to row [1] column [1] on screen
print (rotation in degrees) on screen ▶
acceleration#
The acceleration block returns the robot’s acceleration along the specified axis (forward, rightward, or downward) in units of g, ranging from -4.00 to 4.00.
(acceleration of [forward v] axis in g :: custom-controller-inertial-timer)
Parameters |
Description |
---|---|
axis |
The axis to return the acceleration of:
|
Example
when started :: hat events
[Show the change in acceleration as the robot begins to move.]
set cursor to row [4] column [1] on screen
print (join [Resting: ] (acceleration of [rightward v] axis in g :: custom-controller-inertial-timer)) on screen ▶
set cursor to next row on screen
wait [0.5] seconds
move [right v] for [50] [mm v] ◀ and don't wait
wait [0.1] seconds
print (join [Startup: ] (acceleration of [rightward v] axis in g :: custom-controller-inertial-timer)) on screen ▶
get turn rate#
The get turn rate block returns the robot’s current rotation speed along the specified axis (roll, pitch, or yaw) in degrees per second (dps) as an integer.
The image below uses arrows to show the direction of positive rotation for roll, pitch, yaw.
(get turn rate of [yaw v] axis in dps)
Parameters |
Description |
---|---|
axis |
The axis to return the turn rate of:
|
Example
when started :: hat events
[Observe the yaw turn rate as the robot turns.]
turn [right v] for [180] degrees ◀ and don't wait
forever
clear screen
set cursor to row [1] column [1] on screen
print (get turn rate of [yaw v] axis in dps) on screen ▶
orientation#
The orientation block returns the robot’s roll, pitch, or yaw, in the range of -180.00 to 180.00 degrees as a decimal number.
The image below uses arrows to show the direction of positive rotation for roll, pitch, yaw.
orientation of [yaw v] in degrees
Parameters |
Description |
---|---|
axis |
The orientation axis:
|
Example
when started :: hat events
[Display the robot's orientation as it is rotated by hand.]
forever
clear row [1] on screen
set cursor to row [1] column [1] on screen
print (orientation of [roll v] in degrees) on screen ▶
wait [0.05] seconds
Actions#
when crashed#
The when crashed block triggers an event when the robot detects a sudden impact or collision based on the accelerometer’s readings and the current crash sensitivity.
when crashed :: hat events
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Move forward until the robot crashes.]
set move velocity to [100] %
move [forward v]
when crashed :: hat events
stop all movement
play sound [crash v] ▶
set crash sensitivity#
The set crash sensitivity block adjusts the acceleration threshold required to trigger a crash response.
set crash sensitivity to [low v]
Parameters |
Description |
---|---|
sensitivity |
The sensitivity of the robot to detect crashes:
|
Example
when started :: hat events
[Detect a crash at a slow velocity.]
set move velocity to [35] %
set crash sensitivity to [high v]
move [forward v]
when crashed :: hat events
stop all movement
play sound [crash v] ▶
reset heading#
The reset heading block resets the robot’s heading to 0 degrees.
reset heading
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Face left before turning around.]
turn to heading [270] degrees ▶
reset heading
wait [1] seconds
turn to heading [180] degrees ▶
reset rotation#
The reset rotation block resets the robot’s rotation value to 0 degrees.
reset rotation
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Turn for 480 degrees before resetting rotation.]
turn [right v] for [480] degrees ▶
reset rotation
when started :: hat events
forever
clear screen
set cursor to row [1] column [1] on screen
print (rotation in degrees) on screen ▶