-
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.
Added controls for the intake and conveyor system
- Loading branch information
tgurlik
committed
Jan 6, 2020
1 parent
d27e4ca
commit 4684855
Showing
8 changed files
with
393 additions
and
9 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
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) 2018-2019 FIRST. All Rights Reserved. */ | ||
/* Open Source Software - may be modified and shared by FRC teams. The code */ | ||
/* must be accompanied by the FIRST BSD license file in the root directory of */ | ||
/* the project. */ | ||
/*----------------------------------------------------------------------------*/ | ||
|
||
package frc.robot.commands; | ||
|
||
import frc.robot.subsystems.Conveyor; | ||
import edu.wpi.first.wpilibj2.command.CommandBase; | ||
|
||
/** | ||
* An example command that uses an example subsystem. | ||
*/ | ||
public class ConveyorDown extends CommandBase { | ||
@SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) | ||
private final Conveyor m_conveyor; | ||
|
||
/** | ||
* Creates a new ConveyorDown Command. | ||
* | ||
* @param subsystem The subsystem used by this command. | ||
*/ | ||
public ConveyorDown(Conveyor conveyor) { | ||
m_conveyor = conveyor; | ||
// Use addRequirements() here to declare subsystem dependencies. | ||
addRequirements(conveyor); | ||
} | ||
|
||
// Called when the command is initially scheduled. | ||
@Override | ||
public void initialize() { | ||
} | ||
|
||
// Called every time the scheduler runs while the command is scheduled. | ||
@Override | ||
public void execute() { | ||
m_conveyor.lowerConveyor(); | ||
} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) { | ||
m_conveyor.stopConveyor(); | ||
} | ||
|
||
// Returns true when the command should end. | ||
@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,53 @@ | ||
/*----------------------------------------------------------------------------*/ | ||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ | ||
/* Open Source Software - may be modified and shared by FRC teams. The code */ | ||
/* must be accompanied by the FIRST BSD license file in the root directory of */ | ||
/* the project. */ | ||
/*----------------------------------------------------------------------------*/ | ||
|
||
package frc.robot.commands; | ||
|
||
import frc.robot.subsystems.Conveyor; | ||
import edu.wpi.first.wpilibj2.command.CommandBase; | ||
|
||
/** | ||
* An example command that uses an example subsystem. | ||
*/ | ||
public class ConveyorUp extends CommandBase { | ||
@SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) | ||
private final Conveyor m_conveyor; | ||
|
||
/** | ||
* Creates a new ConveyorUp. | ||
* | ||
* @param subsystem The subsystem used by this command. | ||
*/ | ||
public ConveyorUp(Conveyor conveyor) { | ||
m_conveyor = conveyor; | ||
// Use addRequirements() here to declare subsystem dependencies. | ||
addRequirements(conveyor); | ||
} | ||
|
||
// Called when the command is initially scheduled. | ||
@Override | ||
public void initialize() { | ||
} | ||
|
||
// Called every time the scheduler runs while the command is scheduled. | ||
@Override | ||
public void execute() { | ||
m_conveyor.raiseConveyor(); | ||
} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) { | ||
m_conveyor.stopConveyor(); | ||
} | ||
|
||
// Returns true when the command should end. | ||
@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,38 @@ | ||
/*----------------------------------------------------------------------------*/ | ||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ | ||
/* Open Source Software - may be modified and shared by FRC teams. The code */ | ||
/* must be accompanied by the FIRST BSD license file in the root directory of */ | ||
/* the project. */ | ||
/*----------------------------------------------------------------------------*/ | ||
|
||
package frc.robot.subsystems; | ||
|
||
import com.ctre.phoenix.motorcontrol.can.WPI_VictorSPX; | ||
|
||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.Constants; | ||
|
||
public class Conveyor extends SubsystemBase { | ||
private final WPI_VictorSPX m_conveyor = new WPI_VictorSPX(Constants.kConveyor); | ||
|
||
/** | ||
* Runs conveyor up | ||
*/ | ||
public void raiseConveyor() { | ||
m_conveyor.set(Constants.kConveyorSpeed); | ||
} | ||
|
||
/** | ||
* Runs conveyor down | ||
*/ | ||
public void lowerConveyor() { | ||
m_conveyor.set(-Constants.kConveyorSpeed); | ||
} | ||
|
||
/** | ||
* Stops conveyor | ||
*/ | ||
public void stopConveyor() { | ||
m_conveyor.stopMotor(); | ||
} | ||
} |
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,26 @@ | ||
/*----------------------------------------------------------------------------*/ | ||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ | ||
/* Open Source Software - may be modified and shared by FRC teams. The code */ | ||
/* must be accompanied by the FIRST BSD license file in the root directory of */ | ||
/* the project. */ | ||
/*----------------------------------------------------------------------------*/ | ||
|
||
package frc.robot.subsystems; | ||
|
||
import com.ctre.phoenix.motorcontrol.can.WPI_VictorSPX; | ||
|
||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import frc.robot.Constants; | ||
|
||
public class Intake extends SubsystemBase { | ||
private final WPI_VictorSPX m_intake = new WPI_VictorSPX(Constants.kIntake); | ||
|
||
/** | ||
* Runs the intake motor | ||
* @param left Value of left trigger | ||
* @param right Value of right trigger | ||
*/ | ||
public void runIntake(double left, double right) { | ||
m_intake.set(right - left); | ||
} | ||
} |
Oops, something went wrong.