Inertial#

Introduction#

The GO Brain includes a built-in inertial sensor, which allows the robot to track its orientation, heading, and acceleration.

Below is a list of all methods:

Orientation

  • get_heading – Returns the current heading.

  • get_rotation – Returns the current rotation.

  • get_yaw – Returns the current yaw.

  • get_roll – Returns the current roll.

  • get_pitch – Returns the current pitch.

  • calibrate – Calibrates the Inertial Sensor for stable heading tracking.

  • reset_heading – Sets the heading of the Inertial Sensor to 0.

  • reset_rotation – Sets the rotation of the Inertial Sensor to 0.

  • set_heading – Sets the Inertial Sensor’s heading to a specified value.

  • set_rotation – Sets the Inertial Sensor’s rotation to a specified value.

Motion

  • get_acceleration – Returns the linear acceleration along the x, y, or z axis.

Orientation#

get_heading#

get_heading returns the current heading of the Inertial Sensor in degrees.

Note: If a Code Base, Super Car, or Drivetrain is configured, this command becomes drivetrain.get_heading().

Usage:
inertial.get_heading()

Parameters

Description

This method has no parameters.

get_rotation#

get_rotation returns the current rotation of the Inertial Sensor in degrees.

Note: If a Code Base, Super Car, or Drivetrain is configured, this command becomes drivetrain.get_rotation().

Usage:
inertial.get_rotation()

Parameters

Description

This method has no parameters.

get_yaw#

get_yaw returns the current yaw of the Inertial Sensor in degrees.

Note: If a Code Base, Super Car, or Drivetrain is configured, this command becomes drivetrain.get_yaw().

Usage:
inertial.get_yaw()

Parameters

Description

This method has no parameters.

get_roll#

get_roll returns the current roll of the Inertial Sensor in degrees.

Note: If a Code Base, Super Car, or Drivetrain is configured, this command becomes drivetrain.get_roll().

Usage:
inertial.get_roll()

Parameters

Description

This method has no parameters.

get_pitch#

get_pitch returns the current pitch of the Inertial Sensor in degrees.

Note: If a Code Base, Super Car, or Drivetrain is configured, this command becomes drivetrain.get_pitch().

Usage:
inertial.get_pitch()

Parameters

Description

This method has no parameters.

calibrate#

calibrate calibrates the Inertial Sensor. All subsequent lines 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 method becomes unavailable.

Usage:
inertial.calibrate()

Parameters

Description

This method has no parameters.

reset_heading#

reset_heading resets the heading of the Inertial Sensor to 0 degrees.

Note: If a Code Base, Super Car, or Drivetrain is configured, this method becomes unavailable.

Usage:
inertial.reset_heading()

Parameters

Description

This method has no parameters.

reset_rotation#

reset_rotation resets the rotation of the Inertial Sensor to 0 degrees.

Note: If a Code Base, Super Car, or Drivetrain is configured, this method becomes unavailable.

Usage:
inertial.reset_rotation()

Parameters

Description

This method has no parameters.

set_heading#

set_heading sets the heading of the Inertial Sensor to a specified value.

Note: If a Code Base, Super Car, or Drivetrain is configured, this command becomes drivetrain.set_heading().

Usage:
inertial.set_heading(heading)

Parameters

Description

heading

The heading value to set in degrees.

set_rotation#

set_rotation sets the rotation of the Inertial Sensor to a specified value.

Note: If a Code Base, Super Car, or Drivetrain is configured, this command becomes drivetrain.set_rotation().

Usage:

inertial.set_rotation(rotation)

Parameters

Description

rotation

The value to use for the new rotation in degrees.

Motion#

get_acceleration#

get_acceleration returns the acceleration of the Inertial Sensor.

Usage:
inertial.get_acceleration(axis)

Parameters

Description

axis

The axis to return the acceleration from:

  • X
  • Y
  • Z
# Build Used: Super Code Base 2.0
def main():
    # Display the acceleration after moving
    drivetrain.set_drive_velocity(100)
    console.print("Resting: ")
    console.print(inertial.get_acceleration(X), precision=2)
    console.new_line()
    wait(1, SECONDS)
    drivetrain.drive_for(FORWARD, 500, MM, wait=False)
    wait(0.20,SECONDS)
    console.print("Startup: ")
    console.print(inertial.get_acceleration(X), precision=2)

# Start threads — Do not delete
start_thread(main)