View Single Post
  #14   Spotlight this post!  
Unread 15-10-2016, 03:23
calcmogul's Avatar
calcmogul calcmogul is offline
WPILib Developer
AKA: Tyler Veness
FRC #3512 (Spartatroniks)
Team Role: Mentor
 
Join Date: Nov 2011
Rookie Year: 2012
Location: Santa Maria, CA
Posts: 51
calcmogul is just really nicecalcmogul is just really nicecalcmogul is just really nicecalcmogul is just really nice
Re: Position and velocity PIDControllers using same encoder

Quote:
Originally Posted by Oblarg View Post
The use case is controlling a turret - we're wondering if it's possible to do a cascading loop using the same encoder for both the external (position) loop and the internal (velocity) loop.
If I understand your mechanism correctly, you are using both PID controllers to drive the same plant. One handles the position state while the second handles the velocity state. Velocity and acceleration feedforwards may help here. If you know what control signal you need to assert to produce a given velocity and acceleration, you could pass that information via feedforwards to a single position PID controller and remove the velocity PID controller. Otherwise, you could pass them to the inner velocity PID controller, and the velocity PID controller would, in effect, be accounting for uncertainties in your model that generates the velocity feedforward.

A custom controller that accounts for all three states (position, velocity, and acceleration) in the setpoint would be cleaner in my opinion, and the appropriate modifications to the PIDController class shouldn't be too difficult. By the way, state space controllers do this as well, but they require a reasonably accurate system model while PID does not.
Reply With Quote