# Multivariable PID controller

I'm making a robot that uses two DC motors to move, and has two distance sensors on its right side. I want to make a PID controller to control the angle of the robot (using a wall as reference) and also its distance to the wall.

I made a PID controller that can minimize the difference between both sensors' measurements, making the robot go always parallel to the wall. I also made a controller for controlling the distance one sensor measures, for the robot to go always at the same distance to the wall.

What I want to do is combine those two controllers into one. I know there's something called MISO PID controller (multiple inputs single output) but I don't know how to use it or even design it. I thought of adding those two variables (the difference and one sensor's measurement) and using that as the controller's input. Is that right? How can I achieve this?

PS: I also thought of adding the difference between each sensor's measurement and the distance I want, or using those two differences as the variables of my MISO controller.

The principle is called linguistic multivariable fuzzy pid control. The idea is to create a domain specific language and create with that a domain specific controller. The existing sensor variables and existing motor primitives for starting and stopping the servo motors are taken as a base for constructing a higher level behavior system on top. Rodney Brooks described this principle first. In terms of programming it means, to add new methods in the controller class. For example, “stayaway-fromwall”, “move-onthe-line”, “rotate-until” and so on. The motion primitives are forming together with the sensor variables a domain specific language and the controller is formulated in that language.

I know, it sounds very theoretically. A practical example can be tested out in the famous “Karel the robot” game. The user has the task to define new subfunction and combines them into a program. This gets started in the Karel simulator. Programming a real robot in a maze works similar.

• This doesn't address OP's question at all. The Karel game doesn't show or explain how to combine PID controllers. Also, I find zero results online when I search "linguistic multivariable fuzzy pid control" or "linguistic multivariable" pid. Can you please provide links to the methods you mention and/or an example of how it works? – Chuck Jan 2 at 16:49
• @Chuck Which kind of of academic search engine do you have? Google Scholar shows over 1000 hits for “wall following fuzzy controller multivariable”, Additionally, the “Flakey the robot” project by SRI gave a good introduction into linguistic grounded robot control. – Manuel Rodriguez Jan 2 at 18:39
• You said The principle is called linguistic multivariable fuzzy pid control, so I searched that phrase and found nothing. Without quotes turns up results,but then I can't seem to find a paper that has something to covers linguistic and multivariable and fuzzy pid. You mention "Flakey the robot" as a good example, but the wikipedia entry has 6 sentences on it, none of which mention PID. The SRI page has even less information. – Chuck Jan 2 at 18:58
• My point is that you state "the principle is called ____" and then I personally can't find anything that features that phrase. The project you mention in the answer doesn't seem to relate, at least that I can find, to multivariable PID control at all, and again, none of this seems to address the question which is, in essence, "How do I combine two PID controllers?" If your answer is "fuzzy PID control," then please cite a source that shows how fuzzy PID combines multiple PID controllers and/or write a small example here. – Chuck Jan 2 at 19:04

A (possible) way that I could think of is to use a (resource-aware) switching PID controller in your feedback loop. The operation is as follows:

[1] The controller is of the class single-input-single-output.

[2] The input to the controller is the (desired) error i.e., the error measued between the reference position and the location of the wall-1/wall-2 that is being measued along the motion. I omit the discussion on the control output which is redundant.

[3] The fun part starts here: In short the controller will act as a switching PID controller which switches between its two error inputs. Thereby, reducing the error when certain limit exceeds. This limit can be in terms of performance, for instance, how the ideall the robot should maneuver parallel to the wall.

[4] This switching action can be based on algorithims like roll-out policy. Thereby, switching between the inputs whenever it is necessary. Of course, this depends upon your performance specificationsn and your processor's capabilities. Nevertheless, you can dig into topics such as resource aware controller design per se to look more in detail about this.

Disclaimer: Following this procedure might have impact on the stability, hence always verify the stability argument before going forward with these techniques.

• The domain of a wall following robot is too complex for pid switching control. PID switching has it's roots in a mathematical description which can't be provided in case of robot control. So called “roll-out policies” are an optimization technique. If no model is available, the optimization will fail. – Manuel Rodriguez Jan 7 at 9:26
• @Manuel Rodriguez could you elaborate on being too complex and can't be provided for robot control. Also, roll-out policies can also be tweaked to behave based on measured data. – Raaja Jan 7 at 9:33
• Sure, according to the problem description the systems contains of 2 actuators, 2 sensors and a wall which is the reference line to follow. Is it a toy problem in the form of f(x)=y? No, it's an np-hard problem which contains of a non-linear complex statespace which gets divided by project's requirements. It's very likely that the robot is in a maze like environment and has to win a game against other robots. – Manuel Rodriguez Jan 7 at 9:57