Using the camera, we can get how many pixels we are off target. Is there a way to feed that into the PID controls and then have the PID controls output into the robotdrive?
As far as I know, in the provided PID function you have to give it a source (such as an encoder), you cannot give it a number. Also, I’m not sure if the PID output works with robotdrive (arcade mode).
You will have to create your own PID class that extends the current PID class and override some of the methods to get it to work the way that you want it to.
A PID takes a setpoint and a processVariable as inputs, and adjusts its output to make the plant’s output (the processVariable) equal to the setpoint.
You want the “how many pixels we are off target” to be zero, right?
So your setpoint would be 0 (zero), and “how many pixels we are off target” is your process variable. The output from the PID would be your drivetrain rotation command (assuming that “how many pixels we are off target” is a measure of aim, not range).