Python específico para robots#
Todos los comandos VEXcode VR estándar están disponibles para su uso en el patio de juegos V5RC Virtual Skills - High Stakes.
Movimiento#
motor.spin()#
The motor.spin(direction)
command is used to spin a motor indefinitely.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
To use this command, replace motor
with the desired motor or motor group, for example: arm_motor.spin(direction)
.
Objetos |
Descripción |
---|---|
|
Sube o baja el brazo de Axel. |
|
Sube o baja el empujador para empujar los anillos fuera del brazo. |
Parámetros |
Descripción |
---|---|
dirección |
The direction for the motor to move in: |
Devoluciones: Ninguna.
# Lift the Arm up before moving.
arm_motor.spin(FORWARD)
wait(1, SECONDS)
arm_motor.stop()
motor.spin_for()#
The motor.spin_for(direction, distance, units, wait)
command is used to spin a motor for a given amount of degrees or turns.
This is can be a non-waiting or waiting command depending on if the wait
parameter is used.
To use this command, replace motor
with the desired motor or motor group, for example: arm_motor.spin_for(direction, distance, units, wait)
.
Objetos |
Descripción |
---|---|
|
Sube o baja el brazo de Axel. |
|
Sube o baja el empujador para empujar los anillos fuera del brazo. |
Parámetros |
Descripción |
---|---|
dirección |
The direction for the motor to move in: |
distancia |
La distancia que debe recorrer el motor, expresada en un número entero. |
unidades |
The units that the motor will use: |
esperar |
Optional. The wait parameter determines whether the command will block subsequent commands ( |
Devoluciones: Ninguna.
# Lift the Arm up before moving.
arm_motor.spin_for(FORWARD, 400, DEGREES)
motor.spin_to_position()#
The motor.spin_to(angle, units, wait)
command is used to spin a motor to a given position.
This is can be a non-waiting or waiting command depending on if the wait
parameter is used.
To use this command, replace motor
with the desired motor or motor group, for example: arm_motor.spin_for(angle, units, wait)
.
Objetos |
Descripción |
---|---|
|
Sube o baja el brazo de Axel. |
|
Sube o baja el empujador para empujar los anillos fuera del brazo. |
Parámetros |
Descripción |
---|---|
ángulo |
El ángulo específico o número de vueltas que dará el motor. |
unidades |
The units that the motor will use: |
esperar |
Optional. The wait parameter determines whether the command will block subsequent commands ( |
Devoluciones: Ninguna.
# Lift the Arm up before moving.
arm_motor.spin_to_position(400, DEGREES)
motor.stop()#
The motor.stop()
command is used to stop a motor.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
To use this command, replace motor
with the desired motor or motor group, for example: arm_motor.stop()
.
Objetos |
Descripción |
---|---|
|
Sube o baja el brazo de Axel. |
|
Sube o baja el empujador para empujar los anillos fuera del brazo. |
Devoluciones: Ninguna.
# Lift the Arm up before moving.
arm_motor.spin(FORWARD)
wait(1, SECONDS)
arm_motor.stop()
motor.set_position()#
The motor.set_position(position, units)
command is used to set a motor’s encoder position to the given position value.
To use this command, replace motor
with the desired motor or motor group, for example: arm_motor.set_position(position, units)
.
Objetos |
Descripción |
---|---|
|
Sube o baja el brazo de Axel. |
|
Sube o baja el empujador para empujar los anillos fuera del brazo. |
Parámetros |
Descripción |
---|---|
posición |
El entero específico que se debe configurar para el codificador del motor. |
unidades |
The units for the motor to use: |
Devoluciones: Ninguna.
# Make the raised Arm as the new 0 degrees position.
arm_motor.spin_to_position(400, DEGREES)
arm_motor.set_position(0, DEGREES)
motor.set_velocity()#
The motor.set_velocity(velocity, units)
command is used to set the speed of a motor.
To use this command, replace motor
with the desired motor or motor group, for example: arm_motor.set_velocity(velocity, units)
.
Objetos |
Descripción |
---|---|
|
Sube o baja el brazo de Axel. |
|
Sube o baja el empujador para empujar los anillos fuera del brazo. |
Parámetros |
Descripción |
---|---|
velocidad |
La velocidad a la que girará el motor, que varía entre -100 y 100. |
unidades |
The unit for the Motor’s velocity, |
Devoluciones: Ninguna.
# Lift the Arm up before moving.
arm_motor.set_velocity(100, PERCENT)
arm_motor.spin_to_position(400, DEGREES)
motor.set_timeout()#
The motor.set_timeout(value, units)
command is used to set a time limit for a motor’s movement commands.
Esto evita que los comandos de movimiento que no llegan a su posición prevista impidan la ejecución de los comandos posteriores.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
To use this command, replace motor
with the desired motor or motor group, for example: arm_motor.set_timeout(value, units)
.
Objetos |
Descripción |
---|---|
|
Sube o baja el brazo de Axel. |
|
Sube o baja el empujador para empujar los anillos fuera del brazo. |
Parámetros |
Descripción |
---|---|
valor |
La cantidad de tiempo que el motor esperará antes de detenerse. |
unidades |
The unit for the Motor’s timer, |
Devoluciones: Ninguna.
# Lift the Arm up before moving.
arm_motor.set_timeout(1, SECONDS)
arm_motor.spin_for(FORWARD, 3, TURNS)
Eventos#
front_optical.object_detected()#
front_optical.object_detected(callback)
is the same command as eye.object_detected(callback)
.
The command only uses Axel’s Optical Sensor front_optical
to replace eye
in the standard command.
front_optical.object_lost()#
front_optical.object_lost(callback)
is the same command as eye.object_lost(callback)
.
The command only uses Axel’s Optical Sensor front_optical
to replace eye
in the standard command.
Detección#
motor.is_done()#
The motor.is_done()
command is used to return a True or False value if the selected motor has completed its movement.
To use this command, replace motor
with the desired motor or motor group, for example: arm_motor.is_done()
.
Objetos |
Descripción |
---|---|
|
Sube o baja el brazo de Axel. |
|
Sube o baja el empujador para empujar los anillos fuera del brazo. |
Devuelve: Esto devuelve un valor booleano.
motor.is_spinning()#
The motor.is_spinning()
command is used to return a True or False value if the selected motor is moving.
To use this command, replace motor
with the desired motor or motor group, for example: arm_motor.is_spinning()
.
Objetos |
Descripción |
---|---|
|
Sube o baja el brazo de Axel. |
|
Sube o baja el empujador para empujar los anillos fuera del brazo. |
Devuelve: Esto devuelve un valor booleano.
motor.position()#
The motor.position(units)
command is used to return the current rotational position of the selected motor.
To use this command, replace motor
with the desired motor or motor group, for example: arm_motor.position(units)
.
Objetos |
Descripción |
---|---|
|
Sube o baja el brazo de Axel. |
|
Sube o baja el empujador para empujar los anillos fuera del brazo. |
Parámetros |
Descripción |
---|---|
unidades |
The unit of the returned value, |
Devuelve: Esto devuelve un valor numérico.
# Make the raised Arm the new 0 degrees position.
arm_motor.spin_for(FORWARD, 400, DEGREES)
arm_motor.set_position(0, DEGREES)
brain.screen.print(arm_motor.position(DEGREES))
motor.velocity()#
The motor.velocity(units)
command is used to return the current velocity of the selected motor.
To use this command, replace motor
with the desired motor or motor group, for example: arm_motor.velocity(units)
.
Objetos |
Descripción |
---|---|
|
Sube o baja el brazo de Axel. |
|
Sube o baja el empujador para empujar los anillos fuera del brazo. |
Parámetros |
Descripción |
---|---|
unidades |
The unit of the motor’s velocity, |
Devuelve: Esto devuelve un valor numérico.
# Lift the Arm up before moving.
arm_motor.set_velocity(100, PERCENT)
arm_motor.spin_to_position(400, DEGREES)
ai_objects = ai_vision.take_snapshot()#
The ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
statement captures the current image from the AI Vision Sensor and analyzes it for all AI Classifications. Identified classifications are stored in an array. While ai_objects
is the default array name used in VEXcode toolbox commands, you can customize this name as needed.
Importante: Deberás levantar el brazo del robot para que el sensor de visión de IA pueda obtener una instantánea clara del patio de juegos.
Todos los comandos posteriores del sensor de visión de IA se basan en los datos de la instantánea más reciente. Para garantizar que trabaja con la información más actualizada, es importante tomar nuevas instantáneas periódicamente. Cada nueva instantánea actualiza los datos disponibles para todos los comandos del sensor de visión de IA, lo que les permite procesar la información visual más reciente del entorno del sensor.
Before attempting to access data stored from the last snapshot, you should always check if your array is not empty. You can use the len()
function to verify this. If len()
returns 0
, the array is empty and contains no data from the last snapshot.
if len(ai_objects) is not 0:
Devuelve: Esta declaración devuelve una matriz de clasificaciones de IA detectadas y sus propiedades, ordenadas por su área de mayor a menor.
En este ejemplo, se tomará una instantánea y las coordenadas X e Y del centro de la clasificación de IA más grande se imprimirán en la consola de impresión repetidamente.
# Lift the Arm to not block the AI Vision Sensor's field of view.
arm_motor.spin_for(FORWARD, 350, DEGREES)
while True:
brain.screen.clear_screen()
# Take a snapshot with the AI Vision Sensor with the specified
# signature and store the object data into a variable
# "ai_objects".
ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
# Use the len() function to check if the array is empty before
# pulling any data from the array.
if len(ai_objects) is not 0:
# If yes, print the data of the largest AI Classification.
brain.screen.print("Center X: ", ai_objects[0].centerX)
brain.screen.next_row()
brain.screen.print("Center Y: ", ai_objects[0].centerY)
brain.screen.next_row()
else:
brain.screen.print("No object detected.")
# Take a new snapshot every 0.2 seconds.
wait(0.2, SECONDS)
ai_objects[0].id#
The ai_objects.id
property returns the specified index’s id.
Primero se debe crear una matriz utilizando la declaración ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
antes de poder usar esta propiedad.
Tras crear una matriz de clasificaciones de IA, se puede acceder a objetos específicos y sus propiedades mediante su índice. La matriz se ordena por área del objeto, de mayor a menor, con índices que empiezan en 0. Esto significa que ai_objects[0] representa el objeto detectado de mayor tamaño, mientras que el índice más alto representa el de menor tamaño.
Each object has an id
property that identifies its type. The possible id values are:
Mobile Goal:
0
Red Ring:
1
Blue Ring:
2
También puedes comparar la identificación directamente con estas constantes predefinidas:
Mobile Goal:
GameElements.MOBILE_GOAL
Red Ring:
GameElements.RED_RING
Blue Ring:
GameElements.BLUE_RING
Todos los comandos posteriores del sensor de visión de IA se basan en los datos de la instantánea más reciente. Para garantizar que trabaja con la información más actualizada, es importante tomar nuevas instantáneas periódicamente. Cada nueva instantánea actualiza los datos disponibles para todos los comandos del sensor de visión de IA, lo que les permite procesar la información visual más reciente del entorno del sensor.
Before attempting to access data stored from the last snapshot, you should always check if your array is not empty. You can use the len()
function to verify this. If len()
returns 0
, the array is empty and contains no data from the last snapshot.
if len(ai_objects) is not 0:
Devuelve: Esta propiedad devuelve el id del índice especificado como un entero.
En este ejemplo, el sensor de visión de IA tomará una instantánea y luego verificará si la clasificación de IA más grande detectada es un objetivo móvil.
# Lift the Arm by 350 degrees to not block the AI Vision
# Sensor's field of view.
arm_motor.spin_for(FORWARD, 350, DEGREES)
# Take a snapshot with the AI Vision Sensor with the
# specified signature and store the object data into
# a variable "ai_objects".
ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
# Use the len() function to check if the array is empty
# before pulling any data from the array.
if len(ai_objects) is not 0:
# If the array is not empty, check if the largest
# AI Classification is a Mobile Goal.
if ai_objects[0].id == GameElements.MOBILE_GOAL:
brain.screen.print("This is a Mobile Goal.")
else:
brain.screen.print("This is not a Mobile Goal.")
ai_objects[0].centerX#
The ai_objects.centerX
property returns the specified index’s X coordinate of the AI Classification’s exact center.
Primero se debe crear una matriz utilizando la declaración ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
antes de poder usar esta propiedad.
Tras crear una matriz de clasificaciones de IA, se puede acceder a objetos específicos y sus propiedades mediante su índice. La matriz se ordena por área del objeto, de mayor a menor, con índices que empiezan en 0. Esto significa que ai_objects[0] representa el objeto detectado de mayor tamaño, mientras que el índice más alto representa el de menor tamaño.
Las dimensiones de la pantalla del sensor de visión de IA son 320 píxeles de ancho y 240 píxeles de alto y el centro preciso de la pantalla del sensor de visión de IA corresponde a las coordenadas (160, 120).
Todos los comandos posteriores del sensor de visión de IA se basan en los datos de la instantánea más reciente. Para garantizar que trabaja con la información más actualizada, es importante tomar nuevas instantáneas periódicamente. Cada nueva instantánea actualiza los datos disponibles para todos los comandos del sensor de visión de IA, lo que les permite procesar la información visual más reciente del entorno del sensor.
Before attempting to access data stored from the last snapshot, you should always check if your array is not empty. You can use the len()
function to verify this. If len()
returns 0
, the array is empty and contains no data from the last snapshot.
if len(ai_objects) is not 0:
Devuelve: Esta propiedad devuelve la coordenada X del centro del índice especificado como un entero.
Este ejemplo tomará una instantánea e imprimirá la coordenada X central de la clasificación IA más grande.
# Lift the Arm by 350 degrees to not block the AI Vision
# Sensor's field of view.
arm_motor.spin_for(FORWARD, 350, DEGREES)
# Take a snapshot with the AI Vision Sensor with the
# specified signature and store the object data into a
# variable "ai_objects".
ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
# Use the len() function to check if the array is empty
# before pulling any data from the array.
if len(ai_objects) is not 0:
brain.screen.print(ai_objects[0].centerX)
ai_objects[0].centerY#
The ai_objects.id
property returns the specified index’s Y coordinate of the AI Classification’s exact center.
Primero se debe crear una matriz utilizando la declaración ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
antes de poder usar esta propiedad.
Tras crear una matriz de clasificaciones de IA, se puede acceder a objetos específicos y sus propiedades mediante su índice. La matriz se ordena por área del objeto, de mayor a menor, con índices que empiezan en 0. Esto significa que ai_objects[0] representa el objeto detectado de mayor tamaño, mientras que el índice más alto representa el de menor tamaño.
Las dimensiones de la pantalla del sensor de visión de IA son 320 píxeles de ancho y 240 píxeles de alto y el centro preciso de la pantalla del sensor de visión de IA corresponde a las coordenadas (160, 120).
Todos los comandos posteriores del sensor de visión de IA se basan en los datos de la instantánea más reciente. Para garantizar que trabaja con la información más actualizada, es importante tomar nuevas instantáneas periódicamente. Cada nueva instantánea actualiza los datos disponibles para todos los comandos del sensor de visión de IA, lo que les permite procesar la información visual más reciente del entorno del sensor.
Before attempting to access data stored from the last snapshot, you should always check if your array is not empty. You can use the len()
function to verify this. If len()
returns 0
, the array is empty and contains no data from the last snapshot.
if len(ai_objects) is not 0:
Devuelve: Esta propiedad devuelve la coordenada Y del centro del índice especificado como un entero.
Este ejemplo tomará una instantánea e imprimirá la coordenada Y central de la clasificación IA más grande.
# Lift the Arm by 350 degrees to not block the AI Vision
# Sensor's field of view.
arm_motor.spin_for(FORWARD, 350, DEGREES)
# Take a snapshot with the AI Vision Sensor with the
# specified signature and store the object data into a
# variable "ai_objects".
ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
# Use the len() function to check if the array is empty
# before pulling any data from the array.
if len(ai_objects) is not 0:
brain.screen.print(ai_objects[0].centerY)
ai_objects[0].originX#
The ai_objects.id
property returns the specified index’s X coordinate of the AI Classification’s top-leftmost corner.
Primero se debe crear una matriz utilizando la declaración ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
antes de poder usar esta propiedad.
Tras crear una matriz de clasificaciones de IA, se puede acceder a objetos específicos y sus propiedades mediante su índice. La matriz se ordena por área del objeto, de mayor a menor, con índices que empiezan en 0. Esto significa que ai_objects[0] representa el objeto detectado de mayor tamaño, mientras que el índice más alto representa el de menor tamaño.
Las dimensiones de la pantalla del sensor de visión de IA son 320 píxeles de ancho y 240 píxeles de alto y el centro preciso de la pantalla del sensor de visión de IA corresponde a las coordenadas (160, 120).
Todos los comandos posteriores del sensor de visión de IA se basan en los datos de la instantánea más reciente. Para garantizar que trabaja con la información más actualizada, es importante tomar nuevas instantáneas periódicamente. Cada nueva instantánea actualiza los datos disponibles para todos los comandos del sensor de visión de IA, lo que les permite procesar la información visual más reciente del entorno del sensor.
Before attempting to access data stored from the last snapshot, you should always check if your array is not empty. You can use the len()
function to verify this. If len()
returns 0
, the array is empty and contains no data from the last snapshot.
if len(ai_objects) is not 0:
Devuelve: Esta propiedad devuelve la coordenada X de origen del índice especificado como un entero.
Este ejemplo tomará una instantánea e imprimirá la coordenada X de origen de la clasificación IA más grande.
# Lift the Arm by 350 degrees to not block the AI Vision
# Sensor's field of view.
arm_motor.spin_for(FORWARD, 350, DEGREES)
# Take a snapshot with the AI Vision Sensor with the
# specified signature and store the object data into
# a variable "ai_objects".
ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
# Use the len() function to check if the array is
# empty before pulling any data from the array.
if len(ai_objects) is not 0:
brain.screen.print(ai_objects[0].originX)
ai_objects[0].originY#
The ai_objects.id
property returns the specified index’s Y coordinate of the AI Classification’s top-leftmost corner.
Primero se debe crear una matriz utilizando la declaración ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
antes de poder usar esta propiedad.
Tras crear una matriz de clasificaciones de IA, se puede acceder a objetos específicos y sus propiedades mediante su índice. La matriz se ordena por área del objeto, de mayor a menor, con índices que empiezan en 0. Esto significa que ai_objects[0] representa el objeto detectado de mayor tamaño, mientras que el índice más alto representa el de menor tamaño.
Las dimensiones de la pantalla del sensor de visión de IA son 320 píxeles de ancho y 240 píxeles de alto y el centro preciso de la pantalla del sensor de visión de IA corresponde a las coordenadas (160, 120).
Todos los comandos posteriores del sensor de visión de IA se basan en los datos de la instantánea más reciente. Para garantizar que trabaja con la información más actualizada, es importante tomar nuevas instantáneas periódicamente. Cada nueva instantánea actualiza los datos disponibles para todos los comandos del sensor de visión de IA, lo que les permite procesar la información visual más reciente del entorno del sensor.
Before attempting to access data stored from the last snapshot, you should always check if your array is not empty. You can use the len()
function to verify this. If len()
returns 0
, the array is empty and contains no data from the last snapshot.
if len(ai_objects) is not 0:
Devuelve: Esta propiedad devuelve la coordenada Y de origen del índice especificado como un entero.
Este ejemplo tomará una instantánea e imprimirá la coordenada Y de origen de la clasificación IA más grande.
# Lift the Arm by 350 degrees to not block the AI Vision
# Sensor's field of view.
arm_motor.spin_for(FORWARD, 350, DEGREES)
# Take a snapshot with the AI Vision Sensor with the
# specified signature and store the object data into
# a variable "ai_objects".
ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
# Use the len() function to check if the array is
# empty before pulling any data from the array.
if len(ai_objects) is not 0:
brain.screen.print(ai_objects[0].originY)
ai_objects[0].width#
The ai_objects.id
property returns the specified index’s width in pixels.
Primero se debe crear una matriz utilizando la declaración ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
antes de poder usar esta propiedad.
Tras crear una matriz de clasificaciones de IA, se puede acceder a objetos específicos y sus propiedades mediante su índice. La matriz se ordena por área del objeto, de mayor a menor, con índices que empiezan en 0. Esto significa que ai_objects[0] representa el objeto detectado de mayor tamaño, mientras que el índice más alto representa el de menor tamaño.
Todos los comandos posteriores del sensor de visión de IA se basan en los datos de la instantánea más reciente. Para garantizar que trabaja con la información más actualizada, es importante tomar nuevas instantáneas periódicamente. Cada nueva instantánea actualiza los datos disponibles para todos los comandos del sensor de visión de IA, lo que les permite procesar la información visual más reciente del entorno del sensor.
Before attempting to access data stored from the last snapshot, you should always check if your array is not empty. You can use the len()
function to verify this. If len()
returns 0
, the array is empty and contains no data from the last snapshot.
if len(ai_objects) is not 0:
Devuelve: Esta propiedad devuelve el ancho del índice especificado como un entero.
Este ejemplo tomará una instantánea e imprimirá el segundo ancho de clasificación de IA más grande.
# Lift the Arm by 350 degrees to not block the AI Vision
# Sensor's field of view.
arm_motor.spin_for(FORWARD, 350, DEGREES)
# Take a snapshot with the AI Vision Sensor with the
# specified signature and store the object data into a
# variable "ai_objects".
ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
# Use the len() function to check if the array is empty
# before pulling any data from the array.
if len(ai_objects) is not 0:
brain.screen.print(ai_objects[0].width)
ai_objects[0].height#
The ai_objects.id
property returns the specified index’s height in pixels.
Primero se debe crear una matriz utilizando la declaración ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
antes de poder usar esta propiedad.
Tras crear una matriz de clasificaciones de IA, se puede acceder a objetos específicos y sus propiedades mediante su índice. La matriz se ordena por área del objeto, de mayor a menor, con índices que empiezan en 0. Esto significa que ai_objects[0] representa el objeto detectado de mayor tamaño, mientras que el índice más alto representa el de menor tamaño.
Todos los comandos posteriores del sensor de visión de IA se basan en los datos de la instantánea más reciente. Para garantizar que trabaja con la información más actualizada, es importante tomar nuevas instantáneas periódicamente. Cada nueva instantánea actualiza los datos disponibles para todos los comandos del sensor de visión de IA, lo que les permite procesar la información visual más reciente del entorno del sensor.
Before attempting to access data stored from the last snapshot, you should always check if your array is not empty. You can use the len()
function to verify this. If len()
returns 0
, the array is empty and contains no data from the last snapshot.
if len(ai_objects) is not 0:
Devuelve: Esta propiedad devuelve el ancho del índice especificado como un entero.
Este ejemplo tomará una instantánea e imprimirá la segunda altura de clasificación de IA más grande.
# Lift the Arm by 350 degrees to not block the AI Vision
# Sensor's field of view.
arm_motor.spin_for(FORWARD, 350, DEGREES)
# Take a snapshot with the AI Vision Sensor with the
# specified signature and store the object data into a
# variable "ai_objects".
ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
# Use the len() function to check if the array is empty
# before pulling any data from the array.
if len(ai_objects) is not 0:
brain.screen.print(ai_objects[0].height)
front_optical.is_near_object()#
The front_optical.is_near_object()
command is used to report a Boolean value if the Optical Sensor is close enough to an object to detect a color.
Devuelve: Esto informa un valor booleano.
# Print if the Front Optical Sensor is detecting an object.
brain.screen.print(front_optical.is_near_object())
front_optical.color()#
The front_optical.color()
command is used to return the color detected by an Optical Sensor.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
Los siguientes colores se pueden utilizar como comparación con el color detectado por un sensor óptico:
ROJO
VERDE
AZUL
AMARILLO
NARANJA
PÚRPURA
CIAN
Devuelve: Esto devuelve el nombre del color detectado como una cadena.
# Identify the color of the ring on the Arm.
brain.screen.print(front_optical.color())
front_optical.brightness()#
The front_optical.brightness()
command is used to report the amount of light detected by an Optical Sensor within a range of 0 to 100 percent.
Devuelve: Esto devuelve un valor numérico.
# Lift the Arm by 350 degrees to not block the Optical Sensor.
arm_motor.spin_for(FORWARD, 350, DEGREES)
brain.screen.print(front_optical.brightness())
front_optical.hue()#
The front_optical.brightness()
command is used to report the hue of the object detected by an Optical Sensor within a range of 0 to 359. This number represents the location of the detected color on a color wheel.
Devuelve: Esto devuelve un valor numérico.
# Print the hue of the ring on the Arm.
brain.screen.print("Hue: ", optical.hue())
rotation.set_position()#
The pusher_rotation.set_position(value, units)
command is used to sets a Rotation Sensor’s position to the given value.
Parámetros |
Descripción |
---|---|
valor |
El valor para establecer la posición del sensor de rotación. |
unidades |
The unit of the set position, |
Devoluciones: Ninguna.
rotation.angle()#
The pusher_rotation.angle(value, units)
command returns the Pusher Motor’s current angle of rotation in degrees.
Devuelve: Un número entero.
rotation.position()#
The pusher_rotation.position(units)
command returns the Pusher Motor’s current position.
Parámetros |
Descripción |
---|---|
unidades |
The unit of the set position, |
Devuelve: Un número entero.
gps.x_position()#
gps.x_position(units)
returns the X positional offset of a GPS (Game Positioning System™) Sensor or defined origin point from the center of a field.
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 offset value, |
Devuelve: Esto devuelve un valor numérico.
def main():
# Print the current X positional offset of the robot.
brain.screen.print(gps.x_position(MM))
gps.y_position()#
gps.y_position(units)
returns the Y positional offset of a GPS (Game Positioning System™) Sensor or defined origin point from the center of a field.
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 offset value, |
Devuelve: Esto devuelve un valor numérico.
def main():
# Print the current Y positional offset of the robot.
brain.screen.print(gps.y_position(MM))
gps.heading()#
The gps.heading()
command is used to report the heading that a robot is currently facing based on a GPS Sensor’s readings from the VEX GPS Field Code.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
Devuelve: Esto devuelve un valor numérico.
def main():
# Print the current heading of the robot.
brain.screen.print(gps.heading())