-
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.
Aidan's elevator implementaion into arm wow ur so cool
- Loading branch information
1 parent
a5d9938
commit cd38b42
Showing
10 changed files
with
113 additions
and
59 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
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
2 changes: 1 addition & 1 deletion
2
src/main/java/frc/robot/subsystems/ElevatorSubsystem/ElevatorEncoderIO.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
18 changes: 18 additions & 0 deletions
18
src/main/java/frc/robot/subsystems/SingleJointedArmSubsystem/ArmEncoderIO.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,18 @@ | ||
package frc.robot.subsystems.SingleJointedArmSubsystem; | ||
|
||
import org.littletonrobotics.junction.AutoLog; | ||
|
||
public interface ArmEncoderIO { | ||
@AutoLog | ||
class ArmEncoderIOInputs { | ||
double unfilteredArmAngle = 0.0; | ||
double armAngle = 0.0; | ||
double encoderPositionRads = 0; | ||
double encoderPositionRots = 0; | ||
double encoderVelocityRads = 0; | ||
double encoderVelocityRots = 0; | ||
} | ||
public default void updateInputs(ArmEncoderIO.ArmEncoderIOInputs inputs) {} | ||
public default void resetEncoderPositionWithArmAngle() {} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/frc/robot/subsystems/SingleJointedArmSubsystem/ArmEncoderIOThroughbore.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,34 @@ | ||
package frc.robot.subsystems.SingleJointedArmSubsystem; | ||
|
||
import edu.wpi.first.math.filter.LinearFilter; | ||
import edu.wpi.first.math.util.Units; | ||
import edu.wpi.first.wpilibj.DutyCycleEncoder; | ||
import edu.wpi.first.wpilibj.Encoder; | ||
import edu.wpi.first.wpilibj.Timer; | ||
import frc.robot.constants.ElevatorConstants; | ||
import frc.robot.constants.SingleJointedArmConstants; | ||
import frc.robot.subsystems.ElevatorSubsystem.ElevatorEncoderIO; | ||
|
||
public class ArmEncoderIOThroughbore implements ArmEncoderIO{ | ||
private final DutyCycleEncoder armDCEncoder; | ||
LinearFilter armFilter = LinearFilter.singlePoleIIR(0.1, 0.02); | ||
|
||
public ArmEncoderIOThroughbore () { | ||
armDCEncoder = new DutyCycleEncoder(0, SingleJointedArmConstants.fullRange, SingleJointedArmConstants.expectedZero); | ||
} | ||
|
||
@Override | ||
public void updateInputs(ArmEncoderIO.ArmEncoderIOInputs inputs) { | ||
inputs.encoderPositionRots = armDCEncoder.get(); | ||
inputs.encoderPositionRads = Units.rotationsToRadians(inputs.encoderPositionRots); | ||
inputs.encoderVelocityRots = armDCEncoder.get() * armDCEncoder.getFrequency(); | ||
inputs.encoderVelocityRads = Units.rotationsToRadians(inputs.encoderVelocityRads); | ||
|
||
inputs.unfilteredArmAngle = inputs.encoderPositionRads / SingleJointedArmConstants.gearingRatio; | ||
inputs.armAngle = armFilter.calculate(inputs.unfilteredArmAngle); | ||
} | ||
@Override | ||
public void resetEncoderPositionWithArmAngle() { | ||
armDCEncoder.close(); | ||
} | ||
} |
3 changes: 0 additions & 3 deletions
3
src/main/java/frc/robot/subsystems/SingleJointedArmSubsystem/SingleJointedArmIO.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
13 changes: 0 additions & 13 deletions
13
src/main/java/frc/robot/subsystems/SingleJointedArmSubsystem/SingleJointedArmIOEncoder.java
This file was deleted.
Oops, something went wrong.
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