generated from OakvilleDynamics/frc-robot-template
-
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
82c0640
commit 32b7e6d
Showing
4 changed files
with
107 additions
and
0 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,49 @@ | ||
// 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.commands; | ||
|
||
import edu.wpi.first.wpilibj.Joystick; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.subsystems.FlyWheel; | ||
|
||
public class FlyWCommand extends Command { | ||
private final FlyWheel m_FlyWSubsystem; | ||
// controller | ||
// TODO: Change this to the correct controller | ||
private final Joystick ConveyorJoystick = new Joystick(1); | ||
|
||
public FlyWCommand(FlyWheel subsystem) { | ||
m_FlyWSubsystem = subsystem; | ||
addRequirements(m_FlyWSubsystem); | ||
} | ||
|
||
@Override | ||
public void initialize() {} | ||
|
||
@Override | ||
public void execute() { | ||
// TODO: Change this to the correct button | ||
if (ConveyorJoystick.getRawButton(3) == true) { | ||
m_FlyWSubsystem.enableflywheel(); | ||
// TODO: Change this to the correct button | ||
} else if (ConveyorJoystick.getRawButton(4) == true) { | ||
m_FlyWSubsystem.reverseflywheel(); | ||
System.out.println("Conveyor Moving in Reverse"); | ||
} else { | ||
m_FlyWSubsystem.disableflywheel(); | ||
} | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
m_FlyWSubsystem.disableflywheel(); | ||
m_FlyWSubsystem.enableflywheel(); | ||
} | ||
|
||
@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,47 @@ | ||
// 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.subsystems; | ||
|
||
import com.revrobotics.CANSparkLowLevel; | ||
import com.revrobotics.CANSparkMax; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.Constants.MechanismConstants; | ||
|
||
public class FlyWheel extends SubsystemBase { | ||
|
||
private final CANSparkMax flywheelMotor1 = | ||
new CANSparkMax(MechanismConstants.FLYWHEEL_MOTOR_1, CANSparkLowLevel.MotorType.kBrushless); | ||
private final CANSparkMax flywheelMotor2 = | ||
new CANSparkMax(MechanismConstants.FLYWHEEL_MOTOR_2, CANSparkLowLevel.MotorType.kBrushless); | ||
|
||
/** Creates a new flywheel. */ | ||
public FlyWheel() { | ||
flywheelMotor1.setInverted(MechanismConstants.FLYWHEEL_MOTOR_1_INVERTED); | ||
flywheelMotor2.setInverted(MechanismConstants.FLYWHEEL_MOTOR_2_INVERTED); | ||
} | ||
|
||
/** Sets the flywheel motors to 100% power. */ | ||
public void enableflywheel() { | ||
flywheelMotor1.set(MechanismConstants.FLYWHEEL_MOTOR_SPEED); | ||
flywheelMotor2.set(MechanismConstants.FLYWHEEL_MOTOR_SPEED); | ||
} | ||
|
||
/** Sets the flywheel motors to 0% power. */ | ||
public void disableflywheel() { | ||
flywheelMotor1.set(0); | ||
flywheelMotor2.set(0); | ||
} | ||
|
||
/** Sets the flywheel motors to -100% power. (Reverse direction) */ | ||
public void reverseflywheel() { | ||
flywheelMotor1.set(-MechanismConstants.FLYWHEEL_MOTOR_SPEED); | ||
flywheelMotor2.set(-MechanismConstants.FLYWHEEL_MOTOR_SPEED); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
// This method will be called once per scheduler run | ||
} | ||
} |