Skip to content

Commit c838218

Browse files
authored
Merge pull request #82 from strykeforce/logging
Implement Comp Logging
2 parents 5b26157 + 5e0de03 commit c838218

File tree

7 files changed

+99
-10
lines changed

7 files changed

+99
-10
lines changed

src/main/java/frc/robot/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ public static class CompConstants {
719719
public static final double kWheelDiameterInches = 3.0 * (490 / 500.0);
720720

721721
// Elbow
722-
public static final int kElbowZeroTicks = 1155; // 730
722+
public static final int kElbowZeroTicks = 1160; // 730
723723

724724
// Shoulder
725725
public static final double kShoulderMainZeroTicks = 995;

src/main/java/frc/robot/Robot.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,21 @@
1616

1717
public class Robot extends TimedRobot {
1818
private AutoCommandInterface m_autonomousCommand;
19-
private static final Logger logger = LoggerFactory.getLogger(Robot.class);
19+
private static Logger logger;
2020

2121
private RobotContainer m_robotContainer;
2222
private boolean haveAlliance;
2323

2424
@Override
2525
public void robotInit() {
2626
m_robotContainer = new RobotContainer();
27+
logger = LoggerFactory.getLogger(Robot.class);
28+
logger.info(
29+
"Event: {}, Match Type: {}, Match #: {}, Replay #: {}",
30+
DriverStation.getEventName(),
31+
DriverStation.getMatchType(),
32+
DriverStation.getMatchNumber(),
33+
DriverStation.getReplayNumber());
2734
haveAlliance = false;
2835

2936
Shuffleboard.getTab("Match")

src/main/java/frc/robot/RobotContainer.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
package frc.robot;
66

7+
import ch.qos.logback.classic.util.ContextInitializer;
78
import edu.wpi.first.math.geometry.Rotation2d;
9+
import edu.wpi.first.wpilibj.DigitalInput;
810
import edu.wpi.first.wpilibj.DriverStation.Alliance;
911
import edu.wpi.first.wpilibj.Joystick;
1012
import edu.wpi.first.wpilibj.RobotController;
@@ -103,6 +105,14 @@ public class RobotContainer {
103105
private HandSubsystem handSubsystem;
104106

105107
public RobotContainer() {
108+
DigitalInput eventFlag = new DigitalInput(10);
109+
boolean isEvent = eventFlag.get();
110+
if (isEvent && Constants.isCompBot) {
111+
// must be set before the first call to LoggerFactory.getLogger();
112+
System.setProperty(ContextInitializer.CONFIG_FILE_PROPERTY, "logback-event.xml");
113+
System.out.println("Event Flag Removed - logging to file in ~lvuser/logs/");
114+
}
115+
106116
constants = new Constants();
107117
handSubsystem = new HandSubsystem(constants);
108118
intakeSubsystem = new IntakeSubsystem(constants);
@@ -145,14 +155,16 @@ public RobotContainer() {
145155
// FIX ME
146156
robotStateSubsystem.setAllianceColor(Alliance.Blue);
147157

148-
configureTelemetry();
149-
configurePaths();
158+
// configurePaths();
150159
configureDriverButtonBindings();
151160
configureOperatorButtonBindings();
152161
configureMatchDashboard();
153-
configurePitDashboard();
154-
new Trigger(RobotController::getUserButton)
155-
.onTrue(new HealthCheckCommand(driveSubsystem, intakeSubsystem));
162+
if (!isEvent) {
163+
configureTelemetry();
164+
configurePitDashboard();
165+
new Trigger(RobotController::getUserButton)
166+
.onTrue(new HealthCheckCommand(driveSubsystem, intakeSubsystem));
167+
}
156168
}
157169

158170
public void setAuto(boolean isAuto) {

src/main/java/frc/robot/commands/drive/DriveTeleopCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void execute() {
108108
* -DriveConstants.kMaxOmega
109109
* yawLimiter.calculate(
110110
MathUtil.applyDeadband(
111-
-joystick.getRawAxis(RobotContainer.Axis.RIGHT_Y.id),
111+
joystick.getRawAxis(RobotContainer.Axis.RIGHT_Y.id),
112112
DriveConstants.kDeadbandAllStick)));
113113
}
114114
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!-- Logback Configuration for charged up -->
2+
3+
<configuration>
4+
5+
<statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
6+
7+
<timestamp key="byMinute" datePattern="yyyyMMdd'T'HHmm"/>
8+
9+
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
10+
<file>/home/lvuser/logs/${byMinute}.log</file>
11+
<immediateFlush>true</immediateFlush>
12+
<encoder>
13+
<pattern>%date{mm:ss.SSS} [%thread] %-5level %logger{20} - %message %n</pattern>
14+
</encoder>
15+
</appender>
16+
17+
<logger name="org.strykeforce.thirdcoast" level="INFO"/>
18+
<logger name="org.eclipse.jetty" level="INFO"/>
19+
20+
<root level="INFO">
21+
<appender-ref ref="FILE"/>
22+
</root>
23+
24+
</configuration>

src/main/resources/logback.xml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!-- Logback Configuration for charged up -->
2+
3+
<configuration>
4+
5+
<statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
6+
7+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
8+
<encoder>
9+
<pattern>%date{mm:ss.SSS} [%thread] %highlight(%-5level) %logger{20} - %message %n</pattern>
10+
</encoder>
11+
</appender>
12+
13+
<logger name="org.strykeforce.thirdcoast" level="DEBUG"/>
14+
<logger name="org.eclipse.jetty" level="INFO"/>
15+
16+
<root level="verbose">
17+
<appender-ref ref="STDOUT"/>
18+
</root>
19+
20+
</configuration>
21+
22+
23+
<!-- Logback Configuration for charged up -->
24+
25+
<!-- <configuration>
26+
27+
<statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
28+
29+
<timestamp key="byMinute" datePattern="yyyyMMdd'T'HHmm"/>
30+
31+
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
32+
<file>/home/lvuser/logs/${byMinute}.log</file>
33+
<immediateFlush>true</immediateFlush>
34+
<encoder>
35+
<pattern>%date{mm:ss.SSS} [%thread] %-5level %logger{20} - %message %n</pattern>
36+
</encoder>
37+
</appender>
38+
39+
<logger name="org.strykeforce.thirdcoast" level="INFO"/>
40+
<logger name="org.eclipse.jetty" level="INFO"/>
41+
42+
<root level="INFO">
43+
<appender-ref ref="FILE"/>
44+
</root>
45+
46+
</configuration> -->

vendordeps/thirdcoast.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"fileName": "thirdcoast.json",
33
"name": "StrykeForce-ThirdCoast",
4-
"version": "23.1.3",
4+
"version": "23.2.0",
55
"uuid": "13c4f4b5-a1c0-4670-8f8d-b7b03628c0d3",
66
"mavenUrls": ["https://d1cfub2bqs98lp.cloudfront.net/repo"],
77
"jsonUrl": "http://maven.strykeforce.org/thirdcoast.json",
88
"javaDependencies": [
99
{
1010
"groupId": "org.strykeforce",
1111
"artifactId": "thirdcoast",
12-
"version": "23.1.3"
12+
"version": "23.2.0"
1313
}
1414
],
1515
"jniDependencies": [],

0 commit comments

Comments
 (0)