diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index f3ab8b7..85581b9 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -4,11 +4,14 @@ package frc.robot; -import frc.robot.subsystems.Intake; import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.InstantCommand; import edu.wpi.first.wpilibj2.command.StartEndCommand; import edu.wpi.first.wpilibj2.command.button.JoystickButton; +import frc.robot.subsystems.Elevator; +import frc.robot.subsystems.Shooter; +import frc.robot.subsystems.Funnel; /** * This class is where the bulk of the robot should be declared. Since Command-based is a @@ -18,10 +21,17 @@ */ public class RobotContainer { // The robot's subsystems and commands are defined here... - private final Intake m_intake = new Intake(); + + private final Shooter m_shooter = new Shooter(); + + private final Funnel m_funnel = new Funnel(); private final Joystick main_stick = new Joystick(4); + //private final Climber m_climber = new Climber(); + + private final Elevator m_Elevator = new Elevator(); + /** The container for the robot. Contains subsystems, OI devices, and commands. */ public RobotContainer() { // Configure the trigger bindings @@ -31,39 +41,61 @@ public RobotContainer() { private void configureBindings() { - new JoystickButton(main_stick, 1) + new JoystickButton(main_stick, 7) .whileTrue(new StartEndCommand( - () -> m_intake.runMotors(0.4), - () -> m_intake.runMotors(0))); + () -> m_shooter.runMotors(.2), + () -> m_shooter.runMotors(0))); - new JoystickButton(main_stick, 2) - .whileTrue(new StartEndCommand( - () -> m_intake.runMotors(-0.4), - () -> m_intake.runMotors(0))); + new JoystickButton(main_stick, 8) + .onTrue(new InstantCommand(m_funnel::flip)); - new JoystickButton(main_stick, 3) - .whileTrue(new StartEndCommand( - () -> m_intake.runMotors(0.9), - () -> m_intake.runMotors(0))); + /*new JoystickButton(main_stick, 9) + .onTrue(new IntantCommand(m_climber::grabDown(2))); - new JoystickButton(main_stick, 4) - .whileTrue(new StartEndCommand( - () -> m_intake.runMotors(-0.9), - () -> m_intake.runMotors(0))); + new JoystickButton(main_stick, 9) + .whileTrue(new StartEndCommand( + () -> m_climber.grabUp(2), + () -> m_climber.afk())); - new JoystickButton(main_stick, 5) - .whileTrue(new StartEndCommand( - () -> m_intake.runWrist(1), - () -> m_intake.runWrist(0))); + new JoystickButton(main_stick, 10){ + .whileTrue(new StartEndCommand( + () -> m_climber.runMotors(2), + () -> m_climber.afk())); - new JoystickButton(main_stick, 6) - .whileTrue(new StartEndCommand( - () -> m_intake.runWrist(-1), - () -> m_intake.runWrist(0))); + //button 3 + new JoystickButton(main_stick,12) + .onTrue(new StartEndCommand(, + () -> m_climber.afk())); + + //upButton + new JoystickButton(main_stick,11) + .whileTrue(new StartEndCommand( + () -> m_climber.grabUp(2), + () -> m_climber.afk())); + + //downbutton + new JoystickButton(main_stick,11) + .whileTrue(new StartEndCommand( + () -> m_climber.grabDown(2), + () -> m_climber.afk())); + + +*/ + +//i've got this *ding* + //l4 preset + new JoystickButton(main_stick, 9) + .whileTrue(new StartEndCommand( + () -> m_Elevator.l4(), + () -> m_Elevator.afk())); + + + } // Schedule `exampleMethodCommand` when the Xbox controller's B button is pressed, // cancelling on release. } + /** * Use this to pass the autonomous command to the main {@link Robot} class. diff --git a/src/main/java/frc/robot/commands/ExampleCommand.java b/src/main/java/frc/robot/commands/ExampleCommand.java index fac95e7..5a758eb 100644 --- a/src/main/java/frc/robot/commands/ExampleCommand.java +++ b/src/main/java/frc/robot/commands/ExampleCommand.java @@ -1,43 +1,43 @@ -// // Copyright (c) FIRST and other WPILib contributors. -// // Open Source Software; you can modify and/or share it under the terms of -// // the WPILib BSD license file in the root directory of this project. - -// package frc.robot.commands; - -// import frc.robot.subsystems.ExampleSubsystem; -// import edu.wpi.first.wpilibj2.command.Command; - -// /** An example command that uses an example subsystem. */ -// public class ExampleCommand extends Command { -// @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) -// private final ExampleSubsystem m_subsystem; - -// /** -// * Creates a new ExampleCommand. -// * -// * @param subsystem The subsystem used by this command. -// */ -// public ExampleCommand(ExampleSubsystem subsystem) { -// m_subsystem = subsystem; -// // Use addRequirements() here to declare subsystem dependencies. -// addRequirements(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() {} - -// // 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; -// } -// } +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.commands; + +import edu.wpi.first.wpilibj2.command.Command; +import frc.robot.subsystems.Shooter; + +/** An example command that uses an example subsystem. */ +public class ExampleCommand extends Command { + @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) + private final Shooter m_subsystem; + + /** + * Creates a new ExampleCommand. + * + * @param subsystem The subsystem used by this command. + */ + public ExampleCommand(Shooter subsystem) { + m_subsystem = subsystem; + // Use addRequirements() here to declare subsystem dependencies. + addRequirements(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() {} + + // 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/Climber b/src/main/java/frc/robot/subsystems/Climber new file mode 100644 index 0000000..6223463 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Climber @@ -0,0 +1,34 @@ +package frc.robot.subsystems; + +import com.ctre.phoenix6.controls.VoltageOut; +import com.ctre.phoenix6.hardware.TalonFX; +import com.revrobotics.spark.SparkMax; +import com.revrobotics.spark.SparkLowLevel.MotorType; + +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +public class Climber extends SubsystemBase { + + TalonFX motor_one, motor_two; + + public Climber() { + motor_one = new TalonFx(27, /*idk what type our motors are*/); + motor_two = new TalonFX(28, /*idk what type our motors are*/ ); + } + + public void grabUp(double volts) { + motor_one.set(volts); + motor_two.set(volts); + } + + public void afk(){ + motor_one.set(0.5); + motor_two.set(0.5) + } + + public void grabDown(double volts) { + motor_one.set(-volts); + motor_two.set(-volts); + } + +} \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/Elevator.java b/src/main/java/frc/robot/subsystems/Elevator.java new file mode 100644 index 0000000..7624832 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Elevator.java @@ -0,0 +1,101 @@ +package frc.robot.subsystems; + +import com.ctre.phoenix6.controls.VoltageOut; +import com.ctre.phoenix6.hardware.TalonFX; +import com.revrobotics.spark.SparkMax; +import com.revrobotics.spark.SparkLowLevel.MotorType; + +import edu.wpi.first.wpilibj.motorcontrol.Talon; +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +public class Elevator extends SubsystemBase { + TalonFx motor_one; + TalonFX motor_two; + + //max speed is .05 + +public Elevator(){ + //lmk if these below are errors on the team computer too because + //it might just be my computer being difficult again + motor_one; = new TalonFx(/*port*/); + motor_two; = new TalonFx(/*port*/); //side note (again ikr eyeroll) idk the ports but + //im pretty sure the ones we use are in the constants... + + motor_one.setPosition(0); + motor_one.set(.02); //you can change this value if its too slow + // i think... + motor_one.setPosition(0); + motor_two.set(.02); + +//most of the stuff is encoder values i believe bc setPosition is +//using rotations +} + //grab values from actual tests from riologs? + double l4value = motor_one.getPositon(); + //assuming levels are equidistant + public double l3val = .66*l4value; + public double l2val = .33*l4value; + public double l1val = 0.01; + + public void runMotors(double speed) { + motor_one.set(speed); + motor_two.set(-speed); + + } + +//making seperate methods for each level so perchance i can set +//one button per each thing +//joystick thing was perchance too ambitious + public void l4(){ + motor_one.setPositon(l4value); + motor_two.setPosition(-l4value); + //idk if this works for sure, if the + // motors work in opposite directions th + // en do they do to the same positon but + // just like the opposite? idk. + //gemini said yes 🥹 + + } + + public void l3(){ + motor_one.setPositon(l3value); + motor_two.setPosition(-l3value); + } + + public void l2(double l2value){ + motor_one.setPositon(l2value); + motor_two.setPosition(-l2value); + } + + + //i believe zeroeing out the position after each preset might + //make these work and im scared to see what would happen + //if you dont + + public void zeroout(){ + motor_one.setPosition(0); + motor_one.setPosition(0); + } //if this line has an error for you i genuinely dont know why + //girl bye this bracket is making me go insane + //the class ISN'T supposed to end liek dawg ik + //vscode make sense challenge go!t6y54rt + + + //my attempt with the joysticks 🫩✌️ + //the rest is in robot container where all the controls are + //just fry me already + + public void generalmove(velo){ + motor_one.setVotlage(velo); + } + //this error above is related to the one on line 77... 🫩 + //(insert speed gif) + + //also gonna make an "afk" thing that applies constant voltage to perchance + //keep the elevator at the target position like how we did witht eh climber wow + + public void afk(){ + if(motor_one.getPositon() < ) + } + +} \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/Funnel.java b/src/main/java/frc/robot/subsystems/Funnel.java new file mode 100644 index 0000000..1ca0eb1 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Funnel.java @@ -0,0 +1,32 @@ +package frc.robot.subsystems; + +import edu.wpi.first.wpilibj.Servo; +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +public class Funnel extends SubsystemBase { + + Servo motor_one, motor_two; + boolean on_off = false; + + public Funnel() { + motor_one = new Servo(1); + motor_two = new Servo(2); + } + + public void setBoth(double angle, double secondAngle) { + motor_one.setAngle(angle); + motor_two.setAngle(secondAngle); + } + + public void flip() { + if (on_off) { + motor_one.setAngle(180.0); + motor_two.setAngle(0); + } else { + motor_one.setAngle(0); + motor_two.setAngle(180.0); + } + on_off = !on_off; + } + +} \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/Intake.java b/src/main/java/frc/robot/subsystems/Intake.java index 49f84fa..06643be 100644 --- a/src/main/java/frc/robot/subsystems/Intake.java +++ b/src/main/java/frc/robot/subsystems/Intake.java @@ -1,32 +1,26 @@ package frc.robot.subsystems; -import com.ctre.phoenix6.controls.VoltageOut; -import com.ctre.phoenix6.hardware.TalonFX; -import com.revrobotics.spark.SparkMax; import com.revrobotics.spark.SparkLowLevel.MotorType; - +import com.revrobotics.spark.SparkMax; +import com.ctre.phoenix6.hardware.TalonFX; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.SubsystemBase; public class Intake extends SubsystemBase { - SparkMax motor_top, motor_bottom; + SparkMax first_motor, second_motor; + TalonFX wrist; - TalonFX motor_wrist; public Intake() { - motor_top = new SparkMax(27, MotorType.kBrushless); - motor_bottom = new SparkMax(28, MotorType.kBrushless); - motor_wrist = new TalonFX(13); - } - - public void runMotors(double speed) { - motor_top.set(speed); - motor_bottom.set(-speed); + first_motor = new SparkMax(1000, MotorType.kBrushless); + second_motor = new SparkMax(1000, MotorType.kBrushless); } - public void runWrist(double volts) { - motor_wrist.setControl(new VoltageOut(volts)); - + public void runMotors(double speed, double secSpeed) { + SmartDashboard.putNumber("shooter_speed", speed); + first_motor.set(speed); + second_motor.set(-speed); } -} +} \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/Shooter.java b/src/main/java/frc/robot/subsystems/Shooter.java new file mode 100644 index 0000000..0cac5aa --- /dev/null +++ b/src/main/java/frc/robot/subsystems/Shooter.java @@ -0,0 +1,22 @@ +package frc.robot.subsystems; + +import com.revrobotics.spark.SparkLowLevel.MotorType; +import com.revrobotics.spark.SparkMax; + +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +public class Shooter extends SubsystemBase { + + SparkMax shooter_motor; + + public Shooter() { + shooter_motor = new SparkMax(9, MotorType.kBrushless); + } + + public void runMotors(double speed) { + SmartDashboard.putNumber("shooter_speed", speed); + shooter_motor.set(speed); + } + +} diff --git a/src/main/java/frc/robot/subsystems/SwerveAcceleration.java b/src/main/java/frc/robot/subsystems/SwerveAcceleration.java new file mode 100644 index 0000000..1b9380f --- /dev/null +++ b/src/main/java/frc/robot/subsystems/SwerveAcceleration.java @@ -0,0 +1,13 @@ +import edu.wpi.first.math.kinematics.ChassisSpeeds; + +public class SwerveAcceleration extends SubsystemBase{ + public ChassisSpeeds limiter(ChassisSpeeds robotrel){ + ChassisSpeeds real = new ChassisSpeeds(); + if(robotrel.vxMetersPerSecond() > 5){ + real.setvxMetersPerSecond(xyM); + } + if(robotrel.vyMetersPerSecond() > ) + return real; + } + +} \ No newline at end of file diff --git a/src/main/java/frc/robot/subsystems/swerve.java b/src/main/java/frc/robot/subsystems/swerve.java new file mode 100644 index 0000000..69babef --- /dev/null +++ b/src/main/java/frc/robot/subsystems/swerve.java @@ -0,0 +1,13 @@ +import com.ctre.phoenix6.hardware.TalonFX; + +public class swerve{ + private TalonFX motorOne = new TalonFX(23); + private TalonFX motorTwo = new TalonFX(5); + private TaloxFX motorThree = new TalonFX(2); + private TalonFX motorFour = new TalonFX(7); + + + + + +}