Console#

Introduction#

The VEXcode CTE Console is displayed in the Monitor window within VEXcode. It allows you to display text, receive input, monitor variables and sensors, and format printed data in real time.

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.

Below is a list of all methods:

Print — Interact with the console.

  • 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 — Monitor a sensor’s or variable’s value during a project in VEXcode’s Monitor tab.

Print#

print#

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

Usage:
brain.print(value, end)

Parameters

Description

value

The string (in quotations) or numbers to print to the Console.

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

Parameters

Description

This method has no parameters.

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

Parameters

Description

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

Parameters

Description

This method has no parameters.

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

Parameters

Description

variable

The name of the predefined variable to monitor, given as a string.

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

Parameters

Description

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)