diff --git a/Robot2018/src/org/usfirst/frc/team199/Robot2018/DashboardInterface.java b/Robot2018/src/org/usfirst/frc/team199/Robot2018/DashboardInterface.java new file mode 100644 index 0000000..26d372b --- /dev/null +++ b/Robot2018/src/org/usfirst/frc/team199/Robot2018/DashboardInterface.java @@ -0,0 +1,68 @@ +package org.usfirst.frc.team199.Robot2018; + +import edu.wpi.first.wpilibj.Sendable; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; + +/** + * Directly copied from Robot2017 - @kevinzwang + */ + +public interface DashboardInterface { + + /** + * Puts all desired data on SmartDashboard + */ + public default void displayData() { + + } + + /* + * Methods for displaying values with modified keys + */ + default void putNumber(String key, double value) { + SmartDashboard.putNumber(getKey(key), value); + } + + default void putBoolean(String key, boolean value) { + SmartDashboard.putBoolean(getKey(key), value); + } + + default void putString(String key, String value) { + SmartDashboard.putString(getKey(key), value); + } + + default void putSendable(String key, Sendable value) { + SmartDashboard.putData(getKey(key), value); + } + + /* + * Methods for reading numbers, without specifying the modified key + */ + default double getNumber(String key, double defaultValue) { + return SmartDashboard.getNumber(getKey(key), defaultValue); + } + + default boolean getBoolean(String key, boolean defaultValue) { + return SmartDashboard.getBoolean(getKey(key), defaultValue); + } + + default String getString(String key, String defaultValue) { + return SmartDashboard.getString(getKey(key), defaultValue); + } + + default double[] getNumArray(String key, double[] defaultValue) { + return SmartDashboard.getNumberArray(getKey(key), defaultValue); + } + + /** + * Converts the specified display key into one with its subsystem name appended + * as a prefix, to be compatible with the Subsystem widget on SmartDashboard for + * organizational purposes + * + * @param key The name of the original key + * @return A modified key with prefix subsystem name + */ + default String getKey(String key) { + return getClass().getSimpleName() + "/" + key; + } +} diff --git a/Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/Autonomous.java b/Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/Autonomous.java new file mode 100644 index 0000000..d04ae27 --- /dev/null +++ b/Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/Autonomous.java @@ -0,0 +1,67 @@ +package org.usfirst.frc.team199.Robot2018.commands; + +import edu.wpi.first.wpilibj.command.CommandGroup; + +/** + * Initially run during Auto. Responsible for getting input from SmartDashboard + * and the FMS, and then calling RunAuto with the specified script. + */ +public class Autonomous extends CommandGroup implements AutonomousInterface { + + public Autonomous() { + // TODO + + // Add Commands here: + // e.g. addSequential(new Command1()); + // addSequential(new Command2()); + // these will run in order. + + // To run multiple commands at the same time, + // use addParallel() + // e.g. addParallel(new Command1()); + // addSequential(new Command2()); + // Command1 and Command2 will run in parallel. + + // A command group will require all of the subsystems that each member + // would require. + // e.g. if Command1 requires chassis, and Command2 requires arm, + // a CommandGroup containing them would require both the chassis and the + // arm. + } + + /** + * {@inheritDoc} + */ + @Override + public Position getStartingPos() { + // TODO + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public Strategy[] getStrategies() { + // TODO + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public double getDelay() { + // TODO + return 0; + } + + /** + * {@inheritDoc} + */ + @Override + public String pickScript() { + // TODO + return null; + } +} diff --git a/Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/AutonomousInterface.java b/Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/AutonomousInterface.java new file mode 100644 index 0000000..20aadba --- /dev/null +++ b/Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/AutonomousInterface.java @@ -0,0 +1,60 @@ +package org.usfirst.frc.team199.Robot2018.commands; + +import org.usfirst.frc.team199.Robot2018.DashboardInterface; + +import edu.wpi.first.wpilibj.DriverStation; + +public interface AutonomousInterface extends DashboardInterface{ + public enum Position { + LEFT, + CENTER, + RIGHT + } + + public enum Strategy { + AUTO_LINE, + SWITCH, + SCALE, + EXCHANGE, + SWITCH_SCALE, + SWITCH_EXCHANGE, + NOTHING + } + + /** + * Gets the starting position set in SmartDashboard + * + * @return an enum for the starting position + */ + public Position getStartingPos(); + + /** + * Gets the four strategies set in SmartDashboard + * + * @return 4 strategies, in the order of (Switch + Scale ): LL, LR, RR, RL + */ + public Strategy[] getStrategies(); + + /** + * Gets delay before running the specified script set in SmartDashboard + * + * @return delay in seconds + */ + public double getDelay(); + + /** + * Directly gets the string from FMS + * + * @return FMS data + */ + default String getFMS() { + return DriverStation.getInstance().getGameSpecificMessage(); + } + + /** + * Pick the script to run for Autonomous + * + * @return A String representing the name of the script + */ + public String pickScript(); +} diff --git a/Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/RunScript.java b/Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/RunScript.java new file mode 100644 index 0000000..7f8eb54 --- /dev/null +++ b/Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/RunScript.java @@ -0,0 +1,30 @@ +package org.usfirst.frc.team199.Robot2018.commands; + +import edu.wpi.first.wpilibj.command.CommandGroup; + +/** + * Gets the script name and runs the script. + */ +public class RunScript extends CommandGroup implements RunScriptInterface { + + public RunScript(String scriptName) { + // TODO + + // Add Commands here: + // e.g. addSequential(new Command1()); + // addSequential(new Command2()); + // these will run in order. + + // To run multiple commands at the same time, + // use addParallel() + // e.g. addParallel(new Command1()); + // addSequential(new Command2()); + // Command1 and Command2 will run in parallel. + + // A command group will require all of the subsystems that each member + // would require. + // e.g. if Command1 requires chassis, and Command2 requires arm, + // a CommandGroup containing them would require both the chassis and the + // arm. + } +} diff --git a/Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/RunScriptInterface.java b/Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/RunScriptInterface.java new file mode 100644 index 0000000..67fc91d --- /dev/null +++ b/Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/RunScriptInterface.java @@ -0,0 +1,4 @@ +package org.usfirst.frc.team199.Robot2018.commands; + +public interface RunScriptInterface { +} diff --git a/Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/TestAuto.java b/Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/TestAuto.java new file mode 100644 index 0000000..5687013 --- /dev/null +++ b/Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/TestAuto.java @@ -0,0 +1,40 @@ +package org.usfirst.frc.team199.Robot2018.commands; + +import edu.wpi.first.wpilibj.command.CommandGroup; + +/** + * Used for testing the autonomous interfaces. Runs the script specified in + * SmartDashboard + */ +public class TestAuto extends CommandGroup implements TestAutoInterface { + + public TestAuto() { + // TODO + + // Add Commands here: + // e.g. addSequential(new Command1()); + // addSequential(new Command2()); + // these will run in order. + + // To run multiple commands at the same time, + // use addParallel() + // e.g. addParallel(new Command1()); + // addSequential(new Command2()); + // Command1 and Command2 will run in parallel. + + // A command group will require all of the subsystems that each member + // would require. + // e.g. if Command1 requires chassis, and Command2 requires arm, + // a CommandGroup containing them would require both the chassis and the + // arm. + } + + /** + * {@inheritDoc} + */ + @Override + public String getScriptToTest() { + // TODO + return null; + } +} diff --git a/Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/TestAutoInterface.java b/Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/TestAutoInterface.java new file mode 100644 index 0000000..8cef65f --- /dev/null +++ b/Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/TestAutoInterface.java @@ -0,0 +1,12 @@ +package org.usfirst.frc.team199.Robot2018.commands; + +import org.usfirst.frc.team199.Robot2018.DashboardInterface; + +public interface TestAutoInterface extends DashboardInterface { + /** + * gets the script name that we want to run from SmartDashboard + * + * @return the script name + */ + public String getScriptToTest(); +}