Skip to content

Commit

Permalink
Actually move everything into the maven build path
Browse files Browse the repository at this point in the history
  • Loading branch information
PrecociouslyDigital committed Jan 27, 2018
1 parent 967feba commit 716f782
Show file tree
Hide file tree
Showing 34 changed files with 148 additions and 160 deletions.
28 changes: 0 additions & 28 deletions src/com/github/dozer/output/Motors.java

This file was deleted.

25 changes: 0 additions & 25 deletions src/com/github/dozer/output/ServoWrapper.java

This file was deleted.

13 changes: 0 additions & 13 deletions src/com/github/dozer/output/Servos.java

This file was deleted.

18 changes: 0 additions & 18 deletions src/com/github/dozer/util/UpdateMotors.java

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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<Task> 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<Task> 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<Task> 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<Task> 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();
}
}

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/github/dozer/output/Motor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.github.dozer.output;

public interface Motor{
public void set(double speed);
public double get();
public void stop();
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/com/github/dozer/output/MotorSimple.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
10 changes: 10 additions & 0 deletions src/main/java/com/github/dozer/output/Servo.java
Original file line number Diff line number Diff line change
@@ -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();
}
36 changes: 36 additions & 0 deletions src/main/java/com/github/dozer/output/ServoWrapper.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 716f782

Please sign in to comment.