Quote:
Originally Posted by Louisiana Jones
What kind of controller are you using to get the drivetrain to the exact shooting position?
|
We've actually been through a couple of iterations of controllers. At first (way back in the middle of build season) we tried using the wpilib PID controller, but didn't like it because we had a low frame rate coming back from our image processing code, and a not very responsive drivetrain, so we ended up with a huge delay between output to the motors and response in the image, among other things.
At Palmetto we used a step based control that used the gyro for control left and right aiming and just set our shooter hight based on a quadratic equation and the distance from the goal (either from the lidar or the size of the reflected tape, I can't remember what we actually used now)
After we came back from palmetto we decided to basically drop what we had and start over. We went with something really simple: Check which way we need to move, move a little bit in the right direction, repeat.
It's literally 6 lines of code:
Code:
// Adjust wheel encoders based on distance from target
if (pixelXOffset > Constants.IMAGE_LARGE_PIXEL_OFFSET_X)
encoderPosition += isPixelXOffsetPositive * Constants.IMAGE_LARGE_STEP_ANGLE_X;
else if (pixelXOffset > Constants.IMAGE_MEDIUM_PIXEL_OFFSET_X)
encoderPosition += isPixelXOffsetPositive * Constants.IMAGE_MEDIUM_STEP_ANGLE_X;
else if (pixelXOffset > Constants.IMAGE_SMALL_PIXEL_OFFSET_X)
encoderPosition += isPixelXOffsetPositive * Constants.IMAGE_SMALL_STEP_ANGLE_X;
We also use encoders connected to our drivetrain now so we get more precise control of our wheel positions. PID controllers control the encoder positions, we just adjust the setpoints up and down.
We do basically the same thing with the PID controller for the linear actuator that moves the shooter up and down. (Plus some magic that makes it scan up and down when it can't see the target)