For our robot right now, it can move using the Xboxcontroller; however, there is a big issue with the robot drifting to the side when it is driving forward. Because of this, the robot keeps driving incorrectly as the robot always turns after moving forward a certain duration of time. Is this perhaps a programming issue? According to some people in the electrical and mechanical groups in my robotics team, the drift has nothing to do with the hardware of the robot, leading me to believe this is perhaps a software issue.
I don’t see anything obviously wrong with this code (some questionable choices in variable naming aside); your drive command is pretty standard.
Try writing a command that simply sends .5 to both sides of the drive, and see how straight your robot drives. I am somewhat skeptical of the claims of your electrical and mechanical groups.
Looks pretty standard.
I would make sure you have some deadband. Your code sets it to zero which is bad when you noise from your controllers. The default is 2%. Something in the range of .02 to .05 seem to work well.
In my experience, problems like this tend to be mechanical or electrical problems, despite what your mechanical and electrical teams have told you. The common things I have seen cause this problem are
The chain on one side is considerably tighter than the other
The chain on one side is scrubbing against something
The chain on one side is skipping
A motor on one side has a loose connection or the connection is cut somewhere
All of these things can easily cause a drivetrain to drift in one direction while holding straight. Drivetrain code tends to be fairly simple and there aren’t many places that would cause this problem. I would have your other subgroups investigate more.