Skip to content

Commit

Permalink
Merge pull request #478 from frc-862/473-faster-point
Browse files Browse the repository at this point in the history
[#473] - faster point at point
  • Loading branch information
MattD8957 authored Mar 22, 2024
2 parents c271468 + b8ee336 commit d6cf3dd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public class VisionConstants {
public static final Translation2d VISION_LIMIT = new Translation2d(Units.feetToMeters(9),
Units.feetToMeters(5));
public static final double ALIGNMENT_TOLERANCE = 8d; // TODO: make this an actual value
public static final PIDController TAG_AIM_CONTROLLER = new PIDController(0.1, 0, 0, 0.01);
public static final PIDController TAG_AIM_CONTROLLER = new PIDController(0.2, 0, 0, 0.01);
public static final PIDController CHASE_CONTROLLER = new PIDController(0.05, 0, 0);
public static final int TAG_PIPELINE = 0;
public static final int SPEAKER_PIPELINE = 1;
Expand Down
18 changes: 15 additions & 3 deletions src/main/java/frc/robot/command/PointAtPoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

public class PointAtPoint extends Command {

private static final double MIN_POWER = 0.3;
private double minPower = 0.3;

private Swerve drivetrain;
private XboxController driver;
Expand Down Expand Up @@ -104,6 +104,14 @@ public void initLogging() {
inToleranceLog = new BooleanLogEntry(log, "/PointAtPoint/InTolerance");
}


public void setDebugging(){
headingController.setP(LightningShuffleboard.getDouble("Point-At-Point", "P", headingController.getP()));
headingController.setI(LightningShuffleboard.getDouble("Point-At-Point", "I", headingController.getI()));
headingController.setD(LightningShuffleboard.getDouble("Point-At-Point", "D", headingController.getD()));
minPower = LightningShuffleboard.getDouble("Point-At-Point", "Min Power", minPower);
}

@Override
public void execute() {
Pose2d pose = drivetrain.getPose();
Expand All @@ -114,15 +122,19 @@ public void execute() {
targetHeading %= 360;
pidOutput = headingController.calculate((pose.getRotation().getDegrees() + 360) % 360, targetHeading);

if (!inTolerance() && Math.abs(pidOutput) < MIN_POWER) {
pidOutput = Math.signum(pidOutput) * MIN_POWER;
// setDebugging();

if (!inTolerance() && Math.abs(pidOutput) < minPower) {
pidOutput = Math.signum(pidOutput) * minPower;
}


drivetrain.setField(-driver.getLeftY(), -driver.getLeftX(), pidOutput);

LightningShuffleboard.setDouble("Point-At-Point", "Target Heading", targetHeading);
LightningShuffleboard.setDouble("Point-At-Point", "Current Heading",
drivetrain.getPose().getRotation().getDegrees());
LightningShuffleboard.setBool("Point-At-Point", "In Tolerance", inTolerance());

updateLogging();
}
Expand Down

0 comments on commit d6cf3dd

Please sign in to comment.