-
Notifications
You must be signed in to change notification settings - Fork 2
alpha robot #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
alpha robot #3
Changes from 1 commit
beb0c52
25519fd
ef08852
52104c8
be684fd
819f257
8069e75
857aab2
c196ca5
0b5dace
0b9cec3
f7d98b1
fe8dfd7
1fef3ad
aad5683
c06d888
3c1cde9
8ae87ed
0228daa
1f202a7
72e6bad
f68d088
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package frc.robot; | ||
|
|
||
| public class Constants { | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,42 +8,45 @@ | |
| import edu.wpi.first.math.util.Units; | ||
|
|
||
| public class KickerIOReal implements KickerIO { | ||
|
|
||
| public static final int KICKER_MOTOR_ID = 12; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make sure to either use this on line 13 below or not have it |
||
|
|
||
| private TalonFX kickerMotor = new TalonFX(12); | ||
| private PositionVoltage motorRequest = new PositionVoltage(0.0); | ||
|
|
||
| private StatusSignal<Double> supplyVoltageSignal = kickerMotor.getDutyCycle(); | ||
| private StatusSignal<Double> supplyVoltageSignal = kickerMotor.getMotorVoltage(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not technically supply voltage, maybe name outputVoltageSignal or motorVoltageSignal |
||
| private StatusSignal<Double> position = kickerMotor.getRotorPosition(); | ||
| private StatusSignal<Double> velocity = kickerMotor.getRotorVelocity(); | ||
| private StatusSignal<Double> currentDraw = kickerMotor.getStatorCurrent(); | ||
|
|
||
| public KickerIOReal (){ | ||
| TalonFXConfiguration kickerConfig = new TalonFXConfiguration(); | ||
| kickerConfig.Feedback.SensorToMechanismRatio = 125/1; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is also on line 30 |
||
| kickerConfig.Slot0.kP = 10.0; | ||
| kickerConfig.Slot0.kD = 0.0; | ||
| kickerConfig.Slot0.kI = 0.0; | ||
|
|
||
| kickerConfig.CurrentLimits.StatorCurrentLimit = 20.0; | ||
| kickerConfig.CurrentLimits.StatorCurrentLimitEnable = true; | ||
| kickerConfig.Feedback.SensorToMechanismRatio = 125.0; | ||
| kickerMotor.getConfigurator().apply(kickerConfig); | ||
| } | ||
|
|
||
| public void setPosition(double degrees) { | ||
| kickerMotor.setControl(motorRequest.withPosition(Units.degreesToRotations(degrees))); | ||
| kickerMotor.setControl(motorRequest.withPosition(Units.degreesToRotations(degrees))); | ||
| } | ||
|
|
||
| public void reset(double degrees){ | ||
| kickerMotor.setPosition((Units.degreesToRotations(degrees))); | ||
| } | ||
|
|
||
| public KickerIOInputsAutoLogged updateInputs() { | ||
| KickerIOInputsAutoLogged current = new KickerIOInputsAutoLogged(); | ||
| KickerIOInputsAutoLogged updated = new KickerIOInputsAutoLogged(); //new values | ||
|
|
||
| current.currentDrawAmps = currentDraw.refresh().getValue(); | ||
| current.positionRotations = position.refresh().getValue(); | ||
| current.velocityRPM = velocity.refresh().getValue(); | ||
| current.motorOutputVolts = 12 * supplyVoltageSignal.getValue(); | ||
| updated.currentDrawAmps = currentDraw.getValue(); | ||
| updated.positionRotations = position.getValue(); | ||
| updated.velocityRPS = velocity.getValue(); | ||
| updated.motorOutputVolts = 12 * supplyVoltageSignal.getValue(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you dont need to multiply by 12 anymore |
||
|
|
||
| return(current); | ||
| return(updated); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,15 +15,17 @@ | |
|
|
||
| public class PivotIOReal implements PivotIO{ | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same feedback as with kicker |
||
|
|
||
| public static final int PIVOT_MOTOR_ID = 10; | ||
| public static final double PIVOT_GEAR_RATIO = (27.0 / 1) * (48.0 / 22); //check if this is the correct gear ratio | ||
|
|
||
| private TalonFX pivotMotor = new TalonFX(10); | ||
| private PositionVoltage motorRequest = new PositionVoltage(0.0); | ||
|
|
||
| private StatusSignal<Double> supplyVoltageSignal = pivotMotor.getDutyCycle(); | ||
| private StatusSignal<Double> supplyVoltageSignal = pivotMotor.getMotorVoltage(); | ||
| private StatusSignal<Double> position = pivotMotor.getRotorPosition(); | ||
| private StatusSignal<Double> velocity = pivotMotor.getRotorVelocity(); | ||
| private StatusSignal<Double> currentDraw = pivotMotor.getStatorCurrent(); | ||
|
|
||
|
|
||
| public PivotIOReal (){ | ||
| TalonFXConfiguration pivotConfig = new TalonFXConfiguration(); | ||
| pivotConfig.Slot0.kP = 120; | ||
|
|
@@ -51,13 +53,13 @@ public void reset(double degrees){ | |
|
|
||
| @Override | ||
| public PivotIOInputsAutoLogged updateInputs() { | ||
| PivotIOInputsAutoLogged current = new PivotIOInputsAutoLogged(); | ||
| PivotIOInputsAutoLogged updated = new PivotIOInputsAutoLogged(); | ||
|
|
||
| current.currentDrawAmps = currentDraw.refresh().getValue(); | ||
| current.positionRotations = position.refresh().getValue(); | ||
| current.velocityRPM = velocity.refresh().getValue(); | ||
| current.motorOutputVolts = 12 * supplyVoltageSignal.getValue(); | ||
| updated.currentDrawAmps = currentDraw.getValue(); | ||
| updated.positionRotations = position.getValue(); | ||
| updated.velocityRPS = velocity.getValue(); | ||
| updated.motorOutputVolts = 12 * supplyVoltageSignal.getValue(); | ||
|
|
||
| return(current); | ||
| return(updated); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ public PivotIOInputsAutoLogged updateInputs() { | |
|
|
||
| // var motorSimState = motor.getSimState(); | ||
|
|
||
| input.velocityRPM = arm.getVelocityRadPerSec() * 60; | ||
| input.velocityRPS = arm.getVelocityRadPerSec() * 60; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check units here |
||
| input.currentDrawAmps = arm.getCurrentDrawAmps(); | ||
| input.temperatureCelsius = 0; | ||
| input.motorOutputVolts = arm.getOutput(0); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do not need this file, if you added it because of the errors on the import statements in other files you can remove those imports