-
Notifications
You must be signed in to change notification settings - Fork 0
2017: Tuning The Arm
This page will instruct you on how to tune the arm for Rogue Cephalopod.
You will need:
- One (1) Rogue Cephalopod
- One (1) Driver Station
- One (1) Joystick
Ensure that the Driver Station is connected to the robot and open the Smart Dashboard. Locate the item named "Arm Pos" and remember its location. You will use this field to read the number that we use for tuning.
Some sections of the code need to be removed to properly tune the arm. They are all in Arm.java
, in org/usfirst/frc/team5818/robot/subsystems
.
- Comment out both
Math.min
andMath.max
lines inpidWrite(double x)
so it looks like the following:
if (getPosition() <= limitLow) {
// x = Math.max(x, 0);
} else if (getPosition() >= limitHigh) {
// x = Math.min(x, 0);
}
This disables the limits so you can tune with the arm stopping at the wrong spot.
- In
getPosition()
comment out anyif
statements so they have no effect. Theif
here is used to adjust for wrapping on the encoder, which will be explained later.
There are 5 positions you will need to move the arm to for proper tuning. They are, in order of position:
-
COLLECT_POSITION
: The lowest the arm will go, this angle is for collecting gears. -
CLIMB_POSITION
: The end of the arm should be directly above the back camera. This angle is for climbing. -
MID_POSITION
: This is somewhere betweenCLIMB_POSITION
andNINETY_DEGREES
, usually halfway. This angle is so the arm is entirely inside the frame perimeter. -
NINETY_DEGREES
: This is when the arm is at ninety degrees to the ground, i.e. perpendicular. -
LOAD_POSITION
: The hardest one to get, this is the position for loading gears into the turret. You may need to run through a few collect + load cycles to properly tune this one.
To tune each position, simply switch to manual mode and move the arm to the angle described and check "Arm Pos" on the dashboard. Then set the appropriate constant in Arm.java
to the value on the dashboard.
Tips:
- Go slow. There are no limits on the arm in this mode and it may try to go too far.
- Ensure you use manual mode, as the automated positions will not work.
First, uncomment the Math.min
and Math.max
lines to restore the limits.
Then, you will need to check if you need to setup an if
statement like the one commented out previously.
To do so, first you will need to understand how the encoder works. If you are already familiar with this, skip to Properly Adjusting for the Arm Encoder
.
The encoder on the arm is an absolute encoder, meaning that it retains its position after a power-off. However, the encoder only has a range from 0
-4096
. When the encoder is on, it just goes above 4096
or below 0
, and that is the value you will see under "Arm Pos". However, when the encoder is power-cycled, it will add or subtract 4096
until the value is between 0
and 4096
. We counteract this in the code in getPosition()
, so that the values we read are always the same as the values we initially read when tuning the arm.
First determine if you have any values (from the recording stage) above 3500
or below 500
. This is a smaller range than the 0
to 4096
technically allowed, but we want to be safe in case the arm goes a little too far.
If you don't have any values outside that range, you are done! Remove any remaining if
statement from getPosition()
and go to Commit code
. Otherwise, go to the appropriate section for where your values fall outside of the range.
Find a value about 500
lower than your lowest value. Replace [x]
in the following code with your number and copy it to getPosition()
, replacing the other if
:
if (pos < [x]) {
return pos + 4096;
}
Go to Commit code
.
Find a value about 500
higher than your highest value. Replace [x]
in the following code with your number and copy it to getPosition()
, replacing the other if
:
if (pos > [x]) {
return pos - 4096;
}
Continue to Commit code
.
Test your changes, then commit and push. You have tuned the arm!
- Tutorials
- Getting the JDK
- Getting IntelliJ
- Learn Java
- Coding Your First Robot
- Basic Drive Systems
- Command-Based Programming
- 5818-lib
- Dependency Injection
- Formatting Guide
- Command Line Guide
- Quick References
- WPILib Documentation
- Git Book (External Resource)
- Robot Documentation
- Rogue Cephalopod (2017)