Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Two variable PID? I know someone's done it =)... (http://www.chiefdelphi.com/forums/showthread.php?t=48616)

Mr. Lim 14-08-2006 10:05

Two variable PID? I know someone's done it =)...
 
My team hasn't done it, but I'm SURE someone out there has:

A PID loop that controls BOTH velocity and position. Basically it allows you to say "I want to move 33 feet forward, and do it at 6 fps."

The PID loop manages both the acceleration to the target speed, keeps track of the distance travelled, and decelerates and corrects as you approach your target distance.

Surprisingly, I did a search on CD, and didn't come up with much, although I probably missed something :o .

Overviews, explanations, even code snippets would be much appreciated!

-Shawn T. Lim

KenWittlief 14-08-2006 10:51

Re: Two variable PID? I know someone's done it =)...
 
sure, there are many systems that have PID loops on more than one parameter.

Think of it this way, PID loops are used to hold a system parameter at a desired level or output

you could have a PID loop on position, and tell your robot "move forward 6 feet, move back 9 feet" and a separate loop that controls speed.

In this case the position loop would invoke the speed loop. When its told to move forward it would set the speed in the forward direction. The 6 ft/S would be the upper limit of velocity.

Alan Anderson 14-08-2006 12:25

Re: Two variable PID? I know someone's done it =)...
 
Quote:

Originally Posted by KenWittlief
In this case the position loop would invoke the speed loop. When its told to move forward it would set the speed in the forward direction. The 6 ft/S would be the upper limit of velocity.

That's almost exactly how the Katapult (TechnoKats 2006) autonomous drive PID was designed to work. There is a "speed limit" imposed on the output from the position control routine.

Chris Hibner 14-08-2006 18:46

Re: Two variable PID? I know someone's done it =)...
 
Quote:

Originally Posted by SlimBoJones
My team hasn't done it, but I'm SURE someone out there has:

A PID loop that controls BOTH velocity and position. Basically it allows you to say "I want to move 33 feet forward, and do it at 6 fps."

The PID loop manages both the acceleration to the target speed, keeps track of the distance travelled, and decelerates and corrects as you approach your target distance.

Surprisingly, I did a search on CD, and didn't come up with much, although I probably missed something :o .

Overviews, explanations, even code snippets would be much appreciated!

-Shawn T. Lim


If you really want to control multiple parameters simultaneously, the best solution is to use a state space control algorithm. I would recommend doing a web search on "state space control" or "full state feedback".

A good example of trying to control position and velocity with state space methods is shown here (from my alma mater, nonetheless).

Jared Russell 29-08-2006 00:31

Re: Two variable PID? I know someone's done it =)...
 
Miss Daisy has done this for 2 years now.

It's actually not a 2 variable PID problem; it's two 1 variable PID problems.

A velocity control loop looks like this:

Velocity Command --> Velocity PID Controller--> Motor Output (with encoder counts/cycle looping back to the PID controller)

A traditional position control loop looks like this:

Position Command --> Position PID Controller --> Motor Output (with encoder counts looping back to the PID controller)

However, the problem with position command directly affecting a motor output is that (1) motors are rarely linear in response, which is what you want for an ideal PID control system, and (2) there is no guarantee that multiple motors will get to the same position in the same amound of time.

The easiest solution? Instead of generating a motor output from your position loop, generate a velocity command. The velocity controller will ensure that it reaches that speed, and it's response will be more linear, making tuning much easier. Your combined controller would look like this:

Position Command --> Position PID Controller --> Velocity Command --> Velocity PID Controller --> Motor Output (with encoder counts looping to position controller and encoder counts/cycle looping to velocity controller)

This makes user/autonomous code highly redundant: use the same velocity loop in both modes, but in user get the velocity command from the joystick position, and in autonomous get the velocity command from the position control loop (with setpoints generated by dead reckoning, sensors, etc.).

If you need help with how to code this, let me know, but this should get you started.


All times are GMT -5. The time now is 11:22.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi