-
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.
Merge pull request #26 from Robocubs:shooter-commands
Shooter-commands mergey yay happy dan
- Loading branch information
Showing
27 changed files
with
817 additions
and
206 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
14 changes: 14 additions & 0 deletions
14
src/main/java/com/team1701/lib/drivers/digitalinputs/DigitalIO.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,14 @@ | ||
package com.team1701.lib.drivers.digitalinputs; | ||
|
||
import org.littletonrobotics.junction.AutoLog; | ||
|
||
public interface DigitalIO { | ||
@AutoLog | ||
public static class DigitalInputs { | ||
public boolean blocked; | ||
} | ||
|
||
public default void updateInputs(DigitalInputs inputs) {} | ||
|
||
public default void getBlocked() {} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/team1701/lib/drivers/digitalinputs/DigitalIOSensor.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,16 @@ | ||
package com.team1701.lib.drivers.digitalinputs; | ||
|
||
import edu.wpi.first.wpilibj.DigitalInput; | ||
|
||
public class DigitalIOSensor implements DigitalIO { | ||
private final DigitalInput mSensor; | ||
|
||
public DigitalIOSensor(int channel) { | ||
mSensor = new DigitalInput(channel); | ||
} | ||
|
||
@Override | ||
public void updateInputs(DigitalInputs inputs) { | ||
inputs.blocked = mSensor.get(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/team1701/lib/drivers/digitalinputs/DigitalIOSim.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,16 @@ | ||
package com.team1701.lib.drivers.digitalinputs; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class DigitalIOSim implements DigitalIO { | ||
private final Supplier<Boolean> mBlockedSupplier; | ||
|
||
public DigitalIOSim(Supplier<Boolean> blockedSupplier) { | ||
mBlockedSupplier = blockedSupplier; | ||
} | ||
|
||
@Override | ||
public void updateInputs(DigitalInputs inputs) { | ||
inputs.blocked = mBlockedSupplier.get(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/team1701/lib/drivers/encoders/EncoderIODigital.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,30 @@ | ||
package com.team1701.lib.drivers.encoders; | ||
|
||
import com.team1701.robot.Constants; | ||
import edu.wpi.first.math.MathUtil; | ||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import edu.wpi.first.wpilibj.DutyCycleEncoder; | ||
|
||
public class EncoderIODigital implements EncoderIO { | ||
private final DutyCycleEncoder mEncoder; | ||
|
||
public EncoderIODigital(int channel) { | ||
mEncoder = new DutyCycleEncoder(Constants.Shooter.kShooterThroughBoreEncoderId); | ||
mEncoder.setDistancePerRotation(Constants.Shooter.kThroughBoreEncoderDistancePerRotation); | ||
} | ||
|
||
@Override | ||
public void updateInputs(EncoderInputs inputs) { | ||
var rotations = mEncoder.get(); | ||
inputs.position = Rotation2d.fromRotations( | ||
rotations == Double.NaN || rotations == Double.POSITIVE_INFINITY ? 0.0 : rotations); | ||
} | ||
|
||
public void setPositionOffset(Rotation2d offset) { | ||
mEncoder.setPositionOffset(MathUtil.inputModulus(offset.getRotations(), 0.0, 1.0)); | ||
} | ||
|
||
public void setDistancePerRotation(double distancePerRotation) { | ||
mEncoder.setDistancePerRotation(distancePerRotation); | ||
} | ||
} |
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
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
Oops, something went wrong.