From 9d0057ac6505d3678e7afc6ad2dee5f4134fb624 Mon Sep 17 00:00:00 2001 From: amrrao Date: Fri, 28 Jan 2022 18:20:52 -0800 Subject: [PATCH 1/5] made indexer off command --- .../org/usfirst/frc4904/robot/RobotMap.java | 5 +++++ .../frc4904/robot/commands/IndexerOff.java | 0 .../frc4904/robot/commands/IndexerOn.java | 0 .../robot/subsystems/MotorTestSubsystem.java | 21 +++++++++++++++++++ .../robot/subsystems/SubsystemBase.java | 0 5 files changed, 26 insertions(+) create mode 100644 src/main/java/org/usfirst/frc4904/robot/commands/IndexerOff.java create mode 100644 src/main/java/org/usfirst/frc4904/robot/commands/IndexerOn.java create mode 100644 src/main/java/org/usfirst/frc4904/robot/subsystems/MotorTestSubsystem.java create mode 100644 src/main/java/org/usfirst/frc4904/robot/subsystems/SubsystemBase.java diff --git a/src/main/java/org/usfirst/frc4904/robot/RobotMap.java b/src/main/java/org/usfirst/frc4904/robot/RobotMap.java index dd4b24d..4997cc4 100644 --- a/src/main/java/org/usfirst/frc4904/robot/RobotMap.java +++ b/src/main/java/org/usfirst/frc4904/robot/RobotMap.java @@ -3,6 +3,8 @@ import edu.wpi.first.wpilibj2.command.Subsystem; import org.usfirst.frc4904.standard.custom.controllers.CustomJoystick; import org.usfirst.frc4904.standard.custom.controllers.CustomXbox; +import org.usfirst.frc4904.standard.custom.motioncontrollers.CANTalonFX; +import org.usfirst.frc4904.standard.subsystems.motor.Motor; public class RobotMap { public static class Port { @@ -12,6 +14,7 @@ public static class HumanInput { } public static class CANMotor { + public static final int indexerMotor = -1; // TODO: set port } public static class PWM { @@ -51,6 +54,7 @@ public static class Turn { } public static class Component { + public static Motor indexerMotor; } public static class Input { @@ -70,5 +74,6 @@ public RobotMap() { HumanInput.Driver.xbox = new CustomXbox(Port.HumanInput.xboxController); HumanInput.Operator.joystick = new CustomJoystick(Port.HumanInput.joystick); + Component.indexerMotor = new Motor("indexerMotor", false, new CANTalonFX(Port.CANMotor.indexerMotor)); } } \ No newline at end of file diff --git a/src/main/java/org/usfirst/frc4904/robot/commands/IndexerOff.java b/src/main/java/org/usfirst/frc4904/robot/commands/IndexerOff.java new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/org/usfirst/frc4904/robot/commands/IndexerOn.java b/src/main/java/org/usfirst/frc4904/robot/commands/IndexerOn.java new file mode 100644 index 0000000..e69de29 diff --git a/src/main/java/org/usfirst/frc4904/robot/subsystems/MotorTestSubsystem.java b/src/main/java/org/usfirst/frc4904/robot/subsystems/MotorTestSubsystem.java new file mode 100644 index 0000000..a79a863 --- /dev/null +++ b/src/main/java/org/usfirst/frc4904/robot/subsystems/MotorTestSubsystem.java @@ -0,0 +1,21 @@ +import edu.wpi.first.wpilibj.motorcontrol.MotorController; + +//motor code to turn on and off +//import org.usfirst.frc4904.standard.subsystems.motor; + + +public class MotorTestSubsystem extends MotorController { + Motor motor1 = new motor(); + for (MotorController motor : motors) { + if (motor instanceof IMotorController) + ((IMotorController) motor).enableVoltageCompensation(true); + motor.set(5); // Start all motors with 5 speed + + @Override + public void stopMotor() { + for (MotorController motor : motors) { + motor.stopMotor(); + } + } + +} \ No newline at end of file diff --git a/src/main/java/org/usfirst/frc4904/robot/subsystems/SubsystemBase.java b/src/main/java/org/usfirst/frc4904/robot/subsystems/SubsystemBase.java new file mode 100644 index 0000000..e69de29 From 071ecd87fae373d3cf838ba14bb542e7e916c0e5 Mon Sep 17 00:00:00 2001 From: amrrao Date: Sun, 30 Jan 2022 09:49:20 -0800 Subject: [PATCH 2/5] made indexer commands --- build.gradle | 2 +- .../robot/subsystems/MotorTestSubsystem.java | 21 ------------------- 2 files changed, 1 insertion(+), 22 deletions(-) delete mode 100644 src/main/java/org/usfirst/frc4904/robot/subsystems/MotorTestSubsystem.java diff --git a/build.gradle b/build.gradle index 9c0052a..9310189 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ import edu.wpi.first.gradlerio.deploy.roborio.RoboRIO plugins { id "java" - id "edu.wpi.first.GradleRIO" version "2022.1.1" + id "edu.wpi.first.GradleRIO" version "2022.2.1" } sourceCompatibility = JavaVersion.VERSION_11 diff --git a/src/main/java/org/usfirst/frc4904/robot/subsystems/MotorTestSubsystem.java b/src/main/java/org/usfirst/frc4904/robot/subsystems/MotorTestSubsystem.java deleted file mode 100644 index a79a863..0000000 --- a/src/main/java/org/usfirst/frc4904/robot/subsystems/MotorTestSubsystem.java +++ /dev/null @@ -1,21 +0,0 @@ -import edu.wpi.first.wpilibj.motorcontrol.MotorController; - -//motor code to turn on and off -//import org.usfirst.frc4904.standard.subsystems.motor; - - -public class MotorTestSubsystem extends MotorController { - Motor motor1 = new motor(); - for (MotorController motor : motors) { - if (motor instanceof IMotorController) - ((IMotorController) motor).enableVoltageCompensation(true); - motor.set(5); // Start all motors with 5 speed - - @Override - public void stopMotor() { - for (MotorController motor : motors) { - motor.stopMotor(); - } - } - -} \ No newline at end of file From 5c649edc670f8cfadd06066ed91c4ec048b0496b Mon Sep 17 00:00:00 2001 From: amrrao Date: Sun, 30 Jan 2022 10:10:34 -0800 Subject: [PATCH 3/5] Added indexer off and on commands --- .../org/usfirst/frc4904/robot/RobotMap.java | 3 ++- .../frc4904/robot/commands/IndexerOff.java | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/usfirst/frc4904/robot/RobotMap.java b/src/main/java/org/usfirst/frc4904/robot/RobotMap.java index 4997cc4..def10cf 100644 --- a/src/main/java/org/usfirst/frc4904/robot/RobotMap.java +++ b/src/main/java/org/usfirst/frc4904/robot/RobotMap.java @@ -55,6 +55,7 @@ public static class Turn { public static class Component { public static Motor indexerMotor; + public static Motor motor; } public static class Input { @@ -76,4 +77,4 @@ public RobotMap() { Component.indexerMotor = new Motor("indexerMotor", false, new CANTalonFX(Port.CANMotor.indexerMotor)); } -} \ No newline at end of file +} diff --git a/src/main/java/org/usfirst/frc4904/robot/commands/IndexerOff.java b/src/main/java/org/usfirst/frc4904/robot/commands/IndexerOff.java index e69de29..b8f1c75 100644 --- a/src/main/java/org/usfirst/frc4904/robot/commands/IndexerOff.java +++ b/src/main/java/org/usfirst/frc4904/robot/commands/IndexerOff.java @@ -0,0 +1,21 @@ +package org.usfirst.frc4904.robot.commands; + +import org.usfirst.frc4904.robot.RobotMap; +import org.usfirst.frc4904.standard.commands.motor.MotorIdle; +import org.usfirst.frc4904.standard.subsystems.motor.Motor; + +public class IndexerOff extends MotorIdle { + + /** + * Set motor speed to zero + * + * @param motor The motor to manipulate + */ + public IndexerOff(Motor motor) { + super(motor, 0.0); + } + + public IndexerOff() { + super(RobotMap.Component.motor, 0.0); + } +} From 116141569005564e00d3298513393f888fd03d2e Mon Sep 17 00:00:00 2001 From: amrrao Date: Sun, 30 Jan 2022 10:14:17 -0800 Subject: [PATCH 4/5] added on and off indexer commands --- .../org/usfirst/frc4904/robot/commands/IndexerOn.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/org/usfirst/frc4904/robot/commands/IndexerOn.java b/src/main/java/org/usfirst/frc4904/robot/commands/IndexerOn.java index e69de29..2d1355b 100644 --- a/src/main/java/org/usfirst/frc4904/robot/commands/IndexerOn.java +++ b/src/main/java/org/usfirst/frc4904/robot/commands/IndexerOn.java @@ -0,0 +1,11 @@ +package org.usfirst.frc4904.robot.commands; + +import org.usfirst.frc4904.robot.RobotMap; +import org.usfirst.frc4904.standard.commands.motor.MotorConstant; + +public class IndexerOn extends MotorConstant { + public final static double DEFAULT_INTAKE_MOTOR_SPEED = 0.5; //TODO: needs value + public IndexerOn() { + super("IndexerOn", RobotMap.Component.motor, DEFAULT_INTAKE_MOTOR_SPEED); + } +} From 7f094215d453c1cbb05947aa24e825401f31bc8b Mon Sep 17 00:00:00 2001 From: amrrao Date: Sun, 30 Jan 2022 15:07:27 -0800 Subject: [PATCH 5/5] made requested changes to indexer commands --- .../java/org/usfirst/frc4904/robot/RobotMap.java | 2 +- .../usfirst/frc4904/robot/commands/IndexerOff.java | 12 +++--------- .../frc4904/robot/subsystems/SubsystemBase.java | 0 3 files changed, 4 insertions(+), 10 deletions(-) delete mode 100644 src/main/java/org/usfirst/frc4904/robot/subsystems/SubsystemBase.java diff --git a/src/main/java/org/usfirst/frc4904/robot/RobotMap.java b/src/main/java/org/usfirst/frc4904/robot/RobotMap.java index def10cf..312c112 100644 --- a/src/main/java/org/usfirst/frc4904/robot/RobotMap.java +++ b/src/main/java/org/usfirst/frc4904/robot/RobotMap.java @@ -75,6 +75,6 @@ public RobotMap() { HumanInput.Driver.xbox = new CustomXbox(Port.HumanInput.xboxController); HumanInput.Operator.joystick = new CustomJoystick(Port.HumanInput.joystick); - Component.indexerMotor = new Motor("indexerMotor", false, new CANTalonFX(Port.CANMotor.indexerMotor)); + Component.indexerMotor = new Motor("indexerMotor", false, new CANTalonFX(Port.CANMotor.indexerMotor)); // TODO: Need to check motor inversion } } diff --git a/src/main/java/org/usfirst/frc4904/robot/commands/IndexerOff.java b/src/main/java/org/usfirst/frc4904/robot/commands/IndexerOff.java index b8f1c75..dda14af 100644 --- a/src/main/java/org/usfirst/frc4904/robot/commands/IndexerOff.java +++ b/src/main/java/org/usfirst/frc4904/robot/commands/IndexerOff.java @@ -2,20 +2,14 @@ import org.usfirst.frc4904.robot.RobotMap; import org.usfirst.frc4904.standard.commands.motor.MotorIdle; -import org.usfirst.frc4904.standard.subsystems.motor.Motor; + public class IndexerOff extends MotorIdle { /** - * Set motor speed to zero - * - * @param motor The motor to manipulate + * Set indexer motor speed to zero */ - public IndexerOff(Motor motor) { - super(motor, 0.0); - } - public IndexerOff() { - super(RobotMap.Component.motor, 0.0); + super(RobotMap.Component.indexerMotor); } } diff --git a/src/main/java/org/usfirst/frc4904/robot/subsystems/SubsystemBase.java b/src/main/java/org/usfirst/frc4904/robot/subsystems/SubsystemBase.java deleted file mode 100644 index e69de29..0000000