
This lecture gives you a guide for how to study the course in order to take the maximum value out of it.
This lecture explains how a controller uses the error between reference and tank volume to set the mass flow rate, with modern implementations as computer algorithms.
Explore the key differences between open loop and closed loop systems, highlighting how feedback from sensors and controllers adjusts input to achieve targets like mass flow rate and tank level.
Shows controlling a water tank with a feedback controller, using large mass flow steps to meet a target quickly, then notes minor wiggles as the level oscillates around the reference.
A proportional controller multiplies the error by a gain to set the mass flow rate, steering the water tank toward the desired volume as the error approaches zero.
Learn how to approximate volume over time using numerical integration, applying the trapezoidal rule to update water volume with discrete time steps, mass flow rate, and density.
Explore a closed loop water tank system modeled in continuous and discrete mathematics. A proportional controller updates mass flow rate at 50 Hz to track changing volume references.
See how a proportional controller with kp of 100 drives the tank level toward the reference line via mass flow rate, then kp of 1000 yields faster response and tracking.
Explore a frictionless magnetic train that uses a PID controller to catch randomly falling objects. See why a proportional controller fails here and how PID components improve control, with code.
This video directs you to the PID simulation codes at the end of the first section and the NPC codes at the NPC coding section, and requests your feedback.
Translate acceleration into velocity and then position through numerical integration. Convert continuous equations to discrete form for implementation in code, using time steps and a water tank analogy.
A proportional controller converts position error into acceleration via kp, causing the train to overshoot and oscillate around the reference point as force aligns with the error.
Explain how a proportional controller yields zero acceleration at zero error, yet the train overshoots because velocity remains nonzero and the position keeps moving past the target.
Explain why a proportional controller cannot handle two integrators in a train model and how adding a derivative controller enables reaching the target position.
Learn how a derivative controller, when combined with a proportional controller, creates a PD controller that shapes the system response by damping error and stabilizing the train's motion.
Tune the controller by selecting kp and kd to balance proportional and derivative effects, so the derivative resists rapid error changes while the proportional pulls toward the reference line.
Explore the PID controller integral part and how gravity on an inclined rail yields normal and tangential components, balanced by normal force and motion via tangential component.
Move to a 45-degree incline to reveal the tangential component of gravity accelerates the train along the rails, and incorporate this component in magnet-induced force equations.
Sum the tangential gravity and magnet forces to obtain the net force, decompose into x and y, and apply double integration to velocity and position, highlighting the integral controller.
Analyze a train on an incline under a PD controller, where zero error and zero derivative fail to counter gravity, creating steady state error that integral action resolves.
Demonstrates how integral control, combined with proportional and derivative actions (PID), eliminates steady-state error by accumulating the error over time and providing corrective force.
Demonstrates a PID-controlled magnetic train simulation with inclination angle, tuning gains, and real-time error, derivative, and integral analysis to improve tracking across five trials.
Explore Linux terminal, macOS terminal, and Windows command prompt to run Python files, navigate folders with cd and ls or dir, and master basic terminal commands.
Install python and its libraries numpy and map plot lib exactly as shown to ensure compatibility, using the tested versions on Windows 10 and macOS Big Sur.
Install python on Windows 11, add to path, test hello world, then install numpy, matplotlib, scipy, cvxopt, qp solvers, sympy, control, and moviepy for MPC and LQR in autonomous vehicles.
Install python 3.8.7 on macOS, test with a hello world script in the terminal, then install pip and numpy.
The lecture explains Python code for a pid train simulation that catches cubes on an inclined rail, detailing library imports, random positions, time arrays, and preallocated data structures.
Explain a Python multi-trial simulation with nested loops, computing PID error, derivative, and integral, applying force with gravity, and updating velocity and position via trapezoidal integration to get x and y.
Learn how a PID controller aligns train and cube center points to catch the cube, using horizontal and vertical thresholds, trial-and-error tuning, and Python animation for visualization.
Explore how to create Python animations with Matplotlib, build figures with subplots, define animated objects, and use FuncAnimation to visualize data over frames.
Explore modeling a cylindrical water tank with radius and volume bounds, using a time vector and frame-based animation to visualize proportional control of tank volumes toward references.
Learn MPC, a universal technique that fuses with real-world applications and feels intuitive, and develop the three core abilities: understand the problem intuitively, quantify it mathematically, and translate into code.
Model a simple autonomous car with constant forward velocity, using an npc controller for a lane change by steering delta, as a 3-dof x, y, psi system with mpc concepts.
Explore how forces cause linear acceleration and moments cause rotation, define moment of inertia, and compare how mass distribution affects rotational resistance in objects.
Learn how forces at the center of mass cause translational motion without rotation, while forces away from the center create moments that rotate the rod.
Explore converting body-frame velocities to the global earth-fixed frame, and derive X dot and Y dot for trajectory error using a 20 m/s longitudinal speed and a PI/6 angle.
Apply the bicycle model delta to a four-wheeled car with Ackerman steering, approximating ideal steering via a trapezoidal linkage that assigns delta1 and delta2 based on turning direction.
The lecture shows how a bicycle model rotates about the center of mass, defines the longitudinal and lateral body frame, and describes velocity directions and the slip angle beta.
Explain how a bicycle model uses longitudinal velocity along the body with a small lateral center-of-mass component, derived from the instantaneous center of rotation and perpendicular velocity directions.
Derive the lateral equation of motion for a bicycle model, linking delta steering to lateral forces and moments, and showing how forces yield lateral acceleration and angular acceleration.
Derives centripetal acceleration for a turning vehicle, using v^2/R and a small slip-angle approximation to relate longitudinal velocity to angular velocity, then connects to vehicle dynamics.
Explore the centripetal acceleration in circular motion, deriving a_c = v^2 / r using calculus, with velocity and acceleration vectors, angular rate, and constant radius.
Express lateral forces as F_yf = C_alpha_f alpha_f and F_yr = C_alpha_r alpha_r using the bicycle model, valid for small slip angles.
Explore rear wheel velocity in turning dynamics by relating center of mass motion to rear wheel angle, using a small angle approximation for easier controller design.
Transform the equations of motion and lateral forces into a vector-matrix form. Fill in the matrix and vector in the exercise to advance toward a state-space representation.
Convert the bicycle model's equations of motion to a state-space form, derive matrices A, B, C, D, E, F, and reveal constant-velocity dynamics for controller design.
Identify states as the variables needed to describe a car's behavior, formulating open-loop state-based first-order differential equations with inputs, while keeping states minimal to capture lateral and angular dynamics.
Augment the car control system by adding missing states via variable substitution to build an augmented state-space model with x1 to x4, and rewrite the dynamics using delta as input.
Form state-based equations to simplify the open-loop box and compute state derivatives from initial states using the a-f constants. Update states every 0.1 seconds (10 hz) for the mpc loop.
Explore computing new states in an open-loop system by using an inner loop to subdivide the sample time, increasing derivative precision while the controller runs at 10 Hz.
Explain the open-loop state update algorithm using a single delta over a 0.1 s sample time, subdividing into five steps to compute intermediate states and derivatives, preparing for vector–matrix notation.
Put the system in vector-matrix form to enable model predictive control that minimizes error and delta changes, and compare embassy basic, robust, and non-linear variants with small-angle state-space assumptions.
Compare linear time invariant, linear time varying, and nonlinear state-space models by examining constant versus time varying A, B, C, and D matrices and their impact on outputs.
Explains why the four-state model cannot be cast as a linear time-invariant system due to cos psi and sin psi terms in y dot, with a straight-road simplification.
Derives a linear time-invariant model for autonomous car lateral dynamics using small angle approximations, converting yaw and velocity terms into a state-space with two outputs.
Derive a linear time-invariant state-space model from the bicycle model for lateral control, using small angle approximations and constant velocity, with A, B, C, D constant, D typically zero.
Learn model predictive control through a rocket lander example, predicting multiple steps ahead and tuning thrust to achieve a smooth zero-altitude landing via discrete horizon and error tracking.
Model predictive control selects a sequence of thrust levels from K to K plus five to land smoothly, minimizing a cost function that balances error and feasible thrust.
Describe how a two-part model predictive control cost function is formed and minimized over a five-sample horizon, using error terms and thrust, plus a second term to add realism.
Model predictive control computes a sequence of thrust inputs from a cost function, discusses horizon length tradeoffs, and uses a receding-horizon loop to re-optimize after applying the first input.
Learn how model predictive control fuses sensor data and model predictions with a Kalman filter to counter sensor noise and uncertainty, and explore quadratic cost effects.
Explain why a quadratic cost function enables a well defined minimum in model predictive control, unlike linear or cubic forms, with positive weights and finite j_min.
Quadratic cost functions simplify finding the minimum: set the derivative to zero, use the second derivative to confirm a minimum, with positive weights giving minimum and negative weights indicating maximum.
Compute the gradient of multi-dimensional cost functions and set partial derivatives to zero to locate minima. Quadratic costs with positive weights guarantee the minimum; beware saddle points in higher dimensions.
Explain why quadratic cost functions in model predictive control produce a single smooth minimum with positive weights, avoiding non-smooth absolute-value costs, and how MPC optimizes a five-period horizon trajectory.
Analyze a bicycle model that forms a continuous LTI system with four states and two outputs. Discretize x_{k+1}=A_d x_k + B_d u_k and y_k=C_d x_k + D_d u_k for MPC.
Predict future states of a discrete LTI system with MPC by expressing x_k as A^k x0 plus Delta_0 to Delta_{k-1}, and rewrite to use only five inputs for optimization.
Explore how model predictive control predicts five future states using compact state space vectors, A and B matrices, and first-input optimization to guide autonomous car trajectories.
Learn how to reformulate the MPC cost function with a stronger last-sample weight, diagonal Q and R, and a single steering input in a bicycle model.
Explore how to augment an MPC controller for autonomous cars by modeling the steering input as a change in angle, focusing on minimizing delta delta for smooth lane changes.
Augment the state space by adding the previous steering angle as a state. Model the system with tilde matrices and output tilde for MPC while minimizing cost.
Reframe the MPC error term as reference minus output using a state-space model with a five-step horizon, substituting the Cx terms, and shift inputs to steering deltas for smoother ride.
Expand the MPC cost function by treating inputs as delta steering wheel angles, augment the state, and show constant offsets do not affect the optimal solution.
Rewrite the MPC cost function by combining terms, using a Q diagonal structure, and expand the summation to include K plus I, x tilde, and the R input term.
Rewrite the cost function to depend only on input changes, embed state information in A and B, and derive the gradient to zero to obtain the optimal steering delta sequence.
Derive the gradient of a quadratic vector-matrix cost by treating loop constants, rewriting as f^T W, and showing gradient with respect to W equals the coefficient vector A1 through AD.
Derive the gradient of the quadratic form g(W) = W^T A W and rewrite it as a double sum, clarifying how W, W^T, and A interact in index notation.
Derive the gradient of a quadratic vector-matrix form by expanding index-based sums with diagonal exclusions. Take the partial derivative with respect to w1 to show term-by-term contributions.
Take partial derivatives with respect to W_k, generalizing to any dimension, and reorganize terms to obtain the gradient vector for G(W)=W^T A W.
Derive the gradient of a quadratic vector-matrix form and show that for a symmetric matrix A, the gradient is A W plus F; explain the one-half cost cancellation.
Learn to use Linux Terminal, Mac OS Terminal, and Windows Command Prompt to run Python programs, navigate folders with cd, view files with less, and use tab completion.
Install the Python versions and matplotlib to run simulations, place two downloaded files in same folder, follow installation steps for Windows 10 and Mac OS, and analyze code and results.
Install Python on Windows 11 and configure essential libraries such as numpy, matplotlib, SciPy, Cvxopt, SymPy, and control to support mpc and autonomous vehicle projects.
Install Python 3.8 on Ubuntu 20.04, verify NumPy version, install pip and Matplotlib, and run the simulations from the Linux terminal or Windows command prompt.
Review how the course models a lane change with a bicycle model, lateral control, discrete lti form, and an mpc-style optimization for steering to track a trajectory.
Discover how to implement npc control in code for an autonomous car simulator, covering main and support files, trajectory generation, augmented state, reference signals, and delta computations.
Describe how the init function sets initial vehicle constants (mass, inertia, stiffness, geometry) and defines model predictive control matrices, stored in a reusable constants list for main and support files.
Describe how the state_space function builds discrete A, B, C, D matrices from init data, using mass, inertia, cornering stiffness, wheel distances, sample time, and velocity for NPC/MPC analysis.
Learn how to generate the MPC cost function matrices for autonomous cars by building augmented A, B, C, D matrices and assembling Q, R, S blocks across the horizon.
This lecture explains the open loop new states function, updating the state vector with first derivatives using a 30-step oilor integrator methodology, based on the current state and steering input.
Learn how the code extracts optimal ci and big y values from the augmented state vector to plot horizon-five trajectories, and why it uses only the first control input.
This update precomputes the double bar and other matrices for the LTI system before the main loop, then regenerates them as the horizon shortens toward the end to speed execution.
Learn how Python uses matplotlib to animate simulated data, organizing data first and then displaying it with a 3x3 subplot figure and a FuncAnimation with 10 seconds of frames.
Explore how the autonomous car simulator tests different reference trajectories, showing close following of a wavy parabola with a sinusoid, and how weight matrices control angle tracking.
The world is changing! The technology is changing! The advent of automation in our societies is spreading faster than anyone could have anticipated. At the forefront of our technological progress is autonomy in systems. Self driving cars and other autonomous vehicles are likely to be part of our every day lives. How would you like to understand and be able design these autonomous vehicles? How would you like to understand Mathematics behind it?
Welcome! In this course, you will be exposed to one of the most POWERFUL techniques there are, that are able to guide and control systems precisely and reliably.
You are going to DESIGN, MASTER and APPLY:
mathematical models in the form of state-space systems and equations of motion
a PID controller to a simple magnetic train that needs to catch objects that randomly fall from the sky
a Model Predictive Controller (MPC) to an autonomous car in a simple lane changing maneuver on a straight road at a constant forward speed.
You will LEARN the fundamentals and the logic of Modelling, PID and MPC that will allow you to apply it to other systems you might encounter in the future.
You need 3 things when solving an Engineering problem: INTUITION, MATHEMATICS, CODING! You can't choose - you really need them all. After this course, you will master Modelling, PID and MPC in all these 3 ways. That's a promise!
I'm very excited to have you in my course and I can't wait to teach you what I know.
Let's get started!