-
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.
- Loading branch information
1 parent
1791983
commit 2515ae6
Showing
6 changed files
with
31 additions
and
278 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,35 @@ | ||
// Copyright 2021-2024 FRC 6328, FRC 5829 | ||
// http://github.com/Mechanical-Advantage | ||
// | ||
// This program is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU General Public License | ||
// version 3 as published by the Free Software Foundation or | ||
// available in the root directory of this project. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
package frc.robot.subsystems.intake; | ||
|
||
import edu.wpi.first.math.controller.SimpleMotorFeedforward; | ||
import edu.wpi.first.math.util.Units; | ||
import com.revrobotics.CANSparkLowLevel.MotorType; | ||
import com.revrobotics.CANSparkMax; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.Constants; | ||
import frc.robot.Constants.EnvironmentalConstants; | ||
import org.littletonrobotics.junction.AutoLogOutput; | ||
import org.littletonrobotics.junction.Logger; | ||
import frc.robot.Constants.IntakeConstants; | ||
|
||
public class Intake extends SubsystemBase { | ||
private final IntakeIO io; | ||
private final IntakeIOInputsAutoLogged inputs = new IntakeIOInputsAutoLogged(); | ||
private final SimpleMotorFeedforward ffModel; | ||
// private static final double GEAR_RATIO = 52.0 / 34.0; // May be reciprocal | ||
|
||
/** Creates a new Flywheel. */ | ||
public Intake(IntakeIO io) { | ||
this.io = io; | ||
private final CANSparkMax intakeMotor = | ||
new CANSparkMax(IntakeConstants.kIntakeSparkMaxCanId, MotorType.kBrushless); | ||
private final CANSparkMax followerIntakeMotor = | ||
new CANSparkMax(IntakeConstants.kFollowerIntakeSparkMaxCanId, MotorType.kBrushless); | ||
|
||
io.configurePID( | ||
Constants.IntakeConstants.kP, Constants.IntakeConstants.kI, Constants.IntakeConstants.kD); | ||
public Intake() { | ||
intakeMotor.restoreFactoryDefaults(); | ||
followerIntakeMotor.restoreFactoryDefaults(); | ||
|
||
switch (EnvironmentalConstants.currentMode) { | ||
case REAL: | ||
case REPLAY: | ||
ffModel = new SimpleMotorFeedforward(0.1, 0.05); | ||
break; | ||
case SIM: | ||
ffModel = new SimpleMotorFeedforward(0.0, 0.03); | ||
break; | ||
default: | ||
ffModel = new SimpleMotorFeedforward(0.0, 0.0); | ||
break; | ||
} | ||
} | ||
intakeMotor.setInverted(false); | ||
|
||
@Override | ||
public void periodic() { | ||
io.updateInputs(inputs); | ||
Logger.processInputs("Intake", inputs); | ||
} | ||
followerIntakeMotor.follow(intakeMotor, false); | ||
|
||
/** Run open loop at the specified voltage. */ | ||
public void runVolts(double volts) { | ||
io.setVoltage(volts); | ||
intakeMotor.burnFlash(); | ||
followerIntakeMotor.burnFlash(); | ||
} | ||
|
||
/** Run closed loop at the specified velocity. */ | ||
public void runVelocity(double velocityRPM) { | ||
var velocityRadPerSec = Units.rotationsPerMinuteToRadiansPerSecond(velocityRPM); | ||
io.setVelocity(velocityRadPerSec, ffModel.calculate(velocityRadPerSec)); | ||
|
||
// Log flywheel setpoint | ||
Logger.recordOutput("Intake/SetpointRPM", velocityRPM); | ||
public void setPercent(double pct) { | ||
intakeMotor.set(pct); | ||
} | ||
|
||
/** Stops the flywheel. */ | ||
public void stop() { | ||
io.stop(); | ||
} | ||
|
||
/** Returns the current velocity in RPM. */ | ||
@AutoLogOutput | ||
public double getVelocityRPM() { | ||
return Units.radiansPerSecondToRotationsPerMinute(inputs.velocityRadPerSec); | ||
} | ||
|
||
/** Returns the current velocity in radians per second. */ | ||
public double getCharacterizationVelocity() { | ||
return inputs.velocityRadPerSec; | ||
intakeMotor.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
68 changes: 0 additions & 68 deletions
68
src/main/java/frc/robot/subsystems/intake/IntakeIOSim.java
This file was deleted.
Oops, something went wrong.
99 changes: 0 additions & 99 deletions
99
src/main/java/frc/robot/subsystems/intake/IntakeIOSparkMax.java
This file was deleted.
Oops, something went wrong.