Skip to content

Commit

Permalink
Minor Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Mason-Lam committed Nov 28, 2023
1 parent 9517191 commit dc8b6fd
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 40 deletions.
4 changes: 2 additions & 2 deletions 3128-Common.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "3128-common",
"version": "0.0.6",
"version": "0.0.7",
"uuid": "ae3fa5a2-78d9-47e8-921a-dba45b889445",
"mavenUrls": [
"https://jitpack.io"
Expand All @@ -11,7 +11,7 @@
{
"groupId": "com.github.Team3128",
"artifactId": "3128-common",
"version": "0.0.6"
"version": "0.0.7"
}
],
"jniDependencies": [],
Expand Down
4 changes: 2 additions & 2 deletions 3128-common.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "3128-common",
"version": "0.0.6",
"version": "0.0.7",
"uuid": "ae3fa5a2-78d9-47e8-921a-dba45b889445",
"mavenUrls": [
"https://jitpack.io"
Expand All @@ -11,7 +11,7 @@
{
"groupId": "com.github.Team3128",
"artifactId": "3128-common",
"version": "0.0.6"
"version": "0.0.7"
}
],
"jniDependencies": [],
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/common/core/controllers/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@ public Controller(double kP, double kI, double kD, double kS, double kV, double
this.type = type;
}

/**
* Create a new object to control PID + FF logic for a subsystem.
* <p>Sets kP, kI, kD, kS, kV, kG values.
*
* @param kP The proportional coefficient.
* @param kI The integral coefficient.
* @param kD The derivative coefficient.
* @param kS The static gain.
* @param kV The velocity gain.
* @param kG The gravity gain.
* @param type The type of setpoint used by the controller
*/
public Controller(double kP, double kI, double kD, double kS, double kV, double kG, Type type) {
this(kP, kI, kD, kS, kV, kG, type, 0.02);
}

/**
* Create a new object to control PID logic for a subsystem.
* <p>Sets kP, kI, kD, period values.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/common/core/subsystems/NAR_PIDSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public abstract class NAR_PIDSubsystem extends SubsystemBase {
public NAR_PIDSubsystem(Controller controller) {
m_controller = controller;
controller.setMeasurementSource(()-> getMeasurement());
controller.addOutput(this::useOutput);
controller.addOutput(output -> useOutput(output, getSetpoint()));
min = Double.NEGATIVE_INFINITY;
max = Double.POSITIVE_INFINITY;
safetyThresh = 5;
Expand Down Expand Up @@ -166,7 +166,7 @@ public boolean atSetpoint() {
*
* @param output the output of the PIDController
*/
protected abstract void useOutput(double output);
protected abstract void useOutput(double output, double setpoint);

/**
* Returns the measurement of the process variable used by the PIDController.
Expand All @@ -185,7 +185,7 @@ public void enable() {
/** Disables the PID control. Sets output to zero. */
public void disable() {
m_enabled = false;
useOutput(0);
useOutput(0, 0);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ private NarwhalDashboard(int port) throws UnknownHostException {
super(new InetSocketAddress(port));
}

/**
* Returns the selectedAuto on the web server
* @return A string containing an auto
*/
public String getSelectedAuto() {
return selectedAuto;
}

/**
* Initializes NarwhalDashboard autos and buttons
*/
Expand Down Expand Up @@ -203,6 +211,7 @@ public void addButton(String key, BooleanConsumer button) {
@Override
public void onMessage(WebSocket conn, String message) {
Log.info("NarwhalDashboard", message);
//Message format category + key + value or category + value, example auto:"exampleAuto"
final String[] parts = message.split(":");

if (!actionMap.containsKey(parts[0])) return;
Expand Down
66 changes: 33 additions & 33 deletions src/main/java/common/utility/shuffleboard/NAR_Shuffleboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,24 @@ public void update() {
private static HashMap<String, HashMap<String, entryInfo>> tabs = new HashMap<String, HashMap<String,entryInfo>>();;

/**
* Creates a new tab entry
*
* @param tabName the title of the new tab
*/
* Creates a new tab entry
*
* @param tabName the title of the new tab
*/
private static void create_tab(String tabName) {
tabs.put(tabName, new HashMap<String,entryInfo>());
}

/**
* Displays a value in Shuffleboard
*
* @param tabName the title of the tab to select
* @param name the name of the entry
* @param data value to display
* @param x -coord of the entry starting from 0
* @param y -coord of the entry starting from 0
* @return simple widget that can be modified
*/
* Displays a value in Shuffleboard
*
* @param tabName the title of the tab to select
* @param name the name of the entry
* @param data value to display
* @param x -coord of the entry starting from 0
* @param y -coord of the entry starting from 0
* @return simple widget that can be modified
*/
public static SimpleWidget addData(String tabName, String name, Object data, int x, int y) {
return addData(tabName, name, data, x, y, 1, 1);
}
Expand Down Expand Up @@ -111,27 +111,27 @@ public static SimpleWidget addData(String tabName, String name, Supplier<Object>
}

/**
* Displays a value in Shuffleboard
*
* @param tabName the title of the tab to select
* @param name the name of the entry
* @param data value to display
* @param x -coord of the entry starting from 0
* @param y -coord of the entry starting from 0
* @param width -of the entry
* @param height -of the entry
* @return simple widget that can be modified
*/
public static SimpleWidget addData(String tabName, String name, Object data, int x, int y, int width, int height) {
if(!tabs.containsKey(tabName)) create_tab(tabName);
if (tabs.get(tabName).containsKey(name)) {
tabs.get(tabName).get(name).m_data.setValue(data);
return tabs.get(tabName).get(name).m_entry;
* Displays a value in Shuffleboard
*
* @param tabName the title of the tab to select
* @param name the name of the entry
* @param data value to display
* @param x -coord of the entry starting from 0
* @param y -coord of the entry starting from 0
* @param width -of the entry
* @param height -of the entry
* @return simple widget that can be modified
*/
public static SimpleWidget addData(String tabName, String name, Object data, int x, int y, int width, int height) {
if(!tabs.containsKey(tabName)) create_tab(tabName);
if (tabs.get(tabName).containsKey(name)) {
tabs.get(tabName).get(name).m_data.setValue(data);
return tabs.get(tabName).get(name).m_entry;
}
SimpleWidget entry = Shuffleboard.getTab(tabName).add(name,data).withPosition(x, y).withSize(width,height);
tabs.get(tabName).put(name, new entryInfo(entry,null));
return entry;
}
SimpleWidget entry = Shuffleboard.getTab(tabName).add(name,data).withPosition(x, y).withSize(width,height);
tabs.get(tabName).put(name, new entryInfo(entry,null));
return entry;
}

/**
* Displays complex values, like subsystems and command, works on all classes that extend sendable
Expand Down

0 comments on commit dc8b6fd

Please sign in to comment.