Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   PIDController class (PIDSource/PIDOutput interfaces?) (http://www.chiefdelphi.com/forums/showthread.php?t=71781)

Jared Russell 01-10-2009 01:30 PM

PIDController class (PIDSource/PIDOutput interfaces?)
 
I was looking at the WPILib codebase and saw that their PIDController class uses the PIDSource and PITOutput interfaces for I/O to/from the control loop. However I was surprised to see that no WPILib classes actually inherit from these interfaces.

Is the intention that I should inherit from PIDSource and PIDOutput as necessary? Ex:

Code:

class PIDEncoder : public Encoder, public PIDSource
{
... (override PIDget() here)
};

class PIDJaguar : public Jaguar, public PIDOutput
{
... (override WritePID() here)
};

Or is there some other intended design pattern that I'm not getting?

Thanks

wt200999 01-10-2009 07:51 PM

Re: PIDController class (PIDSource/PIDOutput interfaces?)
 
Give it a try and see what happens. Tell me how its goes, I am starting to look at the same thing now.


also

Quote:

All sensors that can be used with the PID class will implement the PIDSource
They probably haven't implemented it themselves.

Jared Russell 01-10-2009 09:39 PM

Re: PIDController class (PIDSource/PIDOutput interfaces?)
 
Quote:

Originally Posted by wt200999 (Post 797972)
Give it a try and see what happens. Tell me how its goes, I am starting to look at the same thing now.


also



They probably haven't implemented it themselves.

Thanks for responding. Yeah, I guess that WPI didn't get to it yet. Extending sensors/outputs should be just fine.

BradAMiller 01-11-2009 09:49 AM

Re: PIDController class (PIDSource/PIDOutput interfaces?)
 
The idea is that you create subclasses of whatever you want to read inheriting PIDSource and whatever you want to control inheriting PIDOutput. They provide the methods to get the values from the sensor and provide output values for the controlled thing.

It works that way because a single sensor might not be used, but maybe some group of sensors, or a camera X position, or something more complex. And the thing being controlled may be more complex then just a motor.

We'll try to post an example later today.


All times are GMT -5. The time now is 10:35 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi