View Single Post
  #29   Spotlight this post!  
Unread 27-06-2013, 15:13
apples000's Avatar
apples000 apples000 is offline
Registered User
no team
 
Join Date: Mar 2012
Rookie Year: 2012
Location: United States
Posts: 222
apples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant futureapples000 has a brilliant future
Re: Team 254 2013 FRC Code

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();
            }
          }
      }
    }
  };
Reply With Quote