|
| 1 | +package frc.robot.subsystems.drive; |
| 2 | + |
| 3 | +import edu.wpi.first.math.geometry.Rotation2d; |
| 4 | +import edu.wpi.first.math.kinematics.SwerveModulePosition; |
| 5 | +import java.util.ArrayList; |
| 6 | +import java.util.List; |
| 7 | +import java.util.Optional; |
| 8 | +import java.util.Queue; |
| 9 | +import java.util.concurrent.ArrayBlockingQueue; |
| 10 | +import java.util.concurrent.locks.Lock; |
| 11 | +import java.util.concurrent.locks.ReentrantLock; |
| 12 | +import java.util.function.Supplier; |
| 13 | +import org.littletonrobotics.junction.AutoLog; |
| 14 | + |
| 15 | +public class OdometryManager { |
| 16 | + public static Lock odometryLock = new ReentrantLock(); |
| 17 | + public static double ODOMETRY_FREQUENCY_HZ = 200.0; |
| 18 | + |
| 19 | + private static OdometryManager instance = null; |
| 20 | + |
| 21 | + public static OdometryManager getInstance() { |
| 22 | + if (instance == null) { |
| 23 | + instance = new OdometryManager(); |
| 24 | + } |
| 25 | + return instance; |
| 26 | + } |
| 27 | + |
| 28 | + private final Queue<Double> timestampQueue = new ArrayBlockingQueue<>(20); |
| 29 | + private final List<ModuleSource> m_moduleSources = new ArrayList<>(4); |
| 30 | + private GyroSource m_gyroSource = null; |
| 31 | + |
| 32 | + public void registerModuleSource( |
| 33 | + Supplier<Optional<Double>> drivePositionSupplier, |
| 34 | + Supplier<Optional<Rotation2d>> turnAngleSupplier) {} |
| 35 | + |
| 36 | + public void registerGyroSource(Supplier<Optional<Rotation2d>> robotYawSupplier) {} |
| 37 | + |
| 38 | + private static void run() {} |
| 39 | + |
| 40 | + private record ModuleSource( |
| 41 | + Queue<Double> drivePositionQueue, |
| 42 | + Supplier<Optional<Double>> drivePositionSupplier, |
| 43 | + Queue<Rotation2d> turnAngleQueue, |
| 44 | + Supplier<Optional<Rotation2d>> turnAngleSupplier) {} |
| 45 | + |
| 46 | + private record GyroSource( |
| 47 | + Queue<Rotation2d> robotYawQueue, Supplier<Optional<Rotation2d>> robotYawSupplier) {} |
| 48 | + |
| 49 | + @AutoLog |
| 50 | + public class TimestampInputs { |
| 51 | + public double[] timestamps; |
| 52 | + |
| 53 | + public Rotation2d[] gyroYaws; |
| 54 | + public SwerveModulePosition[][] modulePositions; |
| 55 | + } |
| 56 | +} |
0 commit comments