Configuring the GPS Sensor in VEXcode V5

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. 

The VEXcode V5 Toolbar with the Devices icon highlighted in a red box. The devices icon is located between the Code Viewer button and the Monitor button.

Select the Devices icon.

The Devices Window open in VEXcode V5 with the Add a Device button highlighted, indicating what to select next.

Select Add a device.

Devices options that can be added to the configuration, with the GPS option highlighted in a red box. GPS is located in the center of the fifth row of options, between Distance and Arm.

Select GPS.

Devices Window in VEXcode V5 with the port options available. The window reads 'Select a port' at the top, and ports 1 through 21 are listed in 3 rows of icons.

Select the Smart Port that the GPS Sensor is plugged into on the V5 Robot Brain.

The GPS Sensor configuration window showing the X and Y offsets for the sensor set to 0 mm and the angle offset set to 180 degrees. The Done button in the bottom right is highlighted with a red outline.

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. 

A top-down view of the Axel robot. A green box highlights the GPS sensor on the back right section of the robot. A circular dot is on the front of the robot, on top of the robot's arm.

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.

A top down view of the field. The sensor faces behind the robot, which is shown by a solid green arrow. The reference point for the robot is on the opposite side, which is represented by a dotted green arrow.

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.

A top down view of the Axel robot showing the green highlighted box around the GPS sensor and green circle over the robot's arm. An X and Y grid is placed over Axel, showing the green circle over Axel's arm to be the center of the grid (0,0). The highlighting green box around the GPS Sensor is in the negative Y and positive X axes of the grid.

In the example of Axel, the GPS Sensor is located behind and to the right of the reference point at the robot's arm.

The same top down image of the Axel robot. A blue Y axis arrow moves down the Y axis towards the back of the robot. A red X axis arrow points to the right towards the center of the now highlighted in red GPS Sensor.

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

The same top down view of the Axel robot. A dotted line connects the red highlighted GPS Sensor. A solid line connects the center of the grid and the center of the GPS Sensor showing the distance between the two on the X axis to be 50mm.

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.

The same top down view of the Axel robot. A dotted line connects the red highlighted GPS Sensor. A solid line connects the center of the grid and the center of the GPS Sensor showing the distance between the two on the y axis to be -320mm.

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 top down view of the Axel robot in the middle of a circle showing a 0 in front of the robot, a 90 to its right, a 180 behind it, and a 270 to its left. The GPS Sensor is highlighted with a green box with an arrow pointing towards the 180. There is a green circle over the robot's arm and an arrow pointing to the 0.

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

The GPS Configuration window in the devices window with a red rectangle highlighting the X, Y, and angle offsets input boxes.

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

The GPS Configuration window in the devices window with a red rectangle highlighting the angle offset, which reads 180 degrees.

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

The GPS Configuration window in the devices window with a red rectangle highlighting the image of a smaller robot on the right side of the configuration window. The image of the smaller robot's GPS sensor has changed with the modified GPS offsets, matching Axel's GPS Sensor position.

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. 

The GPS Configuration window in the devices window with all configuration changes made. The X offset reads 50 mm. The Y offset reads -320mm. The angle offset reads 180 degrees. The Done button is highlighted in red.

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.

For more information, help, and tips, check out the many resources at VEX Professional Development Plus

Last Updated: