Consola#

Introducción#

La consola VEXcode CTE se muestra en la ventana Monitor dentro de VEXcode. Permite visualizar texto, recibir datos de entrada, supervisar variables y sensores, y formatear datos impresos en tiempo real.

Note: The Console is only available when a Brain has been constructed with brain = Brain(), as all Console output is driven through methods on the Brain instance.

This page uses brain as the example Brain name. Replace it with your own configured name as needed.

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

Imprimir — Interactuar con la consola.

  • print — Print text to the console.

  • new_line — Move the console cursor position at the start of the next row down.

  • clear — Clear all text from the console.

  • set_print_color — Set the color text will display in for the console.

Monitor: supervise el valor de un sensor o variable durante un proyecto en la pestaña Monitor de VEXcode.

Imprimir#

print#

print prints values in the console using the current cursor position.

Usage:
brain.print(value, end)

Parámetros

Descripción

value

La cadena (entre comillas) o los números que se imprimirán en la consola.

end

Optional. By default, Python will add a new line after each print command. To print multiple values to the same line, use the end parameter.

# Print a greeting
brain.print("Hello there!")

new_line#

new_line moves the cursor to the start of the row below the current position in the console.

Usage:
brain.new_line()

Parámetros

Descripción

Este método no tiene parámetros.

# Print on two lines
brain.print("Line 1")
brain.new_line()
brain.print("Line 2")

set_print_color#

set_print_color sets the color used when printing text to the console.

Usage:
brain.set_print_color(color)

Parámetros

Descripción

color

The color to print text with:

  • BLACK
  • BLUE
  • GREEN
  • RED

# Print in different colors
brain.print("Default text color")
brain.new_line()
brain.set_print_color(RED)
brain.print("Red text color")

clear#

clear clears all text from the console.

Usage:
brain.clear()

Parámetros

Descripción

Este método no tiene parámetros.

# Clear the console after printing
brain.print("This will disappear...")
wait(2, SECONDS)
brain.clear()

Monitor#

monitor_variable#

monitor_variable adds a predefined variable to be monitored in the Monitor tab of VEXcode.

Usage:
monitor_variable(“variable”)

Parámetros

Descripción

variable

El nombre de la variable predefinida que se va a monitorizar, especificado como una cadena de texto.

# Monitor the amount of loops
global loops
monitor_variable("loops")

# Move in a square 3 times
for loops in range(12):
    arm.move_inc(100, 0, 0)
    arm.move_inc(0, 100, 0)
    arm.move_inc(-100, 0, 0)
    arm.move_inc(0, 100, 0)

actions = 0
# Monitor the amount of loops and actions
global loops, actions
monitor_variable("loops", "actions")

# Move in a square 3 times
for loops in range(12):
    arm.move_inc(100, 0, 0)
    arm.move_inc(0, 100, 0)
    arm.move_inc(-100, 0, 0)
    arm.move_inc(0, 100, 0)
    actions = actions + 4

monitor_sensor#

monitor_sensor adds a sensor value to be monitored in the Monitor tab of VEXcode.

Usage:
monitor_sensor(“sensor”)

Parámetros

Descripción

sensor

Which sensor to monitor, given as a string:

  • arm.is_done
  • arm.get_x
  • arm.get_y
  • arm.get_z
  • arm.get_pitch
  • arm.get_roll
  • arm.get_yaw
  • arm.can_arm_reach_to
  • arm.can_arm_reach_inc
  • arm.can_end_effector_reach_to
  • arm.get_end_effector_reach_inc

# Monitor the x-axis in the Monitor tab
monitor_sensor("arm.get_x")
arm.move_to(40, 140, 210)

# Monitor the x-, y-, and z-axes in the Monitor tab
monitor_sensor("arm.get_x", "arm.get_y", "arm.get_z")
arm.move_inc(100, 0, 0)
arm.move_inc(0, 100, 0)
arm.move_inc(-100, 0, 0)
arm.move_inc(0, 100, 0)