Module 5: Robotics Interlude - Reactive Control


PID Control

Exercise 1: Recall the winch example: Winch.java. Try different torque values to lift the load to the desired height.
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 in Winch.java for the horizontal case. Experiment with different values of the constant kP, for example: kP=5, 10, 50. What do you observe? Where have you seen this dynamic behavior before?
To address the above problem, we will use damping:
Exercise 3: Implement proportional-derivative control in Winch.java for the horizontal case. Experiment with different values of the constants kP and kD. For example: kD=10, 100, 1000 (using previous values of kP). Does any value of kD fix the problem?
Exercise 4: Apply PD-control to the vertical case. What do you observe?
To address the above problem, we will use integrative-control:
Exercise 5: Apply PID-control to the vertical case. Experiment with different kI values.

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 α=10, δ=40 and a forward velocity of 10. 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 φ>0 to turn left and φ<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 kP. 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 wo proportionality constants kP and kD 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?

Goal seeking

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

  • Assumptions:
    • Destination coordinates are known.
    • Nothing is known about obstacles.
    • We will have readings from the 8 range sensors at any time.
  • A simple algorithm:

    • Head towards goal
                => We can do this because we can compute the angle towards the goal
    • If an obstacle is encountered, use wall-following to go around the obstacle

  • Some notation:
              θ = current orientation (heading)
              γ = direction to goal

  • Pseudocode:
          Algorithm: follow-wall
          1.   if dN > δ and |θ-γ| > ε
                   // There's no obstacle, but we're not in the right direction.
          2.       turn towards goal
          3.   else if dN > δ and |θ-γ| < ε
                   // We're in the right direction, and there's no obstacle.
          4.       move forward
          5.   else
          6.       follow wall
          7.   endif
          

Exercise 14: Implement the above in MySimpleCarController2.java and see if it works.

To address this problem:

  • We need to give "turning" enough time.
              => We need to stay "in turning mode" for a while.
              => 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 γ - θ < &epsilon
         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           // We have the algorithm for this.
         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
              => 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 γ - θ < &epsilon
         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           // We have the algorithm for this.
         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.

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)