Skip to content

Commit

Permalink
Merge pull request #6 from applepi-2067/gordon/port/swerve_phoenix6
Browse files Browse the repository at this point in the history
Gordon/port/swerve phoenix6
  • Loading branch information
jcorcoran authored Jan 17, 2024
2 parents b209602 + ba2ccef commit 09fb240
Show file tree
Hide file tree
Showing 12 changed files with 548 additions and 160 deletions.
4 changes: 0 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ repositories {
}

// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
// Also defines JUnit 5.
dependencies {
implementation wpi.java.deps.wpilib()
implementation wpi.java.vendor.java()
Expand All @@ -71,9 +70,6 @@ dependencies {
nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop)
simulationRelease wpi.sim.enableRelease()

testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

implementation "com.github.Oblarg:Oblog:5.1.0"
}

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import io.github.oblarg.oblog.Logger;

/**
* The VM is configured to automatically run this class, and to call the functions corresponding to
Expand Down Expand Up @@ -44,6 +45,8 @@ public void robotPeriodic() {
// and running subsystem periodic() methods. This must be called from the robot's periodic
// block in order for anything in the Command-based framework to work.
CommandScheduler.getInstance().run();

Logger.updateEntries();
}

/** This function is called once each time the robot enters Disabled mode. */
Expand Down
84 changes: 38 additions & 46 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
@@ -1,63 +1,55 @@
// 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;

import frc.robot.Constants.OperatorConstants;
import frc.robot.commands.Autos;
import frc.robot.commands.ExampleCommand;
import frc.robot.subsystems.ExampleSubsystem;

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 edu.wpi.first.wpilibj2.command.button.Trigger;

/**
* This class is where the bulk of the robot should be declared. Since Command-based is a
* "declarative" paradigm, very little robot logic should actually be handled in the {@link Robot}
* periodic methods (other than the scheduler calls). Instead, the structure of the robot (including
* subsystems, commands, and trigger mappings) should be declared here.
*/

import io.github.oblarg.oblog.Logger;

import frc.robot.subsystems.Drivetrain;


public class RobotContainer {
// The robot's subsystems and commands are defined here...
private final ExampleSubsystem m_exampleSubsystem = new ExampleSubsystem();
// Subsystems.
private final Drivetrain m_drivetrain;

// Controllers.
private static final int DRIVER_CONTROLLER_PORT = 0;
private final CommandXboxController m_driverController;

// Replace with CommandPS4Controller or CommandJoystick if needed
private final CommandXboxController m_driverController =
new CommandXboxController(OperatorConstants.kDriverControllerPort);

/** The container for the robot. Contains subsystems, OI devices, and commands. */
public RobotContainer() {
// Configure the trigger bindings
m_drivetrain = Drivetrain.getInstance();

m_driverController = new CommandXboxController(DRIVER_CONTROLLER_PORT);
configureBindings();

Logger.configureLoggingAndConfig(this, false);
}

/**
* Use this method to define your trigger->command mappings. Triggers can be created via the
* {@link Trigger#Trigger(java.util.function.BooleanSupplier)} constructor with an arbitrary
* predicate, or via the named factories in {@link
* edu.wpi.first.wpilibj2.command.button.CommandGenericHID}'s subclasses for {@link
* CommandXboxController Xbox}/{@link edu.wpi.first.wpilibj2.command.button.CommandPS4Controller
* PS4} controllers or {@link edu.wpi.first.wpilibj2.command.button.CommandJoystick Flight
* joysticks}.
*/
private void configureBindings() {
// Schedule `ExampleCommand` when `exampleCondition` changes to `true`
new Trigger(m_exampleSubsystem::exampleCondition)
.onTrue(new ExampleCommand(m_exampleSubsystem));

// Schedule `exampleMethodCommand` when the Xbox controller's B button is pressed,
// cancelling on release.
m_driverController.b().whileTrue(m_exampleSubsystem.exampleMethodCommand());
m_drivetrain.setDefaultCommand(
Commands.run(
() -> m_drivetrain.drive(
m_driverController.getLeftX(),
m_driverController.getLeftY(),
m_driverController.getRightX()
),
m_drivetrain
)
);

m_driverController.a().onTrue(
new InstantCommand(
() -> m_drivetrain.resetGyro()
)
);
}

/**
* Use this to pass the autonomous command to the main {@link Robot} class.
*
* @return the command to run in autonomous
*/
// Use this to pass the autonomous command to the main Robot.java class.
public Command getAutonomousCommand() {
// An example command will be run in autonomous
return Autos.exampleAuto(m_exampleSubsystem);
return null;
}
}
20 changes: 0 additions & 20 deletions src/main/java/frc/robot/commands/Autos.java

This file was deleted.

43 changes: 0 additions & 43 deletions src/main/java/frc/robot/commands/ExampleCommand.java

This file was deleted.

16 changes: 16 additions & 0 deletions src/main/java/frc/robot/constants/RobotMap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package frc.robot.constants;


public final class RobotMap {
public static class canIDs {
public static class Drivetrain {
// Follows back left, back right, front left, front right convention.
public static final int[] DRIVE = {1, 2, 3, 4};

public static final int[] STEER = {5, 6, 7, 8};
public static final int[] CANCoder = {1, 2, 3, 4};

public static final int GYRO = 9;
}
}
}
Loading

0 comments on commit 09fb240

Please sign in to comment.