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