Go to Post The possibilities for zip ties are endless. - Elgin Clock [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 04-02-2015, 12:37
cstelter cstelter is offline
Programming Mentor
AKA: Craig Stelter
FRC #3018 (Nordic Storm)
Team Role: Mentor
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Mankato, MN
Posts: 77
cstelter will become famous soon enough
default m_period for PIDController???

Hi All,
Our team (3018 Nordic Storm) has created a PIDSubsytem class and instantiated 4 of them and given them a SpeedController implementation

i.e.

class NordicSpeedController extends PIDSubsytem implements SpeedController{
...
}

In this way we can instantiate 4 separate PID Subsystems by passing a Talon and an encoder to each and then in the class we implement the set() entry from the SpeedController interface to call setSetpoint() and set up the returnPIDInput to scale the rate of the encoder such that 1.0 generates a rate that is our maximum. This can also be accomplished by the call to setDistancePerPulse() though.

Then we pass these 4 NordicSpeedControllers to RobotDrive and we of course get far better results on our mecanum drive than using a standard SpeedController (Talon) with just PWM setting without feedback.

As we were tuning the PID, we discovered that it was *very* sluggish. Upon further investigation, we discovered that in PIDController.java we have:

public static final double kDefaultPeriod = .05;
...
private double m_period = kDefaultPeriod;


From what I could tell, these are in seconds so we only revisit the pid 20 times a second by default??? I don't have last year's wpilib on my system but I seem to recall teleopPeriodic was called 50 times a second and that PID's defaulted to 100 times a second (0.01 period).

We changed our period to .005 (by passing in p,i,d,f,period constructor via super()) and things got much better, so I think we followed the breadcrumbs properly to resolve our issue.

So my question for the forum is-- did we get off in the weeds and misunderstand something? I tried searching CD for various keywords to find a discussion of the above but failed miserably-- that's not to say there are no threads,but I could not find any. I find it hard to believe others have not run across this. If we are not in the weeds-- I wanted to raise the visibility of this because a 50ms period is going to make PIDs not work well at all from our experience.

In looking at how PIDController schedules its period, it seems that an overall scheduler schedules all tasks and that the minimum resolution is 1ms. I discovered this at home after our practice so I will be having our team try 1ms instead of 5ms the next time we meet (unfortunately only 3 times a week ). Running 4 pids at 5ms period barely put the roboRio load over 20% so that was pretty cool!

We had planned to use the CAN Talon to marshal the PID for each motor in a largely similar way (to minimize effort of rio), but we didn't have the SRX when our pracitce chassis was complete. We have the Talon's now, but we still haven't wired them up yet, and I'm wondering if there will be much of a benefit.

Thoughts anyone? Anyone have similar insights to share? I think adding a Speed Controller interface to a PID Subsystem is a nifty way to use RobotDrive along with encoders which otherwise isn't terribly simple, so I wanted to throw that out there for teams to consider as well.
Reply With Quote
 


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 22:31.

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