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:


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

Give it a try and see what happens. Tell me how its goes, I am starting to look at the same thing now.

also

All sensors that can be used with the PID class will implement the PIDSource

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.

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.