Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions 2022 Season/src/main/java/frc/robot/Lib/InterpolationTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,21 @@ public class InterpolationTable {
private final double[][] referencePoints;
private final int propertyCount;

/**
* Constructor for the InterpolationTable
* @param referencePoints - The reference points to put into the interpolation table
*/
public InterpolationTable(double[][] referencePoints) {
Arrays.sort(referencePoints, INPUT_SORTER);
this.referencePoints = referencePoints;
propertyCount = referencePoints[0].length - 1;
}

/**
* Loops through the reference points and gets the desired list based on the input
* @param input - Input used to determine the desired list
* @return - Desired list of reference points
*/
public double[] sample(double input) {
int leftBoundIndex = 0;
int rightBoundIndex = referencePoints.length - 1;
Expand Down Expand Up @@ -54,6 +63,14 @@ public double[] sample(double input) {
return outputs;
}

/**
* Returns a new output by calculating the interpolation between the two points
* @param input - The input used to determine the interpolation
* @param outputProperty - Index used to calculate the slope of point1 and point2
* @param point1 - List of the first point
* @param point2 - List of the second point
* @return - new interpolated value.
*/
private double interpolate(double input, int outputProperty, double[] point1, double[] point2) {
outputProperty++;
double slope = (point2[outputProperty] - point1[outputProperty]) / (point2[0] - point1[0]);
Expand Down
9 changes: 8 additions & 1 deletion 2022 Season/src/main/java/frc/robot/Lib/Photoeye.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@
import edu.wpi.first.wpilibj.DigitalInput;

public class Photoeye extends DigitalInput {

/**
* Constructor for the Photoeye
* @param port - Port to read the photoeye digital input from
*/
public Photoeye(int port)
{
super(port);
}

/**
* Get the state of the photoeye
* @return true | false
*/
public boolean isBlocked()
{
return !this.get();
Expand Down
52 changes: 52 additions & 0 deletions 2022 Season/src/main/java/frc/robot/Subsystems/Climber.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public Climber(){
_climbTarget = Constants.kClimbPullUpPosition;
}

/**
* Resets the climber encoder only if the limitSwitch is pressed
*/
public void resetClimbEncoder()
{
if (isLimitSwitchPressed())
Expand All @@ -70,22 +73,36 @@ public void resetClimbEncoder()
}
}

/**
* Checks if climber limit switch is pressed
* @return - <strong> true </strong> if limit switch is pressed
*/
public boolean isLimitSwitchPressed()
{
return _climbLimitSwitch.isPressed();
}

/**
* Sets a new climberTarget based on the position provided
* @param position - Position to set climberTarget to
*/
public void setClimbPosition(double position)
{
_climbTarget = position;
}

/**
* Sets the left and right climber motor to -1
*/
public void extend()
{
_leftClimbMotor.set(-1);
_rightClimbMotor.set(-1);
}

/**
* Moves both the left and right climber motors respectively based on the value of the climberEncoder
*/
public void climb()
{
if (_climbEncoder.get() <= 1) {
Expand All @@ -97,53 +114,85 @@ public void climb()
}
}

/**
* Stops moving the climber motors
*/
public void stopClimb()
{
_leftClimbMotor.set(0);
_rightClimbMotor.set(0);
}

/**
* Checks if the climberEncoder value is greater than or equals to the climberTarget values
* @return - <strong> true </strong> if the climberTarger has been reached or passed
*/
public boolean isExtendFinished()
{
return _climbEncoder.get() >= _climbTarget;
}

/**
* Sets the speed of both the left and right climber motors
* @param speed - Speed you would like to set the climber motors
*/
public void setClimberMotor(double speed)
{
_leftClimbMotor.set(speed);
_rightClimbMotor.set(speed);
}

/**
* Sets the climber forward
*/
public void setClimberForward()
{
_climber.set(Value.kForward);
}

/**
* Sets the climber in reverse
*/
public void setClimberReverse()
{
_climber.set(Value.kReverse);
}

/**
* Sets the climber off
*/
public void setClimberOff()
{
_climber.set(Value.kOff);
}

/**
* Sets the ratchet in reverse
*/
public void engageRatchet()
{
_ratchet.set(Value.kReverse);
}

/**
* Sets the ratchet forward
*/
public void disengageRatchet()
{
_ratchet.set(Value.kForward);
}

/**
* Sets the ratchet off
*/
public void setRatchetOff()
{
_climber.set(Value.kOff);
}

/**
* Logs the data of the climber to the SmartDashboard
*/
public void LogTelemetry() {
// TODO Auto-generated method stub

Expand All @@ -153,6 +202,9 @@ public void LogTelemetry() {
SmartDashboard.putNumber("rightClimbCurrent", _rightClimbMotor.getOutputCurrent());
}

/**
* Reads the data of the climber from the SmartDashboard... This function is not implemented yet
*/
public void ReadDashboardData() {
// TODO Auto-generated method stub

Expand Down
45 changes: 45 additions & 0 deletions 2022 Season/src/main/java/frc/robot/Subsystems/Collector.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ public class Collector implements ISubsystem {
private boolean _bottomChamberState = false;
private boolean _topChamberState = false;

/**
* Get the Collector instance
* @return - Instance of collector
*/
public static Collector GetInstance()
{
if (_instance == null)
Expand All @@ -39,6 +43,9 @@ public static Collector GetInstance()
return _instance;
}

/**
* Constructor for the Collector
*/
public Collector()
{
_collectorMotor = new CANSparkMax(Constants.kCollectMotorDeviceId, MotorType.kBrushless);
Expand Down Expand Up @@ -72,11 +79,17 @@ public void stopCollect() {
_collectorMotor.set(0.0);
}

/**
* Stops the collector chamber back and front motors
*/
public void stopChamber() {
_frontChamberMotor.set(0.0);
_backChamberMotor.set(0.0);
}

/**
* Moves the collector chamber back and front motors, to collect the cargo
*/
public void intake() {
_collectorSolenoid.set(true);
_collectorMotor.set(-_collectorSpeed);
Expand All @@ -86,17 +99,27 @@ public void intake() {
_backChamberMotor.set(-_chamberSpeed);
}
}

/**
* Moves the collector motors, to spit the cargo
*/
public void spit() {
_collectorMotor.set(_collectorSpeed);
}

/**
* Moves the collector chamber back and front motors, to eject the cargo
*/
public void eject() {
_collectorSolenoid.set(true);
_collectorMotor.set(_collectorSpeed);
_frontChamberMotor.set(_chamberSpeed);
_backChamberMotor.set(-_chamberSpeed);
}

/**
* Moves the cargo using the front and back chamber motors, and increase ball count accordingly
*/
public void feed() {
_frontChamberMotor.set(-_chamberSpeed);
_backChamberMotor.set(_chamberSpeed);
Expand All @@ -119,11 +142,18 @@ public void feed() {
_bottomChamberState = _chamberBottomSensor.isBlocked();
}

/**
* Sets the ballCount in the collector based on the {@param ballCount}
* @param ballCount - The number of balls in the collector
*/
public void setBallCount(int ballCount)
{
_ballCount = ballCount;
}

/**
* Runs mutiple if conditions that determine the ball count and whether or not the chamber will stopped
*/
public void index()
{
if (_chamberTopSensor.isBlocked())
Expand Down Expand Up @@ -156,19 +186,31 @@ public void index()
_bottomChamberState = _chamberBottomSensor.isBlocked();
}

/**
* Moves the collected front and back motors in the negative direction of the chamber speed.
*/
public void chamberUp() {
_frontChamberMotor.set(-_chamberSpeed);
_backChamberMotor.set(-_chamberSpeed);
}

/**
* Sets the collector solenoid output to true
*/
public void collectorDown() {
_collectorSolenoid.set(true);
}

/**
* Sets the collector solenoid output to false
*/
public void collectorUp() {
_collectorSolenoid.set(false);
}

/**
* Logs collector data into the SmartDashboard
*/
public void LogTelemetry() {
// TODO Auto-generated method stub

Expand All @@ -181,6 +223,9 @@ public void LogTelemetry() {
SmartDashboard.putNumber("ballCount", _ballCount);
}

/**
* Reads collector data from SmartDashboard... At the moment this function is not implemented
*/
public void ReadDashboardData() {
// TODO Auto-generated method stub

Expand Down
Loading