This assignment has several parts: LQR control design, Kalman filter design, and nonlinear policy design using whatever technique you want to try out. We will again use the two-wheel inverted pendulum (TWIP) After doing this assignment you will have experience using "traditional" optimal control design techniques, and if you choose, reinforcement learning. I want you to use some kind of AI (ChatGPT, Gemini, Claude, ...) to do this assignment, in order to develop skills in using this new technology. I use AI to derive dynamic models and write code. A challenge for you is to guide the AI to get the right answer. In order to do this, you have to be able to tell when an answer is not correct. Looking at simulator output, and testing the data against a dynamic model derived in a different way are good ways to do this. Here is my chat about TWIPs with ChatGPT which shows how to linearize the dynamics, here is how to make the Kalman filter with hacks for a unicycle, and here is another example of using an AI: ChatGPT. The initial prompt.
The Q and R cost matrices are the design variables used to control how the LQR technique designs the controller. Play with them. What happens if you increase or decrease R? What happens if you increase or decrease the relative cost of body angle states vs. wheel angle states? What happens if you increase or decrease the relative cost of positions vs. velocities?
As part of the writeup, please produce plots of the TWIP states vs. time to demonstrate the results and tuning. The TAs can process pictures effectively.
You need to choose the variance of the process noise (Qf) and measurement noise (Rf). These variables are the design variables for the filter, rather than representing realistic estimates of the sensor variances. To choose Qf and Rf, you should simulate the filter with some added process and measurement noise (you can drive the TWIP around using the LQR controller to do these tests). What happens when you increase or decrease Rf? What happens when you increase or decrease the variance of the accelerometer relative to the encoder that measures wheel angle?
As part of the writeup, please produce plots of the estimated and actual TWIP states over time to demonstrate filter performance and any improvements due to tuning. The TAs can process pictures effectively.
One of the TAs recommended this lecture with these slides.
You need to make up an optimization criterion (it can be the same or different from your LQR cost function). Methods you could try include some variant of dynamic programming, or some variant of reinforcement learning like PPO. Get the AI to write the code to create this controller.
It would be nice to compare the LQR (linear) and your nonlinear policy. Under what conditions is there a significant difference in performance. Plots comparing performance are useful.
Using any method you want, including reinforcement learning, output a time-optimal trajectory to any desired wheel_angle (and corresponding location) obeying the no-slip and torque limit constraints.
It would be nice to compare your LQR (linear) controller, your nonlinear regulator, and your nonlinear trajectory follower. Plots are appreciated.
Rant: In the machine learning world this is often called a "goal conditioned" policy. I find this terminology confusing. It arises from the probabilistic nature of many RL policies p(action|state,goal), where the probability of an action is conditioned on a state and a goal. Given that the probabilistic nature of many RL policies is a hack to encourage exploration, high performance policies with known or learned models after exploration is done are typically deterministic and it doesn't make sense to use any term like "X conditioned".
What to turn in: Your (or an AI's) writeup of what you did, how you did it, and what you learned is what is important here. Provide any prompts and responses from any AI you used, as well as code you or an AI wrote.