-
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.
[#12] Created basic collector with beambreak
- Loading branch information
Showing
4 changed files
with
130 additions
and
11 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,38 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.command; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystem.Collector; | ||
|
||
public class Collect extends Command { | ||
|
||
// Declares collector | ||
private Collector collector; | ||
|
||
public Collect(Collector collector) { | ||
// Sets collector from parameter | ||
this.collector = collector; | ||
addRequirements(collector); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
collector.setPower(1d); | ||
} | ||
|
||
@Override | ||
public void execute() {} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
collector.stop(); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return false; | ||
} | ||
} |
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,51 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.subsystem; | ||
|
||
import com.ctre.phoenix6.hardware.TalonFX; | ||
import edu.wpi.first.wpilibj.DigitalInput; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.Constants; | ||
|
||
public class Collector extends SubsystemBase { | ||
|
||
// Declare collector hardware | ||
private TalonFX collectorMotor; | ||
private DigitalInput collectorEntryBeamBreak; | ||
|
||
public Collector() { | ||
// Initialize collector hardware | ||
collectorMotor = new TalonFX(Constants.RobotMap.CAN.COLLECTOR_MOTOR); | ||
collectorEntryBeamBreak = new DigitalInput(Constants.RobotMap.COLLECTOR_ENTRY_BEAMBREAK); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
|
||
} | ||
|
||
/** | ||
* @return When an object is present, returns false, otherwise returns true | ||
*/ | ||
public boolean getEntryBeamBreakState() { | ||
return collectorEntryBeamBreak.get(); | ||
} | ||
|
||
/** | ||
* Sets the power of the collector motor | ||
* @param power Double value from -1.0 to 1.0 (positive collects inwards) | ||
*/ | ||
public void setPower(double power) { | ||
collectorMotor.set(power); | ||
} | ||
|
||
/** | ||
* Stops the collector | ||
*/ | ||
public void stop() { | ||
setPower(0d); | ||
} | ||
|
||
} |