Skip to content

Commit 6fa5479

Browse files
committed
add sendables to LiveWindow
1 parent 5ca6adb commit 6fa5479

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/main/java/org/carlmontrobotics/lib199/SparkVelocityPIDController.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import edu.wpi.first.util.sendable.Sendable;
99
import edu.wpi.first.util.sendable.SendableBuilder;
10+
import edu.wpi.first.util.sendable.SendableRegistry;
1011

1112
public class SparkVelocityPIDController implements Sendable {
1213

@@ -32,6 +33,8 @@ public SparkVelocityPIDController(String name, CANSparkMax spark, double default
3233
this.kV = kV;
3334

3435
pidController.setReference(targetSpeed, ControlType.kVelocity, 0, calculateFF(targetSpeed));
36+
37+
SendableRegistry.addLW(this, "SparkVelocityPIDController", spark.getDeviceId());
3538
}
3639

3740
public RelativeEncoder getEncoder() {

src/main/java/org/carlmontrobotics/lib199/swerve/SwerveModule.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import edu.wpi.first.math.trajectory.TrapezoidProfile;
1717
import edu.wpi.first.util.sendable.Sendable;
1818
import edu.wpi.first.util.sendable.SendableBuilder;
19+
import edu.wpi.first.util.sendable.SendableRegistry;
1920
import edu.wpi.first.wpilibj.Timer;
2021
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
2122

@@ -113,14 +114,16 @@ public SwerveModule(SwerveConfig config, ModuleType type, CANSparkMax drive, CAN
113114

114115
this.rollDegSupplier = rollDegSupplier;
115116
this.pitchDegSupplier = pitchDegSupplier;
117+
118+
SendableRegistry.addLW(this, "SweverModule", type.toString());
116119
}
117120

118121
private double prevTurnVelocity = 0;
119122
public void periodic() {
120123
double measuredAngleDegs = getModuleAngle();
121124
TrapezoidProfile.State goal = turnPIDController.getGoal();
122125
goal = new TrapezoidProfile.State(goal.position, goal.velocity);
123-
126+
124127
double period = turnPIDController.getPeriod();
125128
double optimalTurnVelocityDps = Math.abs(MathUtil.inputModulus(goal.position-measuredAngleDegs, -180, 180))/period;
126129
setMaxTurnVelocity(Math.min(maxAchievableTurnVelocityDps, optimalTurnVelocityDps));

0 commit comments

Comments
 (0)