Go to Post Jeez, I love my job! :) - dlavery [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 25-03-2012, 16:23
Clint Clint is offline
Registered User
FRC #0308 (Monsters)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2011
Location: Michigan
Posts: 2
Clint is an unknown quantity at this point
Bug in WPILib PIDController?

The following code excerpt is found in PIDController.cpp of revision 3111 of WPILib, on lines 128 through 141.
Code:
double potentialIGain = (m_totalError + m_error) * m_I;
if (potentialIGain < m_maximumOutput)
{
	if (potentialIGain > m_minimumOutput)
		m_totalError += m_error;
	else
		m_totalError = m_minimumOutput / m_I;
}
else
{
	m_totalError = m_maximumOutput / m_I;
}

m_result = m_P * m_error + m_I * m_totalError + m_D * (m_error - m_prevError);
In the lines of code above, a subtle problem exists, under a certain few specific conditions:
  • Output is restricted with a minimum or maximum of 0
  • m_I is 0

Under these instances, the first if statement fails (or, it continues through to the second inner statement which also fails). In both cases, the total error is calculated by dividing by m_I. When m_I is zero--a perfectly logical use case--m_totalError becomes NaN.
As a result, m_result becomes NaN as well. Subsequently, when PIDController::Calculate writes this value to the output, errors rapidly accumulate in the console.


Clint
Reply With Quote
  #2   Spotlight this post!  
Unread 26-03-2012, 11:41
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,050
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Bug in WPILib PIDController?

You should file a bug at the WPILib tracker.

http://firstforge.wpi.edu/sf/tracker....wpilib_c_bugs
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #3   Spotlight this post!  
Unread 26-03-2012, 19:32
Clint Clint is offline
Registered User
FRC #0308 (Monsters)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2011
Location: Michigan
Posts: 2
Clint is an unknown quantity at this point
Re: Bug in WPILib PIDController?

Thanks. If anyone else is interested in following this issue, the artifact can be found here.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 13:06.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi