Location Sensor - Robot Features - VEXcode VR

The VR Robot has a multitude of sensors, including a Location Sensor.

The following article will cover:

  • Location Sensor on the VR Robot
  • VEXcode VR Blocks Used with the Location Sensor
    • Position of robotblock
    • Position angle in degreesblock
  • Common Uses of the Location Sensor
  • Location Sensor Example Projects

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.

location sensing

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.

VR robot pen callout

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:

Grip_Map_with_Axis__1_.jpg

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.

Dashboard location

The Location Sensor values can be displayed on the Monitor Console in VEXcode VR. To learn more about the Monitor Console, view the Variable and Sensing Values Monitoring - Tutorials - VEXcode VR article.

Monitor console


VEXcode VR Blocks Used with the Location Sensor

Position of robot block

The Position of robot block reports the X or Y coordinate position of the VR Robot.

Position of robot block

The X or Y coordinate position can be selected from the drop-down menu on the block.

Positio of robot x block

The mm or inches units can be selected from the drop-down menu on the block.

Position of robot block

The Position of robot block reports the X and Y coordinate position of the VR Robot in numbers as either millimeters (mm) or inches.

Monitor mm

Monitor inches

Position angle in degrees block

The Position angle in degrees block reports the angle of the VR Robot in degrees.

Position angle in degrees block

The location angle ranges from 0 degrees to 359.9 degrees following a compass heading style.

VR top down

The Position angle in degrees block reports the current angle of the VR Robot in degrees to the nearest tenths place. The values range from 0.0 to 359.9 degrees.

Monitor position angle in degrees


Common Uses of the Location Sensor

The Location Sensor on the VR Robot can be used in many ways.

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. So, 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. In this example, the Castle is close to a Y-value of -300mm, thus, if I set the VR Robot to stop after it passes a Y-value greater than -300, it will not crash into the Castle.

Threshgold greater then -300

The Location Sensor can also be used to move the VR Robot to a known location. For example, in the following project, the first green disk appears to be at the location (800, -200). Thus, 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.

Threshhold disk

The Location Sensor can also be used to determine the current angle of the VR Robot. For example, in the following project, the VR Robot will drive forward, and then turn right once the VR Robot’s angle is greater than 89 degrees. Note that the position angle in degrees in the Monitor Console is 91.8 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 block as they are executed. Thus, the 91.8 degrees is not a mistake, it is intended due to processing time and the speed of the VR Robot.

Drive until 90 degrees


Location Sensor Example Projects

In the following example, the VR Robot will drive forward until the Y-axis is greater than zero. Notice the X and Y coordinate values in the Monitor Console.

Monitor console

In the following example, the VR Robot will drive forward until the Y-axis is greater than zero, then it will turn right, and drive forward until the X-axis is greater than zero. This will allow the VR Robot to drive until it is very close to the origin. Notice the X and Y coordinate values in the Monitor Console.

Drive until origin