PIDController strategy for slow sensor/vision update rates

I am just curious if people have noticed any significant (or bad) behaviors out of a PID controlled loop if the pidGet() method returns the same value?


      @Override
      public double pidGet() {
           // How much bad impact is there if the video subsystem has not processed
           // determined new information since the last time the PIDController called pidGet()?
 
           double angleToTarget = videoSystem.getAngleToTarget();
           return angleToTarget;
      }

It seems like it probably isn’t a huge deal if you are only using P, but I’m concerned about what happens when D and I are non-zero.

While we can increase the period of the PIDController so that it is slightly larger than our camera’s frame rate, there is always the possibility that we might fail to detect the current frame being processed. In this case we will have no new information to work with when our pidGet() is called.

We can detect if this occurs. Unfortunately we are not certain as to what to do about it.


      @Override
      public double pidGet() {
           // Get the count of times the video subsystem has computed new values
           int updateCnt = videoSystem.getUpdateCount();
           if (updateCnt == lastUpdateCnt) {
              // Video system has not found the target since we were last called!!!
              // Now what do we do? I guess for now we'll just fall through and
              // use the old information.
           }

           // Used to verify that we have new information to work with
           lastUpdateCnt = updateCnt;

           // Get angle to target computed by video subsystem
           double angleToTarget = videoSystem.getAngleToTarget();
           return angleToTarget;
      }

Right now, we are just not worrying about it (we just return the old information to the PIDController). But, this doesn’t feel right (especially since this makes the change in error go to 0 - dropping D from the output).

We have thought about extending the PIDController class and overriding the calculate() method so that it only runs when new information is available, but we weren’t certain if this might introduce other issues.

Does anyone have some other suggestions?

Thanks.

Unless you have a very fast vision processing time (< 25ms), using vision targeting for PID is pretty bad. You’ll be better off grabbing the angle and plugging that into the setpoint of a gyro/encoder-based PID controller.

Thanks, that makes sense to me. Sounds like the general strategy is to just let a slow/sporadic sensor (like vision processing) drive the set point for a PID that uses another sensor that has a higher and more reliable refresh rate (like a gyro).