1DfAutoLevel
1 Df Auto Level is a class that allows you to automatically level your claw given a certain rotation of a lift. 1 Df corresponds to 1 degree of freedom, which is the rotation of the lift.
Where lift is the rotation of the lift, and there are two joints of rotation, the claw and the lift.
How to use it
To use it, you need to create the instance of the class with the following parameters:
The tuner
If you have used anything else in this library, you may have a register class already, if not, make one following the example in ConfigCreator.
Then, add the following line to your register class:
This will register the OpMode with the name "AutoLevel1DfTuner." Run it, and it will tell you what to do!
Math Explanation
The math behind this is actually very simple, I will refer to the input as 'theta' and output as ' alpha' for convenience.
The main goal is to find the angle of the servo given the angle of the lift where theta is the bottom of the triangle, and alpha is the top of the triangle.
There is a linear relationship between theta and alpha, as in SlopeIntercept form, which for me, I found to be -.26x+96, however, I was using a gear reduction, so the slope will be different, but I would expect it to be negative.
The equation is:
The fun part of this is that the input shaft is more than usually 1800 ticks, which means you need to calculate that yourself by converting it to degrees. The easiest way is to get the ticks of the encoder, and find degree/ticks
which when multiplied by the ticks will give you the degrees.
The most effective way is just to run a test to get the encoder ticks, then move it to 90 degrees and get the ticks. Then do 90/ticks
to get the effective conversion factor.