Skip to content

Commit

Permalink
Allow Canandgyro to be used for swerve pose estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
viggy96 committed Oct 30, 2024
1 parent 524e032 commit 91e533d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.lasarobotics.hardware.PurpleManager;
import org.lasarobotics.hardware.ctre.Pigeon2;
import org.lasarobotics.hardware.kauailabs.NavX2;
import org.lasarobotics.hardware.reduxrobotics.Canandgyro;
import org.lasarobotics.utils.GlobalConstants;
import org.lasarobotics.vision.AprilTagCamera;
import org.littletonrobotics.junction.AutoLog;
Expand Down Expand Up @@ -114,6 +115,24 @@ public SwervePoseEstimatorService(Matrix<N3,N1> odometryStdDev, Pigeon2 imu, MAX
);
}

/**
* Create Swerve Pose Estimator Service
* <p>
* This service runs in the background and keeps track of where the robot is on the field
* @param odometryStdDev Standard deviation of wheel odometry measurements
* @param imu Redux Robotics Canandgyro
* @param modules MAXSwerve modules
*/
public SwervePoseEstimatorService(Matrix<N3,N1> odometryStdDev, Canandgyro imu, MAXSwerveModule... modules) {
this(
odometryStdDev,
() -> imu.getInputs().rotation2d,
() -> imu.getInputs().yawRate,
() -> true,
modules
);
}

private SwervePoseEstimatorService(Matrix<N3,N1> odometryStdDev,
Supplier<Rotation2d> rotation2dSupplier,
Supplier<Measure<Velocity<Angle>>> yawRateSupplier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.lasarobotics.hardware.PurpleManager;
import org.littletonrobotics.junction.AutoLog;
import org.littletonrobotics.junction.Logger;
import org.littletonrobotics.junction.inputs.LoggableInputs;

import com.reduxrobotics.frames.Frame;

Expand Down Expand Up @@ -132,7 +131,7 @@ protected void periodic() {
}

@Override
public LoggableInputs getInputs() {
public CanandgyroInputsAutoLogged getInputs() {
synchronized (m_inputs) { return m_inputs; }
}

Expand Down

0 comments on commit 91e533d

Please sign in to comment.