Go to Post During the day on Thursday, I had to change costumes a few times, being "Andy the inspector", to "Andy the green power ranger drive coach", to "Andy the President of AndyMark, meeting with companies". I am sure some people in the guys' bathroom were wondering what I was up to. - Andy Baker [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 28-02-2013, 17:27
jwhite jwhite is offline
Registered User
FRC #2823
Team Role: Mentor
 
Join Date: Feb 2013
Rookie Year: 2013
Location: Saint Paul, MN
Posts: 69
jwhite is an unknown quantity at this point
PIDController (.cpp) issues and concerns

I thought I'd report some troubles we found with the pid controller code while we're waiting for our regional.

We wanted to use the PIDController class to control a Jaguar for rate control. (And yes, if we'd done CAN protocol, we wouldn't need this, but we're not that cool a team...yet).

But it seems to me that the current code really does not work well for rate control.
The Screen Steps Live documentation for using the PIDController to govern a rate:
http://wpilib.screenstepslive.com/s/...rs-pid-control
seems to suggest that the 'feed forward' term will help. But kF is just a constant offset. We were not able to get any kind of PID tuning that was workable just using that.

We ended up wrapping the Jaguar class with another class that implemented PIDWrite as a delta, not an absolute, and that gave us reasonable results, and also seemed to be a more theoretically correct implementation. (My PID experts insist that the goal of PID code should be to drive error to 0, not to have an I term that provides a perpetual error correction).

Also, the OnTarget() method consistently crashed for us; my guess is that the use of GetError(), and the doubled critical sections cause that crash.

Hope this helps someone else.

Cheers,

Jeremy
  #2   Spotlight this post!  
Unread 28-02-2013, 18:03
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,745
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: PIDController (.cpp) issues and concerns

We're using a very slightly modified version of the PIDController class quite successfully for speed control on 3 shooter wheels. The only modification is to change the integral anti-windup measures to work slightly differently. We're using P, I, and FF terms and it's working well. A velocity PID like you're using is technically more correct, but whatever works.

What kind of crashes were you getting with the OnTarget method? We're using that to determine when to exit the shooter speed setting command, so it's getting called every teleop loop, and we haven't had any problems.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
  #3   Spotlight this post!  
Unread 28-02-2013, 18:10
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,600
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: PIDController (.cpp) issues and concerns

Quote:
Originally Posted by jwhite View Post
Also, the OnTarget() method consistently crashed for us; my guess is that the use of GetError(), and the doubled critical sections cause that crash.
Are you running the 2nd C++ update from 2/7? It has a fix for OnTarget hanging.
  #4   Spotlight this post!  
Unread 28-02-2013, 18:39
jwhite jwhite is offline
Registered User
FRC #2823
Team Role: Mentor
 
Join Date: Feb 2013
Rookie Year: 2013
Location: Saint Paul, MN
Posts: 69
jwhite is an unknown quantity at this point
Re: PIDController (.cpp) issues and concerns

Quote:
Originally Posted by Joe Ross View Post
Are you running the 2nd C++ update from 2/7? It has a fix for OnTarget hanging.
My recollection is that we still had an issue after that update. Sadly, we're not in a good position to retest (darn bags :-/).
  #5   Spotlight this post!  
Unread 28-02-2013, 23:49
Tanaythan's Avatar
Tanaythan Tanaythan is offline
Programmer
AKA: Tanay Nathan
FRC #3256 (Warriorborgs)
Team Role: Programmer
 
Join Date: Feb 2011
Rookie Year: 2010
Location: San Jose
Posts: 27
Tanaythan is an unknown quantity at this point
Re: PIDController (.cpp) issues and concerns

It's still quite simple just to make your own OnTarget() method as well as GetError(). Even though it is more redundant, it should not lock the thread like it will otherwise. Simply, use GetSetpoint() and PIDGet() from your PIDSource object to calculate the error. From there, you can tune your OnTarget() error. For example...

Code:
//PIDSource is called source, PIDController is called controller.
float error = controller->GetSetpoint() - source->PIDGet();
float tolerance = error * .05; //any percentage value
return fabs(tolerance) < 5; // a tuned value
__________________
Tanay Nathan
Programmer
Team #3256 Warriorborgs
  #6   Spotlight this post!  
Unread 28-02-2013, 23:50
jwhite jwhite is offline
Registered User
FRC #2823
Team Role: Mentor
 
Join Date: Feb 2013
Rookie Year: 2013
Location: Saint Paul, MN
Posts: 69
jwhite is an unknown quantity at this point
Re: PIDController (.cpp) issues and concerns

Quote:
Originally Posted by rawrxp View Post
It's still quite simple just to make your own OnTarget() method as well as GetError(). Even though it is more redundant, it should not lock the thread like it will otherwise. Simply, use GetSetpoint() and PIDGet() from your PIDSource object to calculate the error. From there, you can tune your OnTarget() error. For example...

Code:
//PIDSource is called source, PIDController is called controller.
float error = controller->GetSetpoint() - source->PIDGet();
float tolerance = error * .05; //any percentage value
return fabs(tolerance) < 5; // a tuned value
Oh, sure, and that's what we did. I was just mentioning the troubles we had in case any listening WPILib authors were interested in fixing 'em...
  #7   Spotlight this post!  
Unread 28-02-2013, 23:53
Tanaythan's Avatar
Tanaythan Tanaythan is offline
Programmer
AKA: Tanay Nathan
FRC #3256 (Warriorborgs)
Team Role: Programmer
 
Join Date: Feb 2011
Rookie Year: 2010
Location: San Jose
Posts: 27
Tanaythan is an unknown quantity at this point
Re: PIDController (.cpp) issues and concerns

Quote:
Originally Posted by jwhite View Post
Oh, sure, and that's what we did. I was just mentioning the troubles we had in case any listening WPILib authors were interested in fixing 'em...
If I recall correctly, it was noted to the WPILib authors and in one of their logs in wpilib.screenstepslive.com, they had mentioned they fixed this problem. You can just resubmit a ticket to them at this link.
__________________
Tanay Nathan
Programmer
Team #3256 Warriorborgs

Last edited by Tanaythan : 28-02-2013 at 23:55.
  #8   Spotlight this post!  
Unread 01-03-2013, 10:08
jwhite jwhite is offline
Registered User
FRC #2823
Team Role: Mentor
 
Join Date: Feb 2013
Rookie Year: 2013
Location: Saint Paul, MN
Posts: 69
jwhite is an unknown quantity at this point
Re: PIDController (.cpp) issues and concerns

Quote:
Originally Posted by rawrxp View Post
If I recall correctly, it was noted to the WPILib authors and in one of their logs in wpilib.screenstepslive.com, they had mentioned they fixed this problem. You can just resubmit a ticket to them at this link.
Yeah, good point, that's where I should add a note after we retest. I find the firstforge web site a bit deceptive; it has good activity, but then bits of cruft. What's nice about posting here is that you get immediate answers

Cheers,

Jeremy
  #9   Spotlight this post!  
Unread 02-03-2013, 01:54
William Kunkel William Kunkel is offline
Programming Lead
AKA: Kunkel
FRC #0422 (Mech Tech Dragons)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Richmond, VA
Posts: 94
William Kunkel is an unknown quantity at this point
Re: PIDController (.cpp) issues and concerns

Our team also had issues with the WPILib PID implementation, and we ended up doing pretty much the same thing: wrapping the Talon class to use PID output as a delta rather than an absolute. So far it's been working alright, but it's ugly.
Closed Thread


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 03:21.

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