We’ve had good results using this very helpful sample as a TeleOp OpMode. But in Autonomous the question is how to know when the automatic drive is complete and the robot is positioned in front of the desired AprilTag. Do we need to check that the rangeError, headingError, and yawError have not changed in a certain amount of time or is there a better way?
If you’re going to adapt the RobotAutoDriveToAprilTagOmni.java sample to autonomous, the first step is truly understand the sample code. How does the robot know when to stop driving?
Currently the sample uses the three local variables (that you’ve identified) to drive the robot. Do we have to “watch” the values to see “if they haven’t changed in a while” or can we be smarter?
desiredTag.ftcPose.rangeis not equal to the
DESIRED_DISTANCEglobal variable, the
rangeErroris the difference between the two - when that difference is nonzero, it causes the robot to drive.
yawErroris nonzero, it causes the robot to strafe.
headingErroris nonzero, it causes the robot to turn.
Is there some value you can check to know when the robot no longer has to do anything else to drive to the location? I think so.