Skip to content

Commit

Permalink
Cancoder ports fixed, now fixing pid constants
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepBlueRobots committed Oct 16, 2024
1 parent ebef462 commit 20d4180
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
27 changes: 14 additions & 13 deletions src/main/java/org/carlmontrobotics/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ public static final class Effectorc {
public static final double[] kS = { /* /Intake/ */0.22, /* /Outake/ */0.29753 * 2 };
public static final double[] kV = {0.122, 0.11124};
public static final double[] kA = {0, 0.039757};
public static final int INTAKE_PORT = 9; // port
public static final int OUTTAKE_PORT = 10; // port
public static final int INTAKE_DISTANCE_SENSOR_PORT = 11; // port
public static final int OUTAKE_DISTANCE_SENSOR_PORT = 10; // port
public static final int INTAKE_PORT = 50; // ports
public static final int OUTTAKE_PORT = 51; // port
public static final int INTAKE_DISTANCE_SENSOR_PORT = 52; // port
public static final int OUTAKE_DISTANCE_SENSOR_PORT = 53; // port
public static final double DISTANCE_BETWEEN_SENSORS_INCHES = 8.189; // inches
public static final double OFFSET_FROM_GROUND_INCHES = 21; // in
public static final double DS_DEPTH_INCHES = 9.97; // Distance sensor Depth
Expand Down Expand Up @@ -110,8 +110,8 @@ public static final class Armc {

// Motor port
public static final int ARM_MOTOR_PORT_MASTER =
CONFIG.isSwimShady() ? 20 : 13;
public final static int ARM_MOTOR_PORT_FOLLOWER = 18;
CONFIG.isSwimShady() ? 55 : 13;
public final static int ARM_MOTOR_PORT_FOLLOWER = 60;
// Config for motors
public static final boolean MOTOR_INVERTED_MASTER = false;
public static final boolean MOTOR_INVERTED_FOLLOWER = true; // verifyed by design AND physical testing
Expand Down Expand Up @@ -253,7 +253,7 @@ public static final class Drivetrainc {
// kP, kI, and kD constants for turn motor controllers in the order of
// front-left, front-right, back-left, back-right.
// Determine correct turn PID constants
public static final double[] turnkP = { 51.078, 60.885, 60.946, 60.986 }; // {0.00374, 0.00374, 0.00374,
public static final double[] turnkP = { 0.00374, 0.00374, 0.00374, 0.00374 }; // {0.00374, 0.00374, 0.00374,
// 0.00374};
public static final double[] turnkI = { 0, 0, 0, 0 };
public static final double[] turnkD = { 0/* dont edit */, 0.5, 0.42, 1 }; // todo: use d
Expand All @@ -263,8 +263,9 @@ public static final class Drivetrainc {
// V = kS + kV * v + kA * a
// 12 = 0.2 + 0.00463 * v
// v = (12 - 0.2) / 0.00463 = 2548.596 degrees/s
public static final double[] turnkV = { 2.6532, 2.7597, 2.7445, 2.7698 };
public static final double[] turnkA = { 0.17924, 0.17924, 0.17924, 0.17924 };
// public static final double[] turnkV = { 2.6532, 2.7597, 2.7445, 2.7698 };
public static final double[] turnkV = { 0.00463, 0.00463, 0.00463, 0.00463 }; // swimshady
public static final double[] turnkA = { 0.000115, 0.000115, 0.000115, 0.000115 }; // swimshady

// kP is an average of the forward and backward kP values
// Forward: 1.72, 1.71, 1.92, 1.94
Expand Down Expand Up @@ -327,10 +328,10 @@ public static final class Drivetrainc {
public static final int turnBackLeftPort = CONFIG.isSwimShady() ? 20 : 15; //
public static final int turnBackRightPort = CONFIG.isSwimShady() ? 2 : 16; // correct

public static final int canCoderPortFL = CONFIG.isSwimShady() ? 4 : 0;
public static final int canCoderPortFR = CONFIG.isSwimShady() ? 2 : 3;
public static final int canCoderPortBL = CONFIG.isSwimShady() ? 3 : 2;
public static final int canCoderPortBR = CONFIG.isSwimShady() ? 1 : 1;
public static final int canCoderPortFL = CONFIG.isSwimShady() ? 1 : 0;
public static final int canCoderPortFR = CONFIG.isSwimShady() ? 3 : 3;
public static final int canCoderPortBL = CONFIG.isSwimShady() ? 2 : 2;
public static final int canCoderPortBR = CONFIG.isSwimShady() ? 4 : 1;

// #endregion

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/carlmontrobotics/subsystems/Arm.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public class Arm extends SubsystemBase {
private final CANSparkMax armMotorMaster/* left */ = MotorControllerFactory
.createSparkMax(ARM_MOTOR_PORT_MASTER, MotorConfig.NEO);
private final CANSparkMax armMotorFollower/* right */ =
MotorControllerFactory.createSparkMax(ARM_MOTOR_PORT_FOLLOWER,
MotorConfig.NEO);
MotorControllerFactory.createSparkMax(ARM_MOTOR_PORT_FOLLOWER// ARM_MOTOR_PORT_FOLLOWER,
, MotorConfig.NEO);
private final SparkAbsoluteEncoder armMasterEncoder = armMotorMaster
.getAbsoluteEncoder(SparkAbsoluteEncoder.Type.kDutyCycle);

Expand Down
18 changes: 14 additions & 4 deletions src/main/java/org/carlmontrobotics/subsystems/Drivetrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,20 @@ public void periodic() {
// SmartDashboard.putNumber("Gyro Compass Heading", gyro.getCompassHeading());
// SmartDashboard.putNumber("Compass Offset", compassOffset);
// SmartDashboard.putBoolean("Current Magnetic Field Disturbance", gyro.isMagneticDisturbance());
// SmartDashboard.putNumber("front left encoder", moduleFL.getModuleAngle());
// SmartDashboard.putNumber("front right encoder", moduleFR.getModuleAngle());
// SmartDashboard.putNumber("back left encoder", moduleBL.getModuleAngle());
// SmartDashboard.putNumber("back right encoder", moduleBR.getModuleAngle());
SmartDashboard.putNumber("front turn left encoder", moduleFL.getModuleAngle());
SmartDashboard.putNumber("front turn right encoder", moduleFR.getModuleAngle());
SmartDashboard.putNumber("back turn left encoder", moduleBL.getModuleAngle());
SmartDashboard.putNumber("back turn right encoder", moduleBR.getModuleAngle());

// SmartDashboard.putNumber("front drive left encoder",
// moduleFL.getModuleAngle());
// SmartDashboard.putNumber("front drive right encoder",
// moduleFR.getModuleAngle());
// SmartDashboard.putNumber("back drive left encoder",
// moduleBL.getModuleAngle());
// SmartDashboard.putNumber("back drive right encoder",
// moduleBR.getModuleAngle());

}

@Override
Expand Down

0 comments on commit 20d4180

Please sign in to comment.