Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/frc/robot/sensors/gyro/GyroIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import edu.wpi.first.math.geometry.Rotation2d;
import frc.robot.Robot;
import frc.robot.subsystems.drive.DriveConstants;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOT ENOUGH SPACING


import java.util.function.DoubleSupplier;

Expand Down Expand Up @@ -46,7 +47,7 @@ public default void setOffset(double offset) {

public static GyroIO getIOByMode(DoubleSupplier simRotRate) {
return switch (Robot.getMode()) {
case REAL -> new GyroIONavX();
case REAL -> new GyroIOCanandgyro(DriveConstants.canandgyroId);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUCH CRAPPY NAME

case SIM -> new GyroIOSim(simRotRate);
case REPLAY -> new GyroIO() {
};
Expand Down
70 changes: 70 additions & 0 deletions src/main/java/frc/robot/sensors/gyro/GyroIOCanandgyro.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package frc.robot.sensors.gyro;

import java.util.Queue;

import com.reduxrobotics.sensors.canandgyro.Canandgyro;

import edu.wpi.first.math.geometry.Rotation2d;
import frc.robot.sensors.odometry.SparkOdometryThread;

public class GyroIOCanandgyro implements GyroIO {
private final Canandgyro gyro;

double offset = 0;
private final Queue<Double> yawPositionQueue;
private final Queue<Double> yawTimestampQueue;
private final Queue<Double> rate;

double pitchOffset = 0;
double rollOffset = 0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they see me rolling on my front lawn,


public GyroIOCanandgyro(int gyroId) {
gyro = new Canandgyro(gyroId);
rate = SparkOdometryThread.getInstance()
.registerSignal(() -> Math.toRadians(gyro.getAngularVelocityYaw() * 360));
yawTimestampQueue = SparkOdometryThread.getInstance().makeTimestampQueue();
yawPositionQueue = SparkOdometryThread.getInstance().registerSignal(() -> gyro.getYaw() * 2 * Math.PI);
}

@Override
public void updateInputs(GyroIOInputs inputs) {

inputs.isConnected = gyro.isConnected();
inputs.isCalibrating = gyro.isCalibrating();
inputs.angleRadiansRaw = gyro.getYaw() * 2 * Math.PI;
inputs.angularVelocityDegreesPerSecond = gyro.getAngularVelocityYaw() * 360;
inputs.angleDegreesRaw = Math.toDegrees(inputs.angleRadiansRaw);

inputs.roll = new Rotation2d(gyro.getRoll() * 2 * Math.PI - rollOffset);
inputs.pitch = new Rotation2d(gyro.getPitch() * 2 * Math.PI - pitchOffset);

inputs.displacementX = 0;
inputs.displacementY = 0;
inputs.odometryYawRate = rate.stream().mapToDouble((Double value) -> value).toArray();
inputs.odometryYawTimestamps = yawTimestampQueue.stream().mapToDouble((Double value) -> value).toArray();
inputs.odometryYawPositions = yawPositionQueue.stream().map((Double value) -> Rotation2d.fromRadians(value))
.toArray(Rotation2d[]::new);

inputs.accelX = gyro.getAccelerationX();
inputs.accelY = gyro.getAccelerationY();
inputs.accelZ = gyro.getAccelerationZ();
yawTimestampQueue.clear();
yawPositionQueue.clear();
rate.clear();
}

@Override
public double getActual(GyroIOInputs inputs) {
return inputs.angleRadiansRaw - offset;
}

@Override
public double getOffset() {
return offset;
}

@Override
public void setOffset(double offset) {
this.offset = offset;
}
}
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/subsystems/drive/DriveConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public static enum PivotId {
public static final SwerveDriveKinematics kinematics = new SwerveDriveKinematics(frontLeftLocation,
frontRightLocation, backLeftLocation, backRightLocation);

public static final int canandgyroId = 17;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

16 17


public static final ModuleInfo FL = new ModuleInfo(PivotId.FL, SwitchableCANID.of(1).get(),
SwitchableCANID.of(2).get(),
Switchable.of(0).addAlt(RobotTypes.frank25, 2).addAlt(RobotTypes.prime25, 2).get(), 45);
Expand Down
69 changes: 69 additions & 0 deletions vendordeps/ReduxLib-2026.1.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"fileName": "ReduxLib-2026.1.2.json",
"name": "ReduxLib",
"version": "2026.1.2",
"frcYear": "2026",
"uuid": "151ecca8-670b-4026-8160-cdd2679ef2bd",
"mavenUrls": [
"https://maven.reduxrobotics.com/"
],
"jsonUrl": "https://frcsdk.reduxrobotics.com/ReduxLib_2026.json",
"javaDependencies": [
{
"groupId": "com.reduxrobotics.frc",
"artifactId": "ReduxLib-java",
"version": "2026.1.2"
}
],
"jniDependencies": [
{
"groupId": "com.reduxrobotics.frc",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

who even is this redux person. never heard of her

"artifactId": "ReduxLib-fifo",
"version": "2026.1.2",
"isJar": false,
"skipInvalidPlatforms": true,
"validPlatforms": [
"linuxathena",
"linuxx86-64",
"linuxarm64",
"osxuniversal",
"windowsx86-64"
]
}
],
"cppDependencies": [
{
"groupId": "com.reduxrobotics.frc",
"artifactId": "ReduxLib-cpp",
"version": "2026.1.2",
"libName": "ReduxLib",
"headerClassifier": "headers",
"sourcesClassifier": "sources",
"sharedLibrary": true,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"linuxathena",
"linuxx86-64",
"linuxarm64",
"osxuniversal",
"windowsx86-64"
]
},
{
"groupId": "com.reduxrobotics.frc",
"artifactId": "ReduxLib-fifo",
"version": "2026.1.2",
"libName": "reduxfifo",
"headerClassifier": "headers",
"sharedLibrary": true,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"linuxathena",
"linuxx86-64",
"linuxarm64",
"osxuniversal",
"windowsx86-64"
]
}
]
}
Loading