Skip to content

Commit f5fb16c

Browse files
authored
Changes for INWLA (#21)
1 parent d0c61d8 commit f5fb16c

21 files changed

+1089
-231
lines changed

build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ dependencies {
8080

8181
implementation "com.github.Oblarg:Oblog:5.1.0"
8282

83+
implementation 'org.tinylog:tinylog-api:2.6.1'
84+
implementation 'org.tinylog:tinylog-impl:2.6.1'
85+
8386
}
8487

8588
test {

simgui.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"autoFit": true
6363
}
6464
],
65-
"height": 521,
65+
"height": 424,
6666
"series": [
6767
{
6868
"color": [

src/main/java/org/pikerobodevils/frc2023/Constants.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public static class IntakeConstants {
115115

116116
public static final double HOLD_CUBE_SPEED = -0.05;
117117

118-
public static final double SHOOT_CUBE_SPEED = .75;
118+
public static final double DEFAULT_OUTTAKE = .75;
119119
public static final double INTAKE_STALL_DETECTION = 15; // Amps
120120
}
121121

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* Copyright 2023 Pike RoboDevils, FRC Team 1018
2+
* Use of this source code is governed by an MIT-style
3+
* license that can be found in the LICENSE.md file or
4+
* at https://opensource.org/licenses/MIT. */
5+
6+
package org.pikerobodevils.frc2023;
7+
8+
import edu.wpi.first.wpilibj2.command.CommandScheduler;
9+
import org.tinylog.Logger;
10+
import org.tinylog.configuration.Configuration;
11+
12+
public class LogConfig {
13+
private static final String format =
14+
"{date:yyyy-MM-dd HH:mm:ss} - [{tag: none}] - {level}: {message}";
15+
16+
private static final String consoleLevel = "debug";
17+
18+
private static final String dataLogLevel = "trace";
19+
20+
private static final String dataLogEntryKey = "messages";
21+
22+
public static void config() {
23+
Configuration.set("writer1", "org.pikerobodevils.lib.logging.DataLogWriter");
24+
Configuration.set("writer1.level", dataLogLevel);
25+
Configuration.set("writer1.format", format);
26+
27+
Configuration.set("writer2", "org.pikerobodevils.lib.logging.DsConsoleWriter");
28+
Configuration.set("writer2.level", consoleLevel);
29+
Configuration.set("writer2.format", format);
30+
Configuration.set("writer2.entryKey", dataLogEntryKey);
31+
32+
CommandScheduler.getInstance()
33+
.onCommandFinish(
34+
(cmd) -> Logger.tag("Scheduler").trace("Finish Command: {}", cmd.getName()));
35+
CommandScheduler.getInstance()
36+
.onCommandInitialize(
37+
(cmd) -> Logger.tag("Scheduler").trace("Initialize Command: {}", cmd.getName()));
38+
CommandScheduler.getInstance()
39+
.onCommandInterrupt(
40+
(cmd) -> Logger.tag("Scheduler").trace("Interrupted Command: {}", cmd.getName()));
41+
}
42+
}

src/main/java/org/pikerobodevils/frc2023/Robot.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
import edu.wpi.first.wpilibj2.command.Command;
1212
import edu.wpi.first.wpilibj2.command.CommandScheduler;
1313
import io.github.oblarg.oblog.Logger;
14-
import org.pikerobodevils.lib.DataLogUtils;
14+
import org.pikerobodevils.lib.LogUtils;
15+
import org.pikerobodevils.lib.vendor.SparkMax;
1516

1617
public class Robot extends TimedRobot {
1718
private Command m_autonomousCommand;
@@ -26,16 +27,18 @@ public void robotInit() {
2627
DataLogManager.start(Constants.SIM_LOG_DIR);
2728
}
2829
DriverStation.startDataLog(DataLogManager.getLog());
30+
LogConfig.config();
2931

3032
SmartDashboard.putData(CommandScheduler.getInstance());
31-
m_robotContainer = new RobotContainer();
3233

3334
if (isSimulation()) {
3435
DriverStation.silenceJoystickConnectionWarning(true);
3536
}
3637

37-
DataLogUtils.logManifestMetadata(this);
38-
DataLogUtils.logSoftwareVersionMetadata();
38+
LogUtils.logSoftwareVersionMetadata();
39+
LogUtils.logManifestMetadata(this);
40+
m_robotContainer = new RobotContainer();
41+
SparkMax.burnFlashInSync();
3942
}
4043

4144
@Override

src/main/java/org/pikerobodevils/frc2023/RobotContainer.java

+14-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import edu.wpi.first.wpilibj2.command.Commands;
1616
import io.github.oblarg.oblog.Logger;
1717
import org.pikerobodevils.frc2023.commands.Autos;
18-
import org.pikerobodevils.frc2023.commands.Superstructure;
1918
import org.pikerobodevils.frc2023.simulation.ArmSim;
2019
import org.pikerobodevils.frc2023.subsystems.*;
2120

@@ -56,10 +55,15 @@ public RobotContainer() {
5655

5756
autoChooser.setDefaultOption("No auto", Commands.none());
5857
autoChooser.addOption("Drive Back", autos.driveBackAuto());
59-
autoChooser.addOption("Mid cube drive back", autos.scoreMidCubeDriveBack());
58+
autoChooser.addOption("Score low cube only", autos.scoreLowCube());
6059
autoChooser.addOption("Score mid cube only", autos.scoreMidCube());
61-
autoChooser.addOption("Score high cube", autos.scoreHighCube());
62-
autoChooser.addOption("Score high cube then drive", autos.scoreHighCubeDriveBack());
60+
autoChooser.addOption("Score high cube only", autos.scoreHighCube());
61+
autoChooser.addOption("Low cube drive back", autos.scoreLowCubeDriveBack());
62+
autoChooser.addOption("Mid cube drive back", autos.scoreMidCubeDriveBack());
63+
autoChooser.addOption("High cube drive back", autos.scoreHighCubeDriveBack());
64+
autoChooser.addOption("Low cube balance", autos.scoreLowThenBalance());
65+
autoChooser.addOption("Mid cube balance", autos.scoreMidThenBalance());
66+
autoChooser.addOption("High cube balance", autos.scoreHighThenBalance());
6367
autoChooser.addOption("Auto Balance Forwards", autos.autoBalanceForwards());
6468
autoChooser.addOption("Auto Balance Backwards", autos.autoBalanceBackwards());
6569

@@ -70,13 +74,11 @@ private void configureBindings() {
7074
controlboard
7175
.operator
7276
.x()
73-
.onTrue(
74-
Commands.runOnce(() -> superstructure.setCurrentState(Superstructure.GamePiece.Cube)));
77+
.onTrue(Commands.runOnce(() -> superstructure.setGamePiece(Superstructure.GamePiece.Cube)));
7578
controlboard
7679
.operator
7780
.y()
78-
.onTrue(
79-
Commands.runOnce(() -> superstructure.setCurrentState(Superstructure.GamePiece.Cone)));
81+
.onTrue(Commands.runOnce(() -> superstructure.setGamePiece(Superstructure.GamePiece.Cone)));
8082

8183
controlboard.operator.leftTrigger().whileTrue(superstructure.runIntake());
8284

@@ -87,6 +89,10 @@ private void configureBindings() {
8789
.operator
8890
.axisGreaterThan(XboxController.Axis.kLeftY.value, .5)
8991
.onTrue(superstructure.floorPickupCube());
92+
controlboard
93+
.operator
94+
.axisLessThan(XboxController.Axis.kLeftY.value, -.5)
95+
.onTrue(superstructure.setStateCommand(Superstructure.SuperstructureState.CUBE_SHOOT));
9096

9197
controlboard.operator.a().onTrue(superstructure.stowCommand());
9298

src/main/java/org/pikerobodevils/frc2023/commands/Autos.java

+33-9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import edu.wpi.first.wpilibj2.command.CommandBase;
1010
import edu.wpi.first.wpilibj2.command.Commands;
1111
import org.pikerobodevils.frc2023.subsystems.Drivetrain;
12+
import org.pikerobodevils.frc2023.subsystems.Superstructure;
1213

1314
public final class Autos {
1415
Drivetrain drivetrain;
@@ -20,11 +21,21 @@ public Autos(Drivetrain drivetrain, Superstructure superstructure) {
2021
}
2122

2223
public CommandBase driveBackAuto() {
23-
return drivetrain.setLeftRightVoltageCommand(-3, -3).withTimeout(3.5);
24+
return drivetrain.setLeftRightVoltageCommand(-3, -3).withTimeout(3.6);
2425
}
2526

26-
public CommandBase scoreMidCubeDriveBack() {
27-
return scoreMidCube().andThen(driveBackAuto());
27+
public CommandBase scoreLowCube() {
28+
return superstructure
29+
.scoreLowPosition()
30+
.andThen(superstructure.score())
31+
.andThen(superstructure.stowCommand());
32+
}
33+
34+
public CommandBase scoreMidCube() {
35+
return superstructure
36+
.scoreMidPosition()
37+
.andThen(superstructure.score())
38+
.andThen(superstructure.stowCommand());
2839
}
2940

3041
public CommandBase scoreHighCube() {
@@ -36,15 +47,28 @@ public CommandBase scoreHighCube() {
3647
.andThen(superstructure.stowCommand());
3748
}
3849

50+
public CommandBase scoreLowCubeDriveBack() {
51+
return scoreLowCube().andThen(driveBackAuto());
52+
}
53+
54+
public CommandBase scoreMidCubeDriveBack() {
55+
return scoreMidCube().andThen(driveBackAuto());
56+
}
57+
3958
public CommandBase scoreHighCubeDriveBack() {
4059
return scoreHighCube().andThen(driveBackAuto());
4160
}
4261

43-
public CommandBase scoreMidCube() {
44-
return superstructure
45-
.scoreMidPosition()
46-
.andThen(superstructure.score())
47-
.andThen(superstructure.stowCommand());
62+
public CommandBase scoreLowThenBalance() {
63+
return scoreLowCube().andThen(autoBalanceBackwards());
64+
}
65+
66+
public CommandBase scoreMidThenBalance() {
67+
return scoreMidCube().andThen(autoBalanceBackwards());
68+
}
69+
70+
public CommandBase scoreHighThenBalance() {
71+
return scoreHighCube().andThen(autoBalanceBackwards());
4872
}
4973

5074
// Pitch: + --> backwards
@@ -66,7 +90,7 @@ public CommandBase autoBalanceBackwards() {
6690
.withTimeout(1)
6791
.andThen(
6892
drivetrain
69-
.setLeftRightVoltageCommand(-.75, -.75)
93+
.setLeftRightVoltageCommand(-1, -1)
7094
.until(
7195
() -> {
7296
System.out.println(drivetrain.getPitchRate());

src/main/java/org/pikerobodevils/frc2023/commands/Superstructure.java

-149
This file was deleted.

0 commit comments

Comments
 (0)