-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* climber head bones * 2nd motor bindings + logging Co-authored-by: AlexNunemacher <[email protected]> * file conflict resolution (fire sel skills) Co-authored-by: AlexNunemacher <[email protected]> * Formatted. * small problem fixed --------- Co-authored-by: AlexNunemacher <[email protected]> Co-authored-by: AlexNunemacher <[email protected]> Co-authored-by: Matthew Milunic <[email protected]> Co-authored-by: mmilunicmobile <[email protected]>
- Loading branch information
1 parent
18f618e
commit 757e6c8
Showing
7 changed files
with
149 additions
and
21 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
19 changes: 19 additions & 0 deletions
19
src/main/java/frc/robot/subsystems/climber/ClimberHeadIO.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,19 @@ | ||
package frc.robot.subsystems.climber; | ||
|
||
import org.littletonrobotics.junction.AutoLog; | ||
|
||
public interface ClimberHeadIO { | ||
|
||
public void updateInputs(ClimberHeadIOInputs inputs); | ||
|
||
@AutoLog | ||
public class ClimberHeadIOInputs { | ||
public double position = 0; | ||
public double temperature = 0; | ||
public double current = 0; | ||
public double voltage = 0; | ||
public boolean shutdown = false; | ||
} | ||
|
||
public void setVoltage(double voltage); | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/frc/robot/subsystems/climber/ClimberHeadIONeo550.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,52 @@ | ||
package frc.robot.subsystems.climber; | ||
|
||
import com.revrobotics.spark.SparkBase.PersistMode; | ||
import com.revrobotics.spark.SparkBase.ResetMode; | ||
import com.revrobotics.spark.SparkLowLevel; | ||
import com.revrobotics.spark.SparkMax; | ||
import com.revrobotics.spark.config.SparkBaseConfig; | ||
import com.revrobotics.spark.config.SparkBaseConfig.IdleMode; | ||
import com.revrobotics.spark.config.SparkMaxConfig; | ||
import frc.robot.constants.ClimberConstants; | ||
|
||
public class ClimberHeadIONeo550 implements ClimberHeadIO { | ||
private SparkMax climberHeadMotor = | ||
new SparkMax(ClimberConstants.CLIMBER_HEAD_ID, SparkLowLevel.MotorType.kBrushless); | ||
|
||
public ClimberHeadIONeo550() { | ||
climberHeadMotor.getEncoder().setPosition(0); | ||
|
||
SparkBaseConfig config = | ||
new SparkMaxConfig() | ||
.smartCurrentLimit((int) ClimberConstants.ClimberHeadCurrent) | ||
.secondaryCurrentLimit(ClimberConstants.ClimberHeadCurrent) | ||
.idleMode(IdleMode.kBrake); | ||
climberHeadMotor.configure( | ||
config, ResetMode.kNoResetSafeParameters, PersistMode.kPersistParameters); | ||
} | ||
|
||
private boolean shutdown = false; | ||
|
||
private double lastVoltage = 0; | ||
|
||
public void updateInputs(ClimberHeadIOInputs inputs) { | ||
inputs.position = climberHeadMotor.getEncoder().getPosition(); | ||
inputs.voltage = climberHeadMotor.getBusVoltage() * climberHeadMotor.getAppliedOutput(); | ||
inputs.current = climberHeadMotor.getOutputCurrent(); | ||
inputs.temperature = climberHeadMotor.getMotorTemperature(); | ||
|
||
if (inputs.temperature > 60) { | ||
shutdown = true; | ||
} else if (inputs.temperature < 58) { | ||
shutdown = false; | ||
} | ||
|
||
inputs.shutdown = shutdown; | ||
|
||
climberHeadMotor.setVoltage(lastVoltage); | ||
} | ||
|
||
public void setVoltage(double voltage) { | ||
lastVoltage = voltage; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/frc/robot/subsystems/climber/ClimberHeadIOSim.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,17 @@ | ||
package frc.robot.subsystems.climber; | ||
|
||
public class ClimberHeadIOSim implements ClimberHeadIO { | ||
private double voltage = 0; | ||
private double position = 0; | ||
|
||
public void updateInputs(ClimberHeadIOInputs inputs) { | ||
|
||
position -= 0.02 * voltage; | ||
|
||
inputs.position = position; | ||
} | ||
|
||
public void setVoltage(double voltage) { | ||
this.voltage = voltage; | ||
} | ||
} |
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