Python específico para robots#
El VR Rover tiene acceso a los comandos estándar de VR Drivetrain, Eventos, Control, Variables y Funciones.
Transmisión#
tren motriz.drive_to()#
The drivetrain.drive_to(object, wait)
command is used to drive the VR Rover the distance between it and a specified object.
This is can be a non-waiting or waiting command depending on if the wait
parameter is used.
Parámetros |
Descripción |
---|---|
objeto |
The object that the VR Rover will drive to: |
esperar |
Optional. The wait parameter determines whether the command will block subsequent commands ( |
If a mineral or enemy is not detected in the VR Rover’s visual range when the drivetrain.drive_to()
command is called, the robot will not drive.
However, when the BASE
parameter is used, the robot will drive forward the amount of distance between it and the base.
Devoluciones: Ninguna.
def main():
# Drive the VR Rover to the nearest mineral.
drivetrain.drive_to(MINERALS)
tren motriz.go_to()#
The drivetrain.go_to(object, wait)
command is used to turn and drive the VR Rover to a specified object.
This is can be a non-waiting or waiting command depending on if the wait
parameter is used.
Parámetros |
Descripción |
---|---|
objeto |
The object that the VR Rover will turn and drive to: |
esperar |
Optional. The wait parameter determines whether the command will block subsequent commands ( |
If a mineral or enemy is not detected in the VR Rover’s visual range when the drivetrain.go_to()
command is called, the robot will not drive.
However, when the BASE
parameter is used, the robot will always turn towards the base and then drive towards it.
Devoluciones: Ninguna.
def main():
# Turn the VR Rover towards the base and drive to it.
drivetrain.go_to(BASE)
tren motriz.turn_to()#
The drivetrain.turn_to(object, wait)
command is used to turn the VR Rover towards a specified object.
This is can be a non-waiting or waiting command depending on if the wait
parameter is used.
Parámetros |
Descripción |
---|---|
objeto |
The object that the VR Rover will turn to: |
esperar |
Optional. The wait parameter determines whether the command will block subsequent commands ( |
If a mineral or enemy is not detected in the VR Rover’s visual range when the drivetrain.drive_to()
command is called, the robot will not drive.
However, when the BASE
parameter is used, the robot will turn to face the base.
Devoluciones: Ninguna.
def main():
# Turn the VR Rover towards the nearest mineral.
drivetrain.turn_to(MINERALS)
Comportamiento#
rover.pickup()#
The rover.pickup(object)
command is used to pick up minerals in the playground.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
Parámetros |
Descripción |
---|---|
objeto |
The object that the VR Rover can pick up: |
Devoluciones: Ninguna.
def main():
# Turn and drive the VR Rover to the nearest minerals.
drivetrain.go_to(MINERALS)
# Pick up the minerals.
rover.pickup(MINERALS)
rover.drop()#
The rover.drop(object)
command is used to drop minerals in the playground.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
Parámetros |
Descripción |
---|---|
objeto |
The object that the VR Rover can drop: |
Devoluciones: Ninguna.
def main():
# Pick up the minerals.
rover.pickup(MINERALS)
# Drive in reverse for 200 millimeters.
drivetrain.drive_for(REVERSE, 200, MM)
# Drop the minerals.
rover.drop(MINERALS)
rover.use()#
The rover.use(object)
command is used to consume minerals in its storage to recharge its energy level and gain XP. The minerals must be on the ground to be consumed.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
Parámetros |
Descripción |
---|---|
objeto |
The object that the VR Rover can consume: |
Devoluciones: Ninguna.
def main():
# Turn and drive the VR Rover to the nearest minerals.
drivetrain.go_to(MINERALS)
# Consume the minerals.
rover.use(MINERALS)
rover.absorb_radiación()#
The rover.absorb_radiation(object)
command is used to absorb radiation from enemies in the Rover Rescue playground.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
Parámetros |
Descripción |
---|---|
objeto |
The object that the VR Rover can absorb radiation from: |
Devoluciones: Ninguna.
def main():
# Turn and drive the VR Rover to the nearest enemy.
drivetrain.go_to(ENEMY)
# Absorb radiation from the enemy once.
rover.absorb_radiation(ENEMY)
rover.standby()#
The rover.standby(percent)
command is used to put the VR Rover into standby mode until the specified battery threshold is reached.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
Cuando esté en modo de espera, el VR Rover utilizará su batería más lentamente, pero el contador de Número de días de supervivencia aumentará a un ritmo mayor.
Una vez que se alcanza el umbral del nivel de batería, el VR Rover saldrá del modo de espera, volverá a consumir su batería y aumentará el contador de Número de días de supervivencia al ritmo normal.
Si el umbral superado es igual o superior al nivel actual de la batería, el VR Rover no entrará en modo de espera.
Parámetros |
Descripción |
---|---|
por ciento |
The battery threshold that the VR Rover will exit standby mode at, from |
Devoluciones: Ninguna.
def main():
# Go into standby mode until battery reaches 35%.
rover.standby(35)
Aspecto#
El VR Rover no tiene acceso al VR Pen, pero aún puede imprimir en su consola de monitor.
Eventos#
Cuando Rover está bajo ataque#
The rover.on_under_attack(callback)
command runs the callback function when the VR Rover takes damage from an enemy.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
Devoluciones: Ninguna.
# Define a new function for when the rover is under attack.
def under_attack():
# The rover will print that it is under attack in the Print Console.
brain.print("The rover is under attack!")
def main():
# Register the under_attack() function to trigger
# when the rover is under attack.
rover.on_under_attack(under_attack)
# Wait .15 seconds to allow the function time to register in the event.
wait(.15, SECONDS)
Cuando Rover sube de nivel#
The rover.on_level_up(callback)
command runs the callback function when the VR Rover moves from one level to the next.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
Devoluciones: Ninguna.
# Define a new function for when the rover levels up.
def level_up():
# The rover will print that it leveled up in the Print Console.
brain.print("The rover leveled up!")
def main():
# Register the level_up() function to trigger
# when the rover levels up.
rover.on_level_up(level_up)
# Wait .15 seconds to allow the function time to register in the event.
wait(.15, SECONDS)
Detección#
El VR Rover tiene acceso a los comandos estándar de cerebro, tren motriz y detección de distancia.
rover.batería()#
The rover.battery()
command reports the current battery level of the VR Rover.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
Devuelve: Esto informa un valor numérico.
def main():
# Print the current battery level.
brain.print(rover.battery())
rover.minerales_almacenados()#
The rover.minerals_stored()
command reports the current amount of minerals the VR Rover has in its storage.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
Devuelve: Esto informa un valor numérico.
def main():
# Print the current amount of minerals in the VR Rover's storage.
brain.print(rover.minerals_stored())
rover.level()#
The rover.level()
command reports the current level of the VR Rover.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
Devuelve: Esto informa un valor numérico.
def main():
# Print the current level of the VR Rover.
brain.print(rover.level())
rover.exp()#
The rover.exp()
command reports the number of Experience Points (XP) that the VR Rover has at the current level.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
Devuelve: Esto informa un valor numérico.
def main():
# Print the current amount of XP that the VR Rover has.
brain.print(rover.exp())
rover.capacidad_de_almacenamiento()#
The rover.storage_capacity()
command reports the carrying capacity of the VR Rover.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
Devuelve: Esto informa un valor numérico.
def main():
# Print the carrying capacity of the VR Rover.
brain.print(rover.storage_capacity())
rover.bajo_ataque()#
The rover.under_attack()
command reports whether the VR Rover is under attack from an enemy.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
Devuelve: Esto informa un valor booleano.
def main():
# Continuously check the if statement every 5 milliseconds.
while True:
wait(5, MSEC)
# Check if the rover has come under attack.
if rover.under_attack() = True:
# Print a message to the Print Console.
brain.print("The rover is under attack!")
rover.detects()#
The rover.detects(object)
command reports whether the VR Rover detects an enemy or minerals in its smelling range.
Parámetros |
Descripción |
---|---|
objeto |
The Game Element to detect: |
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
El radio de detección del VR Rover es de 800 milímetros (MM). Esto se puede ver en el minimapa del Patio de Juegos, indicado por el círculo amarillo alrededor del VR Rover.
Devuelve: Esto informa un valor booleano.
def main():
# Continuously check the if statement every 5 milliseconds.
while True:
wait(5, MSEC)
# Check if the rover has detected any minerals.
if rover.detects(MINERALS) = True:
# Turn and drive to the closest minerals.
drivetrain.go_to(MINERALS)
# Pick up the minerals.
rover.pickup(MINERALS)
rover.ve()#
The rover.sees(object)
command reports whether the VR Rover sees detectable objects in its vision range.
Parámetros |
Descripción |
---|---|
objeto |
The Game Element to see: |
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
El rango de visión del VR Rover es de 1000 milímetros (mm) desde el Rover y dentro de su campo de visión.
El campo de visión del VR Rover es de 40 grados. Esto se puede ver en el minimapa del Patio de Juegos, indicado por el cono gris translúcido en la parte frontal del VR Rover.
Devuelve: Esto informa un valor booleano.
def main():
# Continuously check the if statement every 5 milliseconds.
while True:
wait(5, MSEC)
# Check if the rover can see any minerals.
if rover.sees(MINERALS) = True:
# Turn and drive to the closest minerals.
drivetrain.go_to(MINERALS)
# Pick up the minerals.
rover.pickup(MINERALS)
rover.ángulo()#
The rover.angle(object)
command reports the direction in degrees of the closest specified object within the VR Rover’s vision range (1000 millimeters) and within its field of view.
Parámetros |
Descripción |
---|---|
objeto |
The Game Element to report the direction of: |
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
El rango de visión del VR Rover es de 1000 milímetros (mm) desde el Rover y dentro de su campo de visión.
El campo de visión del VR Rover es de 40 grados. Esto se puede ver en el minimapa del Patio de Juegos, indicado por el cono gris translúcido en la parte frontal del VR Rover.
Devuelve: Esto informa un valor numérico.
def main():
# Print the direction in degrees of the closest minerals.
brain.print(rover.angle(MINERALS))
rover.get_distance()#
The rover.get_distance(object, units)
command reports the distance from the VR Rover to minerals, enemies, obstacles, hazards, or the base if they’re within its vision range.
Parámetros |
Descripción |
---|---|
objeto |
Game Element to report distances from VR Rover: |
unidades |
The units to report the distance as: Millimeters ( |
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
El rango de visión del VR Rover es de 1000 milímetros (mm) desde el Rover y dentro de su campo de visión.
El campo de visión del VR Rover es de 40 grados. Esto se puede ver en el minimapa del Patio de Juegos, indicado por el cono gris translúcido en la parte frontal del VR Rover.
If BASE
is passed as the object
parameter, the VR Rover will always report the distance, even if the Base is not in view.
If OBSTACLE
or HAZARD
is passed as the object
parameter, but no obstacle or hazard is within view, the rover.get_distance()
command will return 1000
millimeters or 39.37
inches.
Devuelve: Esto informa un valor numérico.
def main():
# Print the distance between the VR Rover and the base.
brain.print(rover.get_distance(BASE))
rover.ubicación()#
The rover.location(object, axis, units)
command reports the X or Y coordinate location of minerals, enemies, obstacles, hazards, or the base if they’re within its vision range.
Parámetros |
Descripción |
---|---|
objeto |
Game Element to report locations of: |
eje |
The axis to return values on: |
unidades |
The units to report the distance as: Millimeters ( |
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
If BASE
is passed as the object
parameter, the VR Rover will always report the location, even if the Base is not in view.
Devuelve: Esto informa un valor numérico.
def main():
# Print the current location of the VR Rover on the Y axis in millimeters.
brain.print(rover.location(ROVER, Y, MM))
rover.nivel_enemigo()#
The rover.enemy_level()
command reports the level of the closest enemy detected in the VR Rover’s vision.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
El radio de detección del VR Rover es de 800 milímetros (MM). Esto se puede ver en el minimapa del Patio de Juegos, indicado por el círculo amarillo alrededor del VR Rover.
If no enemy is detected, rover.enemy_level()
will return 0
.
Devuelve: Esto informa un valor numérico.
def main():
# Print the level of the closest detected enemy.
brain.print(rover.enemy_level())
rover.radiación_enemiga()#
The rover.enemy_radiation()
command reports the radiation of the closest enemy detected in the VR Rover’s vision.
Este es un comando sin espera y permite que cualquier comando posterior se ejecute sin demora.
El radio de detección del VR Rover es de 800 milímetros (MM). Esto se puede ver en el minimapa del Patio de Juegos, indicado por el círculo amarillo alrededor del VR Rover.
If no enemy is detected, rover.enemy_radiation()
will return 0
.
Devuelve: Esto informa un valor numérico.
def main():
# Print the radiation of the closest detected enemy.
brain.print(rover.enemy_radiation())