Skip to content

Commit

Permalink
Began work on the state machine
Browse files Browse the repository at this point in the history
Added states
  • Loading branch information
joshs48 committed Jan 9, 2020
1 parent 171588e commit 262dd67
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/main/java/frc/robot/core/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.core.components.ControlSystem;
import frc.robot.core.components.Drivetrain;
import frc.robot.core.components.LauncherRevUp;
import frc.robot.core.components.LauncherState;

/**
* The VM is configured to automatically run this class, and to call the
Expand Down Expand Up @@ -58,6 +60,8 @@ public void robotInit() {
*/
@Override
public void robotPeriodic() {
LauncherState state = new LauncherRevUp(null, null);
state = state.run();
}

/**
Expand Down
36 changes: 30 additions & 6 deletions src/main/java/frc/robot/core/components/Launcher.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,42 @@
package frc.robot.core.components;
import edu.wpi.first.wpilibj.SpeedController;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.core.components.ControlSystem;
import frc.robot.core.components.Drivetrain;

interface launcher {
boolean stopMotors();
boolean startMotors();
double shoot(double velocity, int burst);
boolean nextState;
void stopMotors();
void startMotors();
void shoot(double velocity, int burst);
void nextState();


}
class UpShoot implements launcher {

@Override
public void stopMotors() {
Upshoot.set(0);

}

@Override
public void startMotors() {
Upshoot.set(1);
}

@Override
public void shoot(double velocity, int burst) {



}

class UpShoot implements launcher{
@Override
public void nextState() {


}

}
25 changes: 25 additions & 0 deletions src/main/java/frc/robot/core/components/LauncherRevUp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package frc.robot.core.components;

import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.SpeedController;

public class LauncherRevUp implements LauncherState {
private final SpeedController motor;
private final Encoder encoder;

public LauncherRevUp(SpeedController motor, Encoder encoder){
this.motor = motor;
this.encoder = encoder;
}


@Override
public LauncherState run() {
motor.set(1);
if(encoder.getRate() > 10){
LauncherShoot state = new LauncherShoot(null);
}
return this;
}

}
22 changes: 22 additions & 0 deletions src/main/java/frc/robot/core/components/LauncherShoot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package frc.robot.core.components;

import edu.wpi.first.wpilibj.SpeedController;

public class LauncherShoot implements LauncherState{
private final SpeedController motor;

public LauncherShoot(SpeedController motor, double velocity, double burst){
this.motor = motor;
motor.set(velocity);
try {
motor.wait();
} catch(Exception e) {

}
//wait until total # of balls are fired
}

public LauncherState run(){
return this;
}
}
5 changes: 5 additions & 0 deletions src/main/java/frc/robot/core/components/LauncherState.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package frc.robot.core.components;

public interface LauncherState{
LauncherState run();
}

0 comments on commit 262dd67

Please sign in to comment.