This repository has been archived by the owner on May 19, 2024. It is now read-only.
-
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.
refactor(intake): Use velocity controller for intake rollers.
- Loading branch information
1 parent
c6b7b87
commit 503f188
Showing
4 changed files
with
65 additions
and
13 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/main/java/frc/lib/controller/VelocityControllerIOSim.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,21 @@ | ||
package frc.lib.controller; | ||
|
||
/** Simulated velocity controller. */ | ||
public class VelocityControllerIOSim implements VelocityControllerIO { | ||
|
||
private double velocityRotationsPerSecond = 0.0; | ||
|
||
@Override | ||
public void configure(VelocityControllerIOConstants constants) {} | ||
|
||
@Override | ||
public void update(VelocityControllerIOValues values) { | ||
values.velocityRotationsPerSecond = velocityRotationsPerSecond; | ||
} | ||
|
||
@Override | ||
public void setSetpoint(double velocityRotationsPerSecond) { | ||
this.velocityRotationsPerSecond = velocityRotationsPerSecond; | ||
} | ||
|
||
} |
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,28 +1,30 @@ | ||
package frc.robot.intake; | ||
|
||
import frc.lib.CAN; | ||
import frc.lib.PIDFConstants; | ||
import frc.lib.controller.VelocityControllerIO; | ||
import frc.lib.controller.VelocityControllerIOSim; | ||
import frc.lib.controller.VelocityControllerIOTalonFXPIDF; | ||
import frc.robot.Robot; | ||
import frc.robot.RobotConstants; | ||
import frc.robot.RobotConstants.Subsystem; | ||
import frc.robot.intake.IntakeConstants.BackRollerConstants; | ||
import frc.robot.intake.IntakeConstants.FrontRollerConstants; | ||
|
||
/** Helper class for creating hardware for the intake subsystem. */ | ||
public class IntakeFactory { | ||
|
||
public static VelocityControllerIO createFrontRoller() { | ||
PIDFConstants pidf = new PIDFConstants(); | ||
if (Robot.isReal() && RobotConstants.REAL_SUBSYSTEMS.contains(Subsystem.INTAKE)) { | ||
return new VelocityControllerIOTalonFXPIDF(FrontRollerConstants.CAN, FrontRollerConstants.PIDF); | ||
} | ||
|
||
pidf.kS = 0.13; | ||
pidf.kV = 0.1683; | ||
|
||
return new VelocityControllerIOTalonFXPIDF(new CAN(50), pidf); | ||
return new VelocityControllerIOSim(); | ||
} | ||
|
||
public static VelocityControllerIO createBackRoller() { | ||
PIDFConstants pidf = new PIDFConstants(); | ||
|
||
pidf.kS = 0.13; | ||
pidf.kV = 0.1759; | ||
if (Robot.isReal() && RobotConstants.REAL_SUBSYSTEMS.contains(Subsystem.INTAKE)) { | ||
return new VelocityControllerIOTalonFXPIDF(BackRollerConstants.CAN, BackRollerConstants.PIDF); | ||
} | ||
|
||
return new VelocityControllerIOTalonFXPIDF(new CAN(40), pidf); | ||
return new VelocityControllerIOSim(); | ||
} | ||
} |