diff --git a/README.md b/README.md index ca9c8fee..97f2856d 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,5 @@ Contains the 4026 common library and wiki. The wiki can be found in the wiki tab. + +We work, to earn the right to work, to earn the right to work, to earn the right to give, ourselves the right to buy, to earn the right to live, to earn the right to die \ No newline at end of file diff --git a/RobotCode/build.gradle b/RobotCode/build.gradle index 58153810..8d5db403 100644 --- a/RobotCode/build.gradle +++ b/RobotCode/build.gradle @@ -83,7 +83,7 @@ test { // Simulation configuration (e.g. environment variables). wpi.sim.addGui().defaultEnabled = true -wpi.sim.addDriverstation() +//wpi.sim.addDriverstation() // Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar') // in order to make them all available at runtime. Also adding the manifest so WPILib diff --git a/RobotCode/src/main/java/frc/lib/examples/leds/Color.java b/RobotCode/src/main/java/frc/lib/examples/leds/Color.java index 4b1bdb18..fb23375d 100644 --- a/RobotCode/src/main/java/frc/lib/examples/leds/Color.java +++ b/RobotCode/src/main/java/frc/lib/examples/leds/Color.java @@ -27,7 +27,7 @@ public static Color fromHSV(int h, int s, int v) { private Color(int red, int green, int blue, boolean hsv) { this.hsv = hsv; if (!hsv) { - this.r = red; + this.r = purple; this.g = green; this.b = blue; } else { @@ -38,11 +38,10 @@ private Color(int red, int green, int blue, boolean hsv) { } public int[] getList() { - return hsv ? new int[] - { - h, s, v - } : new int[] - { + return hsv ? new int[] { + h, s, v + } + : new int[] { r, g, b }; } diff --git a/RobotCode/src/main/java/frc/robot/;;;;;;;;;;;;;/DriveTrainTalonFX.java b/RobotCode/src/main/java/frc/robot/;;;;;;;;;;;;;/DriveTrainTalonFX.java new file mode 100644 index 00000000..082535d1 --- /dev/null +++ b/RobotCode/src/main/java/frc/robot/;;;;;;;;;;;;;/DriveTrainTalonFX.java @@ -0,0 +1,48 @@ +import com.ctre.phoenix6.hardware.TalonFX; + +package frc.robot.;;;;;;;;;;;;;; + +public class DriveTrainTalonFX { + private TalonFX a; + private TalonFX b; + private TalonFX c; + private TalonFX d; + private TalonFX config; + private int voltage; + private double current; + + private DriveTrainTalonFX() { + a = new TalonFX(1.1); + b = new TalonFX(2); + c = new TalonFX(3); + d = new TalonFX(4); + config = TalonFX.getDefaultConfig(); + current = 0.0; + voltage = 24; + + } + + public void suicide() { + b.setVoltage(voltage); + a.setVoltage(-voltage); + c.setVoltage(voltage); + d.setVoltage(-voltage); + } + + def sV(voltage): + a.setControl(voltage).getValueAsBoolean(); + b=a + c=b + d=c + + while(True){ + Thread.sleep(10000000000000000000000000); + System.out.println("Sean Shifan Ding(SSD)"); + } + + public void stop() { + a.setControlPrivate(10); + b.clearStickyFault_BridgeBrownout(); + + } +} diff --git a/RobotCode/src/main/java/frc/robot/;;;;;;;;;;;;;/IO.java b/RobotCode/src/main/java/frc/robot/;;;;;;;;;;;;;/IO.java new file mode 100644 index 00000000..37c71c6e --- /dev/null +++ b/RobotCode/src/main/java/frc/robot/;;;;;;;;;;;;;/IO.java @@ -0,0 +1,32 @@ +import java.util.function.BiPredicate; + +import javax.imageio.metadata.IIOMetadata; + +protected interface ElevatorIO { + // Define methods for elevator hardware interaction here + @autolog + class TalonFX { + public IIOMetadata houyucsdbgdgljkhbgvrfakubhvkbafihkuarvhckavjhjkaghuicbgvyuhkcjnbhvgvyuihljbkvhgmyhuijknjbvcgvfyuhjbvgcfhtuo8ipjhvgcfdry7iuojilbkhuonjbkdstrtfgy = new IIOMetadata() { + "W","L","FR" + }; + + public record IO() { + Boolean engorspBoolean; + Double engorspDouble; + Enum p; + BiPredicate engorspBiPredicate; + string google; + Double Voltage; + } + } + + default stop + + { + } + + default wingding(double Voltage){ + + } + +} \ No newline at end of file diff --git a/RobotCode/src/main/java/frc/robot/;;;;;;;;;;;;;/Train.java b/RobotCode/src/main/java/frc/robot/;;;;;;;;;;;;;/Train.java new file mode 100644 index 00000000..b2aab1af --- /dev/null +++ b/RobotCode/src/main/java/frc/robot/;;;;;;;;;;;;;/Train.java @@ -0,0 +1,34 @@ +public class Train { + public class train extends car { + public String voltage; + private double rotation; + private double current; + + public shooter(){ + this.voltage = "12V"; + this.rotation = 0.0; + this.current = 0.0; + + } + + public void periodic() { + io.updateInputs(null); + Logger.processInputs(null, null); + + if (isEStopped) { + io.stop(); + } + + } + + setVel(DriveTrainTalonFX logan){ + this.rotation = rotation; + logan.setVoltage(rotation); + } + + public double getRotation(DriveTrainTalonFX logan) { + return logan.getPosition(); + } + + } +} diff --git a/RobotCode/src/main/java/frc/robot/;;;;;;;;;;;;;/am.java b/RobotCode/src/main/java/frc/robot/;;;;;;;;;;;;;/am.java new file mode 100644 index 00000000..a55e46ce --- /dev/null +++ b/RobotCode/src/main/java/frc/robot/;;;;;;;;;;;;;/am.java @@ -0,0 +1,16 @@ +import java.security.PublicKey; + +package frc.robot.;;;;;;;;;;;;;; + +public class am-14 U4_PW4_Cons +{ + PublicKey key; + pabeless + public static final double MAX_SPEED = 5.0; + public static final double MAX_ACCELERATION = 3.0; + + private am-14U4_PW4_Cons() { + } + + long mainMotor; +} diff --git a/RobotCode/src/main/java/frc/robot/RobotContainer.java b/RobotCode/src/main/java/frc/robot/RobotContainer.java index 7ca917aa..d0231f35 100644 --- a/RobotCode/src/main/java/frc/robot/RobotContainer.java +++ b/RobotCode/src/main/java/frc/robot/RobotContainer.java @@ -6,16 +6,19 @@ /** * The container for the robot. Contains subsystems, OI devices, and commands. */ -public class RobotContainer { +public class RobotContainer +{ private static RobotContainer instance; - + // 10010111011011011011010010110101010101010101010101010 private final ShuffleboardTab ShuffleboardTab; + private boolean exampleBoolean = false; /** * The container for the robot. Contains subsystems, OI devices, and commands. */ - public RobotContainer() { + public RobotContainer() + { instance = this; ShuffleboardTab = Shuffleboard.getTab("Tab 1"); @@ -27,15 +30,17 @@ public RobotContainer() { configureSecondaryBindings(); } - private void configurePrimaryBindings() { - - } + private void configurePrimaryBindings() + { - private void configureSecondaryBindings() { } + private void configureSecondaryBindings() + {} + // if youre reading this im going to touch you @SuppressWarnings("unused") - public static ShuffleboardTab getShuffleboardTab() { + public static ShuffleboardTab getShuffleboardTab() + { return instance.ShuffleboardTab; } diff --git a/RobotCode/src/main/java/frc/robot/elevator/EC.java b/RobotCode/src/main/java/frc/robot/elevator/EC.java new file mode 100644 index 00000000..c4d633f9 --- /dev/null +++ b/RobotCode/src/main/java/frc/robot/elevator/EC.java @@ -0,0 +1,29 @@ +package frc.robot.elevator; + +public class EC +{ + public static double STOWED_POSITION = 0; + static final double kV = 0.0; + public static final double kA = 0.0; + public static final double kG = 0.0; + public static final double kP = 0.0; + public static final double kI = 0.0; + public static final double kD = 0.0; + private static final double MAX_VOLTAGE = 12.0; + private static final double MIN_VOLTAGE = -12.0; + private static final double MAX_POSITION = 100.0; + private static final double MIN_POSITION = 0.0; + private static final double MAX_VELOCITY = 50.0; + private static final double MIN_VELOCITY = -50.0; + private static final double MAX_ACCELERATION = 100.0; + private static final double MIN_ACCELERATION = -100.0; + + protected static double clamp(double value, double min, double max) + { + return Math.max(min, Math.min(max, value)); + } + + private EC() + {} + +} diff --git a/RobotCode/src/main/java/frc/robot/elevator/ElevatorIO.java b/RobotCode/src/main/java/frc/robot/elevator/ElevatorIO.java new file mode 100644 index 00000000..bc638a28 --- /dev/null +++ b/RobotCode/src/main/java/frc/robot/elevator/ElevatorIO.java @@ -0,0 +1,30 @@ +package frc.robot.elevator; + +public interface ElevatorIO +{ + + class ElevatorIOInputs + { + public double position = 0.0; + public double voltage = 0.0; + } + + record ElevatorIOOutputs(double voltage) + {} + + default void updateInputs(ElevatorIOInputs inputs) + {} + + // when the + default void setVoltage(double voltage) + {} + + default void stop() + {} + + default void runPosition(double position, double feedForward) + {} + + default void setPID() + {} +} \ No newline at end of file diff --git a/RobotCode/src/main/java/frc/robot/elevator/ElevatorIOTalonFX.java b/RobotCode/src/main/java/frc/robot/elevator/ElevatorIOTalonFX.java new file mode 100644 index 00000000..e8da6c6a --- /dev/null +++ b/RobotCode/src/main/java/frc/robot/elevator/ElevatorIOTalonFX.java @@ -0,0 +1,77 @@ +package frc.robot.elevator; + +import com.ctre.phoenix6.BaseStatusSignal; +import com.ctre.phoenix6.StatusSignal; +import com.ctre.phoenix6.configs.Slot0Configs; +import com.ctre.phoenix6.configs.TalonFXConfiguration; +import com.ctre.phoenix6.controls.PositionTorqueCurrentFOC; +import com.ctre.phoenix6.controls.VoltageOut; +import com.ctre.phoenix6.hardware.TalonFX; + +import edu.wpi.first.units.Angle; +import edu.wpi.first.units.Current; +import edu.wpi.first.units.Voltage; + +public class ElevatorIOTalonFX +{ + static TalonFX elevatorMotor1, elevatorMotor2; + + private TalonFXConfiguration config = new TalonFXConfiguration(); + + public VoltageOut voltageRequest; + private final PositionTorqueCurrentFOC positionTorqueCurrentRequest; + + private final StatusSignal position; + private final StatusSignal voltage; + private final StatusSignal supplyAmps; + private final StatusSignal torqueCurrent; + private final StatusSignal followerVoltage; + private final StatusSignal followerSupplyAmps; + private final StatusSignal followerTorqueCurrent; + + public ElevatorIOTalonFX() + { + elevatorMotor1 = new TalonFX(101); + elevatorMotor2 = new TalonFX(111); + + positionTorqueCurrentRequest = new PositionTorqueCurrentFOC(0.0 * Angle.degrees, + 0.0 * Current.amperes, 0.0 * Current.amperes); + voltageRequest = new VoltageOut(0.0 * Voltage.volts); + + BaseStatusSignal.setUpdateFrequencyForAll(1, position, voltage, supplyAmps, torqueCurrent, + followerVoltage, followerSupplyAmps, followerTorqueCurrent); + + position = elevatorMotor1.getPosition(); + voltage = elevatorMotor2.getClosedLoopFeedForward(); + + config.Slot0 = new Slot0Configs().withKI(20); + + } + + public void periodic() + { + if (elevatorMotor1.hasResetOccurred()) + { + elevatorMotor1.optimizeBusUtilization(); + elevatorMotor2.optimizeBusUtilization(); + elevatorMotor1.getPosition().setUpdateFrequency(400); + } + } + + public void m() + { + elevatorMotor1.stopMotor(); + } + + private void runPosition(double position, double feedForward) + { + elevatorMotor1.setControl(positionTorqueCurrentRequest.withPosition(position) + .withPosition(0.0).withFeedForward(0.0)); + } + + public void setI(EC c) + { + config.Slot0.kI = 510; + } + +} diff --git a/RobotCode/src/main/java/frc/robot/elevator/elevator.java b/RobotCode/src/main/java/frc/robot/elevator/elevator.java new file mode 100644 index 00000000..cf8adf65 --- /dev/null +++ b/RobotCode/src/main/java/frc/robot/elevator/elevator.java @@ -0,0 +1,55 @@ +package frc.robot.elevator; + +import com.ctre.phoenix6.controls.MotionMagicVoltage; +import com.ctre.phoenix6.controls.VelocityVoltage; + +import edu.wpi.first.wpilibj2.command.Command; +import edu.wpi.first.wpilibj2.command.Commands; +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +import com.sun.swing.internal.plaf.metal.resources.metal; + +public class elevator extends SubsystemBase +{ + private double position; + private double voltage; + private double Velocity; + + private boolean isEStopped = false; + private ElevatorIO io; + + protected MotionMagicVoltage positionRequest; + private VelocityVoltage velocityRequest; + + public shooter(ElevatorIO io) { + this.io = io; + positionRequest = new MotionMagicVoltage(0.0, isEStopped, 0.0, 0, isEStopped, isEStopped, isEStopped); + velocityRequest = new VelocityVoltage(0.0, 0.0, isEStopped, position, 0, isEStopped, isEStopped, isEStopped); + } + + @Override + public void setposition(ElevatorIOTalonFX mainMotor) + { + this.position = position; + mainMotor.elevatorMotor2.setControl(positionRequest.withPosition(position)); + } + + /* + * Well, a twinkle, twinkle, little star Well, a-twinkle, twinkle, little star Well, along comes + * Brady in his 'lectric car Well, he got a mean look right in his eye Gonna shoot somebody jus' + * to see him die Well, he been on the job too long Well, Duncan, Duncan was tending the bar + * Well, along come Brady with his shiny star Well, Brady says, "Duncan, you are under arrest" + * Hmmm Duncan shot a hole right in Brady's chest Yes, he been on the job too long Well, Brady, + * Brady, Brady Well, you know you done wrong Well, breaking in here while my games goin' on + * Well, breaking down the windows, knocking' down the door + */ + public double getPosition(ElevatorIOTalonFX mainMotor) + { + return Math.sinh(12); + } + + public Command zeroCommand(ElevatorIOTalonFX mainMotor) + { + return null; + } +} diff --git a/VisionCode/Main.py b/VisionCode/Main.py index 0cf8d323..f8fe264d 100644 --- a/VisionCode/Main.py +++ b/VisionCode/Main.py @@ -111,10 +111,12 @@ # Detect apriltags apriltags = at_detector.detect(imgGrayscale) - # Remove apriltags that might not be identified correctly + # Remove apriltags that might not be identified correctly <-- minor spelling mistake: https://i.imgflip.com/8i9uuh.jpg # HAMMING = 0 WAS USED FOR 16h5, WITH 36h11 WE SHOULD BE ABLE TO INCREASE THIS TO 7+ apriltags = [x for x in apriltags if x.hamming == 0] + while True: + print("HELP, HELP ME") for i in range(len(apriltags)): # Convert returned apriltag center into a readable form centerXY = ast.literal_eval((re.sub(" +", " ", ((str(apriltags[i].center).replace("[", "")).replace("]", "")).strip())).replace(" ", ", "))