Skip to content

Commit

Permalink
fixed errors from merge
Browse files Browse the repository at this point in the history
  • Loading branch information
GearBoxFox committed Feb 28, 2024
1 parent 9712d5a commit 74e28d9
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 24 deletions.
6 changes: 6 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ private ArmConstants() {}
new Translation2d(Units.inchesToMeters(9.27),
Units.inchesToMeters(12.56));

public static final Transform3d PIVOT_TRANSLATION_METERS =
new Transform3d(Units.inchesToMeters(9.27),
0.0,
Units.inchesToMeters(12.56),
new Rotation3d());

public static final double ARM_LENGTH_METERS = Units.inchesToMeters(22.01);
public static final double WRIST_LENGTH_METERS = Units.inchesToMeters(14.5);
}
Expand Down
39 changes: 20 additions & 19 deletions src/main/java/frc/robot/subsystems/arm/ArmSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.math.geometry.*;
import edu.wpi.first.math.util.Units;
import edu.wpi.first.wpilibj2.command.Command;

import edu.wpi.first.wpilibj2.command.SubsystemBase;
Expand Down Expand Up @@ -108,6 +109,7 @@ public void handleState() {
}
}

/** Gets the top point of the shooter for checking limits*/
public Translation2d calculateArmPosition(double armAngle, double wristAngle) {
return ArmConstants.PIVOT_JOINT_TRANSLATION
// translate the length + direction of the arm
Expand All @@ -119,8 +121,25 @@ public Translation2d calculateArmPosition(double armAngle, double wristAngle) {
.minus(Rotation2d.fromDegrees(wristAngle))));
}

public ArmSetpoints.ArmSetpoint aimbot(Pose2d robotPose) {
/** Gets the transformation of the shooter relative to the drive base */
public Transform3d getShooterTransformation() {
return Constants.ArmConstants.PIVOT_TRANSLATION_METERS.plus(
// Add the movement of the arm
GeomUtils.translationToTransform(new Translation3d(
ArmConstants.ARM_LENGTH_METERS,
new Rotation3d(0.0, Units.degreesToRadians(m_inputs.armPositionDegs), 0.0)
))
);
}

public double aimbotCalculate(Pose3d robotPose) {
Pose3d speakerPose = new Pose3d(AllianceFlipUtil.apply(FieldConstants.CENTER_SPEAKER), new Rotation3d());
Pose3d shooterPivotPose = robotPose.plus(getShooterTransformation());
Transform3d robotToSpeaker = new Transform3d(shooterPivotPose.plus(getShooterTransformation()), speakerPose);

double groundDistance =
Math.sqrt(Math.pow(robotToSpeaker.getX(), 2) + Math.pow(robotToSpeaker.getY(), 2));
return Math.atan2(groundDistance, robotToSpeaker.getZ());
}

/* Command Factories */
Expand Down Expand Up @@ -204,24 +223,6 @@ public Command setWristPowerFactory(double power) {
() -> m_io.setWristVoltage(0.0));
}

public Transform3d getShooterTransformation() {
return new Transform3d(new Pose3d(),
Constants.ArmConstants.PIVOT_TRANSLATION_METERS.plus(
GeomUtils.translationToTransform(new Translation3d(
Constants.ArmConstants.SHOULDER_BAR_LENGTH_METERS,
new Rotation3d(0.0, m_inputs.shoulderPositionRots * Math.PI * 2, 0.0)
))
));
}

public double calcShooterAngle(Pose3d robotPose) {
Pose3d speakerPose = new Pose3d(AllianceFlipUtil.apply(FieldConstants.CENTER_SPEAKER), new Rotation3d());
Pose3d shooterPivotPose = robotPose.plus(getShooterTransformation());
Transform3d robotToSpeaker = new Transform3d(shooterPivotPose.plus(getShooterTransformation()), speakerPose);

double groundDistance =
Math.sqrt(Math.pow(robotToSpeaker.getX(), 2) + Math.pow(robotToSpeaker.getY(), 2));
return Math.atan2(groundDistance, robotToSpeaker.getZ());
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public class DriveSubsystem extends SubsystemBase {

private final VisionSubsystem[] m_cameras;

public DriveSubsystem (
private final PIDController m_thetaPid;
private final PidProperty m_thetaPidProperty;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/subsystems/drive/GyroIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ public void setYawVelocityRadPerSec(double yawVelocityRadPerSec) {
}
}

default void updateInputs(GyroIOInputs inputs) {}
default void updateInputs(GyroIOInputsAutoLogged inputs) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public GyroIOPigeon1(int id) {
}

@Override
public void updateInputs(GyroIOInputs inputs) {
public void updateInputs(GyroIOInputsAutoLogged inputs) {
inputs.setConnected(m_pigeon.getState() == PigeonIMU.PigeonState.Ready);
inputs.setYawPosition(Rotation2d.fromDegrees(m_pigeon.getYaw()));
inputs.setYawVelocityRadPerSec((m_pigeon.getYaw() - prevYaw) / Units.millisecondsToSeconds(20));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public GyroIOPigeon2(boolean phoenixDrive) {
}

@Override
public void updateInputs(GyroIOInputs inputs) {
public void updateInputs(GyroIOInputsAutoLogged inputs) {
inputs.setConnected(BaseStatusSignal.refreshAll(yaw, yawVelocity).equals(StatusCode.OK));
inputs.setYawPosition(Rotation2d.fromDegrees(yaw.getValueAsDouble()));
inputs.setYawVelocityRadPerSec(Units.degreesToRadians(yawVelocity.getValueAsDouble()));
Expand Down
1 change: 0 additions & 1 deletion src/main/java/frc/robot/subsystems/shooter/ShooterIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ public void setTofDistanceIn(double tofDistanceIn) {
this.tofDistanceIn = tofDistanceIn;
}
}
}
default void setMotorVoltageTL(double voltage) {}
default void setMotorVoltageTR(double voltage) {}
default void setMotorVoltageBL(double voltage) {}
Expand Down

0 comments on commit 74e28d9

Please sign in to comment.