Go to Post note: spelling, punctuation and good grammar are your friends - use them and enjoy the benefits of legible, understandable prose - dlavery [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

 
Reply
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 27-05-2011, 11:48
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,722
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: PIDController Rotate

Quote:
Originally Posted by Ether View Post
Isn't there a generic PID in the WPI library for Java which lets you specify where the output goes? Like the LabVIEW PID ?


unfortunately not that I can find. Here is the link to the JavaDoc for the WPI Library. If you can find something let me know.

http://robotics.loyola.ca/javadoc201...s-noframe.html
Reply With Quote
  #17   Spotlight this post!  
Unread 27-05-2011, 12:00
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: PIDController Rotate

WPILib and WPILibJ PID controllers take PIDOutputs as constructor parameters - this is where they "put" their output command. Some classes in WPILib(J) already implement the PIDOutput interface (like Victor or Jaguar). But because you can apply PID to so many different types of problems, there are going to be lots of instances where you need to write some code to "glue" the PIDController to whatever it is you want to control.

There are a couple of ways you could do this:

1. Make a new class that implements PIDOutput. You must implement a "pidWrite" function for your new class - this will get called every time the PID controller has a new output available.

2. Don't use the PIDOutput feature; instead, simply call <yourPIDcontrollername>.get() inside of a periodic loop (like "teleopPeriodic()" in IterativeRobot) to grab the output of the controller at some regular frequency.

3. Write your own PID controller class that behaves exactly the way you want it to
Reply With Quote
  #18   Spotlight this post!  
Unread 27-05-2011, 12:01
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,572
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 Rotate

seems like it would be easy to make a class that implements PIDOutput that only sets a variable.
Reply With Quote
  #19   Spotlight this post!  
Unread 27-05-2011, 12:03
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,722
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: PIDController Rotate

Quote:
Originally Posted by Jared341 View Post
WPILib and WPILibJ PID controllers take PIDOutputs as constructor parameters - this is where they "put" their output command. Some classes in WPILib(J) already implement the PIDOutput interface (like Victor or Jaguar). But because you can apply PID to so many different types of problems, there are going to be lots of instances where you need to write some code to "glue" the PIDController to whatever it is you want to control.

There are a couple of ways you could do this:

1. Make a new class that implements PIDOutput. You must implement a "pidWrite" function for your new class - this will get called every time the PID controller has a new output available.

2. Don't use the PIDOutput feature; instead, simply call <yourPIDcontrollername>.get() inside of a periodic loop (like "teleopPeriodic()" in IterativeRobot) to grab the output of the controller at some regular frequency.

3. Write your own PID controller class that behaves exactly the way you want it to
So far I've taken the first step. I'm guessing this was the way it was intended to be done in Java. Currently my PIDOutput class takes a forward speed and a RobotDrive as parameters for its constructor and adjusts the right and left side motors as needed to correct the rotation.
Reply With Quote
  #20   Spotlight this post!  
Unread 27-05-2011, 12:07
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,722
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: PIDController Rotate

Quote:
Originally Posted by Jared341 View Post
2. Don't use the PIDOutput feature; instead, simply call <yourPIDcontrollername>.get() inside of a periodic loop (like "teleopPeriodic()" in IterativeRobot) to grab the output of the controller at some regular frequency.
How would you accomplish this without passing the PIDController's constructor a PIDOutput object? Create an abstract instance of one?
Reply With Quote
  #21   Spotlight this post!  
Unread 27-05-2011, 12:20
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: PIDController Rotate

Quote:
Originally Posted by notmattlythgoe View Post
How would you accomplish this without passing the PIDController's constructor a PIDOutput object? Create an abstract instance of one?
Yeah, you would just create a minimalist implementation of a PIDOutput (it could even be an anonymous class).

Something like...
Code:
xxx = new PIDController(Kp, Ki, Kd, source, new PIDOutput() {void pidWrite(double output){ } }, period);
Reply With Quote
  #22   Spotlight this post!  
Unread 27-05-2011, 12:27
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,722
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: PIDController Rotate

Quote:
Originally Posted by Jared341 View Post
Yeah, you would just create a minimalist implementation of a PIDOutput (it could even be an anonymous class).

Something like...
Code:
xxx = new PIDController(Kp, Ki, Kd, source, new PIDOutput() {void pidWrite(double output){ } }, period);
Makes sense. Having the thread controlled PID system is very nice though. Just takes that little bit of extra work. Once I get the code tested on the robot I will post it here for people to look at.
Reply With Quote
  #23   Spotlight this post!  
Unread 31-05-2011, 23:59
Strants Strants is offline
Registered User
AKA: Gavin Stewart
FRC #1977
Team Role: College Student
 
Join Date: Dec 2010
Rookie Year: 2010
Location: Colorado
Posts: 11
Strants is an unknown quantity at this point
Re: PIDController Rotate

Just a couple nit-picks: you defined DRIVE_P, DRIVE_I, and DRIVE_D as zero, which means that the controller won't do any corrections. Also, what is the value variable in the PIDRotate class supposed to do?
Reply With Quote
  #24   Spotlight this post!  
Unread 01-06-2011, 07:03
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,722
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: PIDController Rotate

Quote:
Originally Posted by Strants View Post
Just a couple nit-picks: you defined DRIVE_P, DRIVE_I, and DRIVE_D as zero, which means that the controller won't do any corrections. Also, what is the value variable in the PIDRotate class supposed to do?
I instantiated all of the PID values to 0 because I didn't have the correct values on me at the time. Here are some update files, I'm hoping to get the code tested this afternoon.
Attached Files
File Type: txt PIDRotate.txt (689 Bytes, 31 views)
File Type: txt RobotDrive2363.txt (2.2 KB, 23 views)
File Type: txt RobotTemplate.txt (12.4 KB, 17 views)
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:16.

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