In order to use the data from the GPS (Game Positioning System) Sensor in a project, the sensor first needs to be added as a device in VEXcode V5. This article will walk you through how to configure the GPS Sensor in VEXcode V5. Watch the video below to learn about the concepts covered in this article.
Configuring the GPS Sensor in VEXcode V5
Add a Device
When starting to program with VEXcode V5, blocks for the GPS Sensor will not appear in the Toolbox until it has been configured. To configure the GPS Sensor, add it as a device in your project.
Select the Devices icon.
Select Add a device.
Select GPS.
Select the Smart Port that the GPS Sensor is plugged into on the V5 Robot Brain.
Select Done to add the GPS Sensor as a device without setting the offsets.
To learn more about GPS Sensor Offsets, read the section below.
GPS Sensor Offsets
What is an offset?
In the configuration, you have the option to add offset information. An offset is the difference between a reference point on the robot and the position of the GPS Sensor. The reference point is a meaningful location on your robot, like the turning center point or the robot's arm. Let's think about why this is important. The examples below show Axel, the Hero Bot for the 2024-2025 VEX V5 Robotics Competition (V5RC) game, High Stakes.
Why are offsets a valuable tool?
Setting the offsets for where the GPS Sensor is in relation to the reference point (Axel's arm) enables you to position Axel's arm at a desired location, rather than the back of the robot. VEXcode uses the offset information to convert the data from the GPS Sensor to use values that correspond with the reference point in your project.
Offsets enable you to use the GPS Sensor's recommended positioning (at the back and facing behind the robot) to get the most accurate data from the sensor, while navigating based on a meaningful location for your robot and your project.
Depending on where your reference point is and the position the GPS Sensor on your robot, the sensor may be offset along the X axis, and/or the Y axis.
In this image of Axel, the GPS Sensor is located on the back right side of the robot (highlighted with a green box). An example reference point is shown here, at Axel's arm, highlighted with a green dot.
It is also important to consider the angle of the GPS Sensor's field of view in relation to the reference point.
Using the recommended position for the GPS Sensor, the sensor will face behind Axel, as shown here with a green arrow.
The reference point however, aligns with the front of the robot, facing the opposite direction. The GPS Sensor has an Angle Offset then, as well.
Measuring the X and Y Offsets
By adding the offset to your configuration, the GPS Sensor values used in your VEXcode V5 project will be automatically adjusted to reflect the offset, and the position of your desired reference point of the robot on the Field.
The GPS Sensor can be offset along the x-axis and/or the y-axis, depending on the mounting location of the sensor on your robot.
In the example of Axel, the GPS Sensor is located behind and to the right of the reference point at the robot's arm.
This means that the sensor is offset along both the X axis (shown with the red arrow) and the Y axis (shown with the blue arrow).
X Offset
On Axel the GPS Sensor is mounted approximately 50 mm on the positive x-axis in relation to the reference point at the robot arm.
The X Offset is then 50mm.
Y Offset
On Axel the GPS Sensor is mounted approximately 320 mm on the negative y-axis in relation to the reference point at the robot arm.
The Y Offset is then –320 mm.
Measuring Angle Offset
The GPS Sensor also reports heading values. However, the GPS Sensor faces in the opposite direction to the robot's forward. This means that the heading values would be opposite to those of the reference point, which faces forward on the robot.
To align the heading of the GPS Sensor with the forward direction of the reference point on the robot, you can set the Angle Offset.
On Axel, the Angle Offset would be 180º.
Note: Based on the recommended positioning of the GPS Sensor, by default, the configuration will set the Angle Offset to 180º.
Inputting Offsets in the Configuration
There are options to change the X, Y, and Angle Offsets.
X and Y Offsets
The X Offset would be set to 50 mm in the configuration.
When the offset value is changed, the graphical location of the GPS Sensor on the robot icon to the right adjusts accordingly. (Note that the graphical location is only an illustration and is not to any specific scale.)
The Y Offset would be set to –320 mm.
When the offset value is changed, the graphical location of the GPS Sensor on the robot icon to the right adjusts accordingly. (Note that the graphical location is only an illustration and is not to any specific scale.)
Angle Offset
By default, the Angle Offset in the configuration is set to 180º, based on the recommended orientation of the GPS Sensor. This means that the reported headings of the GPS Sensor in VEXcode will align with the heading of the robot.
A yellow highlight is shown on the robot icon in the configuration, to illustrate the field of view and show the orientation of the sensor. When the angle offset value is changed, the position of the GPS and the field of view on the robot icon to the right moves accordingly. (Note that the graphical location is only an illustration and is not to any specific scale.)
Note the GPS Position in the Configuration
Notice that the position of the GPS on the robot icon in the configuration aligns with the position of the GPS Sensor on the physical robot.
You can use this graphical representation to ensure that your offsets are entered correctly. The GPS position should match that position on your robot.
Once the X, Y, and Angle Offset values are entered based on the location of the GPS Sensor on your robot, select Done to save the configuration.
GPS Sensing Commands in VEXcode
Once the GPS Sensor is configured, GPS Sensing commands will appear in the Toolbox in VEXcode V5. You can learn about all of the GPS Sensing commands in VEXcode V5 with VEX API. Select the link below to access the GPS Sensing commands for your preferred coding method.
To learn more about the data the GPS sensor is reporting and how that relates to the position of the robot on the Field, view this article.