View Single Post
  #5   Spotlight this post!  
Unread 17-03-2016, 20:23
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
This commit seems to have addressed the bug dvanvoorst is talking about.
Actually that's not the bug I was referring to. Here's the portion of code from the "calculate" method. This is the corrected code:
Code:
        // Update the buffer.
        m_buf.add(m_error);
        m_bufTotal += m_error;
        // Remove old elements when the buffer is full.
        if (m_buf.size() > m_bufLength) {
          m_bufTotal -= m_buf.remove();
The original code used m_buf.push and m_buf.pop instead of add and remove, which resulted in the most recent value being popped off instead of the oldest.

I'm running version 0.1.0.201603020231 of the Java WPILib.