-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoggingSystem.java
More file actions
61 lines (49 loc) · 1.98 KB
/
LoggingSystem.java
File metadata and controls
61 lines (49 loc) · 1.98 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.data;
import java.util.Dictionary;
import java.util.Map;
import com.ctre.phoenix6.SignalLogger;
import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.Subsystem;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Constants.LoggingConstants;
import frc.robot.subsystems.DriveSystem;
public class LoggingSystem extends SubsystemBase {
private Map<String,Subsystem> subsystemArray;
private boolean loggingState = LoggingConstants.DEFAULT_LOGGING_STATE;
private GenericEntry loggingChooser;
/** Creates a new LoggingSystem. */
public LoggingSystem(Map<String,Subsystem> subsystemArray) {
loggingChooser = Shuffleboard.getTab("Logging").add("Enable Logging", false).getEntry();
SmartDashboard.putBoolean("Logging Chooser", false);
this.subsystemArray = subsystemArray;
}
public boolean getLoggingState() {
return loggingState;
}
private boolean getLoggingFlag() {
// An example command will be run in autonomous
return loggingChooser.getBoolean(false); // TODO: Actually use this value
}
@Override
public void periodic() {
// This method will be called once per scheduler run
if (getLoggingFlag() != loggingState) {
loggingState = getLoggingFlag();
if (loggingState) {
SignalLogger.start();
// Log the odometry pose as a double array
} else {
SignalLogger.stop();
}
}
if (loggingState){
var pose = ((DriveSystem)subsystemArray.get(new String("Drive"))).getState().Pose;
var status = SignalLogger.writeDoubleArray("odometry", new double[] {pose.getX(), pose.getY(), pose.getRotation().getDegrees()});
}
}
}