-
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
Showing
16 changed files
with
4,529 additions
and
4,223 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,74 @@ | ||
package frc.robot.intake; | ||
|
||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.REVLibError; | ||
import com.revrobotics.RelativeEncoder; | ||
import edu.wpi.first.math.util.Units; | ||
|
||
public class IntakeIOSparkMAX implements IntakeIO { | ||
|
||
private final CANSparkMax topRollerMotor, bottomRollerMotor, centeringMotors; | ||
private final CANSparkMax m_topRollerMotor, m_bottomRollerMotor, m_centeringMotors; | ||
private final RelativeEncoder m_topRollerEncoder, m_bottomRollerEncoder; | ||
|
||
public IntakeIOSparkMAX() { | ||
topRollerMotor = new CANSparkMax(5, CANSparkMax.MotorType.kBrushless); | ||
bottomRollerMotor = new CANSparkMax(6, CANSparkMax.MotorType.kBrushless); | ||
centeringMotors = new CANSparkMax(8, CANSparkMax.MotorType.kBrushed); | ||
m_topRollerMotor = new CANSparkMax(5, CANSparkMax.MotorType.kBrushless); | ||
m_bottomRollerMotor = new CANSparkMax(6, CANSparkMax.MotorType.kBrushless); | ||
m_centeringMotors = new CANSparkMax(8, CANSparkMax.MotorType.kBrushed); | ||
|
||
m_topRollerEncoder = topRollerMotor.getEncoder(); | ||
m_bottomRollerEncoder = bottomRollerMotor.getEncoder(); | ||
m_topRollerEncoder = m_topRollerMotor.getEncoder(); | ||
m_bottomRollerEncoder = m_bottomRollerMotor.getEncoder(); | ||
|
||
topRollerMotor.restoreFactoryDefaults(); | ||
bottomRollerMotor.restoreFactoryDefaults(); | ||
m_topRollerMotor.restoreFactoryDefaults(); | ||
m_bottomRollerMotor.restoreFactoryDefaults(); | ||
|
||
topRollerMotor.setSmartCurrentLimit(40); | ||
bottomRollerMotor.setSmartCurrentLimit(40); | ||
centeringMotors.setSmartCurrentLimit(40); | ||
m_topRollerMotor.setSmartCurrentLimit(40); | ||
m_bottomRollerMotor.setSmartCurrentLimit(40); | ||
m_centeringMotors.setSmartCurrentLimit(40); | ||
} | ||
|
||
@Override | ||
public void updateInputs(IntakeIOInputs inputs) { | ||
inputs.topRollerVelocityRpm = | ||
Units.rotationsPerMinuteToRadiansPerSecond(m_topRollerEncoder.getVelocity()); | ||
inputs.topRollerAppliedVolts = | ||
topRollerMotor.getAppliedOutput() * topRollerMotor.getBusVoltage(); | ||
inputs.topRollerCurrentAmps = topRollerMotor.getOutputCurrent(); | ||
m_topRollerMotor.getAppliedOutput() * m_topRollerMotor.getBusVoltage(); | ||
inputs.topRollerCurrentAmps = m_topRollerMotor.getOutputCurrent(); | ||
|
||
inputs.bottomRollerVelocityRpm = | ||
Units.rotationsPerMinuteToRadiansPerSecond(m_bottomRollerEncoder.getVelocity()); | ||
inputs.bottomRollerAppliedVolts = | ||
bottomRollerMotor.getAppliedOutput() * bottomRollerMotor.getBusVoltage(); | ||
inputs.bottomRollerCurrentAmps = bottomRollerMotor.getOutputCurrent(); | ||
m_bottomRollerMotor.getAppliedOutput() * m_bottomRollerMotor.getBusVoltage(); | ||
inputs.bottomRollerCurrentAmps = m_bottomRollerMotor.getOutputCurrent(); | ||
|
||
inputs.centeringBagMotorsAppliedVolts = | ||
centeringMotors.getAppliedOutput() * centeringMotors.getBusVoltage(); | ||
inputs.bottomRollerCurrentAmps = centeringMotors.getOutputCurrent(); | ||
m_centeringMotors.getAppliedOutput() * m_centeringMotors.getBusVoltage(); | ||
inputs.bottomRollerCurrentAmps = m_centeringMotors.getOutputCurrent(); | ||
|
||
inputs.rollerMotorsConnected = | ||
m_topRollerMotor.getLastError() == REVLibError.kOk | ||
&& m_bottomRollerMotor.getLastError() == REVLibError.kOk; | ||
inputs.centeringMotorConnected = m_centeringMotors.getLastError() == REVLibError.kOk; | ||
} | ||
|
||
@Override | ||
public void setFrontRollersVoltage(double volts) { | ||
topRollerMotor.setVoltage(volts); | ||
m_topRollerMotor.setVoltage(volts); | ||
} | ||
|
||
@Override | ||
public void setBackRollersVoltage(double volts) { | ||
bottomRollerMotor.setVoltage(volts); | ||
m_bottomRollerMotor.setVoltage(volts); | ||
} | ||
|
||
@Override | ||
public void setCenteringMotorsVoltage(double volts) { | ||
centeringMotors.setVoltage(volts); | ||
m_centeringMotors.setVoltage(volts); | ||
} | ||
|
||
@Override | ||
public void stopRollers() { | ||
topRollerMotor.stopMotor(); | ||
bottomRollerMotor.stopMotor(); | ||
centeringMotors.stopMotor(); | ||
m_topRollerMotor.stopMotor(); | ||
m_bottomRollerMotor.stopMotor(); | ||
m_centeringMotors.stopMotor(); | ||
} | ||
} |
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