This repository was archived by the owner on Jan 10, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
src/main/java/frc/robot/imu Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ package frc .robot .imu ;
2
+
3
+ public enum ImuState {
4
+ DEFAULT_STATE ;
5
+ }
Original file line number Diff line number Diff line change
1
+ package frc .robot .imu ;
2
+
3
+ import com .ctre .phoenix6 .hardware .Pigeon2 ;
4
+
5
+ import dev .doglog .DogLog ;
6
+ import edu .wpi .first .math .geometry .Rotation2d ;
7
+ import frc .robot .util .scheduling .SubsystemPriority ;
8
+ import frc .robot .util .state_machines .StateMachine ;
9
+
10
+ public class ImuSubsystem extends StateMachine <ImuState > {
11
+ private final Pigeon2 imu ;
12
+ private Rotation2d robotHeading = new Rotation2d ();
13
+
14
+ public ImuSubsystem (Pigeon2 imu ) {
15
+ super (SubsystemPriority .IMU , ImuState .DEFAULT_STATE );
16
+ this .imu = imu ;
17
+ }
18
+
19
+ @ Override
20
+ protected void collectInputs () {
21
+ robotHeading = Rotation2d .fromDegrees (imu .getYaw ().getValue ());
22
+ }
23
+
24
+ public Rotation2d getRobotHeading () {
25
+ return robotHeading ;
26
+ }
27
+
28
+ @ Override
29
+ public void robotPeriodic () {
30
+ super .robotPeriodic ();
31
+ DogLog .log ("Imu/RobotHeading" , robotHeading .getDegrees ());
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments