-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into intake-subsystem
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package frc.robot.imu; | ||
|
||
public enum ImuState { | ||
DEFAULT_STATE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package frc.robot.imu; | ||
|
||
import com.ctre.phoenix6.hardware.Pigeon2; | ||
|
||
import dev.doglog.DogLog; | ||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import frc.robot.util.scheduling.SubsystemPriority; | ||
import frc.robot.util.state_machines.StateMachine; | ||
|
||
public class ImuSubsystem extends StateMachine<ImuState> { | ||
private final Pigeon2 imu; | ||
private Rotation2d robotHeading = new Rotation2d(); | ||
|
||
public ImuSubsystem(Pigeon2 imu) { | ||
super(SubsystemPriority.IMU, ImuState.DEFAULT_STATE); | ||
this.imu = imu; | ||
} | ||
|
||
@Override | ||
protected void collectInputs() { | ||
robotHeading = Rotation2d.fromDegrees(imu.getYaw().getValue()); | ||
} | ||
|
||
public Rotation2d getRobotHeading() { | ||
return robotHeading; | ||
} | ||
|
||
@Override | ||
public void robotPeriodic() { | ||
super.robotPeriodic(); | ||
DogLog.log("Imu/RobotHeading", robotHeading.getDegrees()); | ||
} | ||
} |