diff --git a/.env b/.env index 3207e30..c8514a1 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -PROD_FLAG=false \ No newline at end of file +PROD_FLAG=true \ No newline at end of file diff --git a/README.md b/README.md index 2864c18..1bd049d 100644 --- a/README.md +++ b/README.md @@ -1,63 +1,15 @@ -# PWRUP Command Robot Base - -## Introduction - -Welcome to the **PWRUP Command Robot Base**! This repository serves as the foundation for building command-based robots that our team will create in the years ahead. By providing a structured framework, essential libraries, and key features, this template aims to streamline the development process and set our robots up for success. - -### Key Benefits: -- **Modularity:** Easily fork this repository to kickstart a new robot project. -- **Reusability:** Built-in features and libraries ensure consistency and speed up development. -- **Scalability:** Designed to be expanded with additional functionality as our team's needs grow. - ---- - -## Functionality - -This template provides the core structure for building robots using the **Command-Based Programming** model. It includes essential features and tools to simplify the creation and deployment of robot software, ensuring that our team has a solid base to work from. - -### Use Case: -When a new robot project is started, the team can **fork** this repository, allowing them to focus on adding custom code specific to their robot, while benefiting from the standardized tools and libraries already included. +# SPAMURAI --- -## Features Overview - -This repository includes several pre-configured features and libraries to accelerate development and promote best practices. As the team’s requirements evolve, we’ll continue to integrate more functionalities. - -### Current Features: +## TODO -1. **[Source vs. Online Library Building](./docs/SourceBuildingPlugin.md)**: - - Enables developers to decide whether to build the robot software from the **latest source code** or from a pre-built **online library**. - - This flexibility is particularly useful when working under tight deadlines or experimenting with local changes without needing to push to GitHub. - - See the detailed documentation [here](./docs/SourceBuildingPlugin.md). +Todo can be found in the [TODO.md](TODO.md) file. -### Future Expansion: -- Additional libraries and features will be added as the team's needs grow, ensuring the template evolves with the requirements of our robot projects. - ---- - -## Getting Started - -### 1. Forking the Repository -To create a new robot, simply **fork this repository** and start adding your custom robot code. The template is designed to be modular, allowing you to build upon it with minimal configuration. - -### 2. Using the Build System -By default, the repository is configured to use Gradle, with a built-in option for selecting **source vs. online builds**. This ensures that whether you're pulling the latest version of a library from a repository or building locally, the process is seamless. - -Refer to the [SourceBuildingPlugin.md](./docs/SourceBuildingPlugin.md) for more information on configuring the build system based on your current needs. - -### 3. Customizing Your Robot Code -Once you've forked the repository: -- Add your custom subsystems, commands, and robot logic. -- Leverage the pre-configured structure to ensure your robot code adheres to best practices and command-based programming principles. - ---- +## Building -## Contribution Guidelines +This project requires (at the moment) the "PROD_FLAG" to be set to "true" in the ".env" file. This will essentially clone the dependencies from github and manually build them. Turning this off will make this NOT build! -If you have ideas for new features or improvements to this template, please feel free to: -1. Fork the repository. -2. Create a branch for your feature or fix. -3. Submit a pull request with detailed information about the changes. +## Config -We encourage all team members to contribute to this repository so that it continues to meet the evolving needs of our robot projects. +The configs for teleop/auto/other can be found in the /config/ folder. Please read the [documentation](https://github.com/lolhol/KeybindConfigurator) of KeybindConfigurator for more information. All the initiation code is found in the /initiate/ folder (inside src). diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..66677e2 --- /dev/null +++ b/TODO.md @@ -0,0 +1,3 @@ +# This is a list of things that we have to make. + +1. possibly migrate to LUA config for ease of use since you cannot import .toml files in KeybindConfigurator diff --git a/build.gradle b/build.gradle index eb9ae16..c82e67b 100644 --- a/build.gradle +++ b/build.gradle @@ -36,6 +36,11 @@ deploy { files = project.fileTree('src/main/deploy') directory = '/home/lvuser/deploy' } + + frcStaticFileDeploy(getArtifactTypeClass('FileTreeArtifact')) { + files = project.fileTree('config') + directory = '/home/lvuser/config' + } } } } @@ -66,9 +71,9 @@ dependencies { nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop) simulationRelease wpi.sim.enableRelease() - // addGithubRepoJitPack("lolhol", "KeybindConfigurator", "0.2") // Example usage - + addGithubRepoJitPack("lolhol", "KeybindConfigurator", "0.2") + implementation 'com.moandjiezana.toml:toml4j:0.7.2' testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } @@ -97,7 +102,7 @@ wpi.java.configureTestTasks(test) // Configure the string concatenation setting for inline compilation tasks.withType(JavaCompile) { - options.compilerArgs.add '-XDstringConcat=inline' + options.compilerArgs.addAll(['-XDstringConcat=inline', '-Xlint:unchecked']) } // ---------------- Helper functions ---------------- @@ -142,8 +147,11 @@ def addGithubRepo(String user, String repo, String nonProductionImplementationSt println("") println("") - def jarFiles = fileTree(dir: "lib/build", include: '*.jar').filter { jarFile -> - !alreadyAdded.contains(jarFile) + def jarFiles = fileTree(dir: "lib/build", include: "**/*.jar") + println("Adding to dependencies:") + + jarFiles.each { jarFile -> + println(jarFile.path) } dependencies { @@ -151,11 +159,9 @@ def addGithubRepo(String user, String repo, String nonProductionImplementationSt } alreadyAdded.addAll(jarFiles) - - return; - } - - dependencies { - implementation nonProductionImplementationString + } else { + dependencies { + implementation nonProductionImplementationString + } } } \ No newline at end of file diff --git a/config/auto-config.toml b/config/auto-config.toml new file mode 100644 index 0000000..e69de29 diff --git a/config/teleop-config.toml b/config/teleop-config.toml new file mode 100644 index 0000000..1480b17 --- /dev/null +++ b/config/teleop-config.toml @@ -0,0 +1,2 @@ +[testingFunction] +arg0 = "Initiating Teleop with 'testingFunction'!" diff --git a/networktables.json b/networktables.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/networktables.json @@ -0,0 +1 @@ +[] diff --git a/simgui-ds.json b/simgui-ds.json new file mode 100644 index 0000000..73cc713 --- /dev/null +++ b/simgui-ds.json @@ -0,0 +1,92 @@ +{ + "keyboardJoysticks": [ + { + "axisConfig": [ + { + "decKey": 65, + "incKey": 68 + }, + { + "decKey": 87, + "incKey": 83 + }, + { + "decKey": 69, + "decayRate": 0.0, + "incKey": 82, + "keyRate": 0.009999999776482582 + } + ], + "axisCount": 3, + "buttonCount": 4, + "buttonKeys": [ + 90, + 88, + 67, + 86 + ], + "povConfig": [ + { + "key0": 328, + "key135": 323, + "key180": 322, + "key225": 321, + "key270": 324, + "key315": 327, + "key45": 329, + "key90": 326 + } + ], + "povCount": 1 + }, + { + "axisConfig": [ + { + "decKey": 74, + "incKey": 76 + }, + { + "decKey": 73, + "incKey": 75 + } + ], + "axisCount": 2, + "buttonCount": 4, + "buttonKeys": [ + 77, + 44, + 46, + 47 + ], + "povCount": 0 + }, + { + "axisConfig": [ + { + "decKey": 263, + "incKey": 262 + }, + { + "decKey": 265, + "incKey": 264 + } + ], + "axisCount": 2, + "buttonCount": 6, + "buttonKeys": [ + 260, + 268, + 266, + 261, + 269, + 267 + ], + "povCount": 0 + }, + { + "axisCount": 0, + "buttonCount": 0, + "povCount": 0 + } + ] +} diff --git a/simgui.json b/simgui.json new file mode 100644 index 0000000..5f9d275 --- /dev/null +++ b/simgui.json @@ -0,0 +1,10 @@ +{ + "NTProvider": { + "types": { + "/FMSInfo": "FMSInfo" + } + }, + "NetworkTables Info": { + "visible": true + } +} diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java deleted file mode 100644 index c50ba05..0000000 --- a/src/main/java/frc/robot/Constants.java +++ /dev/null @@ -1,19 +0,0 @@ -// 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; - -/** - * The Constants class provides a convenient place for teams to hold robot-wide numerical or boolean - * constants. This class should not be used for any other purpose. All constants should be declared - * globally (i.e. public static). Do not put anything functional in this class. - * - *
It is advised to statically import this class (or one of its inner classes) wherever the - * constants are needed, to reduce verbosity. - */ -public final class Constants { - public static class OperatorConstants { - public static final int kDriverControllerPort = 0; - } -} diff --git a/src/main/java/frc/robot/Main.java b/src/main/java/frc/robot/Main.java index 34f6bf5..07914dd 100644 --- a/src/main/java/frc/robot/Main.java +++ b/src/main/java/frc/robot/Main.java @@ -6,24 +6,11 @@ import edu.wpi.first.wpilibj.RobotBase; -/** - * Do NOT add any static variables to this class, or any initialization at all. - * Unless you know what - * you are doing, do not modify this file except to change the parameter class - * to the startRobot - * call. - */ public final class Main { private Main() { } - /** - * Main initialization function. Do not perform any initialization here. - * - *
- * If you change your main robot class, change the parameter type. - */ public static void main(String... args) { RobotBase.startRobot(Robot::new); } -} +} \ No newline at end of file diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 687a0a0..bdb1f50 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -1,103 +1,86 @@ -// 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 java.io.File; +import java.lang.reflect.InvocationTargetException; + +import org.brigero.KeybindConfigurator; + import edu.wpi.first.wpilibj.TimedRobot; -import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.CommandScheduler; +import frc.robot.initiate.InitiateAuto; +import frc.robot.initiate.InitiateTeleop; -/** - * The VM is configured to automatically run this class, and to call the functions corresponding to - * each mode, as described in the TimedRobot documentation. If you change the name of this class or - * the package after creating this project, you must also update the build.gradle file in the - * project. - */ public class Robot extends TimedRobot { - private Command m_autonomousCommand; + private InitiateTeleop teleopInit; - private RobotContainer m_robotContainer; + private InitiateAuto autoInit; - /** - * This function is run when the robot is first started up and should be used for any - * initialization code. - */ @Override public void robotInit() { - // Instantiate our RobotContainer. This will perform all our button bindings, and put our - // autonomous chooser on the dashboard. - m_robotContainer = new RobotContainer(); + teleopInit = new InitiateTeleop(); + autoInit = new InitiateAuto(); } - /** - * This function is called every 20 ms, no matter the mode. Use this for items like diagnostics - * that you want ran during disabled, autonomous, teleoperated and test. - * - *
This runs after the mode specific periodic functions, but before LiveWindow and - * SmartDashboard integrated updating. - */ @Override public void robotPeriodic() { - // Runs the Scheduler. This is responsible for polling buttons, adding newly-scheduled - // commands, running already-scheduled commands, removing finished or interrupted commands, - // 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(); } - /** This function is called once each time the robot enters Disabled mode. */ @Override - public void disabledInit() {} + public void disabledInit() { + } @Override - public void disabledPeriodic() {} + public void disabledPeriodic() { + } - /** This autonomous runs the autonomous command selected by your {@link RobotContainer} class. */ @Override public void autonomousInit() { - m_autonomousCommand = m_robotContainer.getAutonomousCommand(); + // Please note that the usage of this is outlined in the docs of + // "KeybindConfigurator" - // schedule the autonomous command (example) - if (m_autonomousCommand != null) { - m_autonomousCommand.schedule(); + try { + KeybindConfigurator.runFunctions(new File("config/auto-config.toml"), autoInit); + } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { + e.printStackTrace(); } } - /** This function is called periodically during autonomous. */ @Override - public void autonomousPeriodic() {} + public void autonomousPeriodic() { + } @Override public void teleopInit() { - // This makes sure that the autonomous stops running when - // teleop starts running. If you want the autonomous to - // continue until interrupted by another command, remove - // this line or comment it out. - if (m_autonomousCommand != null) { - m_autonomousCommand.cancel(); + // Please note that the usage of this is outlined in the docs of + // "KeybindConfigurator" + System.out.println("Teleop Init!"); + + try { + KeybindConfigurator.runFunctions(new File("config/teleop-config.toml"), teleopInit); + } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { + e.printStackTrace(); } } - /** This function is called periodically during operator control. */ @Override - public void teleopPeriodic() {} + public void teleopPeriodic() { + } @Override public void testInit() { - // Cancels all running commands at the start of test mode. CommandScheduler.getInstance().cancelAll(); } - /** This function is called periodically during test mode. */ @Override - public void testPeriodic() {} + public void testPeriodic() { + } - /** This function is called once when the robot is first started up. */ @Override - public void simulationInit() {} + public void simulationInit() { + } - /** This function is called periodically whilst in simulation. */ @Override - public void simulationPeriodic() {} + public void simulationPeriodic() { + } } diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java deleted file mode 100644 index a33249e..0000000 --- a/src/main/java/frc/robot/RobotContainer.java +++ /dev/null @@ -1,63 +0,0 @@ -// 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.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. - */ -public class RobotContainer { - // The robot's subsystems and commands are defined here... - private final ExampleSubsystem m_exampleSubsystem = new ExampleSubsystem(); - - // 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 - configureBindings(); - } - - /** - * 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()); - } - - /** - * Use this to pass the autonomous command to the main {@link Robot} class. - * - * @return the command to run in autonomous - */ - public Command getAutonomousCommand() { - // An example command will be run in autonomous - return Autos.exampleAuto(m_exampleSubsystem); - } -} diff --git a/src/main/java/frc/robot/commands/Autos.java b/src/main/java/frc/robot/commands/Autos.java deleted file mode 100644 index 107aad7..0000000 --- a/src/main/java/frc/robot/commands/Autos.java +++ /dev/null @@ -1,20 +0,0 @@ -// 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.commands; - -import frc.robot.subsystems.ExampleSubsystem; -import edu.wpi.first.wpilibj2.command.Command; -import edu.wpi.first.wpilibj2.command.Commands; - -public final class Autos { - /** Example static factory for an autonomous command. */ - public static Command exampleAuto(ExampleSubsystem subsystem) { - return Commands.sequence(subsystem.exampleMethodCommand(), new ExampleCommand(subsystem)); - } - - private Autos() { - throw new UnsupportedOperationException("This is a utility class!"); - } -} diff --git a/src/main/java/frc/robot/commands/ExampleCommand.java b/src/main/java/frc/robot/commands/ExampleCommand.java deleted file mode 100644 index 7481d3c..0000000 --- a/src/main/java/frc/robot/commands/ExampleCommand.java +++ /dev/null @@ -1,43 +0,0 @@ -// 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.commands; - -import frc.robot.subsystems.ExampleSubsystem; -import edu.wpi.first.wpilibj2.command.Command; - -/** An example command that uses an example subsystem. */ -public class ExampleCommand extends Command { - @SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) - private final ExampleSubsystem m_subsystem; - - /** - * Creates a new ExampleCommand. - * - * @param subsystem The subsystem used by this command. - */ - public ExampleCommand(ExampleSubsystem subsystem) { - m_subsystem = subsystem; - // Use addRequirements() here to declare subsystem dependencies. - addRequirements(subsystem); - } - - // Called when the command is initially scheduled. - @Override - public void initialize() {} - - // Called every time the scheduler runs while the command is scheduled. - @Override - public void execute() {} - - // 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/frc/robot/hardware/motor/IMotor.java b/src/main/java/frc/robot/hardware/motor/IMotor.java new file mode 100644 index 0000000..35aa36d --- /dev/null +++ b/src/main/java/frc/robot/hardware/motor/IMotor.java @@ -0,0 +1,28 @@ +package frc.robot.hardware.motor; + +public interface IMotor { + /** + * @param speed (-1.0 to 1.0) where 0 is stationary + */ + void setSpeed(double speed); + + /** + * @return speed (-1.0 to 1.0) where 0 is stationary + */ + double getCurrentSpeed(); + + /** + * @return position in radians + */ + double getPositionRadians(); + + /** + * + * @return position in degrees. + * @note this is a bridge method. It calls the "getPositionRadians" method and + * then converts to degrees. + */ + default double getPositionDegrees() { + return getPositionRadians() * 180 / Math.PI; + } +} diff --git a/src/main/java/frc/robot/hardware/sensor/IVisor.java b/src/main/java/frc/robot/hardware/sensor/IVisor.java new file mode 100644 index 0000000..5bd245c --- /dev/null +++ b/src/main/java/frc/robot/hardware/sensor/IVisor.java @@ -0,0 +1,13 @@ +package frc.robot.hardware.sensor; + +public interface IVisor { + /** + * @return the current voltage + */ + double getVoltage(); + + /** + * @return true if the visor is detected + */ + boolean isDetected(); +} diff --git a/src/main/java/frc/robot/initiate/InitiateAuto.java b/src/main/java/frc/robot/initiate/InitiateAuto.java new file mode 100644 index 0000000..8ae957b --- /dev/null +++ b/src/main/java/frc/robot/initiate/InitiateAuto.java @@ -0,0 +1,5 @@ +package frc.robot.initiate; + +public class InitiateAuto { + +} diff --git a/src/main/java/frc/robot/initiate/InitiateTeleop.java b/src/main/java/frc/robot/initiate/InitiateTeleop.java new file mode 100644 index 0000000..7a64718 --- /dev/null +++ b/src/main/java/frc/robot/initiate/InitiateTeleop.java @@ -0,0 +1,10 @@ +package frc.robot.initiate; + +import java.util.List; + +// This is a class to initialize the teleop period. this is done since the teleop and the like auto can have different configs and functions. +public class InitiateTeleop { + public void testingFunction(String arg0) { + System.out.println(arg0); + } +} diff --git a/src/main/java/frc/robot/subsystems/ExampleSubsystem.java b/src/main/java/frc/robot/subsystems/ExampleSubsystem.java deleted file mode 100644 index 6b375da..0000000 --- a/src/main/java/frc/robot/subsystems/ExampleSubsystem.java +++ /dev/null @@ -1,47 +0,0 @@ -// 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.subsystems; - -import edu.wpi.first.wpilibj2.command.Command; -import edu.wpi.first.wpilibj2.command.SubsystemBase; - -public class ExampleSubsystem extends SubsystemBase { - /** Creates a new ExampleSubsystem. */ - public ExampleSubsystem() {} - - /** - * Example command factory method. - * - * @return a command - */ - public Command exampleMethodCommand() { - // Inline construction of command goes here. - // Subsystem::RunOnce implicitly requires `this` subsystem. - return runOnce( - () -> { - /* one-time action goes here */ - }); - } - - /** - * An example method querying a boolean state of the subsystem (for example, a digital sensor). - * - * @return value of some boolean subsystem state, such as a digital sensor. - */ - public boolean exampleCondition() { - // Query some boolean state, such as a digital sensor. - return false; - } - - @Override - public void periodic() { - // This method will be called once per scheduler run - } - - @Override - public void simulationPeriodic() { - // This method will be called once per scheduler run during simulation - } -}