## Homework 2: LQR

Due 5pm 3/11/2012 in the TA's emailbox.

This assignment is to solve two LQR problems.

1. In the first problem, a robot moves in the x/y plane. The robot's control actions, u_1 and u_2, are to specify a desired x and y velocity, respectively. The only complication is that the robot experiences an additional velocity in the x-direction induced by the "wind" that is linearly proportional to it's distance from the origin along the y-axis. In other words, the x velocity is equal to: x_vel = u_1 + b*y, where b is a constant that denotes how strong the wind is. The y velocity is equal to just u_2.

Use finite horizon LQR to solve this problem. Let T=1000, dT = 0.025, b=1, Q_F = eye*100, Q=eye*1, and R=eye*1 (where eye denotes the identity matrix). You should solve for the optimal policy for this system where the cost function is centered at the origin. You should produce a PDF of two plots: one showing the path found by LQR starting at x=1, y=0 and the other showing the path found starting at x=-1, y=0.

2. In the second problem, a robot can move back and forth along a straight road that goes over the top of a mountain. If the robot moves to the right of the mountaintop, then the robot is pulled further to the right. Conversely, the robot is pulled to the left if it moves to the left of the mountaintop. The control input is a single (scalar) acceleration command. Specifically, the equation of motion is as follows: x_acc = u + x*b, where u is the control input and b denotes the amount by which the robot is "pulled" to the left or right in proportion to its distance from the top.

Use finite horizon LQR to solve this problem. Let T=1000, dT = 0.025, b=1, Q_F = eye*100, Q=eye*1, and R=eye*1 (where eye denotes the identity matrix). You should solve for the optimal policy for this system where the cost function is centered at the origin. You should produce a PDF of two plots: one showing the path found by LQR starting at x=1, x_vel=0 and the other showing the path found starting at x=-1, x_vel=0.

The programming should be done in MATLAB. Students may get access to MATLAB here. Alternatively, students may code in Python (using Numpy). If the student would rather code in a different language, please see Dr Platt or the TA.

Students should submit their homework via email to the TA (suchismi@buffalo.edu) in the form of a ZIP file that includes the following:

1. A single PDF file that containing the plots for each LQR solution.

2. A text file showing output from a sample run of your code.

3. A directory containing all source code for your project.

4. A short readme file enumerating the important files in your submission.