From 716f78279ef2d7ba2ef6fa6f523dad775a4d5202 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Fri, 26 Jan 2018 20:32:14 -0800 Subject: [PATCH] Actually move everything into the maven build path --- src/com/github/dozer/output/Motors.java | 28 ------ src/com/github/dozer/output/ServoWrapper.java | 25 ------ src/com/github/dozer/output/Servos.java | 13 --- src/com/github/dozer/util/UpdateMotors.java | 18 ---- .../java}/com/github/dozer/TaskRobot.java | 0 .../com/github/dozer/coroutine/Task.java | 0 .../github/dozer/coroutine/TaskRunner.java | 0 .../coroutine/helpers/RunContinuousTask.java | 0 .../coroutine/helpers/RunEachFrameTask.java | 0 .../coroutine/helpers/RunParallelTask.java | 90 +++++++++---------- .../coroutine/helpers/RunSequentialTask.java | 0 .../com/github/dozer/input/OI/Input.java | 0 .../com/github/dozer/input/OI/XboxInput.java | 0 .../dozer/input/sensors/LimitSwitch.java | 0 .../dozer/input/sensors/Potentiometer.java | 0 .../dozer/input/sensors/Ultrasound.java | 0 .../dozer/output/DoubleSolenoidWrapper.java} | 4 +- .../java/com/github/dozer/output/Motor.java | 7 ++ .../com/github/dozer/output/MotorGroup.java | 0 .../github/dozer/output/MotorRamping.java} | 20 ++--- .../com/github/dozer/output/MotorSimple.java | 28 ++++++ .../java/com/github/dozer/output/Servo.java | 10 +++ .../com/github/dozer/output/ServoWrapper.java | 36 ++++++++ .../github/dozer/output/SingleSolenoid.java | 7 +- .../java}/com/github/dozer/util/PID.java | 22 ++--- .../CollectionAbortedException.java | 0 .../zoominfo/util/yieldreturn/Collector.java | 0 .../zoominfo/util/yieldreturn/Generator.java | 0 .../yieldreturn/ReferenceYieldAdapter.java | 0 .../util/yieldreturn/ResultHandler.java | 0 .../yieldreturn/ThreadedYieldAdapter.java | 0 .../util/yieldreturn/YieldAdapter.java | 0 .../yieldreturn/YieldAdapterIterable.java | 0 .../yieldreturn/YieldAdapterIterator.java | 0 34 files changed, 148 insertions(+), 160 deletions(-) delete mode 100644 src/com/github/dozer/output/Motors.java delete mode 100644 src/com/github/dozer/output/ServoWrapper.java delete mode 100644 src/com/github/dozer/output/Servos.java delete mode 100644 src/com/github/dozer/util/UpdateMotors.java rename src/{ => main/java}/com/github/dozer/TaskRobot.java (100%) rename src/{ => main/java}/com/github/dozer/coroutine/Task.java (100%) rename src/{ => main/java}/com/github/dozer/coroutine/TaskRunner.java (100%) rename src/{ => main/java}/com/github/dozer/coroutine/helpers/RunContinuousTask.java (100%) rename src/{ => main/java}/com/github/dozer/coroutine/helpers/RunEachFrameTask.java (100%) rename src/{ => main/java}/com/github/dozer/coroutine/helpers/RunParallelTask.java (96%) rename src/{ => main/java}/com/github/dozer/coroutine/helpers/RunSequentialTask.java (100%) rename src/{ => main/java}/com/github/dozer/input/OI/Input.java (100%) rename src/{ => main/java}/com/github/dozer/input/OI/XboxInput.java (100%) rename src/{ => main/java}/com/github/dozer/input/sensors/LimitSwitch.java (100%) rename src/{ => main/java}/com/github/dozer/input/sensors/Potentiometer.java (100%) rename src/{ => main/java}/com/github/dozer/input/sensors/Ultrasound.java (100%) rename src/{com/github/dozer/output/DoubleSolenoid => main/java/com/github/dozer/output/DoubleSolenoidWrapper.java} (85%) create mode 100644 src/main/java/com/github/dozer/output/Motor.java rename src/{ => main/java}/com/github/dozer/output/MotorGroup.java (100%) rename src/{com/github/dozer/output/Motor.java => main/java/com/github/dozer/output/MotorRamping.java} (70%) create mode 100644 src/main/java/com/github/dozer/output/MotorSimple.java create mode 100644 src/main/java/com/github/dozer/output/Servo.java create mode 100644 src/main/java/com/github/dozer/output/ServoWrapper.java rename src/{ => main/java}/com/github/dozer/output/SingleSolenoid.java (71%) rename src/{ => main/java}/com/github/dozer/util/PID.java (61%) rename src/{ => main/java}/com/zoominfo/util/yieldreturn/CollectionAbortedException.java (100%) rename src/{ => main/java}/com/zoominfo/util/yieldreturn/Collector.java (100%) rename src/{ => main/java}/com/zoominfo/util/yieldreturn/Generator.java (100%) rename src/{ => main/java}/com/zoominfo/util/yieldreturn/ReferenceYieldAdapter.java (100%) rename src/{ => main/java}/com/zoominfo/util/yieldreturn/ResultHandler.java (100%) rename src/{ => main/java}/com/zoominfo/util/yieldreturn/ThreadedYieldAdapter.java (100%) rename src/{ => main/java}/com/zoominfo/util/yieldreturn/YieldAdapter.java (100%) rename src/{ => main/java}/com/zoominfo/util/yieldreturn/YieldAdapterIterable.java (100%) rename src/{ => main/java}/com/zoominfo/util/yieldreturn/YieldAdapterIterator.java (100%) diff --git a/src/com/github/dozer/output/Motors.java b/src/com/github/dozer/output/Motors.java deleted file mode 100644 index 91397d5..0000000 --- a/src/com/github/dozer/output/Motors.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.github.dozer.output; - -import java.util.HashMap; -import java.util.Map; - -import com.saintsrobotics.framework.output.Motor; - -public abstract class Motors { - - - private Map motorList = new HashMap<>(); - - public void init() { - motorList.values().forEach(Motor::init); - } - - public void stopAll() { - motorList.values().forEach(Motor::stop); - } - - public void update() { - motorList.values().forEach(Motor::update); - } - public Motor get(String motorName) { - return this.motorList.get(motorName); - - } -} diff --git a/src/com/github/dozer/output/ServoWrapper.java b/src/com/github/dozer/output/ServoWrapper.java deleted file mode 100644 index 887a49c..0000000 --- a/src/com/github/dozer/output/ServoWrapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.github.dozer.output; - -import edu.wpi.first.wpilibj.Servo; - -public class ServoWrapper { - - private final int pin; - private Servo servo; - - ServoWrapper(int pin) { - this.pin = pin; - } - - void init() { - if (pin != -1) { - servo = new Servo(pin); - } - } - - public void setAngle(double degrees) { - if (pin != -1) { - servo.setAngle(degrees); - } - } -} diff --git a/src/com/github/dozer/output/Servos.java b/src/com/github/dozer/output/Servos.java deleted file mode 100644 index 8a43f88..0000000 --- a/src/com/github/dozer/output/Servos.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.github.dozer.output; - -import java.util.HashMap; -import java.util.Map; - -public abstract class Servos { - - private Map servos = new HashMap<>(); - - public void init() { - servos.values().forEach(ServoWrapper::init); - } -} diff --git a/src/com/github/dozer/util/UpdateMotors.java b/src/com/github/dozer/util/UpdateMotors.java deleted file mode 100644 index 006d984..0000000 --- a/src/com/github/dozer/util/UpdateMotors.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.github.dozer.util; - - -import com.github.dozer.coroutine.helpers.RunEachFrameTask; -import com.github.dozer.output.Motors; - -public class UpdateMotors extends RunEachFrameTask { - private Motors motors; - - public UpdateMotors(Motors motors) { - this.motors = motors; - } - - @Override - protected void runEachFrame() { - motors.update(); - } -} diff --git a/src/com/github/dozer/TaskRobot.java b/src/main/java/com/github/dozer/TaskRobot.java similarity index 100% rename from src/com/github/dozer/TaskRobot.java rename to src/main/java/com/github/dozer/TaskRobot.java diff --git a/src/com/github/dozer/coroutine/Task.java b/src/main/java/com/github/dozer/coroutine/Task.java similarity index 100% rename from src/com/github/dozer/coroutine/Task.java rename to src/main/java/com/github/dozer/coroutine/Task.java diff --git a/src/com/github/dozer/coroutine/TaskRunner.java b/src/main/java/com/github/dozer/coroutine/TaskRunner.java similarity index 100% rename from src/com/github/dozer/coroutine/TaskRunner.java rename to src/main/java/com/github/dozer/coroutine/TaskRunner.java diff --git a/src/com/github/dozer/coroutine/helpers/RunContinuousTask.java b/src/main/java/com/github/dozer/coroutine/helpers/RunContinuousTask.java similarity index 100% rename from src/com/github/dozer/coroutine/helpers/RunContinuousTask.java rename to src/main/java/com/github/dozer/coroutine/helpers/RunContinuousTask.java diff --git a/src/com/github/dozer/coroutine/helpers/RunEachFrameTask.java b/src/main/java/com/github/dozer/coroutine/helpers/RunEachFrameTask.java similarity index 100% rename from src/com/github/dozer/coroutine/helpers/RunEachFrameTask.java rename to src/main/java/com/github/dozer/coroutine/helpers/RunEachFrameTask.java diff --git a/src/com/github/dozer/coroutine/helpers/RunParallelTask.java b/src/main/java/com/github/dozer/coroutine/helpers/RunParallelTask.java similarity index 96% rename from src/com/github/dozer/coroutine/helpers/RunParallelTask.java rename to src/main/java/com/github/dozer/coroutine/helpers/RunParallelTask.java index 068fb4a..a2efff0 100644 --- a/src/com/github/dozer/coroutine/helpers/RunParallelTask.java +++ b/src/main/java/com/github/dozer/coroutine/helpers/RunParallelTask.java @@ -1,45 +1,45 @@ -package com.github.dozer.coroutine.helpers; - -import java.util.Arrays; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - - -import com.github.dozer.coroutine.Task; -import com.github.dozer.coroutine.helpers.RunContinuousTask; - -public class RunParallelTask extends RunContinuousTask { - - private List tasks; - - public RunParallelTask(Task... tasks) { - System.out.println("Parallel task constructor"); - this.tasks = new LinkedList<>(); - this.tasks.addAll(Arrays.asList(tasks)); - } - - @Override - protected boolean runContinuously() { - for (Iterator taskIterator = tasks.iterator(); taskIterator.hasNext();) { - - Task task = taskIterator.next(); - if (task.iterator == null) { - task.iterator = task.iterator(); - } - - if (task.waiter != null && task.waiter.getAsBoolean()) { - if (task.iterator.hasNext()) { -// System.out.println(task.toString() + " has next"); - task.waiter = task.iterator.next(); - } else { -// System.out.println(task.toString() + " removed"); - - taskIterator.remove(); - } - } - } - return tasks.isEmpty(); - } -} - +package com.github.dozer.coroutine.helpers; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + + +import com.github.dozer.coroutine.Task; +import com.github.dozer.coroutine.helpers.RunContinuousTask; + +public class RunParallelTask extends RunContinuousTask { + + private List tasks; + + public RunParallelTask(Task... tasks) { + System.out.println("Parallel task constructor"); + this.tasks = new LinkedList<>(); + this.tasks.addAll(Arrays.asList(tasks)); + } + + @Override + protected boolean runContinuously() { + for (Iterator taskIterator = tasks.iterator(); taskIterator.hasNext();) { + + Task task = taskIterator.next(); + if (task.iterator == null) { + task.iterator = task.iterator(); + } + + if (task.waiter != null && task.waiter.getAsBoolean()) { + if (task.iterator.hasNext()) { +// System.out.println(task.toString() + " has next"); + task.waiter = task.iterator.next(); + } else { +// System.out.println(task.toString() + " removed"); + + taskIterator.remove(); + } + } + } + return tasks.isEmpty(); + } +} + diff --git a/src/com/github/dozer/coroutine/helpers/RunSequentialTask.java b/src/main/java/com/github/dozer/coroutine/helpers/RunSequentialTask.java similarity index 100% rename from src/com/github/dozer/coroutine/helpers/RunSequentialTask.java rename to src/main/java/com/github/dozer/coroutine/helpers/RunSequentialTask.java diff --git a/src/com/github/dozer/input/OI/Input.java b/src/main/java/com/github/dozer/input/OI/Input.java similarity index 100% rename from src/com/github/dozer/input/OI/Input.java rename to src/main/java/com/github/dozer/input/OI/Input.java diff --git a/src/com/github/dozer/input/OI/XboxInput.java b/src/main/java/com/github/dozer/input/OI/XboxInput.java similarity index 100% rename from src/com/github/dozer/input/OI/XboxInput.java rename to src/main/java/com/github/dozer/input/OI/XboxInput.java diff --git a/src/com/github/dozer/input/sensors/LimitSwitch.java b/src/main/java/com/github/dozer/input/sensors/LimitSwitch.java similarity index 100% rename from src/com/github/dozer/input/sensors/LimitSwitch.java rename to src/main/java/com/github/dozer/input/sensors/LimitSwitch.java diff --git a/src/com/github/dozer/input/sensors/Potentiometer.java b/src/main/java/com/github/dozer/input/sensors/Potentiometer.java similarity index 100% rename from src/com/github/dozer/input/sensors/Potentiometer.java rename to src/main/java/com/github/dozer/input/sensors/Potentiometer.java diff --git a/src/com/github/dozer/input/sensors/Ultrasound.java b/src/main/java/com/github/dozer/input/sensors/Ultrasound.java similarity index 100% rename from src/com/github/dozer/input/sensors/Ultrasound.java rename to src/main/java/com/github/dozer/input/sensors/Ultrasound.java diff --git a/src/com/github/dozer/output/DoubleSolenoid b/src/main/java/com/github/dozer/output/DoubleSolenoidWrapper.java similarity index 85% rename from src/com/github/dozer/output/DoubleSolenoid rename to src/main/java/com/github/dozer/output/DoubleSolenoidWrapper.java index a29c494..065c9ca 100644 --- a/src/com/github/dozer/output/DoubleSolenoid +++ b/src/main/java/com/github/dozer/output/DoubleSolenoidWrapper.java @@ -2,12 +2,12 @@ import edu.wpi.first.wpilibj.DoubleSolenoid; -public class DoubleSolenoid { +public class DoubleSolenoidWrapper { private final int pin1; private final int pin2; private DoubleSolenoid doubleSolenoid; - DoubleSolenoid(int pin1, int pin2) { + DoubleSolenoidWrapper(int pin1, int pin2) { // TODO Generic this in some way. this.pin1 = pin1; this.pin2 = pin2; diff --git a/src/main/java/com/github/dozer/output/Motor.java b/src/main/java/com/github/dozer/output/Motor.java new file mode 100644 index 0000000..02c5efb --- /dev/null +++ b/src/main/java/com/github/dozer/output/Motor.java @@ -0,0 +1,7 @@ +package com.github.dozer.output; + +public interface Motor{ + public void set(double speed); + public double get(); + public void stop(); +} \ No newline at end of file diff --git a/src/com/github/dozer/output/MotorGroup.java b/src/main/java/com/github/dozer/output/MotorGroup.java similarity index 100% rename from src/com/github/dozer/output/MotorGroup.java rename to src/main/java/com/github/dozer/output/MotorGroup.java diff --git a/src/com/github/dozer/output/Motor.java b/src/main/java/com/github/dozer/output/MotorRamping.java similarity index 70% rename from src/com/github/dozer/output/Motor.java rename to src/main/java/com/github/dozer/output/MotorRamping.java index 7dd72f2..d00ceb7 100644 --- a/src/com/github/dozer/output/Motor.java +++ b/src/main/java/com/github/dozer/output/MotorRamping.java @@ -3,27 +3,23 @@ import edu.wpi.first.wpilibj.SpeedController; import edu.wpi.first.wpilibj.PWMTalonSRX; -public class Motor { +public class MotorRamping implements Motor{ public static final double MOTOR_RAMPING = 0.01; - private final int pin; - private final boolean inverted; private SpeedController speedController; - Motor(int pin, boolean inverted) { - // TODO Generic this in some way. - this.pin = pin; - this.inverted = inverted; - } - - public void init() { - speedController = new PWMTalonSRX(pin); - speedController.setInverted(inverted); + MotorRamping(SpeedController speedController, boolean inverted) { + this.speedController = speedController; + this.speedController.setInverted(inverted); } private double setpoint = 0; private double current = 0; + public double get(){ + return speedController.get(); + } + public void set(double speed) { setpoint = speed; diff --git a/src/main/java/com/github/dozer/output/MotorSimple.java b/src/main/java/com/github/dozer/output/MotorSimple.java new file mode 100644 index 0000000..d8675f9 --- /dev/null +++ b/src/main/java/com/github/dozer/output/MotorSimple.java @@ -0,0 +1,28 @@ +package com.github.dozer.output; + +import edu.wpi.first.wpilibj.SpeedController; + +public class MotorSimple implements Motor { + private SpeedController speedController; + + MotorSimple(SpeedController speedController, boolean inverted) { + this.speedController = speedController; + this.speedController.setInverted(inverted); + } + + private double setpoint = 0; + private double current = 0; + + public double get(){ + return speedController.get(); + } + + + public void set(double speed) { + this.speedController.set(speed); + } + + public void stop() { + speedController.stopMotor(); + } +} diff --git a/src/main/java/com/github/dozer/output/Servo.java b/src/main/java/com/github/dozer/output/Servo.java new file mode 100644 index 0000000..1595921 --- /dev/null +++ b/src/main/java/com/github/dozer/output/Servo.java @@ -0,0 +1,10 @@ +package com.github.dozer.output; + +public interface Servo { + public void setAngle(double angle); + public double getAngle(); + public void setRadians(double rads); + public double getRadians(); + public void setPosition(double pos); + public double getPosition(); +} diff --git a/src/main/java/com/github/dozer/output/ServoWrapper.java b/src/main/java/com/github/dozer/output/ServoWrapper.java new file mode 100644 index 0000000..a1d173f --- /dev/null +++ b/src/main/java/com/github/dozer/output/ServoWrapper.java @@ -0,0 +1,36 @@ +package com.github.dozer.output; + + +public class ServoWrapper implements Servo { + + private edu.wpi.first.wpilibj.Servo servo; + + ServoWrapper(int pin) { + this.servo = new edu.wpi.first.wpilibj.Servo(pin); + } + + + public void setAngle(double degrees) { + servo.setAngle(degrees); + } + + public double getAngle(){ + return servo.getAngle(); + } + + public void setRadians(double radians) { + this.setAngle(Math.toDegrees(radians)); + } + + public double getRadians(){ + return Math.toDegrees(this.getAngle()); + } + + public void setPosition(double pos){ + servo.setPosition(pos); + } + + public double getPosition(){ + return servo.get(); + } +} diff --git a/src/com/github/dozer/output/SingleSolenoid.java b/src/main/java/com/github/dozer/output/SingleSolenoid.java similarity index 71% rename from src/com/github/dozer/output/SingleSolenoid.java rename to src/main/java/com/github/dozer/output/SingleSolenoid.java index 3d14c96..584d49f 100644 --- a/src/com/github/dozer/output/SingleSolenoid.java +++ b/src/main/java/com/github/dozer/output/SingleSolenoid.java @@ -3,17 +3,12 @@ import edu.wpi.first.wpilibj.Solenoid; public class SingleSolenoid { - private final int pin; private Solenoid solenoid; SingleSolenoid(int pin) { - // TODO Generic this in some way. - this.pin = pin; + this.solenoid = new Solenoid(pin); } - public void init() { - solenoid = new Solenoid(pin); - } //This used to be a double. Not sure why, since solenoid has only had a public void set(boolean on) { diff --git a/src/com/github/dozer/util/PID.java b/src/main/java/com/github/dozer/util/PID.java similarity index 61% rename from src/com/github/dozer/util/PID.java rename to src/main/java/com/github/dozer/util/PID.java index 5d58b90..83887c4 100644 --- a/src/com/github/dozer/util/PID.java +++ b/src/main/java/com/github/dozer/util/PID.java @@ -26,21 +26,21 @@ public PID(double kp, double ki, double kd, double maxSum) { public double compute(double input, double setpoint) { double error = setpoint - input; - errorSum += error * ki; - if (errorSum < -maxSum) - errorSum = -maxSum; - if (errorSum > maxSum) - errorSum = maxSum; + this.errorSum += error * ki; + if (this.errorSum < -this.maxSum) + this.errorSum = -this.maxSum; + if (this.errorSum > this.maxSum) + this.errorSum = this.maxSum; SmartDashboard.putNumber("pid_error_sum", errorSum); - double output = kp * error + errorSum - kd * (error - lastError); - if (output < outMin) - output = outMin; - if (output > outMax) - output = outMax; + double output = this.kp * error + this.errorSum - this.kd * (error - this.lastError); + if (output < this.outMin) + output = this.outMin; + if (output > this.outMax) + output = this.outMax; - lastError = error; + this.lastError = error; return output; } } diff --git a/src/com/zoominfo/util/yieldreturn/CollectionAbortedException.java b/src/main/java/com/zoominfo/util/yieldreturn/CollectionAbortedException.java similarity index 100% rename from src/com/zoominfo/util/yieldreturn/CollectionAbortedException.java rename to src/main/java/com/zoominfo/util/yieldreturn/CollectionAbortedException.java diff --git a/src/com/zoominfo/util/yieldreturn/Collector.java b/src/main/java/com/zoominfo/util/yieldreturn/Collector.java similarity index 100% rename from src/com/zoominfo/util/yieldreturn/Collector.java rename to src/main/java/com/zoominfo/util/yieldreturn/Collector.java diff --git a/src/com/zoominfo/util/yieldreturn/Generator.java b/src/main/java/com/zoominfo/util/yieldreturn/Generator.java similarity index 100% rename from src/com/zoominfo/util/yieldreturn/Generator.java rename to src/main/java/com/zoominfo/util/yieldreturn/Generator.java diff --git a/src/com/zoominfo/util/yieldreturn/ReferenceYieldAdapter.java b/src/main/java/com/zoominfo/util/yieldreturn/ReferenceYieldAdapter.java similarity index 100% rename from src/com/zoominfo/util/yieldreturn/ReferenceYieldAdapter.java rename to src/main/java/com/zoominfo/util/yieldreturn/ReferenceYieldAdapter.java diff --git a/src/com/zoominfo/util/yieldreturn/ResultHandler.java b/src/main/java/com/zoominfo/util/yieldreturn/ResultHandler.java similarity index 100% rename from src/com/zoominfo/util/yieldreturn/ResultHandler.java rename to src/main/java/com/zoominfo/util/yieldreturn/ResultHandler.java diff --git a/src/com/zoominfo/util/yieldreturn/ThreadedYieldAdapter.java b/src/main/java/com/zoominfo/util/yieldreturn/ThreadedYieldAdapter.java similarity index 100% rename from src/com/zoominfo/util/yieldreturn/ThreadedYieldAdapter.java rename to src/main/java/com/zoominfo/util/yieldreturn/ThreadedYieldAdapter.java diff --git a/src/com/zoominfo/util/yieldreturn/YieldAdapter.java b/src/main/java/com/zoominfo/util/yieldreturn/YieldAdapter.java similarity index 100% rename from src/com/zoominfo/util/yieldreturn/YieldAdapter.java rename to src/main/java/com/zoominfo/util/yieldreturn/YieldAdapter.java diff --git a/src/com/zoominfo/util/yieldreturn/YieldAdapterIterable.java b/src/main/java/com/zoominfo/util/yieldreturn/YieldAdapterIterable.java similarity index 100% rename from src/com/zoominfo/util/yieldreturn/YieldAdapterIterable.java rename to src/main/java/com/zoominfo/util/yieldreturn/YieldAdapterIterable.java diff --git a/src/com/zoominfo/util/yieldreturn/YieldAdapterIterator.java b/src/main/java/com/zoominfo/util/yieldreturn/YieldAdapterIterator.java similarity index 100% rename from src/com/zoominfo/util/yieldreturn/YieldAdapterIterator.java rename to src/main/java/com/zoominfo/util/yieldreturn/YieldAdapterIterator.java