Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

Commit d4f014f

Browse files
committed
intake assist manager inital code
1 parent 077e170 commit d4f014f

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/main/java/frc/robot/intake_assist/IntakeAssistManager.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package frc.robot.intake_assist;
22

3+
import dev.doglog.DogLog;
4+
import edu.wpi.first.math.geometry.Rotation2d;
5+
import edu.wpi.first.math.geometry.Translation2d;
6+
import edu.wpi.first.math.kinematics.ChassisSpeeds;
7+
import edu.wpi.first.networktables.NetworkTableInstance;
8+
import edu.wpi.first.wpilibj2.command.Command;
39
import frc.robot.imu.ImuSubsystem;
410
import frc.robot.localization.LocalizationSubsystem;
511
import frc.robot.swerve.SwerveSubsystem;
@@ -11,6 +17,8 @@ public class IntakeAssistManager extends LifecycleSubsystem {
1117
private final LocalizationSubsystem localization;
1218
private final SwerveSubsystem swerve;
1319
private final ImuSubsystem imu;
20+
private static final double MAX_ANGLE_CHANGE = -35.0;
21+
private static final double MIN_ANGLE_CHANGE = 35.0;
1422

1523
public IntakeAssistManager(
1624
LocalizationSubsystem localization, SwerveSubsystem swerve, ImuSubsystem imu) {
@@ -20,4 +28,28 @@ public IntakeAssistManager(
2028
this.swerve = swerve;
2129
this.imu = imu;
2230
}
31+
32+
33+
34+
public double getRobotRelativeAssistSpeeds(ChassisSpeeds fieldRelativeInputSpeeds ){
35+
36+
double tx = NetworkTableInstance.getDefault().getTable(LIMELIGHT_NAME).getEntry("tx").getDouble(0);
37+
38+
Rotation2d robotToNoteAngle = Rotation2d.fromDegrees(tx);
39+
40+
Rotation2d fieldRelativeNoteAngle = imu.getRobotHeading().plus(robotToNoteAngle);
41+
42+
Rotation2d driverRequest = fieldRelativeNoteAngle;
43+
44+
double angleError = imu.getRobotHeading().minus(driverRequest).getDegrees();
45+
46+
double angleChange = Math.max(MAX_ANGLE_CHANGE, Math.min(MIN_ANGLE_CHANGE, angleError * 0.2));
47+
48+
return angleChange;
49+
50+
51+
52+
}
53+
54+
2355
}

src/main/java/frc/robot/swerve/SwerveState.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ public enum SwerveState {
44
TELEOP,
55
TELEOP_SNAPS,
66
AUTO,
7-
AUTO_SNAPS;
7+
AUTO_SNAPS,
8+
INTAKE_ASSIST_TELEOP,
9+
INTAKE_ASSIST_AUTO;
810
}

0 commit comments

Comments
 (0)