Staggering Proportions: Design Lab 5 6.01 - Spring 2013

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Design Lab 5 6.

01 Spring 2013 Staggering Proportions


Goals: In this lab, we will program the robot to move parallel to a wall, while maintaining a constant, desired distance from the wall. Although this task is closely related to the wall nder task (Design Lab 4), we will nd that a simple proportional controller has poor performance. We will create a model of the system to understand the source of the problem, so that we can implement a more sophisticated controller with much better performance (next week).

1 Proportional wall-follower
We wish to drive the robot at a constant forward velocity of V = 0.1 m/s along a wall. To maintain a constant distance between the robot and wall, we will steer left if the robot is too close to the wall and steer right otherwise. We will think about this problem as a control problem in which we set the rotational velocity [n] (not shown) to reduce the error between the desired distance di [n] = 0.5 m and the actual distance do [n]. Then if the error e[n] = di [n] do [n] is positive (indicating that the robot is too close to the wall), we will set [n] to be positive, which will steer left (which increases [n], and ultimately increases do [n]).

[n 1] do [n] do [ n 1 ]
wall

VT
desired path

di [n] = 0.5 m

Edit the le wallFollowerBrain.py to implement a proportional controller. We have provided a procedure called sonarDist.getDistanceRight to calculate the perpendicular distance to the wall from inp.sonars, as follows. If both sonars 6 and 7 hit the wall (as indicated by values less than sonarMax), then these hits establish a straight line, from which the perpendicular distance is calculated. If only one of sonars 6 and 7 hit the wall, then that sonar distance is returned (since we cannot triangulate the position of the wall). If neither of sonars 6 and 7 hits, then None is returned. Test your code by using soar in wallFollowerWorld.py. Notice that the brain has code to plot the distance to the wall as a function of discrete time (where one step is 0.1 seconds) after the brain has been stopped. Experiment with a few values of the gain of your proportional controller to determine how gain aects the resulting behavior. For each oscillatory response, determine the period of the oscillation, and enter the gain and period in the table below. Save plots for three values of gain to illustrate the trends that you found.

Design Lab 5

6.01 Spring 2013

period

Checko 1.

Show your three plots to a sta member. What quantities (and units) are represented on the x and y axes? Describe how the gain K aects behavior of the wall-follower. What value of K is best, and why? Compare the eect of K in this lab and in Design Lab 4 (wall nder).

2 Modeling Behavior with Dierence Equations


We can think of the wall nder system as a control system with the following form.

Di

error

controller

command sensor

plant

Do

2.1 Controller model


Assume that the controller can instantly set the rotational velocity [n] to be proportional to the error e[n], with proportionality constant K. Express this relation as a dierence equation.

Design Lab 5

6.01 Spring 2013

2.2 Plant model


We can think of the plant as containing two parts in cascade. The rst part determines how the angular position of the robot [n] depends on angular velocity [n], and the second part determines how distance to the wall do [n] depends on angular position [n].

2.2.1 Plant 1
Write an expression for [n], the robots angular orientation with respect to the wall, that depends on its rotational velocity. Assume that the rotational velocity at time n 1 is [n 1], and that this rotational velocity is constant until time n. Also assume that the time between steps is T .

2.2.2 Plant 2
Write an expression for do [n], that depends on angular displacement. Assume that the angular displacement at time n 1 is [n 1], and that this angular displacement is constant until time n. Assume that the forward velocity is constant, at V m/s. Linearize the resulting dierence equation using the small angle approximation (i.e., if is small, then sin ). This approximation makes our model linear, allowing us to analyze it easily. It may be useful, however, to think about the consequences of this approximation when trying to account for behaviors in subsequent sections.

2.3 Sensor model


To keep things simple, we will model the sensor as a wire: that is, assume it introduces no delay.

Design Lab 5

6.01 Spring 2013

2.4 System Functional


The subsystems represented by the three dierence equations above connect together to form a system of the following form. Label the boxes to correspond with the model elements (controller, plant1, plant2) in the previous section, and label the wires with the corresponding signals.

+
Convert your dierence equations into operator (R) equations, and nd the system functional.

H=

Do = Di

DL05/sf

Enter the system functional into the tutor, and submit.

2.5 Poles
Find an algebraic expression for the poles p of the system.

p=

Design Lab 5

6.01 Spring 2013

2.6 Fundamental Modes


Choose one of the poles p, and make a sketch of the real part of (pn ) versus n, when K = 1, T = 0.1 second, and V = 0.1 m/s. Also, sketch the imaginary part (pn ) versus n. What do these plots tell you about the response of the system?

real part

n 50 100 150 200

imaginary part

n 50 100 150 200

2.7 Root locus


Draw a line (or lines) on the complex plane (shown below) to indicate the pole locations that result for all possible gains K, as determined in Section 2.5. Indicate (with s) the pole locations associated with each of the gains you used in Checko 1.
Im

Re

Checko 2.

Describe the poles of the wall follower system. How does the gain K aect the poles? What are the implications of the poles for system behavior? Explain the extent to which these implications are consistent with the results from Checko 1.

Design Lab 5

6.01 Spring 2013

3 Software model
In this weeks software lab, you implemented a SystemFunctional class to represent and analyze the performance of linear, time-invariant systems. We can use that class to automate much of the preceding algebra, which is especially useful for large systems that would be dicult to analyze by hand. Write a procedure called wallFollowerModel to model the behavior of the wall follower system. The procedure should take a single input, which is the gain K, and return the corresponding system functional (where T = 0.1 second and V = 0.1 m/s). We have provided a template le called wallFollowerModel.py. The template le will automatically load the sta version of the SystemFunctional class and associated procedures from this weeks software lab. You can access these classes and procedures as sf.SystemFunctional, sf.Cascade, sf.FeedbackAdd, sf.Gain, and sf.R. We have also provided a procedure called sf.FeedbackSubtract, which is similar to sf.FeedbackAdd except that the feedback path is subtracted (instead of being added) to the input. We recommend that you use the sta 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. DL05/model Enter the denition for wallFollowerModel and any procedures it calls into the tutor.

Dene a SystemFunctional for each of the values of K from Checko 1. Use the dominantPole method to determine the period that corresponds to each gain. Enter results in the following table. Trigonometric functions and other math utilities are available in the math module (e.g., math.atan2).

dominant pole

period from pole

period from Checko 1

Checko 3.

Show your results to a sta member. Explain similarities and dierences between your results in this part and your results in Checko 1.

You might also like