Variable and sensor monitoring available in the VEXcode VR Monitor Console provides important visual cues that allow the user to see what is happening in a Python project in real time. The Monitor Console allows users to make a visual connection between the project and the actions of the VR Robot. Monitoring sensor and variable values in the Monitor Console allows the user to view real-time reports of a specific value (or multiple values) in a project.
How to Use the Monitor Console
To open the Monitor Window and view the Monitor Console, select the Monitor icon next to the Help.
The Monitor Console reports Sensor and Variable values.
Using the Monitor Sensor Command
Sensor values can be added using the Monitor Sensor command. Add the identifier for the sensor as a string parameter.
The Monitor Sensor command accepts the following string identifiers.
This list of accepted string identifiers can also be found in the Help for the Monitor Sensor command.
Add the correct string identifier as a parameter in the Monitor Sensor command. For example, add the string "distance.get_distance" to report the distance sensor reading in the Monitor Console.
The sensor value will appear in the Monitor Console when the project is started.
Monitor multiple sensor values by using commas to separate the string identifiers.
Using the Monitor Variable Command
Variables can be added and removed from the Monitor Console using the Monitor Variable command. Define the variable as global, then assign a value. Add the variable as a string parameter.
To create a global variable, add the keyword "global" before the variable name.
Assign an initial value to the variable.
To add a variable to the Monitor Console, add the variable name as a string variable in the Monitor Variables command. A string variable is indicated with " " around the name of the variable.
The variable value will appear when the project is started.
Lists can also be added to the Monitor Console. Before being added to the Monitor Console, lists and 2D lists must be defined.
To create a new list or 2D list, add the keyword "global" before the list name.
Type the values in square brackets to add values to a list.
To add a list to the Monitor Console, add the list name as a string variable in the Monitor Variables command. A string variable is indicated with " " around the name of the variable.
The list values will appear when the project is started.
Monitor multiple variables and/or lists by using commas to separate the variable name string parameters.
Monitoring Sensor Values Example
Monitoring sensor values in the Monitor Console allows the user to view sensor data in real-time.
In this example, the distance from is being monitored in the Monitor Console. The project directs the VR Robot to stop if the VR Robot is less than 500mm from a wall.
Watch as the values of the distance from command change in the Monitor Console.
Note that the sensor value is referenced using quotations in line 28: monitor_sensor("distance.get_distance")
Monitoring Variable Values Example
The Monitor Console can also be used to monitor variable values. The Monitor Console can provide real-time reports of a specific variable in a project.
In this example, the “timesRepeated” variable is used to monitor the number of times the VR Robot repeats a certain behavior. Because of the parameters of the for loop, when this variable reaches the number 5, the VR Robot will exit the loop.
The variable monitoring on the Monitor Console can help to provide real-time feedback to understand the flow of the project.
Note that the variable value is referenced using quotations: monitor_variable("times_repeated")