Add encoder reverse directions to dead wheel localizers

Direction doesn't matter for position regression, but it does matter
for `inPerTick`, `lateralInPerTick`. And everything makes more sense
if the directions are correct.
This commit is contained in:
Ryan Brott
2023-12-23 13:23:40 -08:00
parent ce080b0b51
commit a890105110
4 changed files with 11 additions and 2 deletions

View File

@ -134,7 +134,7 @@ public final class MecanumDrive {
rightFront = new OverflowEncoder(new RawEncoder(MecanumDrive.this.rightFront));
// TODO: reverse encoders if needed
// leftFront.setDirection(DcMotorSimple.Direction.REVERSE);
// leftFront.setDirection(DcMotorSimple.Direction.REVERSE);
lastLeftFrontPos = leftFront.getPositionAndVelocity().position;
lastLeftBackPos = leftBack.getPositionAndVelocity().position;

View File

@ -150,7 +150,7 @@ public final class TankDrive {
}
// TODO: reverse encoder directions if needed
// leftEncs.get(0).setDirection(DcMotorSimple.Direction.REVERSE);
// leftEncs.get(0).setDirection(DcMotorSimple.Direction.REVERSE);
for (Encoder e : leftEncs) {
lastLeftPos += e.getPositionAndVelocity().position;

View File

@ -11,6 +11,7 @@ import com.acmerobotics.roadrunner.ftc.OverflowEncoder;
import com.acmerobotics.roadrunner.ftc.PositionVelocityPair;
import com.acmerobotics.roadrunner.ftc.RawEncoder;
import com.qualcomm.robotcore.hardware.DcMotorEx;
import com.qualcomm.robotcore.hardware.DcMotorSimple;
import com.qualcomm.robotcore.hardware.HardwareMap;
@Config
@ -37,6 +38,9 @@ public final class ThreeDeadWheelLocalizer implements Localizer {
par1 = new OverflowEncoder(new RawEncoder(hardwareMap.get(DcMotorEx.class, "par1")));
perp = new OverflowEncoder(new RawEncoder(hardwareMap.get(DcMotorEx.class, "perp")));
// TODO: reverse encoder directions if needed
// par0.setDirection(DcMotorSimple.Direction.REVERSE);
lastPar0Pos = par0.getPositionAndVelocity().position;
lastPar1Pos = par1.getPositionAndVelocity().position;
lastPerpPos = perp.getPositionAndVelocity().position;

View File

@ -12,6 +12,7 @@ import com.acmerobotics.roadrunner.ftc.OverflowEncoder;
import com.acmerobotics.roadrunner.ftc.PositionVelocityPair;
import com.acmerobotics.roadrunner.ftc.RawEncoder;
import com.qualcomm.robotcore.hardware.DcMotorEx;
import com.qualcomm.robotcore.hardware.DcMotorSimple;
import com.qualcomm.robotcore.hardware.HardwareMap;
import com.qualcomm.robotcore.hardware.IMU;
@ -42,6 +43,10 @@ public final class TwoDeadWheelLocalizer implements Localizer {
// see https://ftc-docs.firstinspires.org/en/latest/hardware_and_software_configuration/configuring/index.html
par = new OverflowEncoder(new RawEncoder(hardwareMap.get(DcMotorEx.class, "par")));
perp = new OverflowEncoder(new RawEncoder(hardwareMap.get(DcMotorEx.class, "perp")));
// TODO: reverse encoder directions if needed
// par.setDirection(DcMotorSimple.Direction.REVERSE);
this.imu = imu;
lastParPos = par.getPositionAndVelocity().position;