diff --git a/src/main/deploy/songs/Africa.chrp b/src/main/deploy/songs/Africa.chrp new file mode 100644 index 0000000..b4c63a1 Binary files /dev/null and b/src/main/deploy/songs/Africa.chrp differ diff --git a/src/main/deploy/songs/Believer.chrp b/src/main/deploy/songs/Believer.chrp new file mode 100644 index 0000000..03c5e18 Binary files /dev/null and b/src/main/deploy/songs/Believer.chrp differ diff --git a/src/main/deploy/songs/Big Brother.chrp b/src/main/deploy/songs/Big Brother.chrp new file mode 100644 index 0000000..1129a8d Binary files /dev/null and b/src/main/deploy/songs/Big Brother.chrp differ diff --git a/src/main/deploy/songs/Bonetrousle.chrp b/src/main/deploy/songs/Bonetrousle.chrp new file mode 100644 index 0000000..d9b1951 Binary files /dev/null and b/src/main/deploy/songs/Bonetrousle.chrp differ diff --git a/src/main/deploy/songs/Cotton Eye Joe.chrp b/src/main/deploy/songs/Cotton Eye Joe.chrp new file mode 100644 index 0000000..18e8bd4 Binary files /dev/null and b/src/main/deploy/songs/Cotton Eye Joe.chrp differ diff --git a/src/main/deploy/songs/Country Roads.chrp b/src/main/deploy/songs/Country Roads.chrp new file mode 100644 index 0000000..1434c29 Binary files /dev/null and b/src/main/deploy/songs/Country Roads.chrp differ diff --git a/src/main/deploy/songs/Duel of the Fates.chrp b/src/main/deploy/songs/Duel of the Fates.chrp new file mode 100644 index 0000000..c09ee54 Binary files /dev/null and b/src/main/deploy/songs/Duel of the Fates.chrp differ diff --git a/src/main/deploy/songs/Epic Sax.chrp b/src/main/deploy/songs/Epic Sax.chrp new file mode 100644 index 0000000..440bf5d Binary files /dev/null and b/src/main/deploy/songs/Epic Sax.chrp differ diff --git a/src/main/deploy/songs/Gourmet Race.chrp b/src/main/deploy/songs/Gourmet Race.chrp new file mode 100644 index 0000000..f0740c8 Binary files /dev/null and b/src/main/deploy/songs/Gourmet Race.chrp differ diff --git a/src/main/deploy/songs/Halo.chrp b/src/main/deploy/songs/Halo.chrp new file mode 100644 index 0000000..8653ccb Binary files /dev/null and b/src/main/deploy/songs/Halo.chrp differ diff --git a/src/main/deploy/songs/Hello World.chrp b/src/main/deploy/songs/Hello World.chrp new file mode 100644 index 0000000..339e4f4 Binary files /dev/null and b/src/main/deploy/songs/Hello World.chrp differ diff --git a/src/main/deploy/songs/HesAPirate.chrp b/src/main/deploy/songs/HesAPirate.chrp new file mode 100644 index 0000000..a4b4c92 Binary files /dev/null and b/src/main/deploy/songs/HesAPirate.chrp differ diff --git a/src/main/deploy/songs/Lone Digger.chrp b/src/main/deploy/songs/Lone Digger.chrp new file mode 100644 index 0000000..f4e1eb7 Binary files /dev/null and b/src/main/deploy/songs/Lone Digger.chrp differ diff --git a/src/main/deploy/songs/MEGALOVANIA.chrp b/src/main/deploy/songs/MEGALOVANIA.chrp new file mode 100644 index 0000000..d26c9f1 Binary files /dev/null and b/src/main/deploy/songs/MEGALOVANIA.chrp differ diff --git a/src/main/deploy/songs/Mii Plaza.chrp b/src/main/deploy/songs/Mii Plaza.chrp new file mode 100644 index 0000000..186e536 Binary files /dev/null and b/src/main/deploy/songs/Mii Plaza.chrp differ diff --git a/src/main/deploy/songs/Number One.chrp b/src/main/deploy/songs/Number One.chrp new file mode 100644 index 0000000..948433c Binary files /dev/null and b/src/main/deploy/songs/Number One.chrp differ diff --git a/src/main/deploy/songs/Sweden.chrp b/src/main/deploy/songs/Sweden.chrp new file mode 100644 index 0000000..3a0b5d9 Binary files /dev/null and b/src/main/deploy/songs/Sweden.chrp differ diff --git a/src/main/deploy/songs/TJ-WNPC.chrp b/src/main/deploy/songs/TJ-WNPC.chrp new file mode 100644 index 0000000..30f78af Binary files /dev/null and b/src/main/deploy/songs/TJ-WNPC.chrp differ diff --git a/src/main/deploy/songs/Take On Me.chrp b/src/main/deploy/songs/Take On Me.chrp new file mode 100644 index 0000000..a5aaa05 Binary files /dev/null and b/src/main/deploy/songs/Take On Me.chrp differ diff --git a/src/main/deploy/songs/The Wolf.chrp b/src/main/deploy/songs/The Wolf.chrp new file mode 100644 index 0000000..3c00ae7 Binary files /dev/null and b/src/main/deploy/songs/The Wolf.chrp differ diff --git a/src/main/deploy/songs/Through the Fire and Flames.chrp b/src/main/deploy/songs/Through the Fire and Flames.chrp new file mode 100644 index 0000000..8a97919 Binary files /dev/null and b/src/main/deploy/songs/Through the Fire and Flames.chrp differ diff --git a/src/main/deploy/songs/VA Main Theme.chrp b/src/main/deploy/songs/VA Main Theme.chrp new file mode 100644 index 0000000..ca3e07b Binary files /dev/null and b/src/main/deploy/songs/VA Main Theme.chrp differ diff --git a/src/main/deploy/songs/Wet Hands.chrp b/src/main/deploy/songs/Wet Hands.chrp new file mode 100644 index 0000000..98a5837 Binary files /dev/null and b/src/main/deploy/songs/Wet Hands.chrp differ diff --git a/src/main/java/frc4388/robot/RobotContainer.java b/src/main/java/frc4388/robot/RobotContainer.java index e678e1a..4d8bc66 100644 --- a/src/main/java/frc4388/robot/RobotContainer.java +++ b/src/main/java/frc4388/robot/RobotContainer.java @@ -16,6 +16,7 @@ import edu.wpi.first.wpilibj2.command.RunCommand; import edu.wpi.first.wpilibj2.command.button.JoystickButton; import frc4388.robot.Constants.*; import frc4388.robot.commands.DriveStraightAtVelocityPID; +import frc4388.robot.commands.DriveWithJoystick; import frc4388.robot.commands.DriveStraightToPositionMM; import frc4388.robot.commands.DriveStraightToPositionPID; import frc4388.robot.commands.DriveWithJoystickUsingDeadAssistPID; @@ -119,6 +120,7 @@ public class RobotContainer { new JoystickButton(getDriverJoystick(), XboxController.Y_BUTTON) .whenPressed(new RunCommand(() -> m_robotDrive.runTurningPID(45), m_robotDrive)); + // sets solenoids into high gear new JoystickButton(getDriverJoystick(), XboxController.START_BUTTON) .whenPressed(new InstantCommand(() -> m_robotDrive.setShiftState(true), m_robotDrive)); diff --git a/src/main/java/frc4388/robot/commands/PlaySongDrive.java b/src/main/java/frc4388/robot/commands/PlaySongDrive.java new file mode 100644 index 0000000..5e0e6b4 --- /dev/null +++ b/src/main/java/frc4388/robot/commands/PlaySongDrive.java @@ -0,0 +1,52 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package frc4388.robot.commands; + +import edu.wpi.first.wpilibj2.command.CommandBase; +import frc4388.robot.subsystems.Drive; + +public class PlaySongDrive extends CommandBase { + private Drive m_drive; + + /** + * Creates a new PlaySongDrive. + */ + public PlaySongDrive(Drive subsystem) { + // Use addRequirements() here to declare subsystem dependencies. + m_drive = subsystem; + addRequirements(m_drive); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + m_drive.m_rightFrontMotor.set(0); + m_drive.m_leftFrontMotor.set(0); + m_drive.m_rightBackMotor.set(0); + m_drive.m_leftBackMotor.set(0); + } + + // Called every time the scheduler runs while the command is scheduled. + @Override + public void execute() { + m_drive.playSong(); + //System.err.println("Playing " + m_drive.m_orchestra.isPlaying()); + //m_drive.m_driveTrain.feedWatchdog(); + } + + // Called once the command ends or is interrupted. + @Override + public void end(boolean interrupted) { + } + + // Returns true when the command should end. + @Override + public boolean isFinished() { + return false; + } +} diff --git a/src/main/java/frc4388/robot/subsystems/Drive.java b/src/main/java/frc4388/robot/subsystems/Drive.java index c898080..c6fa789 100644 --- a/src/main/java/frc4388/robot/subsystems/Drive.java +++ b/src/main/java/frc4388/robot/subsystems/Drive.java @@ -7,6 +7,16 @@ package frc4388.robot.subsystems; +import java.io.File; +import java.io.FilenameFilter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; import com.ctre.phoenix.motorcontrol.ControlMode; import com.ctre.phoenix.motorcontrol.DemandType; import com.ctre.phoenix.motorcontrol.FeedbackDevice; @@ -18,11 +28,15 @@ import com.ctre.phoenix.motorcontrol.SensorTerm; import com.ctre.phoenix.motorcontrol.StatusFrame; import com.ctre.phoenix.motorcontrol.TalonFXControlMode; import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX; +import com.ctre.phoenix.music.Orchestra; import com.ctre.phoenix.sensors.PigeonIMU; import com.ctre.phoenix.sensors.PigeonIMU_StatusFrame; +import edu.wpi.first.wpilibj.Filesystem; import edu.wpi.first.wpilibj.DoubleSolenoid; + import edu.wpi.first.wpilibj.drive.DifferentialDrive; +import edu.wpi.first.wpilibj.shuffleboard.BuiltInWidgets; import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; @@ -42,6 +56,7 @@ public class Drive extends SubsystemBase { public WPI_TalonFX m_leftBackMotor = new WPI_TalonFX(DriveConstants.DRIVE_LEFT_BACK_CAN_ID); public WPI_TalonFX m_rightBackMotor = new WPI_TalonFX(DriveConstants.DRIVE_RIGHT_BACK_CAN_ID); public static PigeonIMU m_pigeon = new PigeonIMU(DriveConstants.PIGEON_ID); + public Orchestra m_orchestra = new Orchestra(); public DifferentialDrive m_driveTrain = new DifferentialDrive(m_leftFrontMotor, m_rightFrontMotor); @@ -51,6 +66,8 @@ public class Drive extends SubsystemBase { public static Gains m_gainsTurning = DriveConstants.DRIVE_TURNING_GAINS; public static Gains m_gainsMotionMagic = DriveConstants.DRIVE_MOTION_MAGIC_GAINS; + SendableChooser m_songChooser = new SendableChooser(); + public DoubleSolenoid speedShift; /** @@ -80,7 +97,7 @@ public class Drive extends SubsystemBase { /* flip input so forward becomes back, etc */ m_leftFrontMotor.setInverted(false); m_rightFrontMotor.setInverted(true); - m_driveTrain.setRightSideInverted(false); + //m_driveTrain.setRightSideInverted(false); m_leftBackMotor.setInverted(InvertType.FollowMaster); m_rightBackMotor.setInverted(InvertType.FollowMaster); @@ -235,8 +252,22 @@ public class Drive extends SubsystemBase { * true means talon's local output is PID0 - PID1, and other side Talon is PID0 + PID1 */ m_rightFrontMotor.configAuxPIDPolarity(false, DriveConstants.DRIVE_TIMEOUT_MS); + + m_orchestra.addInstrument(m_leftBackMotor); + m_orchestra.addInstrument(m_rightFrontMotor); + m_orchestra.addInstrument(m_rightBackMotor); + m_orchestra.addInstrument(m_leftFrontMotor); + + File songsDir = new File(Filesystem.getDeployDirectory().getAbsolutePath() + "/songs"); + System.err.println(songsDir.getPath()); + String[] songsStrings = songsDir.list(); + for (String songString : songsStrings){ + m_songChooser.addOption(songString, songsDir.getAbsolutePath() + "/" + songString); + } + Shuffleboard.getTab("Songs").add(m_songChooser); } + String currentSong = ""; @Override public void periodic() { try { @@ -264,6 +295,11 @@ public class Drive extends SubsystemBase { SmartDashboard.putNumber("PID 0 Pos", m_rightFrontMotor.getSelectedSensorPosition(DriveConstants.PID_PRIMARY)); SmartDashboard.putNumber("PID 1 Pos", m_rightFrontMotor.getSelectedSensorPosition(DriveConstants.PID_TURN)); + if (currentSong != m_songChooser.getSelected()){ + currentSong = m_songChooser.getSelected(); + selectSong(currentSong); + System.err.println(currentSong); + } } catch (Exception e) { System.err.println("Error in the Drive Subsystem"); //e.printStackTrace(System.err); @@ -333,7 +369,7 @@ public class Drive extends SubsystemBase { * using the Differential Drive class to manage the two inputs */ public void driveWithInput(double move, double steer){ - m_driveTrain.arcadeDrive(move, steer); + //m_driveTrain.arcadeDrive(move, steer); } /** @@ -362,7 +398,7 @@ public class Drive extends SubsystemBase { m_rightFrontMotor.set(TalonFXControlMode.Position, targetPos, DemandType.AuxPID, targetGyro); m_leftFrontMotor.follow(m_rightFrontMotor, FollowerType.AuxOutput1); - m_driveTrain.feedWatchdog(); + //m_driveTrain.feedWatchdog(); } /** @@ -376,7 +412,7 @@ public class Drive extends SubsystemBase { m_rightFrontMotor.set(TalonFXControlMode.Velocity, targetVel, DemandType.AuxPID, targetGyro); m_leftFrontMotor.follow(m_rightFrontMotor, FollowerType.AuxOutput1); - m_driveTrain.feedWatchdog(); + //m_driveTrain.feedWatchdog(); } /** @@ -392,6 +428,7 @@ public class Drive extends SubsystemBase { m_leftFrontMotor.follow(m_rightFrontMotor, FollowerType.AuxOutput1); m_driveTrain.feedWatchdog(); + } /** @@ -442,6 +479,21 @@ public class Drive extends SubsystemBase { m_pigeon.setAccumZAngle(0); } + /** + * Plays Music! + */ + public void playSong() { + m_orchestra.play(); + } + + /** + * Selects a song to play! + * @param song The name of the song to be played + */ + public void selectSong(String song) { + SmartDashboard.putString("Selected Song", song); + m_orchestra.loadMusic(song); + } /** * Set to high or low gear based on boolean state, true = high, false = low * @param state Chooses between high or low gear diff --git a/src/main/java/frc4388/robot/subsystems/Storage.java b/src/main/java/frc4388/robot/subsystems/Storage.java index 84f01ec..e61cbef 100644 --- a/src/main/java/frc4388/robot/subsystems/Storage.java +++ b/src/main/java/frc4388/robot/subsystems/Storage.java @@ -59,9 +59,9 @@ public class Storage extends SubsystemBase { final boolean beam_on = m_beamSensors[0].get(); if (beam_on) { - System.err.println("Beam on"); + //System.err.println("Beam on"); } else { - System.err.println("Beam off"); + //System.err.println("Beam off"); } } diff --git a/vendordeps/Phoenix.json b/vendordeps/Phoenix.json index a633555..c6ec878 100644 --- a/vendordeps/Phoenix.json +++ b/vendordeps/Phoenix.json @@ -1,7 +1,7 @@ { "fileName": "Phoenix.json", "name": "CTRE-Phoenix", - "version": "5.17.4", + "version": "5.18.1", "uuid": "ab676553-b602-441f-a38d-f1296eff6537", "mavenUrls": [ "http://devsite.ctr-electronics.com/maven/release/" @@ -11,19 +11,19 @@ { "groupId": "com.ctre.phoenix", "artifactId": "api-java", - "version": "5.17.4" + "version": "5.18.1" }, { "groupId": "com.ctre.phoenix", "artifactId": "wpiapi-java", - "version": "5.17.4" + "version": "5.18.1" } ], "jniDependencies": [ { "groupId": "com.ctre.phoenix", "artifactId": "cci", - "version": "5.17.4", + "version": "5.18.1", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -35,7 +35,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "diagnostics", - "version": "5.17.4", + "version": "5.18.1", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -47,7 +47,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "canutils", - "version": "5.17.4", + "version": "5.18.1", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -58,7 +58,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "platform-stub", - "version": "5.17.4", + "version": "5.18.1", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -69,7 +69,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "core", - "version": "5.17.4", + "version": "5.18.1", "isJar": false, "skipInvalidPlatforms": true, "validPlatforms": [ @@ -83,7 +83,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "wpiapi-cpp", - "version": "5.17.4", + "version": "5.18.1", "libName": "CTRE_Phoenix_WPI", "headerClassifier": "headers", "sharedLibrary": false, @@ -97,7 +97,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "api-cpp", - "version": "5.17.4", + "version": "5.18.1", "libName": "CTRE_Phoenix", "headerClassifier": "headers", "sharedLibrary": false, @@ -111,7 +111,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "cci", - "version": "5.17.4", + "version": "5.18.1", "libName": "CTRE_PhoenixCCI", "headerClassifier": "headers", "sharedLibrary": false, @@ -125,7 +125,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "diagnostics", - "version": "5.17.4", + "version": "5.18.1", "libName": "CTRE_PhoenixDiagnostics", "headerClassifier": "headers", "sharedLibrary": false, @@ -139,7 +139,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "canutils", - "version": "5.17.4", + "version": "5.18.1", "libName": "CTRE_PhoenixCanutils", "headerClassifier": "headers", "sharedLibrary": false, @@ -152,7 +152,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "platform-stub", - "version": "5.17.4", + "version": "5.18.1", "libName": "CTRE_PhoenixPlatform", "headerClassifier": "headers", "sharedLibrary": false, @@ -165,7 +165,7 @@ { "groupId": "com.ctre.phoenix", "artifactId": "core", - "version": "5.17.4", + "version": "5.18.1", "libName": "CTRE_PhoenixCore", "headerClassifier": "headers", "sharedLibrary": false, diff --git a/vendordeps/WPILibOldCommands.json b/vendordeps/WPILibOldCommands.json new file mode 100644 index 0000000..acc8879 --- /dev/null +++ b/vendordeps/WPILibOldCommands.json @@ -0,0 +1,37 @@ +{ + "fileName": "WPILibOldCommands.json", + "name": "WPILib-Old-Commands", + "version": "2020.0.0", + "uuid": "b066afc2-5c18-43c4-b758-43381fcb275e", + "mavenUrls": [], + "jsonUrl": "", + "javaDependencies": [ + { + "groupId": "edu.wpi.first.wpilibOldCommands", + "artifactId": "wpilibOldCommands-java", + "version": "wpilib" + } + ], + "jniDependencies": [], + "cppDependencies": [ + { + "groupId": "edu.wpi.first.wpilibOldCommands", + "artifactId": "wpilibOldCommands-cpp", + "version": "wpilib", + "libName": "wpilibOldCommands", + "headerClassifier": "headers", + "sourcesClassifier": "sources", + "sharedLibrary": true, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "linuxathena", + "linuxraspbian", + "linuxaarch64bionic", + "windowsx86-64", + "windowsx86", + "linuxx86-64", + "osxx86-64" + ] + } + ] +} \ No newline at end of file