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/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index ed560ac..f9a975b 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -12,15 +12,17 @@ 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 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 @@ -32,12 +34,12 @@ 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(); - 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 @@ -46,6 +48,8 @@ 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; + public static hammer_subsystem hammer_subsystem = null; @@ -58,13 +62,16 @@ public Robot(){ */ @Override public void robotInit() { - //index_subsystem = new index_subsystem(); - //shooter_subsystem = new shooter_subsystem(); + System.out.println("Made it"); + 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(); + hammer_subsystem = new hammer_subsystem(); + //lift_subsystem = new lift_subsystem(); m_oi = new OI(); - m_oi.bind(); + 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); diff --git a/src/main/java/frc/robot/RobotMap.java b/src/main/java/frc/robot/RobotMap.java index c7c0b84..d5a4ddf 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,32 +26,55 @@ 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 - public static final int MOTOR_LEFT_1 = 4; //Front left motor - public static final int MOTOR_LEFT_2 = 3; //Back left motor + // 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 = 2; /**Back right motor**/ - //Intake 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; - //Shooter Motor - 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; - //AIR COMPRESSOR - //public static final int AIRCOMP = 0; - //COLOR WHEEL + + // Shooter Motors + public static final int MOTOR_SHOOT_TOP = 9; + public static final int MOTOR_SHOOT_BOTTOM = 8; + + // Color Wheel Motors public static final int MOTOR_COLOR_WHEEL = 7; - //Controllers + + // 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 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; @@ -58,28 +83,20 @@ public class RobotMap { 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 + // Triggers (the lower control surfaces on the front of the controller) 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; - - //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 + // Bumpers (the upper control surfaces on the front of the controller) + public static final int LB = 5; + public static final int RB = 6; + + // 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; } diff --git a/src/main/java/frc/robot/commands/autonomousSelector.java b/src/main/java/frc/robot/commands/autonomousSelector.java index f58ca99..0a2c2c2 100644 --- a/src/main/java/frc/robot/commands/autonomousSelector.java +++ b/src/main/java/frc/robot/commands/autonomousSelector.java @@ -18,21 +18,22 @@ public autonomousSelector(double position, String priority) { Robot.WriteOut("Autonomous Selector Initialized"); if(position == 1){ Robot.WriteOut("Selected Postition 1"); - if(priority.equalsIgnoreCase("Mane1")){ + if(priority.equalsIgnoreCase("mane1")){ Robot.WriteOut("Selected Maneuver 1 on Position 1"); addSequential(new driveOverLine()); } - else if(priority.equalsIgnoreCase("Mane2")){ + 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")){ + if(priority.equalsIgnoreCase("mane1")){ Robot.WriteOut("Selected Maneuver 1 on Position 2"); + } - else if(priority.equalsIgnoreCase("Mane2")){ + 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 8a27542..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,7 +47,7 @@ protected void initialize() { // Called repeatedly when this Command is scheduled to run @Override protected void execute() { - if (Robot.m_oi.Intake_buttonY.get() && 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); diff --git a/src/main/java/frc/robot/commands/driveStraight_command.java b/src/main/java/frc/robot/commands/driveStraight_command.java index b1f9275..9972574 100644 --- a/src/main/java/frc/robot/commands/driveStraight_command.java +++ b/src/main/java/frc/robot/commands/driveStraight_command.java @@ -64,23 +64,43 @@ protected void execute() { rightDist = Math.abs(Robot.rightEncoder.getDistance()); leftDist = Math.abs(Robot.rightEncoder.getDistance()); 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); - 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 = 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; + } + + /* + + 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; + } + */ + + 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/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/commands/index_command.java b/src/main/java/frc/robot/commands/index_command.java index c93c325..e48060a 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,20 +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() { if(Robot.m_oi.buttonB.get()){ - Robot.index_subsystem.indexActivate(true); + Robot.index_subsystem.indexActivate(kReverse); } else{ - Robot.index_subsystem.indexActivate(false); - } - // If the a button is pressed the boolean value is true which activates the pnuematics of the indexing system + 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() { @@ -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/commands/intake_command.java b/src/main/java/frc/robot/commands/intake_command.java index b953690..82075dd 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;//CHECK NECESSARY public intake_command() { // Use requires() here to declare subsystem dependencies // eg. requires(chassis); @@ -25,8 +25,25 @@ 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 if(Robot.m_oi.Intake_buttonB.get()){ + Robot.intake_subsystem.rollerSpeed(-motorSpeed); } else{ Robot.intake_subsystem.rollerSpeed(0); @@ -43,6 +60,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/lift_command.java b/src/main/java/frc/robot/commands/lift_command.java new file mode 100644 index 0000000..8dd4fae --- /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/commands/shooter_command.java b/src/main/java/frc/robot/commands/shooter_command.java index 1ce8387..d09af8d 100644 --- a/src/main/java/frc/robot/commands/shooter_command.java +++ b/src/main/java/frc/robot/commands/shooter_command.java @@ -8,13 +8,16 @@ 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 topSpeedSet = 0.8;// WASN'T HERE BEFORE MERGE + //double maxRPM = 5700; + //double topSpeedSet = 0.8; double maxRPM = 5700; public shooter_command() { requires(Robot.shooter_subsystem); @@ -29,50 +32,51 @@ 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; - topSpeedSet = topSpeed/maxRPM; - bottomSpeedSet = bottomSpeed/maxRPM; + 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; - topSpeedSet = topSpeed/maxRPM; - bottomSpeedSet = bottomSpeed/maxRPM; + 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; - topSpeedSet = topSpeed/maxRPM; - bottomSpeedSet = bottomSpeed/maxRPM; + 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); - Robot.shooter_subsystem.shootAnyway(topSpeedSet, bottomSpeedSet); + 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{ - end(); + 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.shootAnyway(0, 0); + Robot.shooter_subsystem.shooterSet(0, 0); // add back 0 + // VVV CODE IN MERGE CONFLICT + // Robot.shooter_subsystem.setShooterSpeeds(0, 0); + //Robot.shooter_subsystem.shootAnyway(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() { + end(); } } diff --git a/src/main/java/frc/robot/commands/turnRightGoStraight.java b/src/main/java/frc/robot/commands/turnRightGoStraight.java index 72776b2..776ce86 100644 --- a/src/main/java/frc/robot/commands/turnRightGoStraight.java +++ b/src/main/java/frc/robot/commands/turnRightGoStraight.java @@ -15,6 +15,6 @@ public class turnRightGoStraight extends CommandGroup { */ public turnRightGoStraight() { addSequential(new turnGyro_command(90, .5)); - addSequential(new driveStraight_command(0.5,100,-1)); + 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 2e1b22d..d788acd 100644 --- a/src/main/java/frc/robot/subsystems/colorWheel_subsystem.java +++ b/src/main/java/frc/robot/subsystems/colorWheel_subsystem.java @@ -23,6 +23,8 @@ public class colorWheel_subsystem extends Subsystem { WPI_TalonSRX colorWheelWheel = null; + //private static boolean wheelInitialized = false; + // ^^^^^^^ WHAT IS THIS FOR????? /** * A Rev Color Sensor V3 object is constructed with an I2C port as a @@ -84,13 +86,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"; 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); + } +} diff --git a/src/main/java/frc/robot/subsystems/index_subsystem.java b/src/main/java/frc/robot/subsystems/index_subsystem.java index 1ca4098..2ace7af 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,29 +32,35 @@ 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); - 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 = new Compressor(10); + //airComp.clearAllPCMStickyFaults(); + //airComp.stop(); + //solenoid = new DoubleSolenoid(RobotMap.SOLENOID_IN, RobotMap.SOLENOID_OUT); + //if(airComp.getPressureSwitchValue()){ 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){ - if(active){ - airComp.start(); - } - else{ - airComp.stop(); - } - solenoid_right.set(active); - solenoid_left.set(active); + public void indexActivate(Value status){ + System.out.println("Status " + status);// CONFLICT, CHECK VAR status + solenoid.set(status); } } 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..9166d96 --- /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()); + } +} diff --git a/src/main/java/frc/robot/subsystems/shooter_subsystem.java b/src/main/java/frc/robot/subsystems/shooter_subsystem.java index 07291b5..30fe6be 100644 --- a/src/main/java/frc/robot/subsystems/shooter_subsystem.java +++ b/src/main/java/frc/robot/subsystems/shooter_subsystem.java @@ -6,9 +6,10 @@ /*----------------------------------------------------------------------------*/ package frc.robot.subsystems; +import com.revrobotics.CANEncoder; 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; @@ -21,13 +22,17 @@ 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; + // VVV IN MERGE CONFLICT, NOT SURE WHAT IT IS, APPLIES TO FUNCTION IN MERGE CONFLICT BELOW + // 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()); @@ -36,42 +41,57 @@ public void initDefaultCommand() { } //Declaring PID and motors for shooter public shooter_subsystem(){ + // START PREV MERGE CONFLICT topMotor = new CANSparkMax(RobotMap.MOTOR_SHOOT_TOP, MotorType.kBrushless); - bottomMotor = new CANSparkMax(RobotMap.MOTOT_SHOOT_BOTTOM, MotorType.kBrushless); - topPID = topMotor.getPIDController(); - bottomPID = bottomMotor.getPIDController(); + 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 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 shooterSet(double topMotorSpeed, double bottomMotorSpeed){ + topMotor.set(topMotorSpeed); + bottomMotor.set(bottomMotorSpeed); + + // VVV ALL BELOW IN MERGE CONFLICT + + //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); - } + //topPID.setP(kP); + //topPID.setI(kI); + //topPID.setFF(kFF); + //topPID.setIZone(kIz); + //bottomPID.setP(kP); + //bottomPID.setI(kI); + //bottomPID.setFF(kFF); + //bottomPID.setIZone(kIz); */ + + } // NOT CONFLICTING IN MERGE + /** 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); - 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,