1
1
package frc .robot .intake_assist ;
2
2
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 ;
3
9
import frc .robot .imu .ImuSubsystem ;
4
10
import frc .robot .localization .LocalizationSubsystem ;
5
11
import frc .robot .swerve .SwerveSubsystem ;
@@ -11,6 +17,8 @@ public class IntakeAssistManager extends LifecycleSubsystem {
11
17
private final LocalizationSubsystem localization ;
12
18
private final SwerveSubsystem swerve ;
13
19
private final ImuSubsystem imu ;
20
+ private static final double MAX_ANGLE_CHANGE = -35.0 ;
21
+ private static final double MIN_ANGLE_CHANGE = 35.0 ;
14
22
15
23
public IntakeAssistManager (
16
24
LocalizationSubsystem localization , SwerveSubsystem swerve , ImuSubsystem imu ) {
@@ -20,4 +28,28 @@ public IntakeAssistManager(
20
28
this .swerve = swerve ;
21
29
this .imu = imu ;
22
30
}
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
+
23
55
}
0 commit comments