Setting Up Your Three Wheel Localizer
Prerequisites
- Three odometry wheels connected to motor encoder ports on a hub.
Default Values
These are the default values of the ThreeWheelConstants. You can copy and paste this into your static{}
block within LConstants
:
ThreeWheelConstants.forwardTicksToInches = .001989436789;
ThreeWheelConstants.strafeTicksToInches = .001989436789;
ThreeWheelConstants.turnTicksToInches = .001989436789;
ThreeWheelConstants.leftY = 1;
ThreeWheelConstants.rightY = -1;
ThreeWheelConstants.strafeX = -2.5;
ThreeWheelConstants.leftEncoder_HardwareMapName = "leftFront";
ThreeWheelConstants.rightEncoder_HardwareMapName = "rightRear";
ThreeWheelConstants.strafeEncoder_HardwareMapName = "rightFront";
ThreeWheelConstants.leftEncoderDirection = Encoder.REVERSE;
ThreeWheelConstants.rightEncoderDirection = Encoder.REVERSE;
ThreeWheelConstants.strafeEncoderDirection = Encoder.FORWARD;
Steps
1. Odometry Wheel Setup
Open the file LConstants
and navigate to your static{}
block. Configure the following:
- Encoder Ports:
- Replace the
ThreeWheelConstants.leftEncoder_HardwareMapName
,ThreeWheelConstants.rightEncoder_HardwareMapName
, andThreeWheelConstants.strafeEncoder_HardwareMapName
with the names of the ports connected to your encoders. - The names will match the hardware map names of the motor port that they are connected to.
- Replace the
- Odometry Measurements:
- Input the
ThreeWheelConstants.leftY
,ThreeWheelConstants.rightY
, andThreeWheelConstants.strafeX
values. - These values represent the distance of the odometry wheels from the robot's center of rotation on the robot coordinate grid.
- Input the
- Encoder Directions:
- The Encoder Directions can be changed by changing the
Encoder
values forThreeWheelConstants.leftEncoderDirection
,ThreeWheelConstants.rightEncoderDirection
, orThreeWheelConstants.strafeEncoderDirection
. - Run the
Localization Test
and observe the encoder values - If the x value ticks down when the robot moves forward, reverse the direction of both of the parallel pods (left and right).
- If the x value stays relatively constant when the robot drives forward, that means that one of the parallel pods (left and right) need to be reversed.
- If the y value ticks down when the robot strafe left, reverse the direction of the strafe pod.
- The Encoder Directions can be changed by changing the
2. Localizer Tuning
We need to adjust multipliers that convert encoder ticks into real-world measurements (inches or radians). This ensures your localizer's readings are accurate.
a) Forward Localizer Tuner
-
Position a ruler alongside your robot.
-
Push the robot forward by the desired distance (default is 48 inches).
-
The tuner will display two numbers:
-
First number: Distance the robot thinks it has traveled.
-
Second number (multiplier)
-
-
(Optional) Run multiple tests and average the multipliers for better accuracy.
-
Input this value in
LConstants
asThreeWheelConstants.forwardTicksToInches = [multiplier]
, where[multiplier]
is the value you obtained from the tuner.
b) Lateral Localizer Tuner
-
Position a ruler alongside your robot.
-
Push the robot sideways (strafing) by the desired distance (default is 48 inches).
-
The tuner will display two numbers:
-
First number: Distance the robot thinks it has traveled laterally.
-
Second number (multiplier)
-
-
(Optional) Run multiple tests and average the multipliers for better accuracy.
-
Input this value in
LConstants
asThreeWheelConstants.strafeTicksToInches = [multiplier]
, where[multiplier]
is the value you obtained from the tuner.
c) Turn Localizer Tuner
-
Position your robot facing a recognizable landmark, like a field tile edge.
-
Spin the robot counterclockwise for one full rotation (or your desired angle).
-
The tuner will display two numbers:
-
First number: Distance the robot thinks it has spun.
-
Second number (multiplier)
-
-
(Optional) Run multiple tests and average the multipliers for better accuracy.
-
Input this value in
LConstants
asThreeWheelConstants.turnTicksToInches = [multiplier]
, where[multiplier]
is the value you obtained from the tuner.