-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIMUSubsystem.java
More file actions
61 lines (48 loc) · 1.47 KB
/
IMUSubsystem.java
File metadata and controls
61 lines (48 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package frc.robot.subsystems;
import edu.wpi.first.wpilibj.ADIS16470_IMU;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants;
import frc.robot.utils.SmartShuffleboard;
public class IMUSubsystem extends SubsystemBase {
/** Creates a new IMUSubststem. */
private ADIS16470_IMU gyro;
public IMUSubsystem() {
gyro = new ADIS16470_IMU();
}
// add @params Please do this before a competition or while the robot is
// perfectly still
public void resetGyro() {
gyro.reset();
gyro.calibrate();
}
public double getAccelY() {
return gyro.getAccelY();
}
public double getAccelX() {
return gyro.getAccelX();
}
public double getAccelZ() {
return gyro.getAccelZ();
}
public double getAngle() {
return gyro.getAngle();
}
public ADIS16470_IMU getGyro() {
return gyro;
}
public void name() {
}
@Override
public void periodic() {
// This method will be called once per scheduler run
if (Constants.ENABLE_DEBUG) {
SmartShuffleboard.put("Gyro", "Angle", getAngle());
SmartShuffleboard.put("Gyro", "Z accelerated angle", getAccelZ());
SmartShuffleboard.put("Gyro", "Y accelerated angle", getAccelY());
SmartShuffleboard.put("Gyro", "X accelerated angle", getAccelX());
}
}
}