-
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.
I worked on getting the bumper inputs to properly work for each input.
- Loading branch information
1 parent
698ea15
commit cc7ff4a
Showing
6 changed files
with
99 additions
and
35 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
29 changes: 18 additions & 11 deletions
29
src/main/java/frc/robot/subsystems/intake/IntakeBase.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 |
---|---|---|
@@ -1,33 +1,40 @@ | ||
package frc.robot.subsystems.intake; | ||
|
||
import edu.wpi.first.wpilibj.motorcontrol.MotorController; | ||
import edu.wpi.first.wpilibj.motorcontrol.Spark; | ||
import org.littletonrobotics.junction.Logger; | ||
|
||
//import frc.robot.subsystems.intake.IntakeIO; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public class IntakeBase extends SubsystemBase implements Intake { | ||
private final MotorController IntakeMotor; | ||
|
||
private final IntakeIO IO; | ||
private final IntakeIOInputsAutoLogged inputs = new IntakeIOInputsAutoLogged(); | ||
private double voltage; | ||
|
||
public IntakeBase() { | ||
IntakeMotor = new Spark(0); | ||
public IntakeBase(IntakeIO IO) { | ||
|
||
this.IO = IO; | ||
|
||
voltage = 0; | ||
} | ||
|
||
@Override | ||
public void disable() { | ||
voltage = 0; | ||
IntakeMotor.setVoltage(voltage); | ||
IO.setVoltage(voltage); | ||
} | ||
|
||
@Override | ||
public void enable() { | ||
IntakeMotor.setVoltage(voltage); | ||
IO.setVoltage(voltage); | ||
} | ||
|
||
@Override | ||
//Sets the voltage to 5.0 times speed. the speed value is -1 1 | ||
public void setSpeed(double speed) { | ||
voltage = 5.0 * speed; | ||
public void setVoltage(double volts) { | ||
voltage = volts; | ||
} | ||
@Override | ||
public void periodic() { | ||
IO.updateInputs(inputs); | ||
Logger.processInputs("Intake", inputs); | ||
} | ||
} |
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.intake; | ||
|
||
import org.littletonrobotics.junction.AutoLog; | ||
|
||
public interface IntakeIO { | ||
@AutoLog | ||
public static class IntakeIOInputs { | ||
public double velocityRadPerSec = 0.0; | ||
public double appliedVolts = 0.0; | ||
} | ||
|
||
/** Updates the set of loggable inputs. */ | ||
public default void updateInputs(IntakeIOInputs inputs) {} | ||
|
||
/** Run open loop at the specified voltage. */ | ||
public default void setVoltage(double volts) {} | ||
} | ||
|
36 changes: 36 additions & 0 deletions
36
src/main/java/frc/robot/subsystems/intake/IntakeIOSim.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,36 @@ | ||
package frc.robot.subsystems.intake; | ||
|
||
//import edu.wpi.first.math.MathUtil; | ||
import edu.wpi.first.math.system.plant.DCMotor; | ||
import edu.wpi.first.wpilibj.simulation.FlywheelSim; | ||
|
||
public class IntakeIOSim implements IntakeIO{ | ||
private FlywheelSim sim = new FlywheelSim(DCMotor.getNEO(1), 1.5, 0.004); | ||
private double appliedVolts = 0.0; | ||
|
||
@Override | ||
public void updateInputs(IntakeIOInputs inputs) { | ||
|
||
|
||
sim.update(0.02); | ||
|
||
//inputs.positionRad = 0.0; | ||
inputs.velocityRadPerSec = sim.getAngularVelocityRadPerSec(); | ||
inputs.appliedVolts = appliedVolts; | ||
//inputs.currentAmps = new double[] {sim.getCurrentDrawAmps()}; | ||
|
||
|
||
|
||
} | ||
|
||
@Override | ||
public void setVoltage(double volts) { | ||
appliedVolts = volts; | ||
sim.setInputVoltage(volts); | ||
} | ||
|
||
|
||
|
||
|
||
} | ||
|