This repository has been archived by the owner on Jan 10, 2025. It is now read-only.
-
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.
Unfinished shooter needs testing, pid needs tuning Co-authored-by: totallysomeoneyoudontknow <dev.renu@gmail.com>
- Loading branch information
1 parent
d509857
commit 0a68caf
Showing
10 changed files
with
212 additions
and
66 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) 2024 CurtinFRC | ||
// Open Source Software, you can modify it according to the terms | ||
// of the MIT License at the root of this project | ||
|
||
package frc.robot; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.Commands; | ||
import frc.robot.subsystems.Index; | ||
import frc.robot.subsystems.Intake; | ||
import frc.robot.subsystems.Shooter; | ||
|
||
public class Superstructure { | ||
private final Shooter m_shooter; | ||
private final Intake m_intake; | ||
private final Index m_index; | ||
|
||
public Superstructure(Shooter shooter, Intake intake, Index index) { | ||
m_shooter = shooter; | ||
m_intake = intake; | ||
m_index = index; | ||
} | ||
|
||
public Command intake() { | ||
var lol = | ||
m_index.m_intaking.onTrue( | ||
Commands.parallel( | ||
m_intake.intake(3).until(m_index.m_hasNote).andThen(m_intake.stop()), | ||
m_index.intake(-3).until(m_index.m_hasNote).andThen(m_index.stop()))); | ||
return m_intake.intake(8).until(lol); | ||
} | ||
|
||
public Command shooter() { | ||
return m_shooter.spinup(500).andThen(Commands.parallel(m_shooter.maintain(), m_index.shoot())); | ||
} | ||
|
||
public Command stop() { | ||
return Commands.parallel(m_shooter.stop(), m_intake.stop(), m_index.stop()); | ||
} | ||
|
||
public Command outake() { | ||
return Commands.parallel(m_intake.outake(-8), m_index.outake(8)); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) 2024 CurtinFRC | ||
// Open Source Software, you can modify it according to the terms | ||
// of the MIT License at the root of this project | ||
|
||
package frc.robot.subsystems; | ||
|
||
import com.revrobotics.CANSparkLowLevel.MotorType; | ||
import com.revrobotics.CANSparkMax; | ||
import edu.wpi.first.networktables.BooleanPublisher; | ||
import edu.wpi.first.networktables.NetworkTable; | ||
import edu.wpi.first.networktables.NetworkTableInstance; | ||
import edu.wpi.first.wpilibj.DigitalInput; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import edu.wpi.first.wpilibj2.command.button.Trigger; | ||
import frc.robot.Constants; | ||
|
||
public class Index extends SubsystemBase { | ||
private final CANSparkMax m_motor = new CANSparkMax(Constants.indexerPort, MotorType.kBrushless); | ||
private final DigitalInput frontBeambreak = new DigitalInput(Constants.intakeFrontBeambreak); | ||
private final DigitalInput backBeamBreak = new DigitalInput(Constants.intakeBackBeambreak); | ||
|
||
public final Trigger m_hasNote = new Trigger(backBeamBreak::get); | ||
public final Trigger m_intaking = new Trigger(frontBeambreak::get); | ||
|
||
private final NetworkTable driveStats = NetworkTableInstance.getDefault().getTable("Index"); | ||
private final BooleanPublisher m_ntHasNote = driveStats.getBooleanTopic("Has Note").publish(); | ||
private final BooleanPublisher m_ntIntaking = driveStats.getBooleanTopic("Intaking").publish(); | ||
|
||
public Index() {} | ||
|
||
public Command shoot() { | ||
return run(() -> m_motor.setVoltage(-8)).until(m_hasNote.negate()); | ||
} | ||
|
||
public Command intake(double voltage) { | ||
return run(() -> m_motor.setVoltage(voltage)).until(m_hasNote); | ||
} | ||
|
||
public Command outake(double voltage) { | ||
return run(() -> m_motor.setVoltage(voltage)); | ||
} | ||
|
||
public Command stop() { | ||
return runOnce(() -> m_motor.stopMotor()); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
m_ntHasNote.set(m_hasNote.getAsBoolean()); | ||
m_ntIntaking.set(m_intaking.getAsBoolean()); | ||
} | ||
} |
Oops, something went wrong.