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?
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.