Go to Post Just like it is not all about the robots, it is not all about winning the Chairman's Award. - Paul Copioli [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 Rating: Thread Rating: 4 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 12-02-2011, 14:33
basicxman basicxman is offline
Emily Horsman
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Burlington, Ontario
Posts: 971
basicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant future
Send a message via AIM to basicxman Send a message via MSN to basicxman Send a message via Yahoo to basicxman
FIRST Robotics Competition C++ Programming Overview [Resources] [Mind Map]

Hey all,

Been working on this for a couple hours now, it contains a whole bunch of C++ tips and resources for new teams in mind map form (everything's in one place). I will continue to update and add to it.

http://mmrambotics.ca/static/FIRST_R...rogramming.pdf
Reply With Quote
  #2   Spotlight this post!  
Unread 12-02-2011, 16:13
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]

Nice. Can you comment on why you prefer to implement your own PID classes. What are the disadvantages of the WPILib PIDController class in your opinion? What are the advantages of the classes you have come up with?

Last edited by jwakeman : 12-02-2011 at 16:14. Reason: typo
Reply With Quote
  #3   Spotlight this post!  
Unread 12-02-2011, 16:16
basicxman basicxman is offline
Emily Horsman
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Burlington, Ontario
Posts: 971
basicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant future
Send a message via AIM to basicxman Send a message via MSN to basicxman Send a message via Yahoo to basicxman
Re: FIRST Robotics Competition C++ Programming Overview [Resources] [Mind Map]

Quote:
Originally Posted by jwakeman View Post
Can you comment on why you prefer to implement your own PID classes. What are the disadvantages of the WPILib PIDController class in your opinion? What are the advantages of the classes you have come up with?
Writing your own allows students to learn PID concepts vs. plopping in an object and just fiddling with constants. Plus it offers more flexibility and integration with your program without re-compiling the WPI library.
Reply With Quote
  #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
  #5   Spotlight this post!  
Unread 14-02-2011, 00:14
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 671
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: FIRST Robotics Competition C++ Programming Overview [Resources] [Mind Map]

We have our own PID library as well. In our case, aside from the benefits you mentioned, our PID library allows multiple PID controllers to interact. In particular, we defined a PIDDrive object where it takes two PID controllers, one for driving straight and one for turning. Each PID controller can have their own sensors (e.g. driving straight can use the wheel encoders or sonar sensors etc., turning can use the gyro, the compass or the camera etc). Imagine if you can tell the PIDDrive object to "drive forward 20 ft while maintaining heading to the goal seen by the camera". The drive PID controller will calculate the motor values to drive forward 20 ft while the turn PID controller will calculate the motor differential for maintaining the heading. The result from these PID controllers can be combined to generate the final motor values. The PID drive object is extremely flexible, you can tell it to follow a moving object and maintain distance. For example, drive forward and maintain 30-inch distance from the object in front. It can use the sonar sensor for the driving PID controller for setting the 30-inch target while using the camera as the sensor for the turning PID controller to follow the object in front. At first, we were trying to implement this with the WPI PID controller but found that it doesn't have the flexibility. So we wrote our own replacement.
__________________
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 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