Week 1: Building Foundations
March 26, 2026
The joy of learning again. After years of grinding through standard, textbook questions, I envied change, an opportunity to apply that theoretical knowledge into practice. This project provided exactly that. While it still relies heavily on that foundational math, the context is entirely different. It’s a fresh, complex challenge that makes all those years of theory finally feel justified and worth spending time on
For the first few weeks, I will focus on the simulation aspect of my project; after that, I will return to China and stay there until the end of May. Delaying the construction of the physical model both saves the hassle of transporting across borders and gives me access to a wider range of options for parts.
My goal for this week is to completely understand the physics behind this system and derive the governing equations of motion that will allow me to automate the balancing process. These equations will make up the foundation of my project, as both the “sim” and the “real” will rely on the physics of this system to function.
The first, most obvious thought that came to mind was using Newton’s laws to derive equations through balancing forces, Newtonian Mechanics. This idea was quickly scratched when I realized the sheer complexity of the formulas required for this method. Then, borrowing knowledge from my Quantum Physics class, I thought about another way, Euler-Lagrange. This method ignores forces and focuses solely on the energy of a system, eliminating the calculations required to find the forces on a tilting rod on a moving cart.
But before any equations are first derived, the knowns and unknowns of the system need to be established.
System Parameters:
- M: Mass of cart
- m: Mass of pendulum
- I: Moment of Inertia of the pendulum about its center of mass
- x: Horizontal position of the cart
- θ: Angle of the pendulum
- l: Distance from pivot to pendulum center of mass
- F: External force applied to the cart
From these parameters, some basic equations, such as the location of the pendulum’s center of mass and the Lagrangian, can be derived. These are crucial to the control system, as some of these parameters are the exact values the controller aims to minimize to achieve balance.
The core idea behind the Euler-Lagrange method is to look at the system’s total energy—specifically, the Lagrangian (L), which is just the difference between the total kinetic energy (T) and the potential energy (U):
![]()
By mapping out the kinetic energy of the moving cart and the swinging pendulum, and subtracting the potential energy of gravity pulling on the pendulum’s center of mass, we can run the Lagrangian through a set of partial derivatives to find our equations of motion.
![]()
![]()
However, the equations that we are left with are full of non-linearities, like the theta^2 term. A Linear Quadratic Regulator (LQR) does not like those very much; therefore, we need to linearize them. Luckily, we can use small-angle approximations to eliminate some of those terms, giving us clean, linear equations.
![]()
![]()
With these 2 equations, the physics of the simulation is ready; the next step is to embed them into a State-space model for the controller to use. See you next week.
Reader Interactions
Comments
Leave a Reply
You must be logged in to post a comment.

Hi Yin. Are there supossed to be equations inserted in the text? Not sure if it’s my laptop’s problem or what, but I only see the little image symbol where I imagine something is supossed to be.
Also, are you using MatLab for sims? Using CMU email or paying?