(V5 C++) How would I make a function that would make the robot accurately drive forward and backward? The issue is, it is not accurate. Ask it to drive forward 80 inches, and it will drive forward 50. It’s also inconsistent. My idea was to make a drive function based on rotation, utilizing the motors’ internal sensors. It is not working. I would like to know what might be the issue with my function, or what might be a better idea/alternative.
(We have 6 motors) When running Drive(any number) our robot makes a noise but does not turn or move. We have replaced the 1 turns with 90, 360, and 9999 degrees and it does the same exact thing. I’ve tried reversing and unreversing the motors and setting up the robot differently, but it does not work.
In order to make all the spinFor functions spin at the same time, you need to add an additional false parameter at the end because it is by default blocking. Add false to the end of all of them except the last one.
Corrected code:
As for why the drive function wasn’t working, assuming you were using the built-in drivebase class’s functions, it may be not accounting for an external gear ratio. If you want to increase ethe accuracy and speed of your distance drive I recommend looking into making it a PID.
I didn’t think about it working even when only defining the position of one motor group, so I took too many steps. Thank you! I think I understand this now. However, I’m still having issues. “rotation” and “resetRotation” apparently don’t work in V5, so I tried replacing them with “position” and “setPosition(0)” and I got the error that I can’t initialize a vex::rotationUnits parameter with float. So, I changed the type for degrees to vex::rotationUnits and it said "invalid operands to binary expression (vex::rotationUnits and double) despite the fact that there is no usage of the type double anywhere in the code. I then tried changing the type on kP and even removing it and related bits altogether, but it didn’t fix the issue.