Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored Swerve Modules #2

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@ sonar {
}

// Simulation configuration (e.g. environment variables).
wpi.sim.addGui()
//
// The sim GUI is *disabled* by default to support running
// AdvantageKit log replay from the command line. Set the
// value to "true" to enable the sim GUI by default (this
// is the standard WPILib behavior).
wpi.sim.addGui().defaultEnabled = true
wpi.sim.addDriverstation()

// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
Expand Down
Binary file added ctre_sim/CANCoder vers. H - 011 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/CANCoder vers. H - 02 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/CANCoder vers. H - 05 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/CANCoder vers. H - 08 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/Talon FX vers. C - 00 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/Talon FX vers. C - 01 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/Talon FX vers. C - 010 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/Talon FX vers. C - 03 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/Talon FX vers. C - 04 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/Talon FX vers. C - 06 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/Talon FX vers. C - 07 - 0 - ext.dat
Binary file not shown.
Binary file added ctre_sim/Talon FX vers. C - 09 - 0 - ext.dat
Binary file not shown.
Binary file added logs/Log_24-01-19_18-35-38.wpilog
Binary file not shown.
131 changes: 130 additions & 1 deletion networktables.json
Original file line number Diff line number Diff line change
@@ -1 +1,130 @@
[]
[
{
"name": "/Preferences/Drive/Module0/Drive Pid Property.mm.kp",
"type": "double",
"value": 0.05,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module0/Turn Pid Property.mm.kp",
"type": "double",
"value": 7.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module0/Turn Pid Property.mm.ki",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module0/Turn Pid Property.mm.kd",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module1/Drive Pid Property.mm.kp",
"type": "double",
"value": 0.05,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module1/Turn Pid Property.mm.kp",
"type": "double",
"value": 7.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module1/Turn Pid Property.mm.ki",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module1/Turn Pid Property.mm.kd",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module2/Drive Pid Property.mm.kp",
"type": "double",
"value": 0.05,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module2/Turn Pid Property.mm.kp",
"type": "double",
"value": 7.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module2/Turn Pid Property.mm.ki",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module2/Turn Pid Property.mm.kd",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module3/Drive Pid Property.mm.kp",
"type": "double",
"value": 0.05,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module3/Turn Pid Property.mm.kp",
"type": "double",
"value": 7.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module3/Turn Pid Property.mm.ki",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module3/Turn Pid Property.mm.kd",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
}
]
98 changes: 98 additions & 0 deletions networktables.json.bck
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
[
{
"name": "/Preferences/Drive/Module0/Drive Pid Property.mm.kp",
"type": "double",
"value": 0.05,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module0/Turn Pid Property.mm.kp",
"type": "double",
"value": 7.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module0/Turn Pid Property.mm.ki",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module0/Turn Pid Property.mm.kd",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module1/Drive Pid Property.mm.kp",
"type": "double",
"value": 0.05,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module1/Turn Pid Property.mm.kp",
"type": "double",
"value": 7.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module1/Turn Pid Property.mm.ki",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module1/Turn Pid Property.mm.kd",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module2/Drive Pid Property.mm.kp",
"type": "double",
"value": 0.05,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module2/Turn Pid Property.mm.kp",
"type": "double",
"value": 7.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module2/Turn Pid Property.mm.ki",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
},
{
"name": "/Preferences/Drive/Module2/Turn Pid Property.mm.kd",
"type": "double",
"value": 0.0,
"properties": {
"persistent": true
}
}
]
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* constants are needed, to reduce verbosity.
*/
public final class Constants {
public static final Mode currentMode = Mode.REAL;
public static final Mode currentMode = Mode.SIM;

public static enum Mode {
/** Running on a real robot. */
Expand Down
83 changes: 37 additions & 46 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.commands.DriveCommands;
import frc.robot.commands.FeedForwardCharacterization;
Expand All @@ -34,7 +33,6 @@
import frc.robot.subsystems.shooter.ShooterIOPrototype;
import frc.robot.subsystems.shooter.ShooterSubsystem;
import org.littletonrobotics.junction.networktables.LoggedDashboardChooser;
import org.littletonrobotics.junction.networktables.LoggedDashboardNumber;

/**
* This class is where the bulk of the robot should be declared. Since Command-based is a
Expand All @@ -52,52 +50,43 @@ public class RobotContainer {

// Dashboard inputs
private final LoggedDashboardChooser<Command> autoChooser;
private final LoggedDashboardNumber flywheelSpeedInput =
new LoggedDashboardNumber("Flywheel Speed", 1500.0);

/** The container for the robot. Contains subsystems, OI devices, and commands. */
public RobotContainer() {
switch (Constants.currentMode) {
case REAL -> {
// Real robot, instantiate hardware IO implementations
m_driveSubsystem = new DriveSubsystem(
new GyroIOPigeon1(12, true),
new ModuleIOTalonFX(Constants.DriveConstants.FL_MOD_CONSTANTS),
new ModuleIOTalonFX(Constants.DriveConstants.FR_MOD_CONSTANTS),
new ModuleIOTalonFX(Constants.DriveConstants.BL_MOD_CONSTANTS),
new ModuleIOTalonFX(Constants.DriveConstants.BR_MOD_CONSTANTS));
m_shooter = new ShooterSubsystem(new ShooterIOPrototype());
}
case SIM -> {
// Sim robot, instantiate physics sim IO implementations
m_driveSubsystem =
new DriveSubsystem(
new GyroIO() {
},
new ModuleIOSim(),
new ModuleIOSim(),
new ModuleIOSim(),
new ModuleIOSim());
m_shooter = new ShooterSubsystem(new ShooterIOPrototype());
}
default -> {
// Replayed robot, disable IO implementations
m_driveSubsystem =
new DriveSubsystem(
new GyroIO() {
},
new ModuleIO() {
},
new ModuleIO() {
},
new ModuleIO() {
},
new ModuleIO() {
});
m_shooter = new ShooterSubsystem(new ShooterIO() {
});
}
switch (Constants.currentMode) {
case REAL -> {
// Real robot, instantiate hardware IO implementations
m_driveSubsystem = new DriveSubsystem(
new GyroIOPigeon1(12, true),
new ModuleIOTalonFX(Constants.DriveConstants.FL_MOD_CONSTANTS),
new ModuleIOTalonFX(Constants.DriveConstants.FR_MOD_CONSTANTS),
new ModuleIOTalonFX(Constants.DriveConstants.BL_MOD_CONSTANTS),
new ModuleIOTalonFX(Constants.DriveConstants.BR_MOD_CONSTANTS));
m_shooter = new ShooterSubsystem(new ShooterIOPrototype());
}
case SIM -> {
// Sim robot, instantiate physics sim IO implementations
m_driveSubsystem =
new DriveSubsystem(
new GyroIO() {},
new ModuleIOSim(Constants.DriveConstants.FL_MOD_CONSTANTS),
new ModuleIOSim(Constants.DriveConstants.FR_MOD_CONSTANTS),
new ModuleIOSim(Constants.DriveConstants.BL_MOD_CONSTANTS),
new ModuleIOSim(Constants.DriveConstants.BR_MOD_CONSTANTS));
m_shooter = new ShooterSubsystem(new ShooterIOPrototype());
}
default -> {
// Replayed robot, disable IO implementations
m_driveSubsystem =
new DriveSubsystem(
new GyroIO() {},
new ModuleIO() {},
new ModuleIO() {},
new ModuleIO() {},
new ModuleIO() {});
m_shooter = new ShooterSubsystem(new ShooterIO() {});
}
}

// Set up auto routines
autoChooser = new LoggedDashboardChooser<>("Auto Choices", AutoBuilder.buildAutoChooser());
Expand All @@ -106,7 +95,9 @@ public RobotContainer() {
autoChooser.addOption(
"Drive FF Characterization",
new FeedForwardCharacterization(
m_driveSubsystem, m_driveSubsystem::runCharacterizationVolts, m_driveSubsystem::getCharacterizationVelocity));
m_driveSubsystem,
m_driveSubsystem::runCharacterizationVolts,
m_driveSubsystem::getCharacterizationVelocity));

// Configure the button bindings
configureButtonBindings();
Expand Down Expand Up @@ -146,6 +137,6 @@ private void configureButtonBindings() {
* @return the command to run in autonomous
*/
public Command getAutonomousCommand() {
return new InstantCommand();//autoChooser.get();
return autoChooser.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class Module {
public Module(ModuleIO io) {
this.m_io = io;
this.m_moduleConstants = m_io.getModuleConstants();
this.m_index = m_moduleConstants.MODULE_INDEX;
this.m_index = m_moduleConstants.MODULE_INDEX();
// delay to initialize all hardware
Timer.delay(0.5);

Expand Down
Loading
Loading