Wow, you guys did a great job with organizing your code. I love that the PID controller doesn't need to start it's own thread to call the pidSet() method. Also, I think you forgot to update your feed-forward value when the table listen finds a change in the pid gains. You check to see if the key is named "f", but you never end up comparing/changing "f".
Code:
private ITableListener listener = new ITableListener() {
public void valueChanged(ITable table, String key, Object value, boolean isNew) {
if (key.equals("p") || key.equals("i") || key.equals("d") || key.equals("f")) {
if (gains.getP() != table.getNumber("p", 0.0) || gains.getI() != table.getNumber("i", 0.0) ||
gains.getD() != table.getNumber("d", 0.0)) {
System.out.println("Got new PID gains!");
gains.set(table.getNumber("p", 0.0), table.getNumber("i", 0.0), table.getNumber("d", 0.0));
}
} else if (key.equals("setpoint")) {
if (goal != ((Double) value).doubleValue()) {
setGoal(((Double) value).doubleValue());
}
} else if (key.equals("enabled")) {
if (isEnabled() != ((Boolean) value).booleanValue()) {
if (((Boolean) value).booleanValue()) {
enable();
} else {
disable();
}
}
}
}
};