The VR Robot has a multitude of sensors, including a Location Sensor.
Location Sensor on the VR Robot
The VR Robot has a Location Sensor built in that reports the (X, Y) position of the VR Robot. The location of the VR Robot is determined by the center turning point. This is also the location of the pen on the VR Robot.
The Location Sensor also reports the location angle which ranges from 0 degrees to 359.9 degrees following a compass heading style.
Each Playground ranges from -1000mm to 1000mm for the X and Y positions. The starting location of the VR Robot depends on the Playground selected. For more information about location details on a Playground and the coordinate system, view the following articles:
The Location Sensor values can be displayed on the Dashboard in VEXcode VR. To learn more about the Dashboard, view the Dashboard - Playground Features - VEXcode VR article.
The Location Sensor values can be displayed on the Monitor Console in VEXcode VR.
- To learn more about using the Monitor Console with VEXcode VR Blocks, see this article.
- To learn more about using the Monitor Console with VEXcode VR Python, see this article.
Common Uses of the Location Sensor
The Location Sensor on the VR Robot can be used in many ways.
VEXcode VR Blocks | Castle Crasher Playground | |
---|---|---|
VEXcode VR Python | ||
def main(): |
||
The Location Sensor can be used to navigate the coordinates of any Playground. Each Playground ranges from -1000mm to 1000mm for the X and Y positions. For example, if you wanted the VR Robot to stop once it crossed a certain value on the Y-axis, you could set a threshold on the Y-axis to be greater than that value. This center castle in the Castle Crasher Playground is close to a Y-value of -250. So the example project sets the VR Robot to stop driving after it passes a Y-value greater than -300, and will not crash into the castle. |
VEXcode VR Blocks | Disk Mover Playground | |
---|---|---|
VEXcode VR Python | ||
def main(): |
||
The Location Sensor can also be used to move the VR Robot to a known location. In this project, the first green disk appears to be at the location (800, -200). To reach that point, the VR Robot can drive along the X-axis until it reaches 800 and then along the Y-axis until it reaches -200 to pick up the disk. |
VEXcode VR Blocks | Art Canvas Playground | |
---|---|---|
VEXcode VR Python | ||
def main(): |
||
The Location Sensor can also be used to determine the current angle of the VR Robot. In this project, the VR Robot will drive forward, and then turn right. It will wait until the VR Robot's angle is greater than 89 degrees and then change the pen color to red and drive forward another 400mm. Note that the location angle in the Dashboard is 92 instead of exactly 90 or even 89.1. This is because it takes time for the flow of the project to proceed and process each command as they are executed. Thus, the 92 degrees is not a mistake, it is intended due to processing time and the speed of the VR Robot. |
Using the Location Sensor in VEXcode VR Blocks
(Position of robot) block
The (Position of robot) block reports the X or Y coordinate position of the VR Robot.
The X or Y coordinate position can be selected from the drop-down menu on the block.
The mm or inches units can be selected from the drop-down menu on the block.
(Position angle in degrees) block
The (Position angle in degrees) block reports the angle of the VR Robot in degrees to the nearest tenths place. The values range from 0.0 to 359.9 degrees.
Using the Location Sensor in VEXcode VR Python
To begin programming the Location Sensor with Python, you will need to first open a new text project in VEXcode VR. For more information, see this article.
The position command reports the X or Y coordinate position of the VR Robot.
The position angle command reports the angle of the VR Robot in degrees.
To add either of these commands to your project, you can drag the command in from the Toolbox, or type out the command in the workspace using the Autocomplete function. To learn more about Autocomplete in VEXcode VR with Python, see this article.