Go to Post If there are no top tier teams, then who do we look up to for inspiration? - artdutra04 [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

 
 
 
Thread Tools Rating: Thread Rating: 4 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #4   Spotlight this post!  
Unread 12-02-2011, 16:39
jwakeman jwakeman is offline
Registered User
FRC #0063 (Red Barons)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: 16510
Posts: 182
jwakeman is just really nicejwakeman is just really nicejwakeman is just really nicejwakeman is just really nicejwakeman is just really nice
Re: FIRST Robotics Competition C++ Programming Overview [Resources] [Mind Map]

Ok, good to know there are any serious problems since we are using the built-in objects. And plopping them in and fiddling was still plenty of work for us to get it working nicely but I can respect rolling your own. I do have one possible issue with the WPILib implementation however. It does not take into account the dt (loop interval time) when calculating integral and deriviative errors. You can get around it by adjusting your calculated (if you calculated them) Ki and Kd values according to your loop rate but since the PIDController object already knows the dt you set I think it probably should take it into account. Below is some pseudocode from wikipedia http://en.wikipedia.org/wiki/PID_controller that illustrates how the dt could be taken into account. I would be interested in the experts opinion on this and I've been thinking it might be worth submitting an issue on the FirstForge page.

Code:
previous_error = 0
integral = 0
start:
  error = setpoint - actual_position
  integral = integral + (error*dt)
  derivative = (error - previous_error)/dt
  output = (Kp*error) + (Ki*integral) + (Kd*derivative)
  previous_error = error
  wait(dt)
  goto start

Last edited by jwakeman : 12-02-2011 at 16:40. Reason: typo
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 03:05.

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