From 5f2d20365fc8426c1f469428a7aa2e584a461911 Mon Sep 17 00:00:00 2001 From: Rivest8 <7680684+Rivest8@users.noreply.github.com> Date: Tue, 18 Feb 2020 19:27:47 -0600 Subject: [PATCH 01/13] added bind() to robotinit --- src/main/java/frc/robot/Robot.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 40db2c9..5961048 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -49,6 +49,7 @@ public void robotInit() { drive_subsystem = new drive_subsystem(); colorWheel_subsystem = new colorWheel_subsystem(); m_oi = new OI(); + m_oi.bind(); //bind the buttons to commands // m_chooser.setDefaultOption("Default Auto", kDefaultAuto); // m_chooser.addOption("My Auto", kCustomAuto); // SmartDashboard.putData("Auto choices", m_chooser); From 7385fb1583d7f00f1364cf8f074b36848e6d18dc Mon Sep 17 00:00:00 2001 From: Rivest8 <7680684+Rivest8@users.noreply.github.com> Date: Tue, 25 Feb 2020 08:05:43 -0600 Subject: [PATCH 02/13] updated to 2020.3.2 from 2020.1.2 --- build.gradle | 2 +- src/main/java/frc/robot/Robot.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 0e4fe1a..9eb9d8f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id "java" - id "edu.wpi.first.GradleRIO" version "2020.1.2" + id "edu.wpi.first.GradleRIO" version "2020.3.2" } sourceCompatibility = JavaVersion.VERSION_11 diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 5961048..fe43244 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -113,7 +113,7 @@ public static double getFullYaw() { currentYaw = 360 - Robot.navx.getYaw(); } //System.out.println("yaw: "+ currentYaw); - WriteOut("Fused Yaw: "+ currentYaw, 0); + WriteOut("Fused Yaw: "+ currentYaw, 5); return currentYaw; } From 8c39606ee4da0d4a83cd468a3b118361fd745a92 Mon Sep 17 00:00:00 2001 From: Stefan Hauge Date: Mon, 2 Mar 2020 19:11:18 -0600 Subject: [PATCH 03/13] first commit (unsure if works) --- src/main/java/frc/robot/Robot.java | 3 + src/main/java/frc/robot/RobotMap.java | 3 + .../java/frc/robot/commands/lift_command.java | 58 +++++++++++++++++++ .../frc/robot/subsystems/lift_subsystem.java | 39 +++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 src/main/java/frc/robot/commands/lift_command.java create mode 100644 src/main/java/frc/robot/subsystems/lift_subsystem.java diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index cb36a93..f90a54a 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -17,6 +17,7 @@ import frc.robot.subsystems.drive_subsystem; import frc.robot.subsystems.index_subsystem; import frc.robot.subsystems.intake_subsystem; +import frc.robot.subsystems.lift_subsystem; import frc.robot.subsystems.shooter_subsystem; import java.util.Date; import java.text.SimpleDateFormat; @@ -44,6 +45,7 @@ public class Robot extends TimedRobot { public static intake_subsystem intake_subsystem = null; public static index_subsystem index_subsystem = null; public static shooter_subsystem shooter_subsystem = null; + public static lift_subsystem lift_subsystem = null; @@ -61,6 +63,7 @@ public void robotInit() { index_subsystem = new index_subsystem(); shooter_subsystem = new shooter_subsystem(); colorWheel_subsystem = new colorWheel_subsystem(); + lift_subsystem = new lift_subsystem(); m_oi = new OI(); // m_chooser.setDefaultOption("Default Auto", kDefaultAuto); // m_chooser.addOption("My Auto", kCustomAuto); diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index 0f5ab75..022fe39 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -82,4 +82,7 @@ public class RobotMap { //color sensor public static final I2C.Port i2cPort = I2C.Port.kOnboard; + + //lift motor + public static final int LIFTMOTOR = 7; } diff --git a/src/main/java/frc/robot/commands/lift_command.java b/src/main/java/frc/robot/commands/lift_command.java new file mode 100644 index 0000000..bc63f05 --- /dev/null +++ b/src/main/java/frc/robot/commands/lift_command.java @@ -0,0 +1,58 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 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 edu.wpi.first.wpilibj.command.Command; +import frc.robot.Robot; +import frc.robot.subsystems.lift_subsystem; + +public class lift_command extends Command { + public boolean dpad_up; + public lift_command() { + requires(Robot.lift_subsystem); + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + @Override + protected void initialize() { + dpad_up = Robot.m_oi.Driver_upButton.get(); + } + + // Called repeatedly when this Command is scheduled to run + @Override + protected void execute() { + if (dpad_up = true){ + Robot.lift_subsystem.motorSpeed(0.75); + } + else{ + Robot.lift_subsystem.motorSpeed(0); + } + } + + // Make this return true when this Command no longer needs to run execute() + @Override + protected boolean isFinished() { + return false; + } + + // Called once after isFinished returns true + @Override + protected void end() { + Robot.lift_subsystem.motorSpeed(0); + + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + @Override + protected void interrupted() { + end(); + } +} diff --git a/src/main/java/frc/robot/subsystems/lift_subsystem.java b/src/main/java/frc/robot/subsystems/lift_subsystem.java new file mode 100644 index 0000000..ea09fe5 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/lift_subsystem.java @@ -0,0 +1,39 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 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_TalonSRX; + +import edu.wpi.first.wpilibj.command.Subsystem; +import frc.robot.Robot; +import frc.robot.RobotMap; +import frc.robot.commands.lift_command; + +/** + * Add your docs here. + */ +public class lift_subsystem extends Subsystem { + // Put methods for controlling this subsystem + // here. Call these from Commands. + + WPI_TalonSRX liftMotor = null; + + public lift_subsystem(){ + liftMotor = new WPI_TalonSRX(RobotMap.LIFTMOTOR); + } + public void motorSpeed(double speed){ + liftMotor.set(speed); + } + + @Override + public void initDefaultCommand() { + setDefaultCommand(new lift_command()); + // Set the default command for a subsystem here. + // setDefaultCommand(new MySpecialCommand()); + } +} From 6361083e950d06a9819444ff46d545b8f4eacf00 Mon Sep 17 00:00:00 2001 From: Levy8Me Date: Fri, 6 Mar 2020 14:12:02 -0600 Subject: [PATCH 04/13] added m_oi binding --- src/main/java/frc/robot/Robot.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 00ef2ed..aa3623d 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -64,11 +64,7 @@ public void robotInit() { drive_subsystem = new drive_subsystem(); intake_subsystem = new intake_subsystem(); m_oi = new OI(); -<<<<<<< HEAD - m_oi.bind(); -======= m_oi.bind(); //bind the buttons to commands ->>>>>>> 3d3c70cac745b5549e3c313b054f7dc3644f6640 // m_chooser.setDefaultOption("Default Auto", kDefaultAuto); // m_chooser.addOption("My Auto", kCustomAuto); // SmartDashboard.putData("Auto choices", m_chooser); From dd1493543a92c711751367ea79b711549b7cf811 Mon Sep 17 00:00:00 2001 From: Levy8Me Date: Fri, 6 Mar 2020 17:12:31 -0600 Subject: [PATCH 05/13] updated solenoids --- src/main/java/frc/robot/Robot.java | 2 +- src/main/java/frc/robot/RobotMap.java | 6 ++--- .../frc/robot/commands/index_command.java | 15 ++++++++--- .../frc/robot/subsystems/index_subsystem.java | 26 +++++++------------ 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index aa3623d..e9125ad 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -58,7 +58,7 @@ public Robot(){ */ @Override public void robotInit() { - //index_subsystem = new index_subsystem(); + index_subsystem = new index_subsystem(); //shooter_subsystem = new shooter_subsystem(); colorWheel_subsystem = new colorWheel_subsystem(); drive_subsystem = new drive_subsystem(); diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index c7c0b84..2c8ec0b 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -35,8 +35,8 @@ public class RobotMap { public static final int MOTOR_SHOOT_TOP = 2; public static final int MOTOT_SHOOT_BOTTOM = 1; //SOLENOID - public static final int SOLENOID_1 = 10; - public static final int SOLENOID_2 = 11; + public static final int SOLENOID_IN = 0; + public static final int SOLENOID_OUT = 1; //AIR COMPRESSOR //public static final int AIRCOMP = 0; //COLOR WHEEL @@ -82,4 +82,4 @@ public class RobotMap { //color sensor public static final I2C.Port i2cPort = I2C.Port.kOnboard; -} +} \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/index_command.java b/src/main/java/frc/robot/commands/index_command.java index c93c325..5419ecf 100644 --- a/src/main/java/frc/robot/commands/index_command.java +++ b/src/main/java/frc/robot/commands/index_command.java @@ -8,9 +8,14 @@ package frc.robot.commands; import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj.DoubleSolenoid; +import edu.wpi.first.wpilibj.DoubleSolenoid.Value; import frc.robot.Robot; public class index_command extends Command { + Value kOff; + Value kForward; + Value kReverse; public index_command() { requires(Robot.index_subsystem); // Use requires() here to declare subsystem dependencies @@ -20,16 +25,20 @@ public index_command() { // Called just before this Command runs the first time @Override protected void initialize() { + kOff = DoubleSolenoid.Value.kOff; + kForward = DoubleSolenoid.Value.kForward; + kReverse = DoubleSolenoid.Value.kReverse; } // Called repeatedly when this Command is scheduled to run @Override protected void execute() { if(Robot.m_oi.buttonB.get()){ - Robot.index_subsystem.indexActivate(true); + System.out.println("B"); + Robot.index_subsystem.indexActivate(kForward); } else{ - Robot.index_subsystem.indexActivate(false); + Robot.index_subsystem.indexActivate(kReverse); } // If the a button is pressed the boolean value is true which activates the pnuematics of the indexing system } @@ -43,7 +52,7 @@ protected boolean isFinished() { // Called once after isFinished returns true @Override protected void end() { - Robot.index_subsystem.indexActivate(false); + Robot.index_subsystem.indexActivate(kOff); } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/subsystems/index_subsystem.java b/src/main/java/frc/robot/subsystems/index_subsystem.java index 1ca4098..08cc794 100644 --- a/src/main/java/frc/robot/subsystems/index_subsystem.java +++ b/src/main/java/frc/robot/subsystems/index_subsystem.java @@ -7,11 +7,12 @@ package frc.robot.subsystems; -import edu.wpi.first.wpilibj.Solenoid; import edu.wpi.first.wpilibj.command.Subsystem; import frc.robot.RobotMap; import frc.robot.commands.index_command; import edu.wpi.first.wpilibj.Compressor; +import edu.wpi.first.wpilibj.DoubleSolenoid.Value; +import edu.wpi.first.wpilibj.DoubleSolenoid; /** @@ -21,9 +22,8 @@ public class index_subsystem extends Subsystem { // Put methods for controlling this subsystem // here. Call these from Commands. - Solenoid solenoid_right; - Solenoid solenoid_left; - Compressor airComp; + DoubleSolenoid solenoid; + public static Compressor airComp; @Override public void initDefaultCommand() { @@ -32,9 +32,10 @@ public void initDefaultCommand() { // setDefaultCommand(new MySpecialCommand()); } public index_subsystem(){ - airComp = new Compressor(); - solenoid_right = new Solenoid(RobotMap.SOLENOID_1); - solenoid_left = new Solenoid(RobotMap.SOLENOID_2); + airComp = new Compressor(10); + airComp.clearAllPCMStickyFaults(); + airComp.stop(); + solenoid = new DoubleSolenoid(RobotMap.SOLENOID_IN, RobotMap.SOLENOID_OUT); if(airComp.getPressureSwitchValue()){ airComp.start(); } @@ -46,15 +47,8 @@ public index_subsystem(){ /** Extends or retracts both pneumatic pistons based on 'active' * @param active if true pistons are extended if false they are retracted */ - public void indexActivate(boolean active){ - if(active){ - airComp.start(); - } - else{ - airComp.stop(); - } - solenoid_right.set(active); - solenoid_left.set(active); + public void indexActivate(Value status){ + solenoid.set(status); } } From 1ad03b1c81b11ef3e0ee84f8fd78a2331d1be2f9 Mon Sep 17 00:00:00 2001 From: lewisgra000 Date: Fri, 6 Mar 2020 20:21:04 -0600 Subject: [PATCH 06/13] Got to run with no errors but lots commented out --- src/main/java/frc/robot/Robot.java | 6 ++-- src/main/java/frc/robot/RobotMap.java | 8 ++--- .../frc/robot/commands/intake_command.java | 5 +++- .../frc/robot/commands/shooter_command.java | 28 ++++++++--------- .../robot/subsystems/shooter_subsystem.java | 28 ++++++++--------- vendordeps/Phoenix.json | 30 +++++++++---------- vendordeps/REVColorSensorV3.json | 6 ++-- vendordeps/REVRobotics.json | 10 +++---- 8 files changed, 62 insertions(+), 59 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index e9125ad..cb077a8 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -58,9 +58,9 @@ public Robot(){ */ @Override public void robotInit() { - index_subsystem = new index_subsystem(); - //shooter_subsystem = new shooter_subsystem(); - colorWheel_subsystem = new colorWheel_subsystem(); + //index_subsystem = new index_subsystem(); + shooter_subsystem = new shooter_subsystem(); + //colorWheel_subsystem = new colorWheel_subsystem(); drive_subsystem = new drive_subsystem(); intake_subsystem = new intake_subsystem(); m_oi = new OI(); diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index 2c8ec0b..226ce1c 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -32,8 +32,8 @@ public class RobotMap { //Intake Motor public static final int MOTOR_INTAKE = 6; //Shooter Motor - public static final int MOTOR_SHOOT_TOP = 2; - public static final int MOTOT_SHOOT_BOTTOM = 1; + public static final int MOTOR_SHOOT_TOP = 9; + public static final int MOTOT_SHOOT_BOTTOM = 8; //SOLENOID public static final int SOLENOID_IN = 0; public static final int SOLENOID_OUT = 1; @@ -65,8 +65,8 @@ public class RobotMap { public static final int LT = 0; public static final int RT = 1; //Bumpers - public static final int LB = 6; - public static final int RB = 5; + public static final int LB = 5; + public static final int RB = 6; //Encoders public static final int leftEncoderPort1 = 3; diff --git a/src/main/java/frc/robot/commands/intake_command.java b/src/main/java/frc/robot/commands/intake_command.java index b953690..a801289 100644 --- a/src/main/java/frc/robot/commands/intake_command.java +++ b/src/main/java/frc/robot/commands/intake_command.java @@ -11,7 +11,7 @@ import frc.robot.Robot; public class intake_command extends Command { - double motorSpeed = 0.85; + double motorSpeed = 1.0; public intake_command() { // Use requires() here to declare subsystem dependencies // eg. requires(chassis); @@ -28,6 +28,9 @@ protected void execute() { if (Robot.m_oi.Intake_buttonA.get()){ Robot.intake_subsystem.rollerSpeed(motorSpeed); } + else if(Robot.m_oi.Intake_buttonB.get()){ + Robot.intake_subsystem.rollerSpeed(-motorSpeed); + } else{ Robot.intake_subsystem.rollerSpeed(0); } diff --git a/src/main/java/frc/robot/commands/shooter_command.java b/src/main/java/frc/robot/commands/shooter_command.java index 1ce8387..207107c 100644 --- a/src/main/java/frc/robot/commands/shooter_command.java +++ b/src/main/java/frc/robot/commands/shooter_command.java @@ -11,10 +11,10 @@ import frc.robot.Robot; public class shooter_command extends Command { - double topSpeed; + // double topSpeed; double bottomSpeed; double bottomSpeedSet = 0.8; - double topSpeedSet = 0.8; + //double topSpeedSet = 0.8; double maxRPM = 5700; public shooter_command() { requires(Robot.shooter_subsystem); @@ -30,30 +30,30 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() {//Different speeds are set based on what position the d-pad was pushed - if(Robot.m_oi.Intake_dPadLeft.get()){ - topSpeed = 3000; +/* if(Robot.m_oi.Intake_dPadLeft.get()){ + //topSpeed = 3000; bottomSpeed = 1500; - topSpeedSet = topSpeed/maxRPM; + // topSpeedSet = topSpeed/maxRPM; bottomSpeedSet = bottomSpeed/maxRPM; } else if(Robot.m_oi.Intake_dPadUp.get()){ - topSpeed = 3750; + //topSpeed = 3750; bottomSpeed = 3000; - topSpeedSet = topSpeed/maxRPM; + //topSpeedSet = topSpeed/maxRPM; bottomSpeedSet = bottomSpeed/maxRPM; } else if(Robot.m_oi.Intake_dPadRight.get()){ - topSpeed = 5000; + // topSpeed = 5000; bottomSpeed = 5000; - topSpeedSet = topSpeed/maxRPM; + // topSpeedSet = topSpeed/maxRPM; bottomSpeedSet = bottomSpeed/maxRPM; - } + } */ if(Robot.m_oi.Intake_RB.get()){ //Robot.shooter_subsystem.setShooterSpeeds(topSpeed, bottomSpeed); - Robot.shooter_subsystem.shootAnyway(topSpeedSet, bottomSpeedSet); + Robot.shooter_subsystem.shootAnyway(bottomSpeedSet); // add abck topSpeedSet } else{ - end(); + Robot.shooter_subsystem.shootAnyway(0); // add abck topSpeedSet } } @@ -66,8 +66,8 @@ protected boolean isFinished() { // Called once after isFinished returns true @Override protected void end() { - Robot.shooter_subsystem.setShooterSpeeds(0, 0); - Robot.shooter_subsystem.shootAnyway(0, 0); + // Robot.shooter_subsystem.setShooterSpeeds(0, 0); + Robot.shooter_subsystem.shootAnyway(0); // add back 0 } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/subsystems/shooter_subsystem.java b/src/main/java/frc/robot/subsystems/shooter_subsystem.java index 07291b5..caa1b34 100644 --- a/src/main/java/frc/robot/subsystems/shooter_subsystem.java +++ b/src/main/java/frc/robot/subsystems/shooter_subsystem.java @@ -22,7 +22,7 @@ public class shooter_subsystem extends Subsystem { CANPIDController bottomPID; CANPIDController topPID; CANSparkMax bottomMotor; - CANSparkMax topMotor; + // CANSparkMax topMotor; double kP = 0; double kI = 0; double kD = 0; @@ -36,42 +36,42 @@ public void initDefaultCommand() { } //Declaring PID and motors for shooter public shooter_subsystem(){ - topMotor = new CANSparkMax(RobotMap.MOTOR_SHOOT_TOP, MotorType.kBrushless); + //topMotor = new CANSparkMax(RobotMap.MOTOR_SHOOT_TOP, MotorType.kBrushless); bottomMotor = new CANSparkMax(RobotMap.MOTOT_SHOOT_BOTTOM, MotorType.kBrushless); - topPID = topMotor.getPIDController(); + //topPID = topMotor.getPIDController(); bottomPID = bottomMotor.getPIDController(); //topPID.setReference(0, ControlType.kSmartMotion); //bottomPID.setReference(0, ControlType.kSmartMotion); - topPID.setP(kP); + /* topPID.setP(kP); topPID.setI(kI); topPID.setFF(kFF); topPID.setIZone(kIz); bottomPID.setP(kP); bottomPID.setI(kI); bottomPID.setFF(kFF); - bottomPID.setIZone(kIz); + bottomPID.setIZone(kIz); */ } /** Sets the shooters speeds (in RPM) *@param topRPM the max RPM for the top of the shooter (between 5700RPM-1000RPM) *@param bottomRPM the max RPM for the bottom of the shooter (between 5700RPM-1000RPM) */ - public void setShooterSpeeds(double topRPM, double bottomRPM){ + /* public void setShooterSpeeds(double topRPM, double bottomRPM){ if(topRPM < 5700 && bottomRPM < 5700 && topRPM > 1000 && bottomRPM > 1000){ bottomPID.setSmartMotionMaxVelocity(bottomRPM, 0); - topPID.setSmartMotionMaxVelocity(topRPM, 0); + //topPID.setSmartMotionMaxVelocity(topRPM, 0); bottomPID.setSmartMotionMinOutputVelocity(bottomRPM-100, 0); - topPID.setSmartMotionMinOutputVelocity(topRPM-100, 0); + // topPID.setSmartMotionMinOutputVelocity(topRPM-100, 0); bottomPID.setSmartMotionMaxAccel(1500, 0); - topPID.setSmartMotionMaxAccel(1500, 0); + // topPID.setSmartMotionMaxAccel(1500, 0); } else{ //System.out.println("Too fast!"); - topMotor.stopMotor(); + //topMotor.stopMotor(); bottomMotor.stopMotor(); - } - } - public void shootAnyway(double topMotorSpeed, double bottomMotorSpeed){ - topMotor.set(topMotorSpeed); + } */ + // } + public void shootAnyway(double bottomMotorSpeed){ // add back double topMotorSpeed + //topMotor.set(topMotorSpeed); bottomMotor.set(bottomMotorSpeed); } } diff --git a/vendordeps/Phoenix.json b/vendordeps/Phoenix.json index c6ec878..aa5554e 100644 --- a/vendordeps/Phoenix.json +++ b/vendordeps/Phoenix.json @@ -1,7 +1,7 @@ { "fileName": "Phoenix.json", "name": "CTRE-Phoenix", - "version": "5.18.1", + "version": "5.18.2", "uuid": "ab676553-b602-441f-a38d-f1296eff6537", "mavenUrls": [ "http://devsite.ctr-electronics.com/maven/release/" @@ -11,19 +11,19 @@ { "groupId": "com.ctre.phoenix", "artifactId": "api-java", - "version": "5.18.1" + "version": "5.18.2" }, { "groupId": "com.ctre.phoenix", "artifactId": "wpiapi-java", - "version": "5.18.1" + "version": "5.18.2" } ], "jniDependencies": [ { "groupId": "com.ctre.phoenix", "artifactId": "cci", - "version": "5.18.1", + "version": "5.18.2", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -35,7 +35,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "diagnostics", - "version": "5.18.1", + "version": "5.18.2", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -47,7 +47,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "canutils", - "version": "5.18.1", + "version": "5.18.2", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -58,7 +58,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "platform-stub", - "version": "5.18.1", + "version": "5.18.2", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -69,7 +69,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "core", - "version": "5.18.1", + "version": "5.18.2", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -83,7 +83,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "wpiapi-cpp", - "version": "5.18.1", + "version": "5.18.2", "libName": "CTRE_Phoenix_WPI", "headerClassifier": "headers", "sharedLibrary": false, @@ -97,7 +97,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "api-cpp", - "version": "5.18.1", + "version": "5.18.2", "libName": "CTRE_Phoenix", "headerClassifier": "headers", "sharedLibrary": false, @@ -111,7 +111,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "cci", - "version": "5.18.1", + "version": "5.18.2", "libName": "CTRE_PhoenixCCI", "headerClassifier": "headers", "sharedLibrary": false, @@ -125,7 +125,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "diagnostics", - "version": "5.18.1", + "version": "5.18.2", "libName": "CTRE_PhoenixDiagnostics", "headerClassifier": "headers", "sharedLibrary": false, @@ -139,7 +139,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "canutils", - "version": "5.18.1", + "version": "5.18.2", "libName": "CTRE_PhoenixCanutils", "headerClassifier": "headers", "sharedLibrary": false, @@ -152,7 +152,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "platform-stub", - "version": "5.18.1", + "version": "5.18.2", "libName": "CTRE_PhoenixPlatform", "headerClassifier": "headers", "sharedLibrary": false, @@ -165,7 +165,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "core", - "version": "5.18.1", + "version": "5.18.2", "libName": "CTRE_PhoenixCore", "headerClassifier": "headers", "sharedLibrary": false, diff --git a/vendordeps/REVColorSensorV3.json b/vendordeps/REVColorSensorV3.json index 3940c21..9601ef8 100644 --- a/vendordeps/REVColorSensorV3.json +++ b/vendordeps/REVColorSensorV3.json @@ -1,7 +1,7 @@ { "fileName": "REVColorSensorV3.json", "name": "REVColorSensorV3", - "version": "1.0.1", + "version": "1.2.0", "uuid": "cda7b4b1-d003-44ac-a1ef-485c1347059a", "mavenUrls": [ "http://www.revrobotics.com/content/sw/color-sensor-v3/sdk/maven/" @@ -11,7 +11,7 @@ { "groupId": "com.revrobotics.frc", "artifactId": "ColorSensorV3-java", - "version": "1.0.1" + "version": "1.2.0" } ], "jniDependencies": [], @@ -19,7 +19,7 @@ { "groupId": "com.revrobotics.frc", "artifactId": "ColorSensorV3-cpp", - "version": "1.0.1", + "version": "1.2.0", "libName": "ColorSensorV3", "headerClassifier": "headers", "sourcesClassifier": "source", diff --git a/vendordeps/REVRobotics.json b/vendordeps/REVRobotics.json index 63380b6..5eb069f 100644 --- a/vendordeps/REVRobotics.json +++ b/vendordeps/REVRobotics.json @@ -1,7 +1,7 @@ { "fileName": "REVRobotics.json", "name": "REVRobotics", - "version": "1.5.1", + "version": "1.5.2", "uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb", "mavenUrls": [ "http://www.revrobotics.com/content/sw/max/sdk/maven/" @@ -11,14 +11,14 @@ { "groupId": "com.revrobotics.frc", "artifactId": "SparkMax-java", - "version": "1.5.1" + "version": "1.5.2" } ], "jniDependencies": [ { "groupId": "com.revrobotics.frc", "artifactId": "SparkMax-driver", - "version": "1.5.1", + "version": "1.5.2", "skipInvalidPlatforms": true, "isJar": false, "validPlatforms": [ @@ -35,7 +35,7 @@ { "groupId": "com.revrobotics.frc", "artifactId": "SparkMax-cpp", - "version": "1.5.1", + "version": "1.5.2", "libName": "SparkMax", "headerClassifier": "headers", "sharedLibrary": false, @@ -52,7 +52,7 @@ { "groupId": "com.revrobotics.frc", "artifactId": "SparkMax-driver", - "version": "1.5.1", + "version": "1.5.2", "libName": "SparkMaxDriver", "headerClassifier": "headers", "sharedLibrary": false, From 47c0b7173b567e56737e9c975e687caf32609797 Mon Sep 17 00:00:00 2001 From: Stefan Hauge Date: Wed, 9 Dec 2020 16:57:32 -0600 Subject: [PATCH 07/13] updates to clone repo for 2021 --- .wpilib/wpilib_preferences.json | 2 +- build.gradle | 2 +- .../robot/commands/driveStraight_command.java | 25 ++++++++++--------- .../frc/robot/commands/shooter_command.java | 1 + .../subsystems/colorWheel_subsystem.java | 5 ++-- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.wpilib/wpilib_preferences.json b/.wpilib/wpilib_preferences.json index 7f23248..81ef6af 100644 --- a/.wpilib/wpilib_preferences.json +++ b/.wpilib/wpilib_preferences.json @@ -1,6 +1,6 @@ { "enableCppIntellisense": false, "currentLanguage": "java", - "projectYear": "2020", + "projectYear": "2021", "teamNumber": 269 } \ No newline at end of file diff --git a/build.gradle b/build.gradle index 0e4fe1a..9eb9d8f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id "java" - id "edu.wpi.first.GradleRIO" version "2020.1.2" + id "edu.wpi.first.GradleRIO" version "2020.3.2" } sourceCompatibility = JavaVersion.VERSION_11 diff --git a/src/main/java/frc/robot/commands/driveStraight_command.java b/src/main/java/frc/robot/commands/driveStraight_command.java index fe698d8..e272e6e 100644 --- a/src/main/java/frc/robot/commands/driveStraight_command.java +++ b/src/main/java/frc/robot/commands/driveStraight_command.java @@ -65,18 +65,19 @@ protected void execute() { leftDist = Math.abs(Robot.rightEncoder.getDistance()); double leftSpeedEdit = (-((currentYaw/180)/(speedTol))+(speed+(2/speedTol)));; double rightSpeedEdit = (((currentYaw/180)/(speedTol))+speed); - if(360-tol > currentYaw && currentYaw > 180){ //If the degrees off of straight (a.k.a 0 degrees) is greater than 180 but less than 355 - leftSpeed = -leftSpeedEdit; //Ex. 315/180 = 1.75 -> 1.75/5 = 0.35 -> -0.35 -> -0.35+(.5+(2/5)) -> -0.35 + 0.9 -> Speed = 0.55 at 315 deg - rightSpeed = -speed; - } - else if(180 >= currentYaw && currentYaw > tol){ //If the degrees off of straight (a.k.a 0 degrees) is less than or equal to 180 but greater than 5 - leftSpeed = -speed; - rightSpeed = -rightSpeedEdit; //Ex. 45/180 = 0.25 -> 0.25/5 = 0.05 -> 0.05 + 0.5 -> Speed = 0.55 at 45 deg - } - else{ //If the degrees off of straight (a.k.a 0 degrees) is 5 greater/less than straight - leftSpeed = -speed; - rightSpeed = -speed; - } + + if(360-tol > currentYaw && currentYaw > 180){ //If the degrees off of straight (a.k.a 0 degrees) is greater than 180 but less than 355 + leftSpeed = -leftSpeedEdit; //Ex. 315/180 = 1.75 -> 1.75/5 = 0.35 -> -0.35 -> -0.35+(.5+(2/5)) -> -0.35 + 0.9 -> Speed = 0.55 at 315 deg + rightSpeed = -speed; + } + else if(180 >= currentYaw && currentYaw > tol){ //If the degrees off of straight (a.k.a 0 degrees) is less than or equal to 180 but greater than 5 + leftSpeed = -speed; + rightSpeed = -rightSpeedEdit; //Ex. 45/180 = 0.25 -> 0.25/5 = 0.05 -> 0.05 + 0.5 -> Speed = 0.55 at 45 deg + } + else{ //If the degrees off of straight (a.k.a 0 degrees) is 5 greater/less than straight + leftSpeed = -speed; + rightSpeed = -speed; + } System.out.println("Left distance: " + leftDist); System.out.println("Right distance: " + rightDist); diff --git a/src/main/java/frc/robot/commands/shooter_command.java b/src/main/java/frc/robot/commands/shooter_command.java index 69396a1..1bd6c73 100644 --- a/src/main/java/frc/robot/commands/shooter_command.java +++ b/src/main/java/frc/robot/commands/shooter_command.java @@ -63,5 +63,6 @@ protected void end() { // subsystems is scheduled to run @Override protected void interrupted() { + end(); } } diff --git a/src/main/java/frc/robot/subsystems/colorWheel_subsystem.java b/src/main/java/frc/robot/subsystems/colorWheel_subsystem.java index f3c232a..194c34d 100644 --- a/src/main/java/frc/robot/subsystems/colorWheel_subsystem.java +++ b/src/main/java/frc/robot/subsystems/colorWheel_subsystem.java @@ -23,6 +23,7 @@ public class colorWheel_subsystem extends Subsystem { WPI_TalonSRX colorWheelWheel = null; + private static boolean wheelInitialized = false; /** * A Rev Color Sensor V3 object is constructed with an I2C port as a @@ -84,13 +85,13 @@ public String getColor() { * an object is the more light from the surroundings will bleed into the * measurements and make it difficult to accurately determine its color. */ - Color detectedColor = m_colorSensor.getColor(); + final Color detectedColor = m_colorSensor.getColor(); /** * Run the color match algorithm on our detected color */ // String colorString; - ColorMatchResult match = m_colorMatcher.matchClosestColor(detectedColor); + final ColorMatchResult match = m_colorMatcher.matchClosestColor(detectedColor); if (match.color == kBlueTarget) { result = "Blue"; From 75f24e0720cbd002a7c78d45cd1dca3e1a1123d7 Mon Sep 17 00:00:00 2001 From: Stefan Hauge Date: Wed, 9 Dec 2020 17:01:37 -0600 Subject: [PATCH 08/13] skdjfsjk --- src/main/java/frc/robot/OI.java | 24 ++--- src/main/java/frc/robot/Robot.java | 22 +++-- src/main/java/frc/robot/RobotMap.java | 38 ++++---- .../frc/robot/commands/AutoCrossOutline.java | 35 ------- .../robot/commands/Autonomous Selections.txt | 4 + .../robot/commands/autonomousSelector.java | 42 +++++++++ .../robot/commands/colorWheel_command.java | 13 ++- .../frc/robot/commands/driveOverLine.java | 19 ++++ .../robot/commands/driveStraight_command.java | 34 +++++-- .../frc/robot/commands/drive_command.java | 6 +- .../frc/robot/commands/index_command.java | 21 ++++- .../frc/robot/commands/intake_command.java | 20 +++- .../frc/robot/commands/shooter_command.java | 55 +++++++---- .../frc/robot/commands/turnGyro_command.java | 94 +++++++++++++------ .../robot/commands/turnRightGoStraight.java | 20 ++++ .../subsystems/colorWheel_subsystem.java | 1 + .../frc/robot/subsystems/drive_subsystem.java | 2 + .../frc/robot/subsystems/index_subsystem.java | 31 +++--- .../robot/subsystems/shooter_subsystem.java | 46 +++------ vendordeps/Phoenix.json | 30 +++--- vendordeps/REVColorSensorV3.json | 6 +- vendordeps/REVRobotics.json | 10 +- 22 files changed, 359 insertions(+), 214 deletions(-) delete mode 100644 src/main/java/frc/robot/commands/AutoCrossOutline.java create mode 100644 src/main/java/frc/robot/commands/Autonomous Selections.txt create mode 100644 src/main/java/frc/robot/commands/autonomousSelector.java create mode 100644 src/main/java/frc/robot/commands/driveOverLine.java create mode 100644 src/main/java/frc/robot/commands/turnRightGoStraight.java diff --git a/src/main/java/frc/robot/OI.java b/src/main/java/frc/robot/OI.java index 15adee4..363bfa3 100644 --- a/src/main/java/frc/robot/OI.java +++ b/src/main/java/frc/robot/OI.java @@ -63,18 +63,18 @@ public double rightJoystickY(Joystick controller){ public JoystickButton RB = new JoystickButton(driverController,RobotMap.RB); //Intake Controller Buttons - public JoystickButton Intake_buttonX = new JoystickButton(driverController,RobotMap.BUTTON_X); - public JoystickButton Intake_buttonY = new JoystickButton(driverController,RobotMap.BUTTON_Y); - public JoystickButton Intake_buttonA = new JoystickButton(driverController,RobotMap.BUTTON_A); - public JoystickButton Intake_buttonB = new JoystickButton(driverController,RobotMap.BUTTON_B); - public JoystickButton Intake_startButton = new JoystickButton(driverController,RobotMap.START_BUTTON); - public JoystickButton Intake_selectButton = new JoystickButton(driverController,RobotMap.SELECT_BUTTON); - public JoystickButton Intake_dPadLeft = new JoystickButton(driverController,RobotMap.D_PAD_LEFT); - public JoystickButton Intake_dPadRight = new JoystickButton(driverController,RobotMap.D_PAD_RIGHT); - public JoystickButton Intake_dPadUp = new JoystickButton(driverController,RobotMap.D_PAD_UP); - public JoystickButton Intake_dPadDown = new JoystickButton(driverController,RobotMap.D_PAD_DOWN); - public JoystickButton Intake_LB = new JoystickButton(driverController,RobotMap.LB); - public JoystickButton Intake_RB = new JoystickButton(driverController,RobotMap.RB); + public JoystickButton Intake_buttonX = new JoystickButton(intakeController,RobotMap.BUTTON_X); + public JoystickButton Intake_buttonY = new JoystickButton(intakeController,RobotMap.BUTTON_Y); + public JoystickButton Intake_buttonA = new JoystickButton(intakeController,RobotMap.BUTTON_A); + public JoystickButton Intake_buttonB = new JoystickButton(intakeController,RobotMap.BUTTON_B); + public JoystickButton Intake_startButton = new JoystickButton(intakeController,RobotMap.START_BUTTON); + public JoystickButton Intake_selectButton = new JoystickButton(intakeController,RobotMap.SELECT_BUTTON); + public JoystickButton Intake_dPadLeft = new JoystickButton(intakeController,RobotMap.D_PAD_LEFT); + public JoystickButton Intake_dPadRight = new JoystickButton(intakeController,RobotMap.D_PAD_RIGHT); + public JoystickButton Intake_dPadUp = new JoystickButton(intakeController,RobotMap.D_PAD_UP); + public JoystickButton Intake_dPadDown = new JoystickButton(intakeController,RobotMap.D_PAD_DOWN); + public JoystickButton Intake_LB = new JoystickButton(intakeController,RobotMap.LB); + public JoystickButton Intake_RB = new JoystickButton(intakeController,RobotMap.RB); //POV Buttons diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index f90a54a..25b2cf3 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -12,7 +12,7 @@ import edu.wpi.first.wpilibj.TimedRobot; import edu.wpi.first.wpilibj.CounterBase.EncodingType; import edu.wpi.first.wpilibj.command.Scheduler; -import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; +//import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; import frc.robot.subsystems.colorWheel_subsystem; import frc.robot.subsystems.drive_subsystem; import frc.robot.subsystems.index_subsystem; @@ -33,8 +33,8 @@ public class Robot extends TimedRobot { public static OI m_oi; public static AHRS navx; - private String m_autoSelected; - private final SendableChooser m_chooser = new SendableChooser<>(); + //private String m_autoSelected; + //private final SendableChooser m_chooser = new SendableChooser<>(); private static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); private static Date date = new Date(); public static Encoder rightEncoder = new Encoder(RobotMap.leftEncoderPort1, RobotMap.leftEncoderPort2, false, EncodingType.k4X); @@ -58,13 +58,18 @@ public Robot(){ */ @Override public void robotInit() { - drive_subsystem = new drive_subsystem(); - intake_subsystem = new intake_subsystem(); + System.out.println("Made it"); index_subsystem = new index_subsystem(); shooter_subsystem = new shooter_subsystem(); colorWheel_subsystem = new colorWheel_subsystem(); +<<<<<<< HEAD lift_subsystem = new lift_subsystem(); +======= + drive_subsystem = new drive_subsystem(); + intake_subsystem = new intake_subsystem(); +>>>>>>> ebd7965a5aa467985b9c695cf2139d17adc028d9 m_oi = new OI(); + m_oi.bind(); //bind the buttons to commands // m_chooser.setDefaultOption("Default Auto", kDefaultAuto); // m_chooser.addOption("My Auto", kCustomAuto); // SmartDashboard.putData("Auto choices", m_chooser); @@ -121,10 +126,9 @@ private static void PrintMessage(String message, int lvl){ */ public static double getFullYaw() { double currentYaw; - if (Robot.navx.getYaw() <= 0) { - currentYaw = -Robot.navx.getYaw(); - } else { - currentYaw = 360 - Robot.navx.getYaw(); + currentYaw = Robot.navx.getFusedHeading(); + if(Robot.navx.getFusedHeading() < 0){ + currentYaw = 360-(Robot.navx.getFusedHeading()); } //System.out.println("yaw: "+ currentYaw); WriteOut("Current Yaw: "+ currentYaw, 5); diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index 022fe39..d28eef1 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -25,22 +25,22 @@ public class RobotMap { */ //Drive Motors - public static final int MOTOR_LEFT_1 = 1; - public static final int MOTOR_LEFT_2 = 2; - public static final int MOTOR_RIGHT_1 = 3; - public static final int MOTOR_RIGHT_2 = 4; + public static final int MOTOR_LEFT_1 = 4; //Front left motor + public static final int MOTOR_LEFT_2 = 3; //Back left motor + public static final int MOTOR_RIGHT_1 = 1; //Front right motor + public static final int MOTOR_RIGHT_2 = 2; /**Back right motor**/ //Intake Motor - public static final int MOTOR_INTAKE = 5; + public static final int MOTOR_INTAKE = 6; //Shooter Motor - public static final int MOTOR_SHOOT_TOP = 1; - public static final int MOTOT_SHOOT_BOTTOM = 2; + public static final int MOTOR_SHOOT_TOP = 8; + public static final int MOTOR_SHOOT_BOTTOM = 9; //SOLENOID - public static final int SOLENOID_1 = 10; - public static final int SOLENOID_2 = 11; + public static final int SOLENOID_IN = 0; + public static final int SOLENOID_OUT = 1; //AIR COMPRESSOR - public static final int AIRCOMP = 0; + //public static final int AIRCOMP = 0; //COLOR WHEEL - public static final int MOTOR_COLOR_WHEEL = 4; + public static final int MOTOR_COLOR_WHEEL = 7; //Controllers public static final int DRIVER_CONTROLLER = 0; public static final int INTAKE_CONTROLLER = 1; @@ -51,22 +51,22 @@ public class RobotMap { public static final int RIGHT_JOYSTICK_Y = 5; //Buttons public static final int BUTTON_X = 3; - public static final int BUTTON_Y = 2; + public static final int BUTTON_Y = 4; public static final int BUTTON_A = 1; - public static final int BUTTON_B = 4; + public static final int BUTTON_B = 2; public static final int D_PAD_LEFT = 5; public static final int D_PAD_UP = 6; public static final int D_PAD_DOWN = 7; public static final int D_PAD_RIGHT = 8; - public static final int START_BUTTON = 9; - public static final int SELECT_BUTTON = 10; + public static final int START_BUTTON = 8; + public static final int SELECT_BUTTON = 7; //Triggers public static final int LT = 0; public static final int RT = 1; //Bumpers - public static final int LB = 6; - public static final int RB = 5; + public static final int LB = 5; + public static final int RB = 6; //Encoders public static final int leftEncoderPort1 = 3; @@ -82,7 +82,11 @@ public class RobotMap { //color sensor public static final I2C.Port i2cPort = I2C.Port.kOnboard; +<<<<<<< HEAD //lift motor public static final int LIFTMOTOR = 7; } +======= +} +>>>>>>> ebd7965a5aa467985b9c695cf2139d17adc028d9 diff --git a/src/main/java/frc/robot/commands/AutoCrossOutline.java b/src/main/java/frc/robot/commands/AutoCrossOutline.java deleted file mode 100644 index 3466aba..0000000 --- a/src/main/java/frc/robot/commands/AutoCrossOutline.java +++ /dev/null @@ -1,35 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018 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 edu.wpi.first.wpilibj.command.CommandGroup; - -public class AutoCrossOutline extends CommandGroup { - /** - * Add your docs here. - */ - public AutoCrossOutline() { - // Add Commands here: - // e.g. addSequential(new Command1()); - // addSequential(new Command2()); - // these will run in order. - - // To run multiple commands at the same time, - // use addParallel() - // e.g. addParallel(new Command1()); - // addSequential(new Command2()); - // Command1 and Command2 will run in parallel. - - // A command group will require all of the subsystems that each member - // would require. - // e.g. if Command1 requires chassis, and Command2 requires arm, - // a CommandGroup containing them would require both the chassis and the - // arm. - addSequential(new driveStraight_command(.5, 10, -1)); // -1 means timeout isn't used - } -} diff --git a/src/main/java/frc/robot/commands/Autonomous Selections.txt b/src/main/java/frc/robot/commands/Autonomous Selections.txt new file mode 100644 index 0000000..8efc03c --- /dev/null +++ b/src/main/java/frc/robot/commands/Autonomous Selections.txt @@ -0,0 +1,4 @@ +Position 1 Maneuver 1 - Used to only drive over line. +Position 1 Maneuver 2 - Used to turn "right" 90 degrees and then drive straight 100 inches. +Position 2 Maneuver 1 - null +Position 2 Maneuver 2 - null \ No newline at end of file diff --git a/src/main/java/frc/robot/commands/autonomousSelector.java b/src/main/java/frc/robot/commands/autonomousSelector.java new file mode 100644 index 0000000..251bd5b --- /dev/null +++ b/src/main/java/frc/robot/commands/autonomousSelector.java @@ -0,0 +1,42 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 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 edu.wpi.first.wpilibj.command.CommandGroup; +import frc.robot.Robot; + +public class autonomousSelector extends CommandGroup { + /** + * Add your docs here. + */ + public autonomousSelector(double position, String priority) { + Robot.WriteOut("Autonomous Selector Initialized"); + if(position == 1){ + Robot.WriteOut("Selected Postition 1"); + if(priority.equalsIgnoreCase("mane1")){ + Robot.WriteOut("Selected Maneuver 1 on Position 1"); + addSequential(new driveOverLine()); + } + else if(priority.equalsIgnoreCase("mane2")){ + Robot.WriteOut("Selected Maneuver 2 on Position 1"); + addSequential(new turnRightGoStraight()); + } + } + else if(position == 2){ + Robot.WriteOut("Selected Postition 2"); + if(priority.equalsIgnoreCase("mane1")){ + Robot.WriteOut("Selected Maneuver 1 on Position 2"); + + } + else if(priority.equalsIgnoreCase("mane2")){ + Robot.WriteOut("Selected Maneuver 2 on Position 2"); + + } + } + } +} diff --git a/src/main/java/frc/robot/commands/colorWheel_command.java b/src/main/java/frc/robot/commands/colorWheel_command.java index e6f2bd0..82bc89b 100644 --- a/src/main/java/frc/robot/commands/colorWheel_command.java +++ b/src/main/java/frc/robot/commands/colorWheel_command.java @@ -10,7 +10,6 @@ import edu.wpi.first.wpilibj.command.Command; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import frc.robot.Robot; -import frc.robot.RobotMap; import java.util.ArrayList; import edu.wpi.first.wpilibj.DriverStation; @@ -48,14 +47,15 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - if (Robot.m_oi.driverController.getRawButton(RobotMap.BUTTON_Y) && yPressed == false) {//this is not needed if you call the command when the button is pressed + if (Robot.m_oi.Intake_startButton.get() && yPressed == false) {//this is not needed if you call the command when the button is pressed yPressed = true; initialColor = Robot.colorWheel_subsystem.getColor(); + SmartDashboard.putString("FMScolor", initialColor); } gameData = DriverStation.getInstance().getGameSpecificMessage(); - Robot.WriteOut("Control panel sensor target: " + gameData); // color the control panel sensor needs to see for 5 sec + //Robot.WriteOut("Control panel sensor target: " + gameData); // color the control panel sensor needs to see for 5 sec if(gameData.length() > 0 && yPressed) { switch (gameData.charAt(0)) @@ -90,17 +90,16 @@ protected void execute() { break; default : //This is corrupt data - Robot.WriteOut("Corrupt FMS color data"); + //Robot.WriteOut("Corrupt FMS color data"); break; } + SmartDashboard.putString("targetcolor", turnTo); } else { // blah blah } - Robot.WriteOut("Robot sensor color target: " + turnTo); // color the *ROBOT* sensor has to turn to + //Robot.WriteOut("Robot sensor color target: " + turnTo); // color the *ROBOT* sensor has to turn to String colorNow = Robot.colorWheel_subsystem.getColor(); - SmartDashboard.putString("targetcolor", turnTo); - SmartDashboard.putString("FMScolor", initialColor); if (turnTo != null) { // if fms HAS provided a color if (colorNow == turnTo) { // if the wheel has reached its color if (!lastColor.equals(colorNow)) { //for the first iteration record the time. diff --git a/src/main/java/frc/robot/commands/driveOverLine.java b/src/main/java/frc/robot/commands/driveOverLine.java new file mode 100644 index 0000000..cd9e786 --- /dev/null +++ b/src/main/java/frc/robot/commands/driveOverLine.java @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 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 edu.wpi.first.wpilibj.command.CommandGroup; + +public class driveOverLine extends CommandGroup { + /**Robot drives 100 inches (enough to at least go over the line). + * + */ + public driveOverLine() { + addSequential(new driveStraight_command(0.8, 100, -1)); + } +} diff --git a/src/main/java/frc/robot/commands/driveStraight_command.java b/src/main/java/frc/robot/commands/driveStraight_command.java index e272e6e..4402175 100644 --- a/src/main/java/frc/robot/commands/driveStraight_command.java +++ b/src/main/java/frc/robot/commands/driveStraight_command.java @@ -16,7 +16,6 @@ public class driveStraight_command extends Command { public double currentYaw; public double tol = 1.5; public double speed; - public double speedTol = 2; public double leftSpeed; public double rightSpeed; public double inches; @@ -24,6 +23,7 @@ public class driveStraight_command extends Command { public double rightDist; public double leftDist; public double distTol; + public double averageDist; public static driveStraight_command driveStraight = null; Timer stopwatch = new Timer(); @@ -50,7 +50,7 @@ public driveStraight_command(double speed, double inches, double timeout) { protected void initialize() { Robot.leftEncoder.reset(); Robot.rightEncoder.reset(); - Robot.navx.reset(); + startingYaw = Robot.navx.getFusedHeading(); stopwatch.reset(); stopwatch.start(); } @@ -58,11 +58,12 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - currentYaw = Robot.getFullYaw(); - System.out.println("Yaw: "+ currentYaw); - System.out.println("Encoder Avg: " + (Math.abs(Robot.rightEncoder.getRaw()) + Math.abs(Robot.leftEncoder.getRaw()))/2); + currentYaw = Robot.getFullYaw()-startingYaw; + //System.out.println("Yaw: "+ currentYaw); + //System.out.println("Encoder Avg: " + (Math.abs(Robot.rightEncoder.getRaw()) + Math.abs(Robot.leftEncoder.getRaw()))/2); rightDist = Math.abs(Robot.rightEncoder.getDistance()); leftDist = Math.abs(Robot.rightEncoder.getDistance()); +<<<<<<< HEAD double leftSpeedEdit = (-((currentYaw/180)/(speedTol))+(speed+(2/speedTol)));; double rightSpeedEdit = (((currentYaw/180)/(speedTol))+speed); @@ -80,15 +81,32 @@ else if(180 >= currentYaw && currentYaw > tol){ //If the degrees off of straight } System.out.println("Left distance: " + leftDist); +======= + averageDist = (leftDist+rightDist)/2; + if(360-tol > currentYaw && currentYaw > 180){ //If the degrees off of straight (a.k.a 0 degrees) is greater than 180 but less than 355 + leftSpeed = speed; + rightSpeed = speed - ((360 - currentYaw)/(180/speed)); + } + else if(180 >= currentYaw && currentYaw > tol){ //If the degrees off of straight (a.k.a 0 degrees) is less than or equal to 180 but greater than 5 + leftSpeed = speed - ((currentYaw)/(180/speed)); + rightSpeed = speed; + } + else{ //If the degrees off of straight (a.k.a 0 degrees) is 'tol' greater/less than straight + leftSpeed = speed; + rightSpeed = speed; + } + Robot.drive_subsystem.drive(leftSpeed, rightSpeed); + /*System.out.println("Left distance: " + leftDist); +>>>>>>> ebd7965a5aa467985b9c695cf2139d17adc028d9 System.out.println("Right distance: " + rightDist); System.out.println("Left Spd: " + leftSpeed); - System.out.println("Right Spd: " + rightSpeed); + System.out.println("Right Spd: " + rightSpeed);*/ } // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { - if(stopwatch.get() == timeout){ + if(stopwatch.get() == timeout || averageDist >= inches){ return true; } else{ @@ -99,11 +117,13 @@ protected boolean isFinished() { // Called once after isFinished returns true @Override protected void end() { + Robot.drive_subsystem.drive(0); } // Called when another command which requires one or more of the same // subsystems is scheduled to run @Override protected void interrupted() { + end(); } } diff --git a/src/main/java/frc/robot/commands/drive_command.java b/src/main/java/frc/robot/commands/drive_command.java index 6b7b608..1669b4e 100644 --- a/src/main/java/frc/robot/commands/drive_command.java +++ b/src/main/java/frc/robot/commands/drive_command.java @@ -53,7 +53,7 @@ protected void execute() { } //speed reduction - if (Robot.m_oi.RB.get() == true) { + if (Robot.m_oi.RB.get()) { releaseR = false; } else{ if(releaseR == false) { @@ -64,7 +64,7 @@ protected void execute() { releaseR = true; } } - if (Robot.m_oi.LB.get() == true) { + if (Robot.m_oi.LB.get()) { releaseL = false; } else{ if(releaseL == false) { @@ -92,7 +92,7 @@ protected void execute() { //pass the desired speed to the drive substem and make robot go! - Robot.drive_subsystem.drive(leftSpeed, rightSpeed); + Robot.drive_subsystem.drive(-leftSpeed, -rightSpeed); } // Make this return true when this Command no longer needs to run execute() diff --git a/src/main/java/frc/robot/commands/index_command.java b/src/main/java/frc/robot/commands/index_command.java index 9361527..5876cc8 100644 --- a/src/main/java/frc/robot/commands/index_command.java +++ b/src/main/java/frc/robot/commands/index_command.java @@ -8,9 +8,14 @@ package frc.robot.commands; import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj.DoubleSolenoid; +import edu.wpi.first.wpilibj.DoubleSolenoid.Value; import frc.robot.Robot; public class index_command extends Command { + Value kOff; + Value kForward; + Value kReverse; public index_command() { requires(Robot.index_subsystem); // Use requires() here to declare subsystem dependencies @@ -20,15 +25,24 @@ public index_command() { // Called just before this Command runs the first time @Override protected void initialize() { + kOff = DoubleSolenoid.Value.kOff; + kForward = DoubleSolenoid.Value.kForward; + kReverse = DoubleSolenoid.Value.kReverse; } // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - Robot.index_subsystem.indexActivate(Robot.m_oi.Intake_buttonX.get()); - // If the a button is pressed the boolean value is true which activates the pnuematics of the indexing system + if(Robot.m_oi.buttonB.get()){ + Robot.index_subsystem.indexActivate(kReverse); + } + else{ + Robot.index_subsystem.indexActivate(kForward); + }// If the a button is pressed the boolean value is true which activates the pnuematics of the indexing system + Robot.index_subsystem.checkCompressor(); } + // Make this return true when this Command no longer needs to run execute() @Override protected boolean isFinished() { @@ -38,12 +52,13 @@ protected boolean isFinished() { // Called once after isFinished returns true @Override protected void end() { - Robot.index_subsystem.indexActivate(false); + Robot.index_subsystem.indexActivate(kOff); } // Called when another command which requires one or more of the same // subsystems is scheduled to run @Override protected void interrupted() { + end(); } } diff --git a/src/main/java/frc/robot/commands/intake_command.java b/src/main/java/frc/robot/commands/intake_command.java index b953690..7d8d614 100644 --- a/src/main/java/frc/robot/commands/intake_command.java +++ b/src/main/java/frc/robot/commands/intake_command.java @@ -11,7 +11,6 @@ import frc.robot.Robot; public class intake_command extends Command { - double motorSpeed = 0.85; public intake_command() { // Use requires() here to declare subsystem dependencies // eg. requires(chassis); @@ -25,8 +24,22 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - if (Robot.m_oi.Intake_buttonA.get()){ - Robot.intake_subsystem.rollerSpeed(motorSpeed); + if(Robot.m_oi.Intake_buttonX.get()){ + Robot.intake_subsystem.rollerSpeed(1); + } + //Setting intake full speed durring shooter operation (check shooter_subsystem with same buttons) + else if(Robot.m_oi.Intake_buttonY.get()){ + Robot.intake_subsystem.rollerSpeed(1.0); + } + else if(Robot.m_oi.Intake_buttonB.get()){ + Robot.intake_subsystem.rollerSpeed(1.0); + } + //"Normal" buttons for intake operation + else if(Robot.m_oi.Intake_selectButton.get()){ + Robot.intake_subsystem.rollerSpeed(-1.0); + } + else if(Robot.m_oi.Intake_buttonB.get()){ + Robot.intake_subsystem.rollerSpeed(-1); } else{ Robot.intake_subsystem.rollerSpeed(0); @@ -43,6 +56,7 @@ protected boolean isFinished() { @Override protected void end() { Robot.intake_subsystem.rollerSpeed(0); + //Robot.shooter_subsystem.shootAnywayBoth(0); } // Called when another command which requires one or more of the same diff --git a/src/main/java/frc/robot/commands/shooter_command.java b/src/main/java/frc/robot/commands/shooter_command.java index 1bd6c73..d5567dc 100644 --- a/src/main/java/frc/robot/commands/shooter_command.java +++ b/src/main/java/frc/robot/commands/shooter_command.java @@ -8,11 +8,17 @@ package frc.robot.commands; import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import frc.robot.Robot; public class shooter_command extends Command { - double topSpeed; + // double topSpeed; double bottomSpeed; + double bottomSpeedSet = 0.8; + double topSpeedSet = 0.8; + //double maxRPM = 5700; + //double topSpeedSet = 0.8; + double maxRPM = 5700; public shooter_command() { requires(Robot.shooter_subsystem); // Use requires() here to declare subsystem dependencies @@ -26,43 +32,52 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override - protected void execute() {//Different speeds are set based on what position the d-pad was pushed - if(Robot.m_oi.Intake_dPadLeft.get()){ - topSpeed = 3000; - bottomSpeed = 1500; + protected void execute() { + SmartDashboard.putNumber("Bottom RPM: ", Robot.shooter_subsystem.bottomEncoder.getVelocity()); + SmartDashboard.putNumber("Top RPM: ", Robot.shooter_subsystem.topEncoder.getVelocity()); + if(Robot.m_oi.Intake_RB.get()){ + Robot.shooter_subsystem.shooterSet(0, 0.4); } - else if(Robot.m_oi.Intake_dPadUp.get()){ - topSpeed = 3750; - bottomSpeed = 3000; + else if(Robot.m_oi.Intake_LB.get()){ + Robot.shooter_subsystem.shooterSet(0.4, 0); } - else if(Robot.m_oi.Intake_dPadRight.get()){ - topSpeed = 5000; - bottomSpeed = 5000; + else if(Robot.m_oi.Intake_LB.get() || Robot.m_oi.Intake_RB.get()){ + Robot.shooter_subsystem.shooterSet(0.4, 0.4); } - if(Robot.m_oi.Intake_RB.get()){ - Robot.shooter_subsystem.setShooterSpeeds(topSpeed, bottomSpeed); + else if(Robot.m_oi.Intake_buttonA.get()){ + Robot.shooter_subsystem.shooterSet(0.65, 0.65); + } + //Partly keeping intake in check (check intake_command with same buttons) + else if(Robot.m_oi.Intake_buttonY.get()){ + Robot.shooter_subsystem.shooterSet(0.075, 0.1); + } + else if(Robot.m_oi.Intake_buttonB.get()){ + Robot.shooter_subsystem.shooterSet(-0.075, -0.1); } else{ - Robot.shooter_subsystem.setShooterSpeeds(0, 0); + Robot.shooter_subsystem.shooterSet(0, 0); } } - - // Make this return true when this Command no longer needs to run execute() @Override - protected boolean isFinished() { - return false; + protected boolean isFinished() { + return false; } - // Called once after isFinished returns true @Override protected void end() { - Robot.shooter_subsystem.setShooterSpeeds(0, 0); + Robot.shooter_subsystem.shooterSet(0, 0); // add back 0 } + // Make this return true when this Command no longer needs to run execute() + // Called when another command which requires one or more of the same // subsystems is scheduled to run @Override protected void interrupted() { +<<<<<<< HEAD end(); +======= + end(); +>>>>>>> ebd7965a5aa467985b9c695cf2139d17adc028d9 } } diff --git a/src/main/java/frc/robot/commands/turnGyro_command.java b/src/main/java/frc/robot/commands/turnGyro_command.java index 652e9c8..629a166 100644 --- a/src/main/java/frc/robot/commands/turnGyro_command.java +++ b/src/main/java/frc/robot/commands/turnGyro_command.java @@ -11,53 +11,85 @@ import frc.robot.Robot; public class turnGyro_command extends Command { - double currentYaw; - double targetYaw; - double speed; - double leftSpeed; - double rightSpeed; - double tol; - double speedTol; - double rightDist; - double leftDist; + double currentYaw; //the current fused heading yaw for each iteration (0.0 to 360.0) + double turnAmount; //the amount of degrees to turn + double startingYaw; //records the yaw when the command is initalized + double correctedCurYaw; //the adjusted yaw that zeros out the navx without reseting it + double speed; //desired robot speed + double leftSpeed; //calculated left speed + double rightSpeed; //calulcated right speed + double tol = 5; //The amount of degrees in each direction the robot is considered to be within the target angle. (tolernce) + double rightDist; //right drive encoder value in inches travled since start of command + double leftDist; //left drive encoder value in inches travled since start of command + double avgDist; //the average of rightDist and leftDist - /**Sets the angle at for the robot to turn to - * @param targetYaw the goal angle for the robot to move to - * @param speed the speed the robot will turn + int rotations; + double remainingyaw; + + /**turns the robot a specified amount of degreees left or right + * @param turnAmount the amount of degrees the robot will move in postive or negative direction(- turns CCW, + turns CW) + * @param speed the speed the robot will turn (-1.0 to 1.0) */ - public turnGyro_command(double targetYaw, double speed) { + public turnGyro_command(double turnAmount, double speed) { requires(Robot.drive_subsystem); - this.targetYaw = targetYaw; + this.turnAmount = turnAmount; this.speed = speed; - // Use requires() here to declare subsystem dependencies - // eg. requires(chassis); } // Called just before this Command runs the first time @Override protected void initialize() { + startingYaw = Robot.getFullYaw(); + rotations = (int) (startingYaw + Math.abs(turnAmount))/360; //how many times will we pass 360, yes we can rotate multiple times. + remainingyaw = Math.abs(turnAmount)%360; //the remaining amount of degrees to rotate after all full rotations. } // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - currentYaw = Robot.getFullYaw()+targetYaw; - System.out.println("Yaw: "+ currentYaw); - System.out.println("Encoder Avg: " + (Math.abs(Robot.rightEncoder.getRaw()) + Math.abs(Robot.leftEncoder.getRaw()))/2); - rightDist = Math.abs(Robot.rightEncoder.getDistance()); - leftDist = Math.abs(Robot.rightEncoder.getDistance()); - if(360-tol > currentYaw && currentYaw > 180){ //If the degrees off of straight (a.k.a 0 degrees) is greater than 180 but less than 355 - leftSpeed = -speed; //Ex. 315/180 = 1.75 -> 1.75/5 = 0.35 -> -0.35 -> -0.35+(.5+(2/5)) -> -0.35 + 0.9 -> Speed = 0.55 at 315 deg - rightSpeed = speed; - } - else if(180 >= currentYaw && currentYaw > tol){ //If the degrees off of straight (a.k.a 0 degrees) is less than or equal to 180 but greater than 5 + + //get the corrected current yaw. (zeroed out from initial start yaw) + currentYaw = Robot.navx.getFusedHeading(); + if (startingYaw - currentYaw < 0) { // current yaw - starting yaw should be 0 + any diffrence the next iteration. + correctedCurYaw = 360 + (startingYaw - currentYaw); //if the corrected yaw passes 0 then we need to correct it to be > 360 instead of negative. + } else { + correctedCurYaw = startingYaw - currentYaw; + } + + if (turnAmount > 0) { //if we give it a positive number turn to the right(CW), else turn to the left. + if (correctedCurYaw < remainingyaw || rotations > 0) { //if we have not completed all rotations or have not reached the remaining degrees keep turning. + if (rotations <= 1) { + leftSpeed = (speed - ((360 - correctedCurYaw)/(180/speed))); + rightSpeed = -(speed - ((360 - correctedCurYaw)/(180/speed))); + } else { leftSpeed = speed; - rightSpeed = -speed; //Ex. 45/180 = 0.25 -> 0.25/5 = 0.05 -> 0.05 + 0.5 -> Speed = 0.55 at 45 deg + rightSpeed = -speed; } - else{ //If the degrees off of straight (a.k.a 0 degrees) is 5 greater/less than straight - leftSpeed = 0; - rightSpeed = 0; + if (correctedCurYaw >= 360-tol) { //for each rotation we complete + rotations = rotations - 1; } + } else {//completed turn. + end(); + } + } else { //turn to the left(CCW) + if (correctedCurYaw > remainingyaw || rotations > 0) { //if we have not completed all rotations or have not reached the remaining degrees keep turning. + if (rotations <= 1) { + leftSpeed = -(speed - ((360 - correctedCurYaw)/(180/speed))); + rightSpeed = (speed - ((360 - correctedCurYaw)/(180/speed))); + } else { + leftSpeed = -speed; + rightSpeed = speed; + } + if (correctedCurYaw <= tol) { //for each rotation we complete + rotations = rotations - 1; + } + } else {//completed turn. + end(); + } + } + + Robot.drive_subsystem.drive(leftSpeed, rightSpeed); } + // Make this return true when this Command no longer needs to run execute() @Override @@ -68,11 +100,13 @@ protected boolean isFinished() { // Called once after isFinished returns true @Override protected void end() { + Robot.drive_subsystem.drive(0); } // Called when another command which requires one or more of the same // subsystems is scheduled to run @Override protected void interrupted() { + end(); } } diff --git a/src/main/java/frc/robot/commands/turnRightGoStraight.java b/src/main/java/frc/robot/commands/turnRightGoStraight.java new file mode 100644 index 0000000..776ce86 --- /dev/null +++ b/src/main/java/frc/robot/commands/turnRightGoStraight.java @@ -0,0 +1,20 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2018 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 edu.wpi.first.wpilibj.command.CommandGroup; + +public class turnRightGoStraight extends CommandGroup { + /**Robot turns to the "right" 90 degrees and moves straight 100 inches. + * + */ + public turnRightGoStraight() { + addSequential(new turnGyro_command(90, .5)); + addSequential(new driveStraight_command(0.5, 100, -1)); + } +} diff --git a/src/main/java/frc/robot/subsystems/colorWheel_subsystem.java b/src/main/java/frc/robot/subsystems/colorWheel_subsystem.java index 194c34d..59944aa 100644 --- a/src/main/java/frc/robot/subsystems/colorWheel_subsystem.java +++ b/src/main/java/frc/robot/subsystems/colorWheel_subsystem.java @@ -113,6 +113,7 @@ public String getColor() { // SmartDashboard.putNumber("Green", detectedColor.green); // SmartDashboard.putNumber("Blue", detectedColor.blue); // SmartDashboard.putString("Confidence", Math.round(match.confidence * 100) + "%"); + SmartDashboard.putString("DetectedColor", result); return result; diff --git a/src/main/java/frc/robot/subsystems/drive_subsystem.java b/src/main/java/frc/robot/subsystems/drive_subsystem.java index 3a33cbf..33153c6 100644 --- a/src/main/java/frc/robot/subsystems/drive_subsystem.java +++ b/src/main/java/frc/robot/subsystems/drive_subsystem.java @@ -40,6 +40,8 @@ public drive_subsystem(){ backLeftMotor = new WPI_TalonSRX(RobotMap.MOTOR_LEFT_2); SpeedControllerGroup leftMotors = new SpeedControllerGroup(frontLeftMotor, backLeftMotor); SpeedControllerGroup rightMotors = new SpeedControllerGroup(frontRightMotor, backRightMotor); + //rightMotors.setInverted(true); + //leftMotors.setInverted(true); difDrive = new DifferentialDrive(leftMotors, rightMotors); } /** Sets the speed of the main drive diff --git a/src/main/java/frc/robot/subsystems/index_subsystem.java b/src/main/java/frc/robot/subsystems/index_subsystem.java index d6ac09f..8c160f0 100644 --- a/src/main/java/frc/robot/subsystems/index_subsystem.java +++ b/src/main/java/frc/robot/subsystems/index_subsystem.java @@ -7,11 +7,12 @@ package frc.robot.subsystems; -import edu.wpi.first.wpilibj.Solenoid; import edu.wpi.first.wpilibj.command.Subsystem; import frc.robot.RobotMap; import frc.robot.commands.index_command; import edu.wpi.first.wpilibj.Compressor; +import edu.wpi.first.wpilibj.DoubleSolenoid.Value; +import edu.wpi.first.wpilibj.DoubleSolenoid; /** @@ -21,9 +22,8 @@ public class index_subsystem extends Subsystem { // Put methods for controlling this subsystem // here. Call these from Commands. - Solenoid solenoid_right; - Solenoid solenoid_left; - Compressor airComp; + DoubleSolenoid solenoid; + public static Compressor airComp; @Override public void initDefaultCommand() { @@ -32,23 +32,30 @@ public void initDefaultCommand() { // setDefaultCommand(new MySpecialCommand()); } public index_subsystem(){ - airComp = new Compressor(RobotMap.AIRCOMP); - solenoid_right = new Solenoid(RobotMap.SOLENOID_1); - solenoid_left = new Solenoid(RobotMap.SOLENOID_2); - if(airComp.getPressureSwitchValue()){ + airComp = new Compressor(1); + //airComp.clearAllPCMStickyFaults(); + solenoid = new DoubleSolenoid(1, RobotMap.SOLENOID_IN, RobotMap.SOLENOID_OUT); + } + + /** Turns on or off the compressor + */ + public void checkCompressor(){ + System.out.println("Switch "+ airComp.getPressureSwitchValue()); + if(!airComp.getPressureSwitchValue()){ // remember to fix this so take away the ! airComp.start(); } else{ airComp.stop(); } } - + + /** Extends or retracts both pneumatic pistons based on 'active' * @param active if true pistons are extended if false they are retracted */ - public void indexActivate(boolean active){ - solenoid_right.set(active); - solenoid_left.set(active); + public void indexActivate(Value status){ + System.out.println("Status " + status); + solenoid.set(status); } } diff --git a/src/main/java/frc/robot/subsystems/shooter_subsystem.java b/src/main/java/frc/robot/subsystems/shooter_subsystem.java index c9f3d5d..b26cce1 100644 --- a/src/main/java/frc/robot/subsystems/shooter_subsystem.java +++ b/src/main/java/frc/robot/subsystems/shooter_subsystem.java @@ -6,9 +6,9 @@ /*----------------------------------------------------------------------------*/ package frc.robot.subsystems; +import com.revrobotics.CANEncoder; import com.revrobotics.CANPIDController; import com.revrobotics.CANSparkMax; -import com.revrobotics.ControlType; import com.revrobotics.CANSparkMaxLowLevel.MotorType; import edu.wpi.first.wpilibj.command.Subsystem; import frc.robot.RobotMap; @@ -21,13 +21,10 @@ public class shooter_subsystem extends Subsystem { // here. Call these from Commands. CANPIDController bottomPID; CANPIDController topPID; + public CANEncoder topEncoder; + public CANEncoder bottomEncoder; CANSparkMax bottomMotor; CANSparkMax topMotor; - double kP = 0; - double kI = 0; - double kD = 0; - double kIz = 0; - double kFF = 0; @Override public void initDefaultCommand() { setDefaultCommand(new shooter_command()); @@ -37,35 +34,18 @@ public void initDefaultCommand() { //Declaring PID and motors for shooter public shooter_subsystem(){ topMotor = new CANSparkMax(RobotMap.MOTOR_SHOOT_TOP, MotorType.kBrushless); - bottomMotor = new CANSparkMax(RobotMap.MOTOT_SHOOT_BOTTOM, MotorType.kBrushless); - topPID = topMotor.getPIDController(); - bottomPID = bottomMotor.getPIDController(); - topPID.setReference(0, ControlType.kSmartMotion); - bottomPID.setReference(0, ControlType.kSmartMotion); - topPID.setP(kP); - topPID.setI(kI); - topPID.setFF(kFF); - topPID.setIZone(kIz); - bottomPID.setP(kP); - bottomPID.setI(kI); - bottomPID.setFF(kFF); - bottomPID.setIZone(kIz); + bottomMotor = new CANSparkMax(RobotMap.MOTOR_SHOOT_BOTTOM, MotorType.kBrushless); + topEncoder = new CANEncoder(topMotor); + bottomEncoder = new CANEncoder(bottomMotor); + topMotor.setInverted(true); } /** Sets the shooters speeds (in RPM) - *@param topRPM the max RPM for the top of the shooter (can not exceed 5700 RPM) - *@param bottomRPM the max RPM for the bottom of the shooter (can not exceed 5700 RPM) + *@param topMotorSpeed the speed for the top of the shooter (-1 to 1) + *@param bottomMotorSpeed the speed for the bottom of the shooter (-1 to 1) */ - public void setShooterSpeeds(double topRPM, double bottomRPM){ - if(topRPM < 5700 && bottomRPM < 5700 && topRPM > 100 && bottomRPM > 100){ - bottomPID.setSmartMotionMaxVelocity(bottomRPM, 0); - topPID.setSmartMotionMaxVelocity(topRPM, 0); - bottomPID.setSmartMotionMinOutputVelocity(bottomRPM-100, 0); - topPID.setSmartMotionMinOutputVelocity(topRPM-100, 0); - bottomPID.setSmartMotionMaxAccel(1500, 0); - topPID.setSmartMotionMaxAccel(1500, 0); - } - else{ - System.out.println("Too fast!"); - } + public void shooterSet(double topMotorSpeed, double bottomMotorSpeed){ + topMotor.set(topMotorSpeed); + bottomMotor.set(bottomMotorSpeed); + } } diff --git a/vendordeps/Phoenix.json b/vendordeps/Phoenix.json index c6ec878..aa5554e 100644 --- a/vendordeps/Phoenix.json +++ b/vendordeps/Phoenix.json @@ -1,7 +1,7 @@ { "fileName": "Phoenix.json", "name": "CTRE-Phoenix", - "version": "5.18.1", + "version": "5.18.2", "uuid": "ab676553-b602-441f-a38d-f1296eff6537", "mavenUrls": [ "http://devsite.ctr-electronics.com/maven/release/" @@ -11,19 +11,19 @@ { "groupId": "com.ctre.phoenix", "artifactId": "api-java", - "version": "5.18.1" + "version": "5.18.2" }, { "groupId": "com.ctre.phoenix", "artifactId": "wpiapi-java", - "version": "5.18.1" + "version": "5.18.2" } ], "jniDependencies": [ { "groupId": "com.ctre.phoenix", "artifactId": "cci", - "version": "5.18.1", + "version": "5.18.2", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -35,7 +35,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "diagnostics", - "version": "5.18.1", + "version": "5.18.2", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -47,7 +47,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "canutils", - "version": "5.18.1", + "version": "5.18.2", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -58,7 +58,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "platform-stub", - "version": "5.18.1", + "version": "5.18.2", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -69,7 +69,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "core", - "version": "5.18.1", + "version": "5.18.2", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -83,7 +83,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "wpiapi-cpp", - "version": "5.18.1", + "version": "5.18.2", "libName": "CTRE_Phoenix_WPI", "headerClassifier": "headers", "sharedLibrary": false, @@ -97,7 +97,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "api-cpp", - "version": "5.18.1", + "version": "5.18.2", "libName": "CTRE_Phoenix", "headerClassifier": "headers", "sharedLibrary": false, @@ -111,7 +111,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "cci", - "version": "5.18.1", + "version": "5.18.2", "libName": "CTRE_PhoenixCCI", "headerClassifier": "headers", "sharedLibrary": false, @@ -125,7 +125,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "diagnostics", - "version": "5.18.1", + "version": "5.18.2", "libName": "CTRE_PhoenixDiagnostics", "headerClassifier": "headers", "sharedLibrary": false, @@ -139,7 +139,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "canutils", - "version": "5.18.1", + "version": "5.18.2", "libName": "CTRE_PhoenixCanutils", "headerClassifier": "headers", "sharedLibrary": false, @@ -152,7 +152,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "platform-stub", - "version": "5.18.1", + "version": "5.18.2", "libName": "CTRE_PhoenixPlatform", "headerClassifier": "headers", "sharedLibrary": false, @@ -165,7 +165,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "core", - "version": "5.18.1", + "version": "5.18.2", "libName": "CTRE_PhoenixCore", "headerClassifier": "headers", "sharedLibrary": false, diff --git a/vendordeps/REVColorSensorV3.json b/vendordeps/REVColorSensorV3.json index 3940c21..9601ef8 100644 --- a/vendordeps/REVColorSensorV3.json +++ b/vendordeps/REVColorSensorV3.json @@ -1,7 +1,7 @@ { "fileName": "REVColorSensorV3.json", "name": "REVColorSensorV3", - "version": "1.0.1", + "version": "1.2.0", "uuid": "cda7b4b1-d003-44ac-a1ef-485c1347059a", "mavenUrls": [ "http://www.revrobotics.com/content/sw/color-sensor-v3/sdk/maven/" @@ -11,7 +11,7 @@ { "groupId": "com.revrobotics.frc", "artifactId": "ColorSensorV3-java", - "version": "1.0.1" + "version": "1.2.0" } ], "jniDependencies": [], @@ -19,7 +19,7 @@ { "groupId": "com.revrobotics.frc", "artifactId": "ColorSensorV3-cpp", - "version": "1.0.1", + "version": "1.2.0", "libName": "ColorSensorV3", "headerClassifier": "headers", "sourcesClassifier": "source", diff --git a/vendordeps/REVRobotics.json b/vendordeps/REVRobotics.json index 63380b6..5eb069f 100644 --- a/vendordeps/REVRobotics.json +++ b/vendordeps/REVRobotics.json @@ -1,7 +1,7 @@ { "fileName": "REVRobotics.json", "name": "REVRobotics", - "version": "1.5.1", + "version": "1.5.2", "uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb", "mavenUrls": [ "http://www.revrobotics.com/content/sw/max/sdk/maven/" @@ -11,14 +11,14 @@ { "groupId": "com.revrobotics.frc", "artifactId": "SparkMax-java", - "version": "1.5.1" + "version": "1.5.2" } ], "jniDependencies": [ { "groupId": "com.revrobotics.frc", "artifactId": "SparkMax-driver", - "version": "1.5.1", + "version": "1.5.2", "skipInvalidPlatforms": true, "isJar": false, "validPlatforms": [ @@ -35,7 +35,7 @@ { "groupId": "com.revrobotics.frc", "artifactId": "SparkMax-cpp", - "version": "1.5.1", + "version": "1.5.2", "libName": "SparkMax", "headerClassifier": "headers", "sharedLibrary": false, @@ -52,7 +52,7 @@ { "groupId": "com.revrobotics.frc", "artifactId": "SparkMax-driver", - "version": "1.5.1", + "version": "1.5.2", "libName": "SparkMaxDriver", "headerClassifier": "headers", "sharedLibrary": false, From c24a908c3bc9b4cb68a5928b3b1626f31edd6d57 Mon Sep 17 00:00:00 2001 From: PM Date: Wed, 9 Dec 2020 19:16:02 -0600 Subject: [PATCH 09/13] resolving unsure conflicts, ridding weird unused code --- src/main/java/frc/robot/Robot.java | 5 +- src/main/java/frc/robot/RobotMap.java | 5 +- .../robot/commands/driveStraight_command.java | 72 +++++++++---------- .../java/frc/robot/commands/lift_command.java | 2 +- .../frc/robot/commands/shooter_command.java | 4 -- .../subsystems/colorWheel_subsystem.java | 3 +- .../frc/robot/subsystems/lift_subsystem.java | 2 +- 7 files changed, 42 insertions(+), 51 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 25b2cf3..af2c7d3 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -62,12 +62,9 @@ public void robotInit() { index_subsystem = new index_subsystem(); shooter_subsystem = new shooter_subsystem(); colorWheel_subsystem = new colorWheel_subsystem(); -<<<<<<< HEAD - lift_subsystem = new lift_subsystem(); -======= drive_subsystem = new drive_subsystem(); intake_subsystem = new intake_subsystem(); ->>>>>>> ebd7965a5aa467985b9c695cf2139d17adc028d9 + //lift_subsystem = new lift_subsystem(); m_oi = new OI(); m_oi.bind(); //bind the buttons to commands // m_chooser.setDefaultOption("Default Auto", kDefaultAuto); diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index d28eef1..0bf625a 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -82,11 +82,8 @@ public class RobotMap { //color sensor public static final I2C.Port i2cPort = I2C.Port.kOnboard; -<<<<<<< HEAD + //lift motor public static final int LIFTMOTOR = 7; } -======= -} ->>>>>>> ebd7965a5aa467985b9c695cf2139d17adc028d9 diff --git a/src/main/java/frc/robot/commands/driveStraight_command.java b/src/main/java/frc/robot/commands/driveStraight_command.java index 4402175..9972574 100644 --- a/src/main/java/frc/robot/commands/driveStraight_command.java +++ b/src/main/java/frc/robot/commands/driveStraight_command.java @@ -63,44 +63,44 @@ protected void execute() { //System.out.println("Encoder Avg: " + (Math.abs(Robot.rightEncoder.getRaw()) + Math.abs(Robot.leftEncoder.getRaw()))/2); rightDist = Math.abs(Robot.rightEncoder.getDistance()); leftDist = Math.abs(Robot.rightEncoder.getDistance()); -<<<<<<< HEAD - double leftSpeedEdit = (-((currentYaw/180)/(speedTol))+(speed+(2/speedTol)));; - double rightSpeedEdit = (((currentYaw/180)/(speedTol))+speed); + averageDist = (leftDist+rightDist)/2; + if(360-tol > currentYaw && currentYaw > 180){ //If the degrees off of straight (a.k.a 0 degrees) is greater than 180 but less than 355 + leftSpeed = speed; + rightSpeed = speed - ((360 - currentYaw)/(180/speed)); + } + else if(180 >= currentYaw && currentYaw > tol){ //If the degrees off of straight (a.k.a 0 degrees) is less than or equal to 180 but greater than 5 + leftSpeed = speed - ((currentYaw)/(180/speed)); + rightSpeed = speed; + } + else{ //If the degrees off of straight (a.k.a 0 degrees) is 'tol' greater/less than straight + leftSpeed = speed; + rightSpeed = speed; + } - if(360-tol > currentYaw && currentYaw > 180){ //If the degrees off of straight (a.k.a 0 degrees) is greater than 180 but less than 355 - leftSpeed = -leftSpeedEdit; //Ex. 315/180 = 1.75 -> 1.75/5 = 0.35 -> -0.35 -> -0.35+(.5+(2/5)) -> -0.35 + 0.9 -> Speed = 0.55 at 315 deg - rightSpeed = -speed; - } - else if(180 >= currentYaw && currentYaw > tol){ //If the degrees off of straight (a.k.a 0 degrees) is less than or equal to 180 but greater than 5 - leftSpeed = -speed; - rightSpeed = -rightSpeedEdit; //Ex. 45/180 = 0.25 -> 0.25/5 = 0.05 -> 0.05 + 0.5 -> Speed = 0.55 at 45 deg - } - else{ //If the degrees off of straight (a.k.a 0 degrees) is 5 greater/less than straight - leftSpeed = -speed; - rightSpeed = -speed; - } + /* + + double leftSpeedEdit = (-((currentYaw/180)/(speedTol))+(speed+(2/speedTol)));; + double rightSpeedEdit = (((currentYaw/180)/(speedTol))+speed); - System.out.println("Left distance: " + leftDist); -======= - averageDist = (leftDist+rightDist)/2; - if(360-tol > currentYaw && currentYaw > 180){ //If the degrees off of straight (a.k.a 0 degrees) is greater than 180 but less than 355 - leftSpeed = speed; - rightSpeed = speed - ((360 - currentYaw)/(180/speed)); - } - else if(180 >= currentYaw && currentYaw > tol){ //If the degrees off of straight (a.k.a 0 degrees) is less than or equal to 180 but greater than 5 - leftSpeed = speed - ((currentYaw)/(180/speed)); - rightSpeed = speed; - } - else{ //If the degrees off of straight (a.k.a 0 degrees) is 'tol' greater/less than straight - leftSpeed = speed; - rightSpeed = speed; - } - Robot.drive_subsystem.drive(leftSpeed, rightSpeed); - /*System.out.println("Left distance: " + leftDist); ->>>>>>> ebd7965a5aa467985b9c695cf2139d17adc028d9 - System.out.println("Right distance: " + rightDist); - System.out.println("Left Spd: " + leftSpeed); - System.out.println("Right Spd: " + rightSpeed);*/ + if(360-tol > currentYaw && currentYaw > 180){ //If the degrees off of straight (a.k.a 0 degrees) is greater than 180 but less than 355 + leftSpeed = -leftSpeedEdit; //Ex. 315/180 = 1.75 -> 1.75/5 = 0.35 -> -0.35 -> -0.35+(.5+(2/5)) -> -0.35 + 0.9 -> Speed = 0.55 at 315 deg + rightSpeed = -speed; + } + else if(180 >= currentYaw && currentYaw > tol){ //If the degrees off of straight (a.k.a 0 degrees) is less than or equal to 180 but greater than 5 + leftSpeed = -speed; + rightSpeed = -rightSpeedEdit; //Ex. 45/180 = 0.25 -> 0.25/5 = 0.05 -> 0.05 + 0.5 -> Speed = 0.55 at 45 deg + } + else{ //If the degrees off of straight (a.k.a 0 degrees) is 5 greater/less than straight + leftSpeed = -speed; + rightSpeed = -speed; + } + */ + + Robot.drive_subsystem.drive(leftSpeed, rightSpeed); + /*System.out.println("Left distance: " + leftDist); + System.out.println("Right distance: " + rightDist); + System.out.println("Left Spd: " + leftSpeed); + System.out.println("Right Spd: " + rightSpeed);*/ } // Make this return true when this Command no longer needs to run execute() diff --git a/src/main/java/frc/robot/commands/lift_command.java b/src/main/java/frc/robot/commands/lift_command.java index bc63f05..8dd4fae 100644 --- a/src/main/java/frc/robot/commands/lift_command.java +++ b/src/main/java/frc/robot/commands/lift_command.java @@ -9,7 +9,7 @@ import edu.wpi.first.wpilibj.command.Command; import frc.robot.Robot; -import frc.robot.subsystems.lift_subsystem; +//import frc.robot.subsystems.lift_subsystem; public class lift_command extends Command { public boolean dpad_up; diff --git a/src/main/java/frc/robot/commands/shooter_command.java b/src/main/java/frc/robot/commands/shooter_command.java index d5567dc..db5791b 100644 --- a/src/main/java/frc/robot/commands/shooter_command.java +++ b/src/main/java/frc/robot/commands/shooter_command.java @@ -74,10 +74,6 @@ protected void end() { // subsystems is scheduled to run @Override protected void interrupted() { -<<<<<<< HEAD - end(); -======= end(); ->>>>>>> ebd7965a5aa467985b9c695cf2139d17adc028d9 } } diff --git a/src/main/java/frc/robot/subsystems/colorWheel_subsystem.java b/src/main/java/frc/robot/subsystems/colorWheel_subsystem.java index 59944aa..d788acd 100644 --- a/src/main/java/frc/robot/subsystems/colorWheel_subsystem.java +++ b/src/main/java/frc/robot/subsystems/colorWheel_subsystem.java @@ -23,7 +23,8 @@ public class colorWheel_subsystem extends Subsystem { WPI_TalonSRX colorWheelWheel = null; - private static boolean wheelInitialized = false; + //private static boolean wheelInitialized = false; + // ^^^^^^^ WHAT IS THIS FOR????? /** * A Rev Color Sensor V3 object is constructed with an I2C port as a diff --git a/src/main/java/frc/robot/subsystems/lift_subsystem.java b/src/main/java/frc/robot/subsystems/lift_subsystem.java index ea09fe5..9166d96 100644 --- a/src/main/java/frc/robot/subsystems/lift_subsystem.java +++ b/src/main/java/frc/robot/subsystems/lift_subsystem.java @@ -10,7 +10,7 @@ import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX; import edu.wpi.first.wpilibj.command.Subsystem; -import frc.robot.Robot; +//import frc.robot.Robot; import frc.robot.RobotMap; import frc.robot.commands.lift_command; From 11d39a6f4715b37905ca456b5c1a6a3f0c56bc65 Mon Sep 17 00:00:00 2001 From: Stefan Hauge Date: Mon, 14 Dec 2020 21:04:32 -0600 Subject: [PATCH 10/13] commenting unused code, changing maps for 2 motor config --- src/main/java/frc/robot/Robot.java | 10 +++++----- src/main/java/frc/robot/RobotMap.java | 6 +++--- .../java/frc/robot/subsystems/shooter_subsystem.java | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index cb077a8..2d32814 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -32,12 +32,12 @@ public class Robot extends TimedRobot { public static OI m_oi; public static AHRS navx; - private String m_autoSelected; + //private String m_autoSelected; private final SendableChooser m_chooser = new SendableChooser<>(); private static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); private static Date date = new Date(); - private static boolean indexInitalized; - private static boolean colorwheelInitalized; + //private static boolean indexInitalized; + //private static boolean colorwheelInitalized; public static Encoder rightEncoder = new Encoder(RobotMap.leftEncoderPort1, RobotMap.leftEncoderPort2, false, EncodingType.k4X); public static Encoder leftEncoder = new Encoder(RobotMap.rightEncoderPort1, RobotMap.rightEncoderPort2, false, EncodingType.k4X); //declare subsystems @@ -59,10 +59,10 @@ public Robot(){ @Override public void robotInit() { //index_subsystem = new index_subsystem(); - shooter_subsystem = new shooter_subsystem(); + //shooter_subsystem = new shooter_subsystem(); //colorWheel_subsystem = new colorWheel_subsystem(); drive_subsystem = new drive_subsystem(); - intake_subsystem = new intake_subsystem(); + //intake_subsystem = new intake_subsystem(); m_oi = new OI(); m_oi.bind(); //bind the buttons to commands // m_chooser.setDefaultOption("Default Auto", kDefaultAuto); diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index 226ce1c..5725fbd 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -25,10 +25,10 @@ public class RobotMap { */ //Drive Motors - public static final int MOTOR_LEFT_1 = 4; //Front left motor - public static final int MOTOR_LEFT_2 = 3; //Back left motor + public static final int MOTOR_LEFT_1 = 2; //Front left motor + public static final int MOTOR_LEFT_2 = 2; //Back left motor public static final int MOTOR_RIGHT_1 = 1; //Front right motor - public static final int MOTOR_RIGHT_2 = 2; /**Back right motor**/ + public static final int MOTOR_RIGHT_2 = 1; //Back right motor //Intake Motor public static final int MOTOR_INTAKE = 6; //Shooter Motor diff --git a/src/main/java/frc/robot/subsystems/shooter_subsystem.java b/src/main/java/frc/robot/subsystems/shooter_subsystem.java index caa1b34..8ece9f0 100644 --- a/src/main/java/frc/robot/subsystems/shooter_subsystem.java +++ b/src/main/java/frc/robot/subsystems/shooter_subsystem.java @@ -8,7 +8,7 @@ package frc.robot.subsystems; import com.revrobotics.CANPIDController; import com.revrobotics.CANSparkMax; -import com.revrobotics.ControlType; +//import com.revrobotics.ControlType; import com.revrobotics.CANSparkMaxLowLevel.MotorType; import edu.wpi.first.wpilibj.command.Subsystem; import frc.robot.RobotMap; From 1dd3d224bb42acf62cc44cc8fad0d17013b0bd6b Mon Sep 17 00:00:00 2001 From: PM Date: Tue, 15 Dec 2020 18:34:06 -0600 Subject: [PATCH 11/13] fix: robotmap var name, function enclosure, formatting --- src/main/java/frc/robot/RobotMap.java | 2 +- src/main/java/frc/robot/subsystems/shooter_subsystem.java | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index f93991f..4509960 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -33,7 +33,7 @@ public class RobotMap { public static final int MOTOR_INTAKE = 6; //Shooter Motor public static final int MOTOR_SHOOT_TOP = 9; - public static final int MOTOT_SHOOT_BOTTOM = 8; + public static final int MOTOR_SHOOT_BOTTOM = 8; //public static final int MOTOR_SHOOT_TOP = 8; //public static final int MOTOR_SHOOT_BOTTOM = 9; //SOLENOID diff --git a/src/main/java/frc/robot/subsystems/shooter_subsystem.java b/src/main/java/frc/robot/subsystems/shooter_subsystem.java index abd78ab..30fe6be 100644 --- a/src/main/java/frc/robot/subsystems/shooter_subsystem.java +++ b/src/main/java/frc/robot/subsystems/shooter_subsystem.java @@ -79,7 +79,7 @@ public void shooterSet(double topMotorSpeed, double bottomMotorSpeed){ *@param topRPM the max RPM for the top of the shooter (between 5700RPM-1000RPM) *@param bottomRPM the max RPM for the bottom of the shooter (between 5700RPM-1000RPM) */ - /* public void setShooterSpeeds(double topRPM, double bottomRPM){ + /*public void setShooterSpeeds(double topRPM, double bottomRPM){ if(topRPM < 5700 && bottomRPM < 5700 && topRPM > 1000 && bottomRPM > 1000){ bottomPID.setSmartMotionMaxVelocity(bottomRPM, 0); //topPID.setSmartMotionMaxVelocity(topRPM, 0); @@ -92,7 +92,6 @@ public void shooterSet(double topMotorSpeed, double bottomMotorSpeed){ //System.out.println("Too fast!"); //topMotor.stopMotor(); bottomMotor.stopMotor(); - } */ - // } - } + } + }*/ } From 54b6d4be84ed58853637a13bdf60b97568b044cc Mon Sep 17 00:00:00 2001 From: PM Date: Tue, 15 Dec 2020 19:02:58 -0600 Subject: [PATCH 12/13] organized robotmap --- src/main/java/frc/robot/RobotMap.java | 64 ++++++++++++++++----------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index 4509960..8b76a2d 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -9,6 +9,8 @@ import edu.wpi.first.wpilibj.I2C; /** + * IN MEMORIUM: + * The_Whole_Robot_Code_Trust_Me_I_Am_Always_Right_269_2020_Squire_Grace_Forever */ public class RobotMap { @@ -24,34 +26,52 @@ public class RobotMap { * number to each component you want to test. i.e. log only gyro or log only drive or log gyo and drive.. */ - //Drive Motors + // Drive Motors public static final int MOTOR_LEFT_1 = 2; //Front left motor public static final int MOTOR_LEFT_2 = 2; //Back left motor public static final int MOTOR_RIGHT_1 = 1; //Front right motor public static final int MOTOR_RIGHT_2 = 1; //Back right motor - //Intake Motor + + // Intake Motors public static final int MOTOR_INTAKE = 6; - //Shooter Motor + + // Shooter Motors public static final int MOTOR_SHOOT_TOP = 9; public static final int MOTOR_SHOOT_BOTTOM = 8; - //public static final int MOTOR_SHOOT_TOP = 8; - //public static final int MOTOR_SHOOT_BOTTOM = 9; - //SOLENOID + + // Color Wheel Motors + public static final int MOTOR_COLOR_WHEEL = 7; + + // Lift Motors + public static final int LIFTMOTOR = 7; + + // Encoders + public static final int leftEncoderPort1 = 3; + public static final int leftEncoderPort2 = 2; + public static final int rightEncoderPort1 = 0; + public static final int rightEncoderPort2 = 1; + + // SOLENOID public static final int SOLENOID_IN = 0; public static final int SOLENOID_OUT = 1; - //AIR COMPRESSOR - //public static final int AIRCOMP = 0; - //COLOR WHEEL - public static final int MOTOR_COLOR_WHEEL = 7; - //Controllers + + // Air Compressors + // public static final int AIRCOMP = 0; + + // (Color) Sensors + public static final I2C.Port i2cPort = I2C.Port.kOnboard; + + // Controllers public static final int DRIVER_CONTROLLER = 0; public static final int INTAKE_CONTROLLER = 1; - //Joysticks + + // Joysticks (two-axis thumbsticks on the controllers) public static final int LEFT_JOYSTICK_X = 0; public static final int LEFT_JOYSTICK_Y = 1; public static final int RIGHT_JOYSTICK_X = 4; public static final int RIGHT_JOYSTICK_Y = 5; - //Buttons + + // Buttons (all other control surfaces on the top) public static final int BUTTON_X = 3; public static final int BUTTON_Y = 4; public static final int BUTTON_A = 1; @@ -63,27 +83,17 @@ public class RobotMap { public static final int START_BUTTON = 8; public static final int SELECT_BUTTON = 7; - //Triggers + // Triggers (the lower control surfaces on the front of the controller) public static final int LT = 0; public static final int RT = 1; - //Bumpers + + // Bumpers (the upper control surfaces on the front of the controller) public static final int LB = 5; public static final int RB = 6; - - //Encoders - public static final int leftEncoderPort1 = 3; - public static final int leftEncoderPort2 = 2; - public static final int rightEncoderPort1 = 0; - public static final int rightEncoderPort2 = 1; - //POV Buttons + // POV Buttons public static final int UP_BUTTON = 0; public static final int RIGHT_BUTTON = 2; public static final int DOWN_BUTTON = 4; public static final int LEFT_BUTTON = 6; - - //color sensor - public static final I2C.Port i2cPort = I2C.Port.kOnboard; - //lift motor - public static final int LIFTMOTOR = 7; } From ec645e287189aab4f77be2c456ac3d203cc34157 Mon Sep 17 00:00:00 2001 From: PM Date: Tue, 15 Dec 2020 23:21:23 -0600 Subject: [PATCH 13/13] beta hammer command I am going to start a separate branch for further development. --- src/main/java/frc/robot/Robot.java | 9 ++-- src/main/java/frc/robot/RobotMap.java | 3 ++ .../frc/robot/commands/hammer_command.java | 47 +++++++++++++++++++ .../robot/subsystems/hammer_subsystem.java | 34 ++++++++++++++ 4 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 src/main/java/frc/robot/commands/hammer_command.java create mode 100644 src/main/java/frc/robot/subsystems/hammer_subsystem.java diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 9d51303..f9a975b 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -13,15 +13,16 @@ import edu.wpi.first.wpilibj.CounterBase.EncodingType; import edu.wpi.first.wpilibj.command.Scheduler; //import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; +import java.util.Date; +import java.text.SimpleDateFormat; +import java.text.DateFormat; import frc.robot.subsystems.colorWheel_subsystem; import frc.robot.subsystems.drive_subsystem; import frc.robot.subsystems.index_subsystem; import frc.robot.subsystems.intake_subsystem; import frc.robot.subsystems.lift_subsystem; import frc.robot.subsystems.shooter_subsystem; -import java.util.Date; -import java.text.SimpleDateFormat; -import java.text.DateFormat; +import frc.robot.subsystems.hammer_subsystem; /** * The VM is configured to automatically run this class, and to call the @@ -48,6 +49,7 @@ public class Robot extends TimedRobot { public static index_subsystem index_subsystem = null; public static shooter_subsystem shooter_subsystem = null; public static lift_subsystem lift_subsystem = null; + public static hammer_subsystem hammer_subsystem = null; @@ -66,6 +68,7 @@ public void robotInit() { colorWheel_subsystem = new colorWheel_subsystem(); drive_subsystem = new drive_subsystem(); intake_subsystem = new intake_subsystem(); + hammer_subsystem = new hammer_subsystem(); //lift_subsystem = new lift_subsystem(); m_oi = new OI(); m_oi.bind(); //bind the buttons to commands diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index 8b76a2d..d5a4ddf 100644 --- a/src/main/java/frc/robot/RobotMap.java +++ b/src/main/java/frc/robot/RobotMap.java @@ -32,6 +32,9 @@ public class RobotMap { public static final int MOTOR_RIGHT_1 = 1; //Front right motor public static final int MOTOR_RIGHT_2 = 1; //Back right motor + // Hammer Motors (? still not sure what the hammer is) + public static final int MOTOR_HAMMER_1 = 3; + // Intake Motors public static final int MOTOR_INTAKE = 6; diff --git a/src/main/java/frc/robot/commands/hammer_command.java b/src/main/java/frc/robot/commands/hammer_command.java new file mode 100644 index 0000000..52b421e --- /dev/null +++ b/src/main/java/frc/robot/commands/hammer_command.java @@ -0,0 +1,47 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 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 edu.wpi.first.wpilibj2.command.CommandBase; +import frc.robot.Robot; + +public class hammer_command extends CommandBase { + /** + * Creates a new hammer_command. + */ + public hammer_command() { + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(Robot.hammer_subsystem); + } + + // 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() { + if (Robot.m_oi.buttonA.get()) { + Robot.hammer_subsystem.hammerActivate();// other idea would be to make it take a boolean that instructs it whether to be active + } else { + //Robot.hammer_subsystem.hammerActivate(false); + } + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc/robot/subsystems/hammer_subsystem.java b/src/main/java/frc/robot/subsystems/hammer_subsystem.java new file mode 100644 index 0000000..5dd1732 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/hammer_subsystem.java @@ -0,0 +1,34 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 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 edu.wpi.first.wpilibj2.command.CommandScheduler;//https://docs.wpilib.org/en/stable/docs/software/commandbased/subsystems.html#setting-default-commands +import edu.wpi.first.wpilibj2.command.SubsystemBase; +import frc.robot.commands.hammer_command; +import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX; +import frc.robot.RobotMap; + +public class hammer_subsystem extends SubsystemBase { + WPI_TalonSRX hamMotor = null; + /** + * Creates a new hammer_subsystem. + */ + public hammer_subsystem() { + setDefaultCommand(new hammer_command()); + hamMotor = new WPI_TalonSRX(RobotMap.BUTTON_A); + } + + @Override + public void periodic() { + // This method will be called once per scheduler run + } + + public void hammerActivate() { + hamMotor.set(0.3); + } +}