# GPS sensor not moving to the correct point

Hello!

Recently, my team and I have been having issues with the GPS sensor. Initially when we received the senor it worked great! We were able to accurately move the robot to any position on the field with only a few kinks. However, when we switched the robot’s drivetrain to utilize a gear ratio, the example code provided by Vex no longer worked. The robot would turn too much or not enough, turn into walls and did not go to the correct point. For reference, when testing the sensor we made sure it had a clear view of the tape and the tape is installed correctly. We use a custom driving and turning functions which, outside of the sensor code, are accurate. I understand how Vex calculates the distance it needs to travel, though I am a little confused by how they calculate the angle the robot needs to turn to. For further reference, I have learned about arctan in my calc class though do not understand its application here or why there is a conditional statement which adds 180 degrees. Has anyone else ran into issues with their GPS sensor lately? If you have any questions feel free to reach out.

Thanks and have a fantastic day!
–Josh

After adding your ratio, did you change the program to take the ratio into account?

1 Like

Arctan can be used to calculate the angle between two points. C++ has this useful function known as atan2 which is essentially just arctan but it takes into account the sign of the coordinates to determine the quadrant the point is in. It then returns a value in the range [-π, π]. In the case of the GPS sensor, I believe that it calculates the angle between the target and the robot’s position like this: `atan2(robotY - targetY, robotX - targetX);`. This angle can then be used as the heading angle the robot needs to turn to so that it can face the target point. And the conditional statement to add 180 degrees is useful if you want to drive to the point backward.

2 Likes

Yes we did take into account the ratio. I must not have made that clear. We have created custom functions to accurately drive distances and turn. These subsystems are working properly, we have tested them thoroughly. Thank you --Josh

Thank you!! I haven’t had time to respond to your message but we did read your explanation which was very helpful. I also wanted to provide an update as to where we are currently. We are able to drive to a particular X OR Y position, but not an x y coordinate on the field. Again we are using the template so I’m not sure as to why this would be happening. Let me know if you have any insight and thanks again for your help!