Inercial#

Introducción#

El GO Brain incluye un sensor inercial incorporado, que permite al robot rastrear su orientación, rumbo y aceleración.

A continuación se muestra una lista de todos los métodos:

Orientación

  • 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.

Movimiento

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

Orientación#

get_heading#

get_heading devuelve el rumbo actual del sensor inercial en grados.

Nota: Si se configura una transmisión, este comando se convierte en drivetrain.get_heading().

Uso:
inertial.get_heading()

Parámetros

Descripción

Este método no tiene parámetros.

# 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 devuelve la rotación actual del sensor inercial en grados.

Nota: Si se configura una transmisión, este comando se convierte en drivetrain.get_rotation().

Uso:
inertial.get_rotation()

Parámetros

Descripción

Este método no tiene parámetros.

# 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 devuelve la guiñada actual del sensor inercial en grados.

Nota: Si se configura una transmisión, este comando se convierte en drivetrain.get_yaw().

Uso:
inertial.get_yaw()

Parámetros

Descripción

Este método no tiene parámetros.

# 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 devuelve el giro actual del sensor inercial en grados.

Nota: Si se configura una transmisión, este comando se convierte en drivetrain.get_roll().

Uso:
inertial.get_roll()

Parámetros

Descripción

Este método no tiene parámetros.

# 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 devuelve el paso actual del sensor inercial en grados.

Nota: Si se configura una transmisión, este comando se convierte en drivetrain.get_pitch().

Uso:
inertial.get_pitch()

Parámetros

Descripción

Este método no tiene parámetros.

# 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 calibra el sensor inercial. Todas las líneas subsiguientes esperarán a que se complete la calibración antes de ejecutarse. La calibración es un procedimiento interno que mide y compensa el ruido y la deriva del sensor durante un período específico. Durante este tiempo, el cerebro debe permanecer completamente inmóvil (es decir, sobre una superficie estable sin ningún movimiento externo). El movimiento durante la calibración producirá resultados inexactos.

Nota: Si se configura una transmisión, este método no estará disponible.

Uso:
inertial.calibrate()

Parámetros

Descripción

Este método no tiene parámetros.

# 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 restablece el rumbo del sensor inercial a 0 grados.

Nota: Si se configura una transmisión, este método no estará disponible.

Uso:
inertial.reset_heading()

Parámetros

Descripción

Este método no tiene parámetros.

# 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 restablece la rotación del sensor inercial a 0 grados.

Nota: Si se configura una transmisión, este método no estará disponible.

Uso:
inertial.reset_rotation()

Parámetros

Descripción

Este método no tiene parámetros.

# 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 establece el rumbo del sensor inercial a un valor especificado.

Nota: Si se configura una transmisión, este comando se convierte en drivetrain.set_heading().

Uso:
inertial.set_heading(heading)

Parámetros

Descripción

heading

El valor del rumbo a establecer en grados.

# 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 establece la rotación del sensor inercial a un valor especificado.

Nota: Si se configura una transmisión, este comando se convierte en drivetrain.set_rotation().

Uso:

inertial.set_rotation(rotation)

Parámetros

Descripción

rotation

El valor a utilizar para la nueva rotación en grados.

# 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)

Movimiento#

get_acceleration#

get_acceleration devuelve la aceleración del sensor inercial.

Uso:
inertial.get_acceleration(axis)

Parámetros

Descripción

axis

El eje desde el que se retorna la aceleración:

  • 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.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)