This is for 2022-2023 game slapshot:
Our autonomous will work, but when I run it again(without changing the code), it will for example not turn all the way causing the the arm not to hook on the blue dispenser. I have doubts that this has to do with the starting position of the robot since it might be moved over by a millimeter for example when I place it back in the starting position to try again. Is their anyway to set the robot starting position so it start the same place every time? Here is the code so far:
Auto is notoriously inconsistent on this hardware. As you progress, using PID feedback can increase the consistency of the program.
Before you dive in to that, the first thing that jumps out to me on your code is the shooter velocity and arm torque being set in a forever loop. Your code should never get to the first reverse drive based on what you are currently showing us. Is there code elsewhere that is firing a sequence?
Measuring distance with wheel spin can be difficult. When the motors start up at full speed you often lose traction which causes the measurement to be off.
It helps to have a gyro for turning and it helps to set motor speeds low at the start to improve accuracy. Once the robot is hitting the targets, you can start to increase the speeds.
First thing you need is an mechanical deadstop. I.e. a position where the arm cannot move any further. In most cases, builds will automatically have this because linkage arms all have a limited motion so your robot probably already has this.
Next is to either manually with your hands move the arm into that position prior to starting your program and set that to the zero position and reference all movement relative to that position.
Or
Code a time movement of the arm to that position when program starts and again set that to the zero position and reference all movement relative to that position.
My kids do the later because they then to forget to manually put the arm to the zero or deadstop position .
I hope that helps.
Cheers.