Você está na página 1de 4

Design Lab 4

6.01 Spring 2013


Hitting the Wall
Goals:

The goal of this lab is to understand fundamental limits on how quickly and
accurately the robot can move from one location to another. We will find that
achieving either speed or accuracy is easy, but achieving both simultaneously is
difficult (or impossible). In this and the next two labs, we will explore increasingly sophisticated control schemes to improve performance.

Do this lab with your assigned partner.


Get todays files. Open a terminal window (press ctrl + alt + t) and type

> athrun 6.01 getFiles


to set up files for todays exercises in your Athena directory. These files are also available under
the Calendar tab of the 6.01 website.

1 Proportional controller
We wish to program the robot to move toward (or away from) a wall, so as to adjust its position to be
half a meter from the wall. One strategy (which is called bang-bang control) is to move forward
(with a fixed velocity V ) when the distance is greater than half a meter, and to move backward
(with the same speed but opposite direction) otherwise.
Check Yourself 1. What is good about this strategy? What is bad about it?
A more sophisticated strategy is proportional control. In this strategy, the robots velocity is made
proportional to the difference between its desired distance to the wall and its actual distance to the
wall. We will call the proportionality constant K the gain.
Implement a proportional controller by completing the definition of the step procedure in
wallFinderBrain.py. Test your code with soar in the wallFinderWorld.py. When you stop
the simulation, soar will plot the sequence of distances to the wall during the run.
Find three different values of K: one for which the distance converges monotonically, one for which
it oscillates and converges, and one for which it does not converge.

monotonic convergence

oscillatory convergence

does not converge

K =
Make plots for each of these K values. Email your code and plots to your partner.
Checkoff 1.

Show your controller code and plots to a staff member, and discuss which
gains generate which results, and speculate why.
1

Design Lab 4

6.01 Spring 2013

2 Modeling Behavior with Difference Equations


The brain/robot system you just experimented with is an example of a simple control system with
a single input (the desired distance to the wall) and a single output (the actual distance to the wall).
We can think of the control system as having three subsystems: the controller, the plant, and
the sensor.

error

controller

command

plant

sensor
Figure 1 Structure of Control System.
For todays lab, the controller is the robots brain, the plant is the part of the system that is being
controlled (i.e., the robots locomotion system, whose input is an io.Action and whose output is
the robots position), and the sensor is the robots sonars.
Make a mathematical model of the wall finder system as follows. Let do [n] (the o stands for
output) represent the current distance from the robot to the wall, and let di [n] (the i stands for
input) represent the (current) desired distance to the wall. Also let v represent the forward velocity
of the robot. Let T = 0.1 seconds represent the time between steps.

di [n]
do [n]
When the robot receives a new command, we assume that the robot immediately changes its velocity and then holds the new velocity constant until it receives the next command (i.e., the robot
accelerates so fast that we can ignore the acceleration time).
Check Yourself 2. Given the following conditions, what is the distance to the wall on step 1?
v[0] = 1
do [0] = 3

v[1] = 2

do [1] =

Assume the system has the structure shown in Figure 1. Assume that the sensor measures the current distance do [n] and generates the sensed distance ds [n], which is equal to the current distance
delayed by one step time. Let e[n] = di [n] ds [n] represent the error signal, which is the difference between the input distance di [n] and the sensed distance ds [n]. On each step, the controller
commands a forward velocity v[n] in proportion to the error so that v[n] = Ke[n].
Check Yourself 3. Fully label the following diagram. Include do [n], di [n], ds [n], v[n], e[n].

plant

controller
sensor

Design Lab 4

6.01 Spring 2013

Determine difference equations (using constants T and K) to relate the input and output signals of
the following system components.

the controller
the model of the plant
the model of the sensor
Make block diagrams for each of the elements in the system. Use only delays (R), gains, and
adders. Enter your diagrams in the boxes below.
plant
controller

Di

0.1

Do

sensor
Combine these equations to derive a single difference equation for the system. Solve the difference
equation for the current output do [n] in terms of
previous values of the output (do [n 1], do [n 2], ...) and
current and previous values of the input (di [n], di [n 1], ...).

do [n] =
+

Checkoff 2.

do [n 1]+

do [n 2]

di [n]+

di [n 1]+

di [n 2]

Explain your system diagram and difference equations to a staff member.


3

Design Lab 4

6.01 Spring 2013

3 Simulating Behavior with State Machines


We can use the state machine class developed in software lab 4 to simulate the behavior of the
wallFinder system. We have provided a template file called wallFinderModel.py. The template
file will automatically load staff versions of the SM class from Software Lab 4. We recommend that
you use these staff versions while you are developing your new code. If you have time at the end
of this lab, it would be very cool to use your own versions of this code instead of ours.
Write a procedure called wallFinderModel that takes two inputs the gain K, and the initial
distance to the wall start and returns a state machine. Run the state machine to simulate the
response of the wall finder system as it approaches its final location, half a meter from the wall.
Code to generate plots has already been included in wallFinderModel.py. To make plots, start
idle with the -n switch,
> idle -n

Simulate the behaviors for the same gains you used in Checkoff 1. In what ways are the state
machine simulations similar/different from results from soar?

4 Limitations of the Model


There are several features of the robot that are built into soar but not in the simple block diagrams. For example, the speed of the robot is limited by its motors to approximately 0.5 m/s. This
limitation is not built into our simple state machine models of ideal delays, adders, and gains.
One way to reduce the effects of the velocity limitation is to move the starting position of the robot
closer to the desired location. A world called wallFinderCloseWorld.py has been provided for
that purpose.
Compare results for wallFinderCloseWorld.py to the state machine model. What features work
better/worse relative to wallFinderWorld.py?
Checkoff 3.

Explain your plots for the state machine simulations to a staff member. Explain how these plots are similar/different from those from soar (Checkoff
1). Speculate on why the results might differ.

Você também pode gostar