6.01 Midterm 1 Spring 2011: Name: Section
6.01 Midterm 1 Spring 2011: Name: Section
6.01 Midterm 1 Spring 2011: Name: Section
01 Midterm 1
Name:
Spring 2011
Section:
For sta use: 1. 2. 3. 4. 5. total: /16 /24 /16 /28 /16 /100
6.01 Midterm 1
Spring 2011
list of pole(s):
6.01 Midterm 1
Spring 2011
System 2: Consider a dierent system that can be described by a dierence equation of the form
1 1 j . 2 3
A =
B=
6.01 Midterm 1
Spring 2011
>>> p = Polygon([Point(0,0),Point(1,0),Point(1,1),Point(0,1)])
>>> p.perimeter()
4.0 class Polygon:
6.01 Midterm 1
Spring 2011
6.01 Midterm 1
Spring 2011
Assume that the __init__ method for the Polygon class initializes the attribute edges to be a list of Edge instances for the polygon, as well as initializing the points. Dene a new method, sumForEdges, for the Polygon class that takes a procedure as an argument, which applies the procedure to each edge and returns the sum of the results. The example below simply returns the number of edges in the polygon.
>>> p = Polygon([Point(0,0),Point(2,0),Point(2,1),Point(0,1)])
>>> p.sumForEdges(lambda e: 1)
4
6.01 Midterm 1
Spring 2011
6.01 Midterm 1
Spring 2011
x[n] 1 n
Find y[4] and enter its value in the box below.
y[4] =
6.01 Midterm 1
Spring 2011
It is possible to choose coecients for the block diagram on the right so that the systems repre sented by the left and right block diagrams are equivalent. 1 Enter values of p0 , p1 , A, and B that will make the systems equivalent in the boxes below
p0 =
A=
p1 =
B=
Two systems are equivalent if identical inputs generate identical outputs when each system is started from rest (i.e., all delay outputs are initially zero).
6.01 Midterm 1
Spring 2011
Next, we create a class for dening rules. Each rule species the next state, forward velocity and rotational velocity that should result when the robot is in a specied current state and receives a particular type of input. Here is the denition of the class Rule:
class Rule: def __init__(self, currentState, inpType, nextState, outFvel, outRvel):
self.currentState = currentState
self.inpType = inpType
self.nextState = nextState
self.outFvel = outFvel
self.outRvel = outRvel
which says that if we are in state NotFollowing and we get an input of type frontWall, we should transition to state Following and output zero forward and rotational velocities. Finally, we will specify the new state machine class called Robot, which takes a start state, a list of Rule instances, and a procedure to classify input types. The following statement creates an instance of the Robot class that we can use to control the robot in a Soar brain.
r = Robot(NotFollowing, [Rule(NotFollowing, noWall, NotFollowing, 0.1, 0.0), Rule(NotFollowing, frontWall, Following, 0.0, 0.0), Rule(Following, frontWall, Following, 0.0, 0.1)], inpClassifier)
Assume it is an error if a combination of state and input type occurs that is not covered in the rules. In that case, the state will not change and the output will be an action with zero velocities.
10
6.01 Midterm 1
Spring 2011
sonars[3]
1.0 0.4 0.4
sonars[7]
5.0 5.0 5.0
next state
11
6.01 Midterm 1
Spring 2011
Write an instance of the Robot class that implements the charge-and-retreat behavior described above. Make sure that you cover all the cases.
12
6.01 Midterm 1
Spring 2011
13
6.01 Midterm 1
Spring 2011
14
6.01 Midterm 1
Spring 2011
H
System 1
Assume that the system function for H can be written as a ratio of polynomials in R with constant, real-valued, coecients. In this problem, we investigate when the system H is equivalent to the following feedback system
FA =
1 1+H
FB =
1 1H
FC =
H 1+H
FD =
H 1H
Enter FA or FB or FC or FD or None:
15
6.01 Midterm 1
Spring 2011
Let H3 =
Pole(s) of H3 :
16
6.01 Midterm 1
Spring 2011
the input H is a sf.SystemFunction that represents the system H, and H the output is a sf.SystemFunction that represents . 1H You may use the SystemFunction class and other procedures in sf:
Attributes and methods of SystemFunction class:
__init__(self, numPoly, denomPoly)
poles(self)
poleMagnitudes(self)
dominantPole(self)
numerator
denominator
Procedures in sf
sf.Cascade(sf1, sf2)
sf.FeedbackSubtract(sf1, sf2)
sf.FeedbackAdd(sf1, sf2)
sf.Gain(c)
def insideOut(H):
17
6.01 Midterm 1
Spring 2011
18
6.01 Midterm 1
Spring 2011
19
6.01 Midterm 1
Spring 2011
Next, we create a class for dening rules. Each rule species the next state, forward velocity and rotational velocity that should result when the robot is in a specied current state and receives a particular type of input. Here is the denition of the class Rule:
class Rule: def __init__(self, currentState, inpType, nextState, outFvel, outRvel): self.currentState = currentState self.inpType = inpType self.nextState = nextState self.outFvel = outFvel self.outRvel = outRvel
which says that if we are in state NotFollowing and we get an input of type frontWall, we should transition to state Following and output zero forward and rotational velocities. Finally, we will specify the new state machine class called Robot, which takes a start state, a list of Rule instances, and a procedure to classify input types. The following statement creates an instance of the Robot class that we can use to control the robot in a Soar brain.
r = Robot(NotFollowing, [Rule(NotFollowing, noWall, NotFollowing, 0.1, 0.0), Rule(NotFollowing, frontWall, Following, 0.0, 0.0), Rule(Following, frontWall, Following, 0.0, 0.1)], inpClassifier)
Assume it is an error if a combination of state and input type occurs that is not covered in the rules. In that case, the state will not change and the output will be an action with zero velocities.
20
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.