Skip to content

Commit

Permalink
initial support for OTOS as encoder for tuningopmodes (not used for r…
Browse files Browse the repository at this point in the history
…otation yet, still depends on chub imu)
  • Loading branch information
j5155 committed Jun 4, 2024
1 parent f02ae49 commit 9500d7b
Showing 1 changed file with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
import com.acmerobotics.roadrunner.ftc.LateralRampLogger;
import com.acmerobotics.roadrunner.ftc.ManualFeedforwardTuner;
import com.acmerobotics.roadrunner.ftc.MecanumMotorDirectionDebugger;
import com.acmerobotics.roadrunner.ftc.OtosEncoder;
import com.qualcomm.hardware.lynx.LynxModule;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.OpModeManager;
import com.qualcomm.robotcore.eventloop.opmode.OpModeRegistrar;

import org.firstinspires.ftc.robotcore.internal.opmode.OpModeMeta;
import org.firstinspires.ftc.teamcode.MecanumDrive;
import org.firstinspires.ftc.teamcode.SparkFunOTOSDrive;
import org.firstinspires.ftc.teamcode.TankDrive;
import org.firstinspires.ftc.teamcode.ThreeDeadWheelLocalizer;
import org.firstinspires.ftc.teamcode.TwoDeadWheelLocalizer;
Expand Down Expand Up @@ -53,7 +55,42 @@ public static void register(OpModeManager manager) {
if (DISABLED) return;

DriveViewFactory dvf;
if (DRIVE_CLASS.equals(MecanumDrive.class)) {
if (DRIVE_CLASS.equals(SparkFunOTOSDrive.class)) {
dvf = hardwareMap -> {
SparkFunOTOSDrive od = new SparkFunOTOSDrive(hardwareMap, new Pose2d(0, 0, 0));

List<Encoder> leftEncs = new ArrayList<>(), rightEncs = new ArrayList<>();
List<Encoder> parEncs = new ArrayList<>(), perpEncs = new ArrayList<>();
parEncs.add(new OtosEncoder(od.otos,true, od.leftBack));
perpEncs.add(new OtosEncoder(od.otos,false, od.leftBack));

return new DriveView(
DriveType.MECANUM,
MecanumDrive.PARAMS.inPerTick,
MecanumDrive.PARAMS.maxWheelVel,
MecanumDrive.PARAMS.minProfileAccel,
MecanumDrive.PARAMS.maxProfileAccel,
hardwareMap.getAll(LynxModule.class),
Arrays.asList(
od.leftFront,
od.leftBack
),
Arrays.asList(
od.rightFront,
od.rightBack
),
leftEncs,
rightEncs,
parEncs,
perpEncs,
od.lazyImu,
od.voltageSensor,
() -> new MotorFeedforward(MecanumDrive.PARAMS.kS,
MecanumDrive.PARAMS.kV / MecanumDrive.PARAMS.inPerTick,
MecanumDrive.PARAMS.kA / MecanumDrive.PARAMS.inPerTick)
);
};
} else if (DRIVE_CLASS.equals(MecanumDrive.class)) {
dvf = hardwareMap -> {
MecanumDrive md = new MecanumDrive(hardwareMap, new Pose2d(0, 0, 0));

Expand Down

0 comments on commit 9500d7b

Please sign in to comment.