-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e967c2
commit 86a7175
Showing
5 changed files
with
60 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
src/main/java/org/team1540/robot2025/subsystems/grabber/GrabberConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
package org.team1540.robot2025.subsystems.grabber; | ||
|
||
public class GrabberConstants { | ||
public static final int GRABBER_ID = 13; // TODO: Fix this | ||
// TODO: Fix this | ||
public static final int GRABBER_ID = 13; | ||
public static final int BEFORE_BREAK_CANDI_ID = 1; | ||
public static final int AFTER_BREAK_CANDI_ID = 2; | ||
public static final String CANDI_BUS = "canivore"; | ||
|
||
public static final double GRABBER_MOI = 0.025; | ||
public static final double GRABBER_GEAR_RATIO = 24.0 / 36.0; | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/org/team1540/robot2025/subsystems/grabber/GrabberIOSim.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.team1540.robot2025.subsystems.grabber; | ||
|
||
import edu.wpi.first.math.MathUtil; | ||
import edu.wpi.first.math.system.plant.DCMotor; | ||
import edu.wpi.first.math.system.plant.LinearSystemId; | ||
import edu.wpi.first.wpilibj.simulation.DCMotorSim; | ||
|
||
import static org.team1540.robot2025.Constants.LOOP_PERIOD_SECS; | ||
import static org.team1540.robot2025.subsystems.grabber.GrabberConstants.*; | ||
|
||
public class GrabberIOSim implements GrabberIO { | ||
private final DCMotorSim sim = new DCMotorSim( | ||
LinearSystemId.createDCMotorSystem( | ||
DCMotor.getFalcon500Foc(1), | ||
GRABBER_MOI, | ||
GRABBER_GEAR_RATIO | ||
), | ||
DCMotor.getFalcon500Foc(1) | ||
); | ||
|
||
private double motorVoltage = 0.0; | ||
|
||
@Override | ||
public void updateInputs(GrabberIOInputs inputs) { | ||
sim.setInputVoltage(motorVoltage); | ||
sim.update(LOOP_PERIOD_SECS); | ||
inputs.motorCurrentAmps = sim.getCurrentDrawAmps(); | ||
inputs.motorAppliedVolts = motorVoltage; | ||
inputs.velocityRPM = sim.getAngularVelocityRPM(); | ||
inputs.positionRots = sim.getAngularPositionRotations(); | ||
} | ||
|
||
@Override | ||
public void setVoltage(double volts) { | ||
motorVoltage = MathUtil.clamp(volts, -12.0, 12.0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters