Detección#

Sensores de monitorización#

Para agregar el valor de un sensor a la Consola de Monitor, utilice el comando monitor_sensor().

Funciones#

Timer#

cerebro.timer_reset()#

The brain.timer_reset() command is used to reset the Brain’s timer back to 0 seconds.

Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.

Devoluciones: Ninguna.

def main():
    # Wait 10 seconds.
    wait(10, SECONDS)
    # Reset the Brain's timer from 10 seconds back to 0.
    brain.timer_reset()

cerebro.timer_time()#

The brain.timer_time(units) command is used to report the value of the Brain’s timer in seconds.

Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.

Parámetros

Descripción

unidades

The unit of the returned value, SECONDS or MSEC (Milliseconds).

Devuelve: Esto devuelve un valor numérico.

def main():
    # Wait 3 seconds.
    wait(3, SECONDS)
    # Set the numeric variable "brain_timer" to the Brain timer's
    # current value in seconds.
    brain_timer = brain.timer_time(SECONDS)
    # Print the value of "brain_timer".
    brain.print(brain_timer)

drivetrain#

transmisión.is_done()#

The drivetrain.is_done() command is used to return a True or False value if the Drivetrain has completed its movement.

Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.

Devuelve: Esto devuelve un valor booleano.

def main():
    # Drive forward for 20 inches.
    drivetrain.drive_for(FORWARD, 20, INCHES)
    # Check if the Drivetrain has stopped moving.
    if drivetrain.is_done():
        # Print that the Drivetrain has finished moving.
        brain.print("Drivetrain has finished moving!")

tren motriz.is_moving()#

The drivetrain.is_moving() command is used to return a True or False value if the Drivetrain is currently moving.

Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.

Devuelve: Esto devuelve un valor booleano.

def main():
    # Drive forward for 20 inches and allow subsequent commands to execute.
    drivetrain.drive_for(FORWARD, 20, INCHES, wait=False)
    # Wait 10 Milliseconds for Drivetrain to start moving.
    wait(10, MSEC)
    # Check if the Drivetrain is moving.
    if drivetrain.is_moving():
        # Print that the Drivetrain is moving.
        brain.print("Drivetrain is moving!")

tren motriz.heading()#

The drivetrain.heading(units) command returns the direction that the Drivetrain is facing by using the Gyro sensor’s current angular position. The numerical value from 0.00 to 359.99 (the DEGREES) will increase when rotating clockwise and decrease when rotating counter-clockwise.

Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.

The drivetrain.heading(units) command returns a range from 0.00 to 359.99 degrees.

Parámetros

Descripción

unidades

The unit of the returned value, DEGREES.

Devuelve: Esto devuelve un valor numérico.

def main():
    # Turn to the right for 400 degrees.
    drivetrain.turn_for(RIGHT, 400, DEGREES)
    # Print the VR Robot's current heading.
    brain.print(drivetrain.heading(DEGREES))

tren motriz.rotación()#

The drivetrain.rotation(units) command returns the Drivetrain’s angle of rotation. The numerical value (the DEGREES) will increase when rotating clockwise and a decrease when rotating counter-clockwise.

Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.

Parámetros

Descripción

unidades

The unit of the returned value, DEGREES.

Devuelve: Esto devuelve un valor numérico.

def main():
    # Turn to the right for 400 degrees.
    drivetrain.turn_for(RIGHT, 400, DEGREES)
    # Print the VR Robot's current angle of rotation.
    brain.print(drivetrain.rotation(DEGREES))

bumper#

Para identificar qué sensores de parachoques puede utilizar su robot VR, consulte la página de detalles de su área de juegos.

parachoques.presionando()#

The bumper.pressing() returns if the specified bumper is pressed.

Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.

Devuelve: Esto devuelve un valor booleano.

def main():
    # Drive forward.
    drivetrain.drive(FORWARD)
    # Continuously check the if statement every 5 Milliseconds.
    while True:
        wait(5, MSEC)
        # Check if the Left Bumper is Pressed.
        if left_bumper.pressing():
            # Stop the Drivetrain.
            drivetrain.stop()

distance#

Para identificar qué sensores de distancia puede utilizar su robot VR, consulte la página de detalles de su área de juegos.

distancia.objeto_encontrado()#

The distance.found_object() command reports whether the built-in Distance Sensor sees an object or surface within 3000 mm.

Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.

Devuelve: Esto informa un valor booleano.

def main():
    # Print if the Front Distance Sensor has detected something.
    brain.print(front_distance.found_object())

distancia.get_distance()#

The distance.get_distance(units) command the distance of the nearest object from the Distance Sensor.

Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.

Parámetros

Descripción

unidades

The unit of the returned value, MM or INCHES.

Devuelve: Esto devuelve un valor numérico.

def main():
    # Print the distance from the Front Sensor to the nearest object in inches.
    brain.print(front_distance.get_distance(INCHES))

eye#

Para identificar qué sensores oculares puede utilizar su robot VR, consulte la página de detalles de su área de juegos.

ojo.cerca_del_objeto()#

The eye.near_object() command is used to report a Boolean value if the Color Sensor Eye is close enough to an object to detect a color.

Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.

Devuelve: Esto informa un valor booleano.

def main():
    # Print if the Down Eye Sensor is detecting a color.
    brain.print(down_eye.near_object())

ojo.detect()#

The eye.detect(color) command is used to report if the Color Sensor Eye is close enough to an object to detect a color.

Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.

Parámetros

Descripción

color

The color that the Color Sensor Eye will detect: NONE, BLACK, RED, GREEN, BLUE.

Devuelve: Esto devuelve un valor booleano.

def main():
    # Print if the Down Eye Sensor is detecting the color blue.
    brain.print(down_eye.detect(BLUE))

ojo.brillo()#

The eye.brightness(units) command is used to report the brightness of an object from one of the Color Sensor Eyes.

Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.

Parámetros

Descripción

unidades

The unit of the returned value, PERCENT.

Devuelve: Esto devuelve un valor numérico.

def main():
    # Print the brightness of the object in front of the VR Robot.
    brain.print(front_eye.brightness(PERCENT))

location#

ubicación.posición()#

The location.position(axis, units) command is used to report the X or Y coordinate position of the Robot.

Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.

Parámetros

Descripción

eje

The axis of the coordinates, X or Y.

unidades

The unit for the coordinates, MM (Millimeters) or INCHES.

Devuelve: Esto devuelve un valor numérico.

def main():
    # Print the current Y coordinate of the VR Robot in Millimeters.
    brain.print(location.position(Y, MM))

ubicación.ángulo_de_posición()#

The location.position_angle(units) command is used to report the current angle of the VR Robot.

Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.

Parámetros

Descripción

unidades

The unit for the VR Robot’s angle, DEGREES.

Devuelve: Esto devuelve un valor numérico.

def main():
    # Print the current angle of the VR Robot.
    brain.print(location.position_angle(DEGREES))