Our season is over for the year and our coach has tasked me with using our robot from this season and figuring out how to set up and use the GPS sensor. Currently programming with Vexcode V5. Trying to get it to start in a corner facing the 0 degree heading and have it drive to the center of the field. When I start it the robot drives straight and runs into the opposite wall instead of stopping and turning. Any advice on how to do this?
A few problems with this code:
- Every time the button ‘A’ is pressed, the GPS position is reset. My understanding is that you mean to press it only once per run, but I still believe you do not need to continuously reset the GPS position as the GPS sensor does not drift.
- Assuming you only press the button once per run, the problem is that the code all runs instantly. You set your position, start driving forward, and then, without waiting, check to see if you’ve reached the end. Instead, you may need to find some way to “wait until” the GPS x position is less than 0 before continuing the code. (Due to decimals, it will probably never equal 0.)
1 Like
I am setting it to when ‘A’ is pressed just so I can control it because it does some other stuff under the when started block. Thanks for the advice. I will update it and try it this afternoon. Might end up having some more questions later.
I am not the best in block but hopefully this should help, I think what happened with your code was the “if” block checks right when you click the button, But with a wait-until block no blocks will run until the values you put in are true.