PID control of a rover?

Hi PID gurus,

Ive built my first little rover type robot using the sharp IR sensors for distance measurement. trouble is the “on/off” type control i dont really like as it just mindlessly bumps,reverses and turns all day long and i know some sort of PID controller can peform much much better.

My design is simply to have a specific distance reading from the IR sensor as the set point it must try to stay above , thus steering away from walls or objects as that would cause the distance to decrease.

Now ive done third year control systems theory so i can design and tune a single input single output system but i took the thermodynamics paper so i missed out on the MIMO stuff in control.

does anyone have any links to good info about what im trying to achieve here? or other projects similar? my confusion is what to do in order for the PID system to either choose left or right to turn as this is multiple outputs.

Thanks

Could you perform the pid conversion after you determine which direction you need to turn.

For example if the sensor on the right side of the vehicle is detecting an obstacle, call the left turn function which calls the pid function and uses the result to turn left. Therefore your pid functino only uses 1 input at a time.

Or am i misunderstanding what your trying to accomplish?

yeah i need to have a good hard think about it. Thing is at the moment i have only one IR sensor center mounted so there has to be some trialing by turning left or right when it approaches the wall/object to work out which is the better option to avoid collision.

i hope to make it rotate on a servo soon , which will help me with this problem.

i guess the PID would come into effect once it reached the setpoint value on one of the sensors and other times would be turned off so it doesnt ‘seek’ the wall. im not too sure how i can do this with a single sensor currently , any thoughts on this?

-sensor value reaches setpt
-PID loop gets the error from setpoint
-robot tries turning left a small increment
-PID loop gets error
-robot tries turning right a small increment
-PID loop gets error
-two errors are compared (negative would be the worse choice to turn)
-turn based on the last comparison

-sensor value reaches setpt
-PID loop gets the error from setpoint
-robot tries turning left a small increment
-PID loop gets error
-robot tries turning right a small increment
-PID loop gets error
-two errors are compared (negative would be the worse choice to turn)
-turn based on the last comparison

With only one sensor, this makes the best sense to me. In the negative case, you would reverse straight back some small (assumed safe) interval and retest distance. Or you could randomly (?) choose one direction and just go with it until en error condition occurred again.

Will your sensor give you a value, or does it only set a state when it reaches some set point? If you get a value, then you can solve ambiguous states such as both directions being clear and which way is best to turn.