Inertial#

Introduction#

The VEX 123 Robot has a built-in Inertial Sensor. This sensor can measure how the robot is moving.

The Inertial Sensor uses an accelerometer to measure changes in motion, such as speeding up, slowing down, or stopping suddenly during a crash.

Below is a list of all Inertial methods:

Getters — Return how the robot is moving.

  • is_crashed — Returns whether the robot has detected a crash.

  • get_acceleration — Returns how quickly the robot is speeding up or slowing down on the selected axis.

Getters#

is_crashed#

is_crashed returns a Boolean that reports whether the robot has detected a crash — a sudden stop or impact.

  • True — The robot has detected a crash.

  • False — The robot has not detected a crash.

Usage:
robot.is_crashed()

Parameters

Description

This method has no parameters.

# Back up after a crash.
robot.drive(FORWARD)
while not robot.is_crashed():
    wait(0.05, SECONDS)
robot.drive_for(REVERSE, 200, MM)

get_acceleration#

Acceleration is how quickly the robot is speeding up or slowing down. get_acceleration returns the acceleration of the robot on the selected axis, from -4.0 G to 4.0 G.

A G is a unit used to measure acceleration. 1 G is about the acceleration you feel from gravity while sitting still.

The value can be positive or negative depending on the direction of acceleration on the selected axis. The axis options are X, Y, and Z.

Usage:
robot.inertial.get_acceleration(axis)

Parameters

Description

axis

The axis to measure acceleration on: X, Y, or Z.

# Display the acceleration on the X axis
while True:
    console.clear()
    console.print(robot.inertial.get_acceleration(X), precision=2)
    wait(0.1, SECONDS)