diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index ba1ec5c..611e7c8 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -1,5 +1,6 @@
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 3e79c5f..5821b2f 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -4,5 +4,5 @@
-
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 0000000..797acea
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 682050b..f9ac5cc 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,8 +5,11 @@
+
+
+
+
-
@@ -26,16 +29,41 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -51,8 +79,14 @@
+
+
+
+
+
+
@@ -81,4 +115,16 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/github/mittyrobotics/DriveTrain.java b/src/main/java/com/github/mittyrobotics/DriveTrain.java
new file mode 100644
index 0000000..84c1334
--- /dev/null
+++ b/src/main/java/com/github/mittyrobotics/DriveTrain.java
@@ -0,0 +1,32 @@
+package com.github.mittyrobotics;
+
+import edu.wpi.first.wpilibj.Spark;
+import edu.wpi.first.wpilibj2.command.SubsystemBase;
+
+public class DriveTrain extends SubsystemBase {
+
+ public static DriveTrain instance = null;
+ public static DriveTrain getInstance(){
+ if(instance==null){
+ instance = new DriveTrain();
+ }
+ return instance;
+ }
+ Spark sparkLeft, sparkRight;
+
+ public void initHardware(){
+ //initialize stuff here
+ sparkLeft = new Spark(Constants.LEFT_MOTOR_ID);
+ sparkRight = new Spark(Constants.RIGHT_MOTOR_ID);
+ }
+ public void setMotors(double val){
+ sparkLeft.set(val);
+ sparkRight.set(val);
+ }
+ public void setSparkLeft(double val){
+ sparkLeft.set(val);
+ }
+ public void setSparkRight(double val){
+ sparkRight.set(val);
+ }
+}
diff --git a/src/main/java/com/github/mittyrobotics/OI.java b/src/main/java/com/github/mittyrobotics/OI.java
new file mode 100644
index 0000000..88c51f1
--- /dev/null
+++ b/src/main/java/com/github/mittyrobotics/OI.java
@@ -0,0 +1,20 @@
+package com.github.mittyrobotics;
+import edu.wpi.first.wpilibj.XboxController;
+public class OI {
+ private static OI instance;
+ private XboxController xboxController;
+
+ public static OI getInstance(){
+ if(instance == null){
+ instance = new OI();
+ }
+ return instance;
+ }
+
+ public XboxController getXboxController(){
+ if(xboxController == null){
+ xboxController = new XboxController(0);
+ }
+ return xboxController;
+ }
+}
diff --git a/src/main/java/com/github/mittyrobotics/Robot.java b/src/main/java/com/github/mittyrobotics/Robot.java
index 63ba14c..4941afc 100644
--- a/src/main/java/com/github/mittyrobotics/Robot.java
+++ b/src/main/java/com/github/mittyrobotics/Robot.java
@@ -1,29 +1,62 @@
package com.github.mittyrobotics;
-
-import edu.wpi.first.wpilibj.DigitalInput;
-import edu.wpi.first.wpilibj.Encoder;
-import edu.wpi.first.wpilibj.Spark;
-import edu.wpi.first.wpilibj.TimedRobot;
+import edu.wpi.first.wpilibj.*;
import edu.wpi.first.wpilibj.controller.PIDController;
-
-
+import edu.wpi.first.wpilibj.trajectory.TrapezoidProfile;
+import edu.wpi.first.wpilibj.DoubleSolenoid;
+import com.github.mittyrobotics.util.Compressor;
//Java automatically runs this class, and calls the various functions.
/*
* YOUR WIFI MUST BE CONNECTED TO ROMI FOR THIS TO WORK
*/
public class Robot extends TimedRobot {
+ Spark SparkLeft, SparkRight;
+ DigitalInput digitalInput1;
+ DigitalInput input2;
+ DigitalInput input3;
+ DigitalInput input4;
+ XboxController controller;
+ RomiGyro gyro;
+ boolean clicked;
+ boolean released;
//Runs when the robot is first started up and should be used for any initialization code
/*
+
* INITIALIZE CLASSES HERE
*/
-
-
+ TrapezoidProfile.State start; //start variable from type trapezoidprofile.state
+ TrapezoidProfile.State end; //end var
+ TrapezoidProfile.Constraints constraints; //constraints var from .constraints
+ TrapezoidProfile profile; //profile
+ int counter;
+ double kp, ki, kd;
+ PIDController control = new PIDController(kp, ki, kd);
+ Encoder encoder;
+ DoubleSolenoid s;
+ boolean deadZone;
+ DoubleSolenoid p;
@Override
public void robotInit() {
-
-
+ SparkLeft = new Spark(Constants.LEFT_MOTOR_ID;
+ SparkRight = new Spark(Constants.RIGHT_MOTOR_ID);
+ SparkLeft.setInverted(true);
+// digitalInput1 = new DigitalInput(0);
+// input2 = new DigitalInput(1);
+// input3 = new DigitalInput(2);
+// input4 = new DigitalInput(3);
+ controller = new XboxController(0);
+// gyro = new RomiGyro();
+// clicked = controller.getAButtonPressed();
+// released = controller.getAButtonReleased();
+// start = new TrapezoidProfile.State(0, 0);
+// end = new TrapezoidProfile.State(1.0, 0);
+ constraints = new TrapezoidProfile.Constraints(0.2, 0.2);
+// profile = new TrapezoidProfile(constraints, end, start);
+// encoder = new Encoder(Constants.ENCODER_IDS[0], Constants.ENCODER_IDS[1]);
+// s = new DoubleSolenoid(1,2);
+ deadZone = true;
+ DriveTrain.getInstance().initHardware();
}
//Runs periodically during teleoperated mode
@@ -33,6 +66,67 @@ public void robotInit() {
@Override
public void teleopPeriodic() {
+
+ if (clicked){
+ SparkLeft.set(OI.getInstance().getXboxController().getY(GenericHID.Hand.kLeft);
+ SparkRight.set(OI.getInstance().getXboxController().getX(GenericHID.Hand.kLeft);
+ }
+ TrapezoidProfile.State profileOutput = profile.calculate(0.02*counter);
+ control.setSetpoint(profileOutput.position);
+ double output = control.calculate(encoder.getDistance());
+ SparkLeft.set(output);
+ SparkRight.set(output);
+ counter++;
+
+ if(OI.getInstance().getXboxController().getAButton()){
+ s.set(DoubleSolenoid.Value.kForward);
+ }
+ else if(OI.getInstance().getXboxController().getBButton()){
+ s.set(DoubleSolenoid.Value.kReverse);
+ }
+ else if(OI.getInstance().getXboxController().getXButton()){
+ p.set(DoubleSolenoid.Value.kForward);
+ }
+ else if(OI.getInstance().getXboxController().getYButton()){
+ p.set(DoubleSolenoid.Value.kReverse);
+ }
+
+ if(clicked==false){
+ clicked=false;
+ }
+ if(digitalInput1.get()) {
+ SparkLeft.set(0);
+ SparkRight.set(1);
+ }
+ else if(input2.get()){
+ SparkLeft.set(1);
+ SparkRight.set(0);
+ }
+ else if(input3.get()){
+ SparkLeft.set(1);
+ SparkRight.set(1);
+ }
+ else if(input4.get()) {
+ SparkLeft.set(-1);
+ SparkRight.set(-1);
+ }
+ if(controller.getAButton()){
+ while(gyro.getAngleZ()<=45){
+ SparkLeft.set(-0.5);
+ SparkRight.set(0.5);
+ }
+ }
+
+ if(clicked){
+ SparkLeft.set(controller.getY(GenericHID.Hand.kLeft));
+ SparkRight.set(controller.getY(GenericHID.Hand.kRight));
+ }
+ if(controller.getAButton() && gyro.getAngleZ() <= 45){
+ SparkLeft.set(-0.5);
+ SparkRight.set(0.5);
+ }
+
+ */
}
//Runs when antonomous mode (robot runs on its own) first activated via the desktop application
@@ -59,7 +153,7 @@ public void robotPeriodic() {
}
- //Runs periodically during autonomous mode
+ //Runs periodically during auto6nomous mode
@Override
public void autonomousPeriodic() {
diff --git a/src/main/java/com/github/mittyrobotics/Robot1.java b/src/main/java/com/github/mittyrobotics/Robot1.java
new file mode 100644
index 0000000..8be4242
--- /dev/null
+++ b/src/main/java/com/github/mittyrobotics/Robot1.java
@@ -0,0 +1,80 @@
+package com.github.mittyrobotics;
+
+import edu.wpi.first.wpilibj.*;
+import edu.wpi.first.wpilibj.controller.PIDController;
+import edu.wpi.first.wpilibj.trajectory.TrapezoidProfile;
+
+//Java automatically runs this class, and calls the various functions.
+/*
+ * YOUR WIFI MUST BE CONNECTED TO ROMI FOR THIS TO WORK
+ */
+public class Robot1 extends TimedRobot {
+
+ Spark SparkLeft, SparkRight;
+ double deadZone = 0.2;
+ boolean inDeadZone;
+ XboxController controller;
+ @Override
+ public void robotInit() {
+ DriveTrain.getInstance().initHardware();
+ SparkLeft = new Spark(Constants.LEFT_MOTOR_ID);
+ SparkRight = new Spark(Constants.RIGHT_MOTOR_ID);
+
+ //Runs periodically during teleoperated mode
+ /*
+ * WRITE YOUR DRIVE CODE HERE
+ */
+ controller = new XboxController(0);
+
+ }
+ @Override
+ public void teleopPeriodic() {
+ if(controller.getY(GenericHID.Hand.kLeft) > -deadZone && OI.getInstance().getXboxController().getY(GenericHID.Hand.kLeft) > deadZone){
+ DriveTrain.getInstance().setSparkLeft(OI.getInstance().getXboxController().getY(GenericHID.Hand.kLeft));
+ SparkLeft.set(controller.getY(GenericHID.Hand.kLeft));
+ SparkRight.set(controller.getY(GenericHID.Hand.kRight));
+ inDeadZone = false;
+ }
+ else if() {
+ inDeadZone = true;
+ }
+
+
+ }
+
+ //Runs when antonomous mode (robot runs on its own) first activated via the desktop application
+ @Override
+ public void autonomousInit() {
+
+ }
+
+ //Runs when teleoperated mode (robot controlled by driver) is first activated
+ @Override
+ public void teleopInit() {
+
+ }
+
+ //Runs when test mode is activated
+ @Override
+ public void testInit() {
+
+ }
+
+ //Runs whenever the robot is on, periodically: should be used for command schedulers
+ @Override
+ public void robotPeriodic() {
+
+ }
+
+ //Runs periodically during autonomous mode
+ @Override
+ public void autonomousPeriodic() {
+
+ }
+
+ //Runs periodically during test mode
+ @Override
+ public void testPeriodic() {
+
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/github/mittyrobotics/RomiRobot2.java b/src/main/java/com/github/mittyrobotics/RomiRobot2.java
new file mode 100644
index 0000000..85940dc
--- /dev/null
+++ b/src/main/java/com/github/mittyrobotics/RomiRobot2.java
@@ -0,0 +1,148 @@
+package com.github.mittyrobotics;
+import edu.wpi.first.wpilibj.*;
+import edu.wpi.first.wpilibj.controller.PIDController;
+import edu.wpi.first.wpilibj.trajectory.TrapezoidProfile;
+
+public class RomiRobot2 extends TimedRobot {
+ Spark SparkLeft, SparkRight;
+ TrapezoidProfile.State start; //start variable from type trapezoidprofile.state
+ TrapezoidProfile.State end; //end var
+ TrapezoidProfile.Constraints constraints; //constraints var from .constraints
+ TrapezoidProfile profile; //profile
+ RomiGyro gyro;
+ int counter;
+ double kp, ki, kd;
+ PIDController control = new PIDController(kp, ki, kd);
+ Encoder encoder;
+
+ public void robotInit() {
+ SparkLeft = new Spark(Constants.LEFT_MOTOR_ID);
+ SparkRight = new Spark(Constants.RIGHT_MOTOR_ID);
+ SparkLeft.setInverted(true);
+ gyro = new RomiGyro();
+ start = new TrapezoidProfile.State(0, 0);
+ end = new TrapezoidProfile.State(1.0, 0);
+ constraints = new TrapezoidProfile.Constraints(0.2, 0.2);
+ profile = new TrapezoidProfile(constraints, end, start);
+ encoder = new Encoder(Constants.ENCODER_IDS[0], Constants.ENCODER_IDS[1]);
+ }
+ public void teleopPeriodic() {
+
+ //straight 12 inches
+
+
+ }
+ public void challenge(){
+ //no whiles
+ //use variable so ++ when done with step6
+ int currDistance = 0;
+ currDistance += 12;
+ moveForward(12, currDistance);
+ changeDirection(90, true);
+ currDistance += 6;
+ moveForward(6,currDistance);
+ changeDirection(90,false);
+ currDistance += 12;
+ moveForward(12,currDistance);
+ changeDirection(120,true);
+ currDistance += 18;
+ moveForward(18,currDistance);
+ changeDirection(130,false);
+ currDistance += 36;
+ moveForward(36, currDistance);
+ changeDirection(90,true);
+ currDistance += 10;
+ moveForward(10, currDistance);
+ changeDirection(60,false);
+ currDistance += 36;
+ moveForward(36, currDistance);
+ }
+ public void challenge2(){
+ int currDistance = 0;
+ currDistance += 12;
+ moveForward(12, currDistance);
+ changeDirection(90, true);
+ currDistance += 6;
+ moveForward(6,currDistance);
+ changeDirection(90,false);
+ currDistance += 24;
+ moveForward(24,currDistance);
+ changeDirection(90,true);
+ currDistance += 15;
+ moveForward(15,currDistance);
+ changeDirection(80,false);
+ currDistance += 6;
+ moveForward(6, currDistance);
+ changeDirection(100,true);
+ currDistance += 24;
+ moveForward(24, currDistance);
+ changeDirection(110,false);
+ currDistance += 36;
+ moveForward(36, currDistance);
+ changeDirection(70,false);
+ currDistance += 30;
+ moveForward(30, currDistance);
+ }
+ public void moveForward(int d_inch, int currDistance){
+ while(encoder.getDistance()