\( \newcommand{\blah}{blah-blah-blah} \newcommand{\eqb}[1]{\begin{eqnarray*}#1\end{eqnarray*}} \newcommand{\eqbn}[1]{\begin{eqnarray}#1\end{eqnarray}} \newcommand{\bb}[1]{\mathbf{#1}} \newcommand{\mat}[1]{\begin{bmatrix}#1\end{bmatrix}} \newcommand{\nchoose}[2]{\left(\begin{array}{c} #1 \\ #2 \end{array}\right)} \newcommand{\defn}{\stackrel{\vartriangle}{=}} \newcommand{\rvectwo}[2]{\left(\begin{array}{c} #1 \\ #2 \end{array}\right)} \newcommand{\rvecthree}[3]{\left(\begin{array}{r} #1 \\ #2\\ #3\end{array}\right)} \newcommand{\rvecdots}[3]{\left(\begin{array}{r} #1 \\ #2\\ \vdots\\ #3\end{array}\right)} \newcommand{\vectwo}[2]{\left[\begin{array}{r} #1\\#2\end{array}\right]} \newcommand{\vecthree}[3]{\left[\begin{array}{r} #1 \\ #2\\ #3\end{array}\right]} \newcommand{\vecdots}[3]{\left[\begin{array}{r} #1 \\ #2\\ \vdots\\ #3\end{array}\right]} \newcommand{\eql}{\;\; = \;\;} \newcommand{\dv}[2]{\frac{#1}{#2}} \newcommand{\half}{\frac{1}{2}} \newcommand{\mmod}{\!\!\! \mod} \newcommand{\ops}{\;\; #1 \;\;} \newcommand{\implies}{\Rightarrow\;\;\;\;\;\;\;\;\;\;\;\;} \definecolor{dkblue}{RGB}{0,0,120} \definecolor{dkred}{RGB}{120,0,0} \definecolor{dkgreen}{RGB}{0,120,0} \)


Module 5: Robotics Interlude - Reactive Control


5.1   PID Control

 

 
Exercise 1: Recall the winch example: Winch.java. Try different torque (voltage) values to lift the load to the desired height. You will also need Function.java and SimplePlotPanel.java. Upon clicking "stop" you will see how the distance y varies with time.
 
Consider the control problem in the winch example:

 
Consider two broad approaches to control:
 
We'll focus on the latter approach in the winch problem:
 
Exercise 2: Implement proportional control for the horizontal case in the nextStep() method of Winch2.java. Experiment with different values of the constant \(k_P\), for example: \(k_P=50,500.\) What do you observe? Where have you seen this dynamic behavior before? What is the value of yMax in the code? What would happen if we mistakenly set the voltage to \(V(t) = k_P \; (y_{Max} + y(t))\)? Try to reason this out before implementing.
 
To address the above problem, we will use damping:
 
Exercise 3: Implement proportional-derivative control for the horizontal case in Winch3.java. Experiment with different values of the constants \(k_P\) and \(k_D\). For example: \(k_D=10, 100, 1000\) (using previous values of \(k_P=50,500\)). Does any value of \(k_D\) fix the problem?
 
Exercise 4: Apply PD-control to the vertical case, writing that version in Winch4.java. Again, experiment with different values of \(kP\). What do you observe?
 
To address the above problem, we will use integrative-control:
 
Exercise 5: Apply PID-control to the vertical case, writing your code in Winch5.java. Experiment with different \( k_I\) values.
 


5.2   Reactive vs planned control

 

In planned control:

 

Contrast this with reactive control:

 

Can a reactive approach be used in a robot planning problem?

 

We will consider simple range sensors:

 
Exercise 6: Download and unpack carSim.jar. Use java CarGUI manual on the command-line to run in manual mode, then select the Unicycle and "basic sensor". Drive around some obstacles (scene-3 or scene-4) and observe how the sensors work.
 
Exercise 7: Examine the file BasicSensorPack.java. You can access the variable sonarDistance[] to get these distances. Here, sonarDistance[0] is the distance in front (North of the vehicle). Next, use this template to write a simple car controller for Scene-3 that goes towards the obstacle, stops just before it and turns left to face North. Don't forget to select "Basic sensor" in carGUI when testing.
 

Next, we will try and follow the "wall" and wind our way around the obstacle:

 
Exercise 8: Implement the above algorithm in your controller using \(\alpha=10, \delta=40\) and a forward velocity of 10, with Scene-3 as the setting. The NE distance is sonarDistance[7] whereas the SE distance is sonarDistance[5] (going anti-clockwise). Recall that we need to set the steering angle \(\phi\gt 0\) to turn left and \(\phi\lt 0\) to turn right. What do you notice when the unicycle tries to turn right at the obstacle corner?
 

To address the problem:

 
Exercise 9: Implement the above algorithm in your controller. Use vel=2 as the reduced speed. Does it solve the problem?
 

Next, let us use the PID approach:

 
Exercise 10: Implement proportional control in your controller. Use a small (e.g. vel=2) velocity throughout. Experiment with different values of the proportionality constant \(k_P\). What do you observe when the vehicle turns a corner?
 

To damp out the oscillations, let's use differential control:

 
Exercise 11: Add derivative control to your controller. Experiment with different values of the two proportionality constants \(k_P\) and \(k_D\) What do you observe?
 

Bounds on values:

 
Exercise 12: See if bounding the sensor values (as inputs to the algorithm) makes a difference. Observe what happens as the vehicle turns near the third obstacle corner (near the x-axis, as it's headed down).
 

An additional fix:

 
Exercise 13: Implement the above algorithm and see if it works. Can you suggest improvements?
 


5.3   State-based control

 

Now let's return to our original problem of getting the vehicle to a desired destination:

 
Exercise 14: Implement the above in MySimpleCarController2.java and see if it works. What do you observe?
 

To address this problem:

  • We need to give "turning" enough time.
              \(\Rightarrow\) We need to stay "in turning mode" for a while.
              \(\Rightarrow\) Need state-based control.

  • Key ideas in state-based control:
    • Know which "state" you are in.
    • In each state, apply appropriate control.

  • Let's try this out:
         1.   if state = Turn-To-Goal
         2.       φ = kP (γ - θ)            // Turn towards goal.
         3.       if γ - θ < ε
         4.           state = Move-Forward  // Change state if direction is correct
         5.       endif
         6.   else if state = Move-Forward
         7.       if dN > δ and |θ-γ| < ε
         8.           move-forward
         9.       else
         10.          follow-wall           // As in the previous section.
         11.      endif
         12.  endif
         
 
Exercise 15: Implement the above algorithm and see if it works.
 

Re-seeking the goal:

  • When wall-following, we could potentially turn away from the goal
              \(\Rightarrow\) We need to keep looking to see if we can get to the goal.

  • Key ideas:
    • While wall-following, see if we have line-of-sight to goal.
    • Since we don't have line-of-sight, we'll use an approximation:

  • Pseudocode:
         1.   if state = Turn-To-Goal
         2.       φ = kP (γ - θ)            // Turn towards goal.
         3.       if γ - θ < ε
         4.           state = Move-Forward  // Change state if direction is correct
         5.       endif
         6.   else if state = Move-Forward
         7.       if dN > δ and |θ-γ| < ε
         8.           move forward
         9.       else
         10.          follow-wall           // As before.
         11.      endif
         12.      if open-to-goal
         13.          state = Turn-To-Goal
         14.      endif
         12.  endif
         
 
Exercise 16: Implement the above in MySimpleCarController3.java and see if it works. The open-to-goal test has been implemented for you.
 
Exercise 17: How can you determine whether it's closer to turn clockwise vs. anticlockwise?
 
Exercise 18: What happens if we are too close to an obstacle on the left side? What changes are needed for obstacle avoidance on the left?
 
Exercise 19: Assuming obstacle avoidance works, draw on paper a scenario on paper where the above goal-seeking algorithm fails to reach the goal. Suggest a better algorithm.
 


5.4   Further info

 

About control theory:

  • We have only superficially covered a single problem in control theory.

  • Control theory is a vast subject with many results.
    • Linear control theory (including PID).
    • Non-linear control theory.
    • Stochastic control theory.

  • Where is control-theory applied in robotics?
    • Simple control theory is useful in optimizing motion.
                e.g., optimal turning for Dubin car (single turn)
    • Advanced control theory is useful in understanding fundamental limitations in control (e.g., PD-control vs. PID-control)


Controlling a robot is more than just control theory:
  • At the highest level, there's planning (e.g., the A* algorithm):
    • Planning takes a distant goal and tries to, using knowledge from sensors/data etc, create a path.
    • Example: various configurations in folding a multi-link arm.

  • Executing a plan requires maneuvers in small steps between various steps:
    • A control algorithm enhanced with PID can create smooth maneuvers.

  • Sometimes, the controls depend on the "state", as we've seen in the above examples.



© 2008, Rahul Simha