Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
ughhhh
Browse files Browse the repository at this point in the history
  • Loading branch information
carokhan committed Oct 9, 2024
1 parent b44357c commit 133b660
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 131 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
},
],
"java.test.defaultConfig": "WPIlibUnitTests",
"java.compile.nullAnalysis.mode": "automatic"
"java.compile.nullAnalysis.mode": "automatic",
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx2G -Xms100m -Xlog:disable"
}
12 changes: 6 additions & 6 deletions src/main/java/frc/robot/BuildConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ public final class BuildConstants {
public static final String MAVEN_GROUP = "";
public static final String MAVEN_NAME = "Forte-2-5";
public static final String VERSION = "unspecified";
public static final int GIT_REVISION = 52;
public static final String GIT_SHA = "aa2e0ff40789b4657d9d2f3ae29e4d086df768a5";
public static final String GIT_DATE = "2024-10-08 14:50:47 EDT";
public static final String GIT_BRANCH = "pivot-revamp";
public static final String BUILD_DATE = "2024-10-08 19:16:55 EDT";
public static final long BUILD_UNIX_TIME = 1728429415040L;
public static final int GIT_REVISION = 53;
public static final String GIT_SHA = "b44357c75fc5d008c8de9056a477ce15fae23851";
public static final String GIT_DATE = "2024-10-08 19:18:00 EDT";
public static final String GIT_BRANCH = "pivot2";
public static final String BUILD_DATE = "2024-10-09 19:20:41 EDT";
public static final long BUILD_UNIX_TIME = 1728516041419L;
public static final int DIRTY = 1;

private BuildConstants(){}
Expand Down
25 changes: 10 additions & 15 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
public final class Constants {
public static final double loopPeriodSecs = 0.02;

public static final double LOOP_TIME = 0.13;
public static final double ROBOT_MASS = 49.8951607;


public static final Mode currentMode = Mode.REAL;
public static final Mode currentMode = Mode.SIM;

public static enum Mode {
/** Running on a real robot. */
Expand Down Expand Up @@ -263,13 +259,12 @@ public static class FeederConstants {

public static class ShooterConstants {
public static final double pivotRatio = 496 / 3;
public static final double pivotLength = Units.inchesToMeters(7.01793315);
public static final double pivotMass = Units.lbsToKilograms(20.655);
// public static final double pivotMOI = SingleJointedArmSim.estimateMOI(pivotLength, pivotMass);
public static final double pivotMOI = .0001;

public static final double pivotLength = Units.inchesToMeters(7.5);
public static final double pivotMass = Units.lbsToKilograms(23);
public static final double pivotMOI = SingleJointedArmSim.estimateMOI(pivotLength, pivotMass);
// public static final double pivotMOI = .0001;

public static final double maxPivotVelocity = 10.5819313;
public static final double maxPivotVelocity = 20;
public static final double maxPivotAccel = 5;

public static final double pivotAbsConversion = Math.PI * 2.0;
Expand All @@ -285,9 +280,9 @@ public static class ShooterConstants {

public static final int pivotCurrentLimit = 25;

public static final double kGPivot = 0.0;
public static final double kVPivot = 0.0;
public static final double kAPivot = 0.0;
public static final double kGPivot = 0.381640625;
public static final double kVPivot = 0.875;
public static final double kAPivot = 0.00;

public static final double kVShooter = 0.0055;
public static final double kAShooter = 0.00;
Expand All @@ -296,7 +291,7 @@ public static class ShooterConstants {
public static final double kIShooterReal = 0.00000;
public static final double kSShooterReal = 0;

public static final double kPPivot = .75;
public static final double kPPivot = 5.0;

public static final double kPShooterSim = 0.5;
public static final double kIShooterSim = 0.0;
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
import frc.robot.subsystems.intake.IntakeIOReplay;
import frc.robot.subsystems.intake.IntakeIOSim;
import frc.robot.subsystems.intake.IntakeIOSparkMax;
import frc.robot.subsystems.pivot.Pivot;
import frc.robot.subsystems.pivot.PivotIOReplay;
import frc.robot.subsystems.pivot.PivotIOSim;
import frc.robot.subsystems.pivot.PivotIOSparkMax;
import frc.robot.subsystems.pivot2.Pivot;
import frc.robot.subsystems.pivot2.PivotIOReplay;
import frc.robot.subsystems.pivot2.PivotIOSim;
import frc.robot.subsystems.pivot2.PivotIOSparkMax;
import frc.robot.subsystems.shooter.Shooter;
import frc.robot.subsystems.shooter.ShooterIOReplay;
import frc.robot.subsystems.shooter.ShooterIOSim;
Expand Down Expand Up @@ -218,9 +218,9 @@ private void configureButtonBindings() {
)
);

m_operator.rightBumper().whileTrue(
m_pivot.runCurrentZeroing()
);
// m_operator.rightBumper().whileTrue(
// m_pivot.runCurrentZeroing()
// );



Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/Visualizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import frc.robot.Constants.ShooterConstants;
import frc.robot.subsystems.climber.Climb;
import frc.robot.subsystems.intake.Intake;
import frc.robot.subsystems.pivot.Pivot;
import frc.robot.subsystems.pivot2.Pivot;

public class Visualizer extends SubsystemBase {
private Mechanism2d m_main;
Expand Down
92 changes: 0 additions & 92 deletions src/main/java/frc/robot/subsystems/pivot/Pivot.java

This file was deleted.

82 changes: 82 additions & 0 deletions src/main/java/frc/robot/subsystems/pivot2/Pivot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// 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.subsystems.pivot2;

import java.util.function.DoubleSupplier;
import org.littletonrobotics.junction.Logger;

import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.controller.ArmFeedforward;
import edu.wpi.first.math.controller.PIDController;
import edu.wpi.first.math.controller.ProfiledPIDController;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.trajectory.TrapezoidProfile;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.PIDCommand;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants;
import frc.robot.Constants.ShooterConstants;
import frc.util.LoggedTunableNumber;

/** Add your docs here. */
public class Pivot extends SubsystemBase {
public PivotIO io;
public PivotIOInputsAutoLogged inputs = new PivotIOInputsAutoLogged();

private ArmFeedforward pivotFF = new ArmFeedforward(0.0, ShooterConstants.kGPivot, ShooterConstants.kVPivot,
ShooterConstants.kAPivot);
private ProfiledPIDController pivotPID = new ProfiledPIDController(0.0, 0.0, 0.0,
new TrapezoidProfile.Constraints(ShooterConstants.maxPivotVelocity, ShooterConstants.maxPivotAccel));
private LoggedTunableNumber kPPivot = new LoggedTunableNumber("Shooter/kPPivot", ShooterConstants.kPPivot);

public Pivot(PivotIO io) {
this.io = io;

kPPivot.initDefault(ShooterConstants.kPPivot);
pivotPID.enableContinuousInput(0, Math.PI * 2);
pivotPID.setTolerance(ShooterConstants.pivotTolerance);
pivotPID.setP(kPPivot.getAsDouble());
}

public void periodic() {
io.processInputs(inputs);
Logger.processInputs("Shooter/Pivot", inputs);
}

public Command setPivotTarget(DoubleSupplier radians) {
return this.run(() -> {
double volts = pivotPID.calculate(inputs.pivotPosition.getRadians(), radians.getAsDouble())
+ pivotFF.calculate(pivotPID.getSetpoint().position,
pivotPID.getSetpoint().velocity)
;
io.setPivotVoltage(volts);
inputs.pivotAppliedVolts = volts;
inputs.pivotTargetPosition = Rotation2d.fromRadians(radians.getAsDouble());

});
}

public Command setPivotVoltage(DoubleSupplier volts) {
return this.run(
() -> {
io.setPivotVoltage(volts.getAsDouble());
});
}

public double getAngleRadians() {
return inputs.pivotPosition.getRadians() + ShooterConstants.simOffset;
}

public double getTargetRadians() {
return inputs.pivotTargetPosition.getRadians() + ShooterConstants.simOffset;
}

public Command resetEncoder() {
return this.run(
() -> {
io.resetEncoder();
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// 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.subsystems.pivot;
package frc.robot.subsystems.pivot2;

import org.littletonrobotics.junction.AutoLog;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// 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.subsystems.pivot;
package frc.robot.subsystems.pivot2;

import edu.wpi.first.math.controller.ArmFeedforward;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.subsystems.pivot;
package frc.robot.subsystems.pivot2;

import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.controller.ArmFeedforward;
Expand All @@ -13,7 +13,7 @@
import frc.robot.Constants.ShooterConstants;

public class PivotIOSim implements PivotIO {
private SingleJointedArmSim pivotSim = new SingleJointedArmSim(DCMotor.getNEO(1), ShooterConstants.pivotRatio, ShooterConstants.pivotMOI, Units.inchesToMeters(ShooterConstants.pivotLength), ShooterConstants.down, ShooterConstants.up, true, ShooterConstants.down);
private SingleJointedArmSim pivotSim = new SingleJointedArmSim(DCMotor.getNEO(1), ShooterConstants.pivotRatio, ShooterConstants.pivotMOI, ShooterConstants.pivotLength, ShooterConstants.down, ShooterConstants.up, true, ShooterConstants.down);

@Override
public void processInputs(PivotIOInputsAutoLogged inputs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// 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.subsystems.pivot;
package frc.robot.subsystems.pivot2;

import com.revrobotics.CANSparkLowLevel.MotorType;
import com.revrobotics.CANSparkMax;
Expand Down Expand Up @@ -30,8 +30,8 @@ public PivotIOSparkMax() {
pivotAbs = new ThroughboreEncoder(pivot.getAbsoluteEncoder(), pivot.getAbsoluteEncoder().getPosition());

pivot.setSmartCurrentLimit(ShooterConstants.pivotCurrentLimit);

pivot.setIdleMode(IdleMode.kCoast);

pivotAbs.abs.setInverted(true);
pivot.setInverted(true);
pivotAbs.abs.setPositionConversionFactor(ShooterConstants.pivotAbsConversion);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.subsystems.pivot;
package frc.robot.subsystems.pivot2;

import com.revrobotics.SparkAbsoluteEncoder;

Expand All @@ -12,10 +12,10 @@ public ThroughboreEncoder(SparkAbsoluteEncoder absoluteEncoder, double absOffset
}

public double getPosition() {
return (abs.getPosition() - offset) % (2 * Math.PI) + ((abs.getPosition() + offset) < 0 ? 2 * Math.PI : 0);
return (abs.getPosition() + offset) % (2 * Math.PI);
}

public void setOffset(double absOffset) {
public void setOffset(double absOffset) {
offset = absOffset;
}

Expand Down

0 comments on commit 133b660

Please sign in to comment.