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 drivetrain is configured, this command becomes drivetrain.get_heading().
Usage:
inertial.get_heading()
Parameters |
Description |
---|---|
This method has no parameters. |
# Build Used: Super Code Base 2.0
def main():
# Display the heading after turning
drivetrain.turn_for(RIGHT, 450)
console.print("Heading: ")
console.print(inertial.get_heading())
# Start threads — Do not delete
start_thread(main)
get_rotation#
get_rotation
returns the current rotation of the Inertial Sensor in degrees.
Note: If a drivetrain is configured, this command becomes drivetrain.get_rotation().
Usage:
inertial.get_rotation()
Parameters |
Description |
---|---|
This method has no parameters. |
# Build Used: Super Code Base 2.0
def main():
# Display the rotation after turning
drivetrain.turn_for(RIGHT, 450)
console.print("Rotation: ")
console.print(inertial.get_rotation())
# Start threads — Do not delete
start_thread(main)
get_yaw#
get_yaw
returns the current yaw of the Inertial Sensor in degrees.
Note: If a drivetrain is configured, this command becomes drivetrain.get_yaw().
Usage:
inertial.get_yaw()
Parameters |
Description |
---|---|
This method has no parameters. |
# Build Used: Super Code Base 2.0
def main():
# Change the LED color based on the yaw while
# moving the robot by hand
monitor_sensor("inertial.get_yaw")
while True:
if inertial.get_yaw() > 0:
bumper.set_color(GREEN)
elif inertial.get_yaw() < 0:
bumper.set_color(RED)
else:
bumper.set_color(NONE)
# Start threads — Do not delete
start_thread(main)
get_roll#
get_roll
returns the current roll of the Inertial Sensor in degrees.
Note: If a drivetrain is configured, this command becomes drivetrain.get_roll().
Usage:
inertial.get_roll()
Parameters |
Description |
---|---|
This method has no parameters. |
# Build Used: Super Code Base 2.0
def main():
# Change the LED color based on the roll while
# moving the robot by hand
monitor_sensor("inertial.get_roll")
while True:
if inertial.get_roll() > 0:
bumper.set_color(GREEN)
elif inertial.get_roll() < 0:
bumper.set_color(RED)
else:
bumper.set_color(NONE)
# Start threads — Do not delete
start_thread(main)
get_pitch#
get_pitch
returns the current pitch of the Inertial Sensor in degrees.
Note: If a drivetrain is configured, this command becomes drivetrain.get_pitch().
Usage:
inertial.get_pitch()
Parameters |
Description |
---|---|
This method has no parameters. |
# Build Used: Super Code Base 2.0
def main():
# Change the LED color based on the pitch while
# moving the robot by hand
monitor_sensor("inertial.get_pitch")
while True:
if inertial.get_pitch() > 0:
bumper.set_color(GREEN)
elif inertial.get_pitch() < 0:
bumper.set_color(RED)
else:
bumper.set_color(NONE)
# Start threads — Do not delete
start_thread(main)
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 drivetrain is configured, this method becomes unavailable.
Usage:
inertial.calibrate()
Parameters |
Description |
---|---|
This method has no parameters. |
# Build Used: Super Code Base 2.0
def main():
# Calibrate the robot
console.print("Calibrating...")
console.new_line()
inertial.calibrate()
console.print("Done!")
# Start threads — Do not delete
start_thread(main)
reset_heading#
reset_heading
resets the heading of the Inertial Sensor to 0 degrees.
Note: If a drivetrain is configured, this method becomes unavailable.
Usage:
inertial.reset_heading()
Parameters |
Description |
---|---|
This method has no parameters. |
# Build Used: Super Code Base 2.0
def main():
# Turn the robot before and after resetting the heading
drivetrain.turn_to_heading(90)
wait(0.5, SECONDS)
inertial.reset_heading()
drivetrain.turn_to_heading(90)
# Start threads — Do not delete
start_thread(main)
reset_rotation#
reset_rotation
resets the rotation of the Inertial Sensor to 0 degrees.
Note: If a drivetrain is configured, this method becomes unavailable.
Usage:
inertial.reset_rotation()
Parameters |
Description |
---|---|
This method has no parameters. |
# Build Used: Super Code Base 2.0
def main():
# Turn the robot before and after resetting the rotation
drivetrain.turn_to_rotation(-90)
wait(0.5, SECONDS)
inertial.reset_rotation()
drivetrain.turn_to_rotation(-90)
# Start threads — Do not delete
start_thread(main)
set_heading#
set_heading
sets the heading of the Inertial Sensor to a specified value.
Note: If a drivetrain is configured, this command becomes drivetrain.set_heading().
Usage:
inertial.set_heading(heading)
Parameters |
Description |
---|---|
|
The heading value to set in degrees. |
# Build Used: Super Code Base 2.0
def main():
# Turn the robot around
inertial.set_heading(180)
drivetrain.turn_to_heading(0)
# Start threads — Do not delete
start_thread(main)
set_rotation#
set_rotation
sets the rotation of the Inertial Sensor to a specified value.
Note: If a drivetrain is configured, this command becomes drivetrain.set_rotation().
Usage:
inertial.set_rotation(rotation)
Parameters |
Description |
---|---|
|
The value to use for the new rotation in degrees. |
# Build Used: Super Code Base 2.0
def main():
# Turn the robot around
inertial.set_rotation(-180)
drivetrain.turn_to_rotation(0)
# Start threads — Do not delete
start_thread(main)
Motion#
get_acceleration#
get_acceleration
returns the acceleration of the Inertial Sensor.
Usage:
inertial.get_acceleration(axis)
Parameters |
Description |
---|---|
|
The axis to return the acceleration from:
|
# Build Used: Super Code Base 2.0
def main():
# Display the acceleration after moving
drivetrain.set_drive_velocity(100)
console.print("Resting: ")
console.new_line()
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.new_line()
console.print(inertial.get_acceleration(X), precision=2)
# Start threads — Do not delete
start_thread(main)