-
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
Showing
7 changed files
with
126 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<factorypath> | ||
<factorypathentry kind="EXTJAR" id="C:\Users\Broncobotics\.gradle\caches\modules-2\files-2.1\com.squareup\javapoet\1.13.0\d6562d385049f35eb50403fa86bb11cce76b866a\javapoet-1.13.0.jar" enabled="true" runInBatchMode="false"/> | ||
<factorypathentry kind="EXTJAR" id="C:\Users\Broncobotics\.gradle\caches\modules-2\files-2.1\org.littletonrobotics.akit.junction\junction-autolog\3.1.0\abaf89ad1ac7acc95dbc0d3f0785a39acf98dd0e\junction-autolog-3.1.0.jar" enabled="true" runInBatchMode="false"/> | ||
<factorypathentry kind="EXTJAR" id="/Users/rohangodha/.gradle/caches/modules-2/files-2.1/org.littletonrobotics.akit.junction/junction-autolog/3.1.0/abaf89ad1ac7acc95dbc0d3f0785a39acf98dd0e/junction-autolog-3.1.0.jar" enabled="true" runInBatchMode="false"/> | ||
<factorypathentry kind="EXTJAR" id="/Users/rohangodha/.gradle/caches/modules-2/files-2.1/com.squareup/javapoet/1.13.0/d6562d385049f35eb50403fa86bb11cce76b866a/javapoet-1.13.0.jar" enabled="true" runInBatchMode="false"/> | ||
</factorypath> |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package frc.robot.subsystems.hang; | ||
|
||
import java.util.function.DoubleSupplier; | ||
|
||
import org.littletonrobotics.junction.Logger; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.Commands; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public class Hang extends SubsystemBase { | ||
HangIO io; | ||
HangIOInputsAutoLogged inputs = new HangIOInputsAutoLogged(); | ||
|
||
public Hang(HangIO io) { | ||
this.io = io; | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
io.updateInputs(inputs); | ||
Logger.processInputs("Hang", inputs); | ||
} | ||
|
||
public void setSpeed(double speed) { | ||
io.setSpeed(speed); | ||
} | ||
|
||
public Command operatorControl(DoubleSupplier speedSupplier) { | ||
return Commands.run(() -> { | ||
double speed = speedSupplier.getAsDouble(); | ||
setSpeed(speed * 0.1); | ||
}, this); | ||
} | ||
} |
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,15 @@ | ||
package frc.robot.subsystems.hang; | ||
|
||
import org.littletonrobotics.junction.AutoLog; | ||
|
||
public interface HangIO { | ||
@AutoLog | ||
public static class HangIOInputs { | ||
public double mainCurrent = 0.0; | ||
public double followerCurrent = 0.0; | ||
} | ||
|
||
default void updateInputs(HangIOInputs inputs) {} | ||
|
||
default void setSpeed(double power) {} | ||
} |
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,56 @@ | ||
package frc.robot.subsystems.hang; | ||
|
||
import com.ctre.phoenix6.BaseStatusSignal; | ||
import com.ctre.phoenix6.StatusSignal; | ||
import com.ctre.phoenix6.configs.TalonFXConfiguration; | ||
import com.ctre.phoenix6.controls.Follower; | ||
import com.ctre.phoenix6.hardware.TalonFX; | ||
import com.ctre.phoenix6.signals.NeutralModeValue; | ||
|
||
import frc.robot.Constants.HangConstants; | ||
|
||
public class HangIOReal implements HangIO { | ||
|
||
TalonFX leader; | ||
TalonFX follower; | ||
|
||
StatusSignal<Double> leaderCurrent; | ||
StatusSignal<Double> followerCurrent; | ||
|
||
public HangIOReal() { | ||
|
||
leader = new TalonFX(HangConstants.leaderCANId); | ||
follower = new TalonFX(HangConstants.followerCANId); | ||
|
||
// TODO: should this boolean be false?? do they rotate in the same ways?? | ||
follower.setControl(new Follower(HangConstants.leaderCANId, true)); | ||
|
||
var config = new TalonFXConfiguration(); | ||
|
||
config.CurrentLimits.SupplyCurrentLimit = 40; | ||
config.CurrentLimits.SupplyCurrentLimitEnable = true; config.MotorOutput.NeutralMode = NeutralModeValue.Brake; | ||
|
||
leader.getConfigurator().apply(config); | ||
follower.getConfigurator().apply(config); | ||
|
||
leaderCurrent = leader.getTorqueCurrent(); | ||
followerCurrent = follower.getTorqueCurrent(); | ||
|
||
// don't really need this to update that often b/c it's just for data visualization | ||
BaseStatusSignal.setUpdateFrequencyForAll(100.0, leaderCurrent, followerCurrent); | ||
leader.optimizeBusUtilization(1.0); | ||
follower.optimizeBusUtilization(1.0); | ||
|
||
} | ||
|
||
public void updateInputs(HangIOInputs inputs) { | ||
inputs.mainCurrent = leaderCurrent.getValueAsDouble(); | ||
inputs.followerCurrent = followerCurrent.getValueAsDouble(); | ||
} | ||
|
||
public void setSpeed(double power) { | ||
leader.set(power); | ||
} | ||
|
||
|
||
} |
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,5 @@ | ||
package frc.robot.subsystems.hang; | ||
|
||
public class HangIOSim implements HangIO { | ||
// todo | ||
} |