DummySensor class, shoot is tested

This commit is contained in:
aarav18
2022-03-05 11:07:54 -07:00
parent 71e082e7bd
commit f895352bb9
10 changed files with 185 additions and 119 deletions
@@ -0,0 +1,74 @@
// 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 frc4388.utility;
import java.util.ArrayList;
public class DummySensor {
private double value;
public double start;
public static ArrayList<DummySensor> instances = new ArrayList<DummySensor>();
/**
* Creates a new DummySensor, which is a helper class for conducting PID tests without a physical robot.
* @param init The start "position" of the sensor (default is 0).
*/
public DummySensor(double init) {
value = init;
start = init;
instances.add(this);
}
/**
* Creates a new DummySensor, which is a helper class for conducting PID tests without a physical robot.
*/
public DummySensor() {
value = 0;
start = 0;
instances.add(this);
}
/**
* Reset the "position" of the DummySensor to its starting value.
*/
public void reset() {
value = start;
}
/**
* Reset the "position" of the DummySensor to a given value.
* @param val The "position" to reset the DummySensor to.
*/
public void reset(double val) {
value = val;
}
/**
* Reset all instances of DummySensor to their starting values.
*/
public static void resetAll() {
for (DummySensor instance : instances) {
instance.reset();
}
}
/**
* Get the "position" of the DummySensor.
* @return The current "position".
*/
public double get() {
return value;
}
/**
* Apply an input to the DummySensor, changing its "position".
* @param input The input to apply.
*/
public void apply(double input) {
value = value + input;
}
}
+24 -24
View File
@@ -6,14 +6,14 @@ package frc4388.utility;
/** Add your docs here. */
public class Gains {
public double m_kP;
public double m_kI;
public double m_kD;
public double m_kF;
public int m_kIzone;
public double m_kPeakOutput;
public double m_kmaxOutput;
public double m_kminOutput;
public double kP;
public double kI;
public double kD;
public double kF;
public int kIzone;
public double kPeakOutput;
public double kmaxOutput;
public double kminOutput;
/**
* Creates Gains object for PIDs
@@ -26,14 +26,14 @@ public class Gains {
*/
public Gains(double kP, double kI, double kD, double kF, int kIzone, double kPeakOutput)
{
m_kP = kP;
m_kI = kI;
m_kD = kD;
m_kF = kF;
m_kIzone = kIzone;
m_kPeakOutput = kPeakOutput;
m_kmaxOutput = m_kPeakOutput;
m_kminOutput = -m_kPeakOutput;
this.kP = kP;
this.kI = kI;
this.kD = kD;
this.kF = kF;
this.kIzone = kIzone;
this.kPeakOutput = kPeakOutput;
this.kmaxOutput = this.kPeakOutput;
this.kminOutput = -this.kPeakOutput;
}
/**
@@ -48,13 +48,13 @@ public class Gains {
*/
public Gains(double kP, double kI, double kD, double kF, int kIzone, double kMinOutput, double kMaxOutput)
{
m_kP = kP;
m_kI = kI;
m_kD = kD;
m_kF = kF;
m_kIzone = kIzone;
m_kminOutput = kMinOutput;
m_kmaxOutput = kMaxOutput;
m_kPeakOutput = (Math.abs(m_kminOutput) > Math.abs(m_kmaxOutput)) ? Math.abs(m_kminOutput) : Math.abs(m_kmaxOutput);
this.kP = kP;
this.kI = kI;
this.kD = kD;
this.kF = kF;
this.kIzone = kIzone;
this.kminOutput = kMinOutput;
this.kmaxOutput = kMaxOutput;
this.kPeakOutput = (Math.abs(this.kminOutput) > Math.abs(this.kmaxOutput)) ? Math.abs(this.kminOutput) : Math.abs(this.kmaxOutput);
}
}