View Single Post
  #9   Spotlight this post!  
Unread 17-03-2016, 20:59
dvanvoorst dvanvoorst is offline
Registered User
FRC #2771 (Code Red)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Grand Rapids, MI
Posts: 61
dvanvoorst is an unknown quantity at this point
Re: Major WPILib PIDController bug

Quote:
Originally Posted by virtuald View Post
I agree, that's a bug there. Different from what Oblarg was saying (unless they meant setSetpoint instead of enable).

The documentation should also probably specify what each of these functions should and should not do (is enable intended to clear the error? should setsetpoint always force onTarget to be false).
He misspoke - he meant setSetpoint and has corrected his original post.

setSetpoint doesn't have to force onTarget to be false because it clears the buffer - which makes isAvgErrorValid() false, which forces onTarget() to be false.

However, I'd be interested in seeing isAvgErrorValid() being changed a bit to not return true until your buffer is full. I've had issues with OnTarget being true because of one value in the buffer when it first started up, even though I asked for a 20 reading average.
I'd like to propose changing this:
Code:
private synchronized boolean isAvgErrorValid() {
    return m_buf.size() != 0;
  }
to this
Code:
  private synchronized boolean isAvgErrorValid() {
    return m_buf.size() == m_bufLength;
  }