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

Commit c6ea8c0

Browse files
committed
created imu subystem
1 parent c82f451 commit c6ea8c0

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package frc.robot.imu;
2+
3+
public enum ImuState {
4+
DEFAULT_STATE;
5+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
}

0 commit comments

Comments
 (0)