Hi,
Does anyone know how to use the V5 GPS Sensor? I tried using the example code, but it just goes around in circles and it’s not going where i want it to go.
Thanks
Can someone give example code. I’m using Vex code V5 Pro.
There’s something known as Open Examples
. It’s built into (at least) VEXcode IQ and (probably) VEXcode V5 Pro. Try the GPS sensor example programs.
Do File
> Open Examples
> Sensing
> [some GPS sensor program] and change the port the sensor is plugged into in the code and download it. Fool around and try to learn something. That’s what I start with. And Google it, find YouTube videos, etc.
That’s what i did. I changed the ports and it goes around in circles still.
The Robot is going forward when I use the example code and it never stops. I tried printing the x and y positions, and it print 0 for x and y position, even when the robot is moving.
// Calibrate the GPS Sensor before starting
GPSsensor.calibrate();
while (GPSsensor.isCalibrating()) { task::sleep(50); }
// Set the approximate starting position of the robot
// This helps the GPS Sensor know its starting position
// if it is too close to the field walls to get an accurate initial reading
//GPSsensor.setLocation(56, -45, inches, 270, degrees);
// Print the starting position of the robot
printPosition();
Drivetrain.drive(reverse);
// Keep driving until the GPS's xPosition passes 0 (horizontal center)
while (!(GPSsensor.xPosition(mm) < 0)) {
printPosition();
wait(0.1, seconds);
}
Drivetrain.stop();
Drivetrain.turnToHeading(90, degrees, true);
Drivetrain.drive(forward);
// Keep driving until the GPS's yPosition passes 0 (vertical center)
while (!(GPSsensor.yPosition(mm) > 0)) {
printPosition();
wait(0.1, seconds);
}
Drivetrain.stop();
// Print the ending position of the robot
printPosition();
return 0;
}
Is the GPS sensor working in the dashboard ? Can it see the field strips correctly ?
is the sensor plugged into the same port that the example is using ?
Thanks for responding. I put the wrong port in my program. Now, when I make the robot go to 0 for x it works but then when I try to use turn to heading, it keeps rotating and it doesn’t stop after 90 degree turn.
That sounds like the drivetrain is configured incorrectly.
Without using the GPS, make sure turnTo right and left work properly and adjust drivetrain as necessary.
we seem to be having the same problem as well. out robot seems to be going in circles and we have made sure the lighting, configuration and ports are correct but our robot seems to be going in circles…