Calculator overview
Inputs and outputs
This summary comes from the calculator's published input and output contract.
Inputs
- Pole pair A, real part (required)
-
Unit 1/s Default -3 Range -8 to -0.8
About this input
The real part of pole pair A, per second, from -8 to -0.8: further left is a faster decay. Used in pole placement.
- Pole pair B, imaginary part (required)
-
Unit rad/s Default 0 Range 0 to 8
About this input
The imaginary part of pole pair B, rad/s, from 0 to 8. Used in pole placement.
- Gain on cart velocity (K2) (required)
-
Unit N s/m Default 4 Range -10000 to 10000
About this input
K2, the gain on the cart velocity, in N s/m, from -10000 to 10000. Used in manual mode, checked in both.
- Pole pair A, imaginary part (required)
-
Unit rad/s Default 2 Range 0 to 8
About this input
The imaginary part of pole pair A, rad/s, from 0 to 8: the poles are real part +/- this times i; 0 is a double real pole. Used in pole placement.
- Pole pair B, real part (required)
-
Unit 1/s Default -4 Range -8 to -0.8
About this input
The real part of pole pair B, per second, from -8 to -0.8. Used in pole placement.
- Tap speed (required)
-
Unit deg/s Default 60 Range -360 to 360
About this input
The angular velocity a tap adds to the pole, in degrees per second, from -360 to 360; 0 means no tap.
- Tap time (required)
-
Unit s Default 0.5 Range 0 to 3.98
About this input
When the tap lands, in s, from 0 to 3.98 in steps of 0.02 s; a tap at 0 s is a starting angular velocity.
- Pole length (required)
-
Unit m Default 0.5 Range 0.2 to 2
About this input
l, the pole length from the hinge to the tip mass, in m, from 0.2 to 2.
- Pole tip mass (required)
-
Unit kg Default 0.2 Range 0.05 to 1
About this input
m, the point mass at the tip of the pole, in kg, from 0.05 to 1. The pole itself is massless.
- Challenge number (required)
-
Default 0 Range 0 to 5
About this input
0 for none, or 1 to 5 to load a challenge. A challenge fixes the cart, the pole, the force limit, the controller mode and the disturbance it is about and leaves only its free inputs to you.
- Controller (required)
-
Default Pole placement Allowed Pole placement, Manual gains
About this input
Pole placement (place the four closed-loop poles as two conjugate pairs; the workbook solves the gains) or Manual gains (type the four gains; the workbook gives the closed-loop polynomial and its Routh test), chosen from the list.
- Will it balance? (challenge 1) (required)
-
Default Not yet predicted Allowed Not yet predicted, It balances, It falls
About this input
Your prediction in challenge 1: Not yet predicted, It balances or It falls, chosen from the list. The run stays hidden until you predict.
- Cart mass (required)
-
Unit kg Default 1 Range 0.5 to 5
About this input
M, the cart mass, in kg, from 0.5 to 5.
- Force limit (required)
-
Unit N Default 20 Range 1 to 100
About this input
The largest force the controller can push the cart with, in N, from 1 to 100; a larger requested force is clipped to this.
- Gain on pole angular velocity (K4) (required)
-
Unit N s/rad Default 7 Range -10000 to 10000
About this input
K4, the gain on the pole angular velocity (in rad/s), in N s/rad, from -10000 to 10000. Used in manual mode, checked in both.
- Gain on cart position (K1) (required)
-
Unit N/m Default 2 Range -10000 to 10000
About this input
K1, the gain on the cart position, in N/m, from -10000 to 10000. The force is F = K1 x + K2 v + K3 theta + K4 w, so a stabilising set has all four gains positive. Used in manual mode, checked in both.
- Starting lean (required)
-
Unit deg Default 0 Range -45 to 45
About this input
The pole's lean at t = 0, in degrees from upright, from -45 to 45; positive leans toward +x (right).
- Gain on pole angle (K3) (required)
-
Unit N/rad Default 34 Range -10000 to 10000
About this input
K3, the gain on the pole angle (in radians), in N/rad, from -10000 to 10000. Used in manual mode, checked in both.
Outputs
- Pole pair A imaginary part used
-
Unit rad/s
About this output
The imaginary part of pole pair A used, rad/s; blank in manual mode.
- Plot bound, top
-
Unit m
About this output
The top of the track view, m: 1.1 times the pole length.
- Plot bound, left
-
Unit m
About this output
The left edge of the track view, m (minus plotXMax).
- Pole pair B real part used
-
Unit 1/s
About this output
The real part of pole pair B used, per second; blank in manual mode.
- Pole pair B imaginary part used
-
Unit rad/s
About this output
The imaginary part of pole pair B used, rad/s; blank in manual mode.
- Pole pair A real part used
-
Unit 1/s
About this output
The real part of pole pair A used, per second; blank in manual mode.
- Plot bound, right
-
Unit m
About this output
The right edge of the track view, m: 1.1 times the largest cart or pole-tip distance shown, at least 1.1.
- Model version
-
No unit declared
About this output
The workbook version.
- Model Status
-
No unit declared
About this output
OK, CHECK (the time step is too coarse for the gains, the pole fell over, the run stopped at the state limit, the loop is not stable, or the pole is still swinging at 4 s) or NOT VALID with the reason. When NOT VALID every model result and grid cell is blank; the challenge result, goal and feedback still show.
- Largest cart travel
-
Unit m
About this output
The largest distance of the cart from its start over the run, m.
- Peak force
-
Unit N
About this output
The largest force the controller applies over the run, N.
- Open-loop unstable pole
-
Unit 1/s
About this output
The unstable pole of the uncontrolled cart-pole, sqrt((M + m) g / (M l)), per second: how fast an uncontrolled pole starts to fall.
- Formula module versions
-
No unit declared
About this output
The formula modules embedded in the workbook and their versions.
- Tap speed used
-
Unit deg/s
About this output
The tap speed used, degrees per second (the challenge's when a challenge fixes it).
- Step ratio (step x fastest-pole bound)
-
No unit declared
About this output
The time step times the fastest-pole bound; above 0.5 the run is flagged as not accurate.
- Settling time (within 1 degree)
-
Unit s
About this output
The time from which the pole stays within 1 degree of upright, in s, on a whole row; blank unless the run is Balanced.
- Closed-loop poles in the right half-plane
-
No unit declared
About this output
The number of closed-loop poles in the right half-plane (sign changes of the Routh first column); blank when an entry is zero and while challenge 1 awaits a prediction.
- Time step
-
Unit s
About this output
The fixed Runge-Kutta time step, 0.02 s.
- Tap time used
-
Unit s
About this output
The tap time used, s: the tap row times 0.02 s (the challenge's when a challenge fixes it).
- Frames at the force limit
-
Unit %
About this output
The share of the frames in which the requested force is beyond the force limit (so the force is clipped), percent.
- Pole tip mass used
-
Unit kg
About this output
The pole tip mass used, kg (the challenge's when a challenge fixes it).
- Pole map: the four closed-loop poles in the s-plane (pole placement)
-
No unit declared
About this output
The s-plane: one row per closed-loop pole (Pole 1 to Pole 4) with its real part (per second) and imaginary part (rad/s); the values are blank in manual mode.
- Pole length used
-
Unit m
About this output
The pole length used, m (the challenge's when a challenge fixes it).
- How the run ends
-
No unit declared
About this output
How the nonlinear run ends: Fell over, Stopped early, Upright for now, but not stable, Balanced or Still swinging. Blank while challenge 1 awaits a prediction.
- Routh-Hurwitz verdict
-
No unit declared
About this output
The Routh-Hurwitz verdict on the closed-loop polynomial: Stable, Unstable with the number of right-half-plane poles, or Not stable when a first-column entry is zero (within 1E-9 relative). Blank while challenge 1 awaits a prediction.
- Routh table: the first column of the closed-loop polynomial
-
No unit declared
About this output
The Routh first column: one row per power (s^4 to s^0) with its entry; an entry after a zero is blank, and the values are withheld while challenge 1 awaits a prediction.
- Closed-loop polynomial, a2
-
No unit declared
About this output
a2 of the closed-loop characteristic polynomial.
- Closed-loop polynomial, a1
-
No unit declared
About this output
a1 of the closed-loop characteristic polynomial.
- Closed-loop polynomial, a0
-
No unit declared
About this output
a0 of the closed-loop characteristic polynomial.
- Fall time
-
Unit s
About this output
When the pole passes 90 degrees, in s, interpolated between rows; blank when it does not fall and while challenge 1 awaits a prediction.
- Controller used
-
No unit declared
About this output
The controller mode used (the challenge's when a challenge fixes it).
- Closed-loop polynomial, a3
-
No unit declared
About this output
a3 of the closed-loop characteristic polynomial s^4 + a3 s^3 + a2 s^2 + a1 s + a0 of the linearised loop.
- Challenge result
-
No unit declared
About this output
No challenge selected, MET or NOT MET.
- Challenge feedback
-
No unit declared
About this output
A prompt while challenge 1 awaits a prediction, else the met or not-met feedback of the selected challenge; blank with no challenge.
- Cart mass used
-
Unit kg
About this output
The cart mass used, kg (the challenge's when a challenge fixes it).
- Cart frames: 201 rows (t = 0 to 4 s every 0.02 s) of the nonlinear run and the linear prediction
-
No unit declared
About this output
The film: one row per frame (201, t = 0 to 4 s every 0.02 s) with the time, the cart position, the pole angle, the pole tip x and y (the angle clamped to 90 degrees for drawing), the force, a saturated flag (1 when the force is clipped), and the linear prediction's angle and cart position. Rows after a fall are blank; frames 1 to 200 are withheld while challenge 1 awaits a prediction.
- Challenge score
-
No unit declared
About this output
100 when the selected challenge is met, else 0.
- Challenge: the value scored
-
No unit declared
About this output
The value the selected challenge scores: the unstable pole count (challenge 1), the settling time (challenges 2 and 4, s), the cart travel (challenge 3, m) or the peak force (challenge 5, N); blank with no challenge, while withheld, or when the measure is blank.
- Challenge goal
-
No unit declared
About this output
The goal of the selected challenge; blank with no challenge.
- Largest gap to the linear prediction
-
Unit deg
About this output
The largest difference between the nonlinear run and the linear prediction, degrees: where linear design stops holding.
- Starting lean used
-
Unit deg
About this output
The starting angle used, degrees (the challenge's when a challenge fixes it).
- Gain on pole angular velocity K4
-
Unit N s/rad
About this output
K4, the pole-angular-velocity gain used, N s/rad.
- Largest angle
-
Unit deg
About this output
The largest lean of the pole over the run, degrees.
- Largest angle, linear prediction
-
Unit deg
About this output
The largest lean of the linear prediction (small angles, unlimited force), degrees.
- Fall time, linear prediction
-
Unit s
About this output
When the linear prediction passes 90 degrees, in s; blank when it does not.
- Gain on pole angle K3
-
Unit N/rad
About this output
K3, the pole-angle gain used, N/rad.
- Final cart position
-
Unit m
About this output
The cart position on the last frame, m.
- Final angle
-
Unit deg
About this output
The pole angle on the last frame (4 s, or the fallen frame), degrees.
- Bound on the fastest closed-loop pole
-
Unit rad/s
About this output
An upper bound on the largest closed-loop pole magnitude, rad/s, at most 6.7% above it (a fixed Graeffe-Fujiwara computation, no iteration).
- Gain on cart velocity K2
-
Unit N s/m
About this output
K2, the cart-velocity gain used, N s/m.
- Gain on cart position K1
-
Unit N/m
About this output
K1, the cart-position gain used, N/m: solved from the placed poles in pole placement, the typed gain in manual mode.
- Force limit used
-
Unit N
About this output
The force limit used, N (the challenge's when a challenge fixes it).
LogicCommons is in beta. If a result, label, or reference looks wrong, tell us here; we read every message.
Methodology
Purpose and model boundary
This lab balances a pole on a cart. A cart of mass M runs on a level, frictionless track, and a pole of length l with a point mass m at its tip is hinged on it. You knock the pole with a starting lean and a tap at a moment you choose, and a controller pushes the cart with a horizontal force to bring the pole back upright, or fails and lets it fall. The controller is linear state feedback on the four states (cart position, cart velocity, pole angle and pole angular velocity), limited to a largest force. Its four gains come either from pole placement, where you place the four closed-loop poles as two conjugate pairs in the s-plane and the model solves the gains, or from gains you type by hand, where the model gives the closed-loop polynomial and a Routh-Hurwitz stability verdict.
The model simulates the full nonlinear cart-pole with this controller for 4 s, in 200 fixed steps of the classic fourth-order Runge-Kutta method. Beside it runs the linear prediction: the small-angle plant with a controller that has no force limit, integrated by the same steps. The gap between the two shows where small-angle, unlimited-force design stops holding. From the run it reports whether the pole balances or falls, the settling and fall times, the largest angle, the cart travel, the peak force and how often the force is at its limit. Five scored challenges turn the lab into exercises.
Nothing in the model iterates. The gains, the closed-loop polynomial, the Routh test and the bound on the fastest pole are closed forms of fixed length; each Runge-Kutta step is one explicit row.
It is a lab for learning feedback control, pole placement and stability, not a tool for designing or tuning a real control system. The cart has no friction, the pole is massless apart from its tip mass, the hinge is frictionless, the force acts at once with no actuator lag, and the controller knows the exact state at every moment.
The model is the calculation authority. The page sends the values you set to the model and draws only what the model returns: every cart position, pole angle, pole-tip point, force, placed pole and plot bound comes from the model's results; the page computes no physics value itself.
Inputs and units
| Input | Meaning and unit |
|---|---|
| Controller | Pole placement (the model solves the gains from the poles you place) or Manual gains (you type the four gains). |
| Cart mass | M, from 0.5 to 5 kg. |
| Pole tip mass | m, the point mass at the tip of the pole, from 0.05 to 1 kg. The pole itself is massless. |
| Pole length | l, from the hinge to the tip, from 0.2 to 2 m. |
| Force limit | Fm, the largest force the controller can apply in either direction, from 1 to 100 N. |
| Pole pair A, real part | sA, from −8 to −0.8 per second. Pair A is the two poles sA + i·ωA and sA − i·ωA. |
| Pole pair A, imaginary part | ωA, from 0 to 8 rad/s. 0 makes pair A a double pole on the real axis. |
| Pole pair B, real part | sB, from −8 to −0.8 per second. |
| Pole pair B, imaginary part | ωB, from 0 to 8 rad/s. |
| Gain on cart position (K1) | Manual mode only, from −10,000 to 10,000 N/m. |
| Gain on cart velocity (K2) | Manual mode only, from −10,000 to 10,000 N·s/m. |
| Gain on pole angle (K3) | Manual mode only, from −10,000 to 10,000 N/rad. |
| Gain on pole angular velocity (K4) | Manual mode only, from −10,000 to 10,000 N·s/rad. |
| Starting lean | θ0, the pole's angle from upright at t = 0, from −45 to 45 degrees. |
| Tap speed | The angular velocity a tap adds to the pole at once, from −360 to 360 degrees per second. 0 is no tap. |
| Tap time | When the tap lands, from 0 to 3.98 s, on a whole multiple of the 0.02 s time step. A tap at 0 s is a starting angular velocity. |
| Challenge number | 0 for free exploration; 1 to 5 loads one of the five challenges. |
| Will it balance? (challenge 1) | Not yet predicted, It balances or It falls. Only challenge 1 uses it. |
Sign conventions: the cart position x and the force F are positive to the right. The pole angle θ is measured from upright, positive when the tip is to the right of the hinge, and its angular velocity ω is positive in the same sense. The controller is
F = K1·x + K2·v + K3·θ + K4·ω
with no minus sign, so a gain set that balances the pole has all four gains positive. Many textbooks write u = −K·x; their gains are these with the sign changed. Angles are entered and returned in degrees and used in radians inside the model.
Every input is checked, whether or not the selected controller uses it: the pole inputs in manual mode and the gains in pole placement keep their values and have no effect. Every input is in the input panel. In a challenge, the inputs the challenge fixes cannot be changed.
Governing relationships
Equations of motion. With the tip at (x + l sin θ, l cos θ), the kinetic energy is ½(M + m)v² + m·l·cos θ·v·ω + ½·m·l²·ω² and the potential energy m·g·l·cos θ, with g = 9.80665 m/s². Lagrange's equations, solved for the two accelerations, give the cart acceleration a_x and the pole angular acceleration a_θ:
a_x = (F + m·sin θ·(l·ω² − g·cos θ)) / (M + m·sin² θ)
a_θ = (g·sin θ − a_x·cos θ) / l
The denominator is at least M, so it is never zero.
The controller. At every evaluation the controller computes U = K1·x + K2·v + K3·θ + K4·ω and applies the force F = U clipped to the range from −Fm to Fm. It acts continuously: the force is evaluated at every Runge-Kutta stage, like an analogue controller, not held constant over a step. A frame is marked saturated when |U| is strictly greater than Fm.
Linearised plant. Near upright (sin θ → θ, cos θ → 1, the ω² term and the m·sin² θ term dropped):
- a_x = (U − m·g·θ) / M and a_θ = (g·θ − a_x) / l, with the unclipped controller U.
The closed-loop polynomial. Closing the linearised plant with the controller gives the characteristic polynomial s⁴ + a3·s³ + a2·s² + a1·s + a0, with
a3 = (K4 − l·K2) / (M·l), a2 = (K3 − l·K1) / (M·l) − (M + m)·g / (M·l)
a1 = K2·g / (M·l), a0 = K1·g / (M·l)
The coefficients are linear in the gains. With all four gains 0 the open-loop poles are 0, 0 and ±p₀, where p₀ = √((M + m)·g / (M·l)) is the open-loop unstable pole: the rate at which an uncontrolled pole starts to fall.
Pole placement. The requested polynomial is the product of the two pairs' quadratics, (s² + pA·s + qA)(s² + pB·s + qB), with pA = −2·sA, qA = sA² + ωA² and the same for pair B. Its coefficients are a3r = pA + pB, a2r = qA + qB + pA·pB, a1r = pA·qB + pB·qA and a0r = qA·qB. Matching them with the closed-loop coefficients above gives each gain in closed form, with no matrix inverse:
- K1 = a0r·M·l / g and K2 = a1r·M·l / g;
- K3 = a2r·M·l + (M + m)·g + l·K1 and K4 = a3r·M·l + l·K2.
Every placed pole has a negative real part, so all four gains come out positive. The positive cart gains, which push the cart further the way it has already moved, are the non-minimum-phase lesson of challenge 1. The model then recomputes a3 to a0 from these gains by the general formulas above, so both modes report the polynomial by one path; in pole placement it equals the requested polynomial to rounding.
The Routh test. The Routh first column of the quartic is 1, a3, D2/a3, D3/D2, a0, with D2 = a3·a2 − a1 and D3 = a1·D2 − a3²·a0. All four poles lie in the open left half-plane exactly when every entry is positive.
- An entry formed by cancelling two terms is treated as zero when it is within one part in a billion (1×10⁻⁹) of the larger of the two: a3 when |K4 − l·K2| is that small against the larger of |K4| and |l·K2|, D2 against the larger of |a3·a2| and |a1|, D3 against the larger of |a1·D2| and |a3²·a0|; a0 is zero only when K1 is 0. Any zero entry reads Not stable (a pole on the imaginary axis or to its right), and the unstable pole count is blank.
- Otherwise the number of sign changes down the column is the number of closed-loop poles in the right half-plane (Routh's theorem): 0 reads Stable, 1 or more reads Unstable with the count.
Pole placement is always stable by this test.
The fastest closed-loop pole and the step ratio. Typed gains can make the closed loop arbitrarily fast, and the model has no root finder, so it bounds the largest pole magnitude ρ from the polynomial with a fixed computation:
- The Fujiwara bound of a monic quartic with coefficients (c3, c2, c1, c0) is 2·max(|c3|, |c2|^(1/2), |c1|^(1/3), (|c0|/2)^(1/4)). Every root lies inside it.
- With S the Fujiwara bound of (a3, a2, a1, a0), the polynomial is scaled so that its roots are divided by S.
- Five Graeffe root-squaring steps follow; each gives the quartic whose roots are the squares of the previous roots, so after five steps they are the 32nd powers of the scaled roots.
- The fastest-pole bound is S times the Fujiwara bound of the fifth step's quartic, raised to the power 1/32.
The bound is never below ρ and at most 8^(1/32) ≈ 1.0671 times ρ. The step ratio is 0.02 s times the bound. Above 0.5 the step is too coarse for the gains and the status warns. Pole placement cannot reach it: its poles are at most √(8² + 8²) ≈ 11.31 rad/s from the origin, a step ratio of at most about 0.24.
The run. The state starts at rest at the starting lean: x = 0, v = 0, θ = θ0, ω = 0. The tap adds its speed to ω on the row of its time (row tap time / 0.02); a tap at 0 s is added at row 0. Each of the 200 rows advances the state by one classic Runge-Kutta step of h = 0.02 s: four stages, each evaluating the controller and the two accelerations, then the weighted update with weights 1, 2, 2, 1 over 6. Row n is at time t = 0.02·n s, from 0 to 4 s. The linear prediction uses the same rows, start, tap and stop rule with the linearised plant and the unclipped controller, so it decays with exactly the closed-loop poles above or, for an unstable loop, grows.
Stop, fall and settle. A run continues to the next row while |θ| is below 90 degrees and |x|, |v| and |ω| are at most 1,000,000; later rows are blank. Each run, nonlinear and linear, applies this to its own values.
- The pole has fallen when the last row reached has |θ| of 90 degrees or more. That row is kept and drawn with the pole lying on the track. The fall time is found by straight-line interpolation of |θ| between that row and the row before it.
- The run has stopped early when it ends before 4 s without falling (the state limit).
- The pole has settled when the run reaches 4 s without falling and |θ| stays at or below 1 degree from some row to the end. The settling time is the time of the first row of that final stretch, a whole multiple of 0.02 s. The settle test reads the angle only; the cart may still be returning to its start.
The run verdict, the first that applies: Fell over; Stopped early; Upright for now, but not stable when the Routh test does not say Stable; Balanced when the pole has settled; Still swinging otherwise.
Measures over the run (the nonlinear run's rows unless stated):
- the largest |θ| (degrees), the largest |x| (cart travel, m), the largest |F| (peak force, N);
- the saturation share: the percentage of rows reached that are marked saturated;
- the final angle and cart position, on the last row reached (row 200, or the fallen row);
- for the linear prediction: its largest |θ|, its fall time by the same interpolation (blank unless it reaches 90 degrees), and the largest difference in angle between the two runs over the rows both reached.
For the drawing. The pole tip is at x + l·sin θc and l·cos θc, with θc the angle limited to ±90 degrees, so a fallen pole lies on the track; the true angle stays in the angle column. The track view spans ±1.1 times the larger of 1 m and the largest |x| or tip x over the rows shown, centred on the start, and its height is 1.1·l. In pole placement the pole map lists the four placed poles, sA ± i·ωA and sB ± i·ωB.
Calculation sequence
The model works through the relationships above in this order:
- It checks the entered inputs, items 1 to 7 of the status list under Errors and warnings. Under NOT VALID every result is blank.
- It fixes the values used: your inputs, or in a challenge the challenge's own values with only its free inputs left to you.
- It finds the gains: from the placed poles in pole placement, or the typed gains in manual mode.
- It computes the closed-loop coefficients, the open-loop pole, the Routh first column and verdict, the fastest-pole bound and the step ratio.
- It runs the 200 Runge-Kutta rows of the nonlinear cart-pole and of the linear prediction, each with its stop rule.
- It applies the fall and settle tests and the run verdict, and computes the measures, the pole-tip points and the plot bounds.
- It sets the status and, in a challenge, scores the challenge.
Outputs and interpretation
- Status: OK, CHECK or NOT VALID, with the reason (see Validation and status logic and Errors and warnings).
- The run: the run verdict; the settling time (s), shown only for Balanced; the fall time (s), shown only for Fell over; the largest angle (degrees) and the peak force (N).
- Gains: K1 to K4, the gains in effect in either mode.
- Stability: the Routh verdict, the number of closed-loop poles in the right half-plane (blank on the boundary) and the open-loop unstable pole (rad/s).
- More of the run: the largest cart travel (m), the saturation share (%), the final angle (degrees) and final cart position (m).
- Linear prediction: its largest angle (degrees), its fall time (s, blank unless it reaches 90 degrees) and the largest difference from the nonlinear run (degrees).
- Challenge: the result, the score, the goal, the feedback and the measured value.
- Polynomial and step (Advanced): the four closed-loop coefficients a3, a2, a1 and a0, the fastest-pole bound (rad/s), the step ratio and the time step (s).
- Plot bounds (Advanced): the left and right ends of the track view and its height (m).
- Values used (Advanced): the controller, cart mass, tip mass, pole length, force limit, the four pole parts (blank in manual mode), starting lean, tap speed and tap time actually used. In a challenge these are the challenge's own.
- Versions (Advanced): the model version and the formula module versions.
- Grids:
- Cart frames: 201 rows, one per time step from 0 to 4 s, of the time (s), the cart position (m), the pole angle (degrees), the pole tip x and y (m), the force (N), a saturated flag (1 when the controller asks for more than the force limit, else 0), and the linear prediction's angle (degrees) and cart position (m). A run's columns are blank after its last row.
- Pole map: the four poles, Pole 1 to Pole 4, with their real (1/s) and imaginary (rad/s) parts. In manual mode the labels stay and the values are blank: the model does not solve the poles of typed gains, and the Routh column and the fastest-pole bound describe that loop instead.
- Routh table: the first column for the rows s⁴ to s⁰. The s² entry is blank when the a3 entry is zero, and the s¹ entry when the a3 or D2 entry is zero.
The page has three levels, which change only what is shown, never a calculation. Explore shows the status, the run verdict, the settling and fall times, the largest angle and the peak force, the cart frames and the pole map. Experiment adds the plant inputs and the challenges, the gains, the stability results, the other run measures, the linear prediction and the Routh table. Advanced adds the outputs marked above.
Reading the results:
- A pole placed further left decays faster, like e^(sA·t), but asks for larger forces. When the force limit is reached the run departs from the linear prediction and can fall even though the linear prediction recovers.
- The default places the poles at −3 ± 2i and a double pole at −4, with a 60 degree per second tap at 0.5 s: the pole leans to about 8.63 degrees and has settled from 2.42 s.
- With all gains 0 the polynomial has a3 = 0, so the Routh verdict reads Not stable. On the 1 kg cart with a 0.2 kg, 0.5 m pole the open-loop pole is about 4.851 rad/s, and from a 2 degree lean the pole falls at about 0.956 s.
- A run can be stable by the Routh test and still fall: the test describes the linear, unlimited-force loop, and a large disturbance with aggressive poles can saturate the force and topple the pole.
- An unstable loop may not have fallen within 4 s, for example when only the cart drifts away; it reads Upright for now, but not stable.
Challenges
Choose a challenge number from 1 to 5. The model loads that challenge's scene, and the inputs it fixes replace yours (the "used" outputs show the values in effect). Every challenge uses the 1 kg cart, the 0.2 kg tip mass on a 0.5 m pole and the 20 N force limit, with its own controller mode and disturbance. The challenge result reads MET or NOT MET, the score is 100 when met and 0 otherwise, and a goal and a feedback line say what is asked and what to try next. The status checks still apply inside a challenge.
- Will it balance? Four positive gains on a 3 degree lean: predict whether they balance the pole. Until you choose a prediction, the Routh verdict and column, every run result and the frames after the first are withheld; the gains, the four coefficients, the pole bound and the first frame still show. The challenge is met when your prediction agrees with the Routh test.
- Quick recovery. From a 10 degree lean, place the poles so the pole stays within 1 degree of upright from 1.5 s on.
- Short track. After a tap of 90 degrees per second, place the poles so the pole balances and the cart never moves more than 0.4 m from its start.
- Fix the gains. A typed gain set that lets the pole fall: change the gains so the Routh test says stable and the pole balances.
- Gentle and quick. From a 10 degree lean, place the poles so the pole balances within 3 s while the force never passes 5 N.
The time limits of challenges 2 and 5 are compared on whole rows (row 75 and row 150), never on a time.
Validation and status logic
The status reads the first message in the list under Errors and warnings that applies. Items 1 to 7 check the values you entered; items 8 to 12 check the values used, which are a challenge's own when one is selected. A CHECK still returns every result; it marks a run that deserves a second look. While challenge 1 waits for a prediction, items 9 to 12 are skipped, because each would reveal how the run ends.
Assumptions and limitations
- A frictionless cart on a level, unbounded track; a massless rigid pole with a point mass at its tip; no hinge friction and no actuator lag. The controller is continuous linear state feedback with exact knowledge of the state, limited at the force limit. A tap changes the pole's angular velocity at once and leaves the cart's velocity unchanged. A pole past 90 degrees has fallen and the run ends; there is no collision model.
- 200 fixed Runge-Kutta steps of 0.02 s, a 4 s run. Accuracy is stated only for step ratios up to 0.5, which pole placement always meets; typed gains above it are flagged. Within that range the linear prediction follows the exact solution of its linear system closely, and on runs that do not fall the nonlinear run agrees with a step four times finer to within 0.02 degree on the worked states and 0.15 degree across the input ranges. When the controller sits at its force limit the exact switching moments shift with the step, so a fall time is less precise than a settled angle.
- The fastest-pole bound is an upper bound, at most about 6.7% above the true largest pole magnitude.
- The Routh test is exact in exact arithmetic. A first-column entry within one part in a billion of zero reads as the boundary (not stable), even if it is a hair positive.
- A slow controller may still be swinging at 4 s, and an unstable loop may not have fallen yet. The settle test reads the angle only.
- The model does not find the poles of a typed gain set; manual mode describes the loop by the Routh column and the fastest-pole bound.
- Two conjugate pairs are placed, so four different real poles cannot be placed: a pair on the real axis is a double pole.
- A value within about 1×10⁻⁹ (relative) of a threshold may fall either side of it. This applies to the fall angle, the settle band, the saturation test, the step limit, the Routh zero band, the tap-time grid and each challenge band.
Restrictions and non-computing states
Every input is required; a blank or out-of-range value reads NOT VALID. The controller and the prediction must each be exactly one of their listed choices, and the tap time must fall on the 0.02 s grid.
Under NOT VALID every result and every grid entry is blank, the time column included. The model and module versions still show, the challenge score reads 0, and a selected challenge reads NOT MET with its goal and its not-met text. A challenge number that is not a whole number from 0 to 5 counts as no challenge selected.
Errors and warnings
The status messages, in the order they are checked:
NOT VALID: choose a controller mode from the listNOT VALID: the cart mass must be from 0.5 to 5 kg, the pole mass from 0.05 to 1 kg and the pole length from 0.2 to 2 mNOT VALID: the force limit must be from 1 to 100 NNOT VALID: each pole's real part must be from -8 to -0.8 per second and its imaginary part from 0 to 8 rad/sNOT VALID: each manual gain must be from -10000 to 10000NOT VALID: the starting angle must be from -45 to 45 degrees, the tap speed from -360 to 360 degrees per second, and the tap time from 0 to 3.98 s in steps of 0.02 sNOT VALID: the challenge number must be a whole number from 0 to 5, and the balance prediction one of the listed choicesCHECK: the gains make the fastest closed-loop motion too quick for the 0.02 s time step (step ratio above 0.5), so this run is not accurate; use smaller gains: the step ratio is above 0.5. Pole placement cannot reach it.CHECK: the pole fell over (it passed 90 degrees) and the frames stop there; the controller could not hold this disturbance: the nonlinear run fell.CHECK: a cart or pole speed or the cart position passed 1,000,000, so the run stops early: the nonlinear run reached the state limit without falling. It guards the formulas; inside the input ranges the run stays far below the limit.CHECK: the closed loop is not stable (Routh test), so although the pole has not fallen within the 4 s run, its motion does not die away: the run did not fall or stop, and the Routh verdict is not Stable.CHECK: the pole is still swinging at the end of the 4 s run (not yet within 1 degree of upright); a faster controller settles sooner: the loop is stable but the pole has not settled by 4 s.OK
References
This laboratory is an educational model of a frictionless cart-pole with a point mass at the tip of the pole, balanced by force-limited linear state feedback. The equations of motion come from Lagrange's equations, and the controller is designed on their linearisation about the upright position. The gains for two placed pole pairs follow in closed form by matching the closed-loop characteristic polynomial, and the stability of typed gains is judged by the Routh-Hurwitz criterion. The fastest closed-loop pole is bounded by Fujiwara's bound after Graeffe's root-squaring, and the motion is integrated with the classic fourth-order Runge-Kutta method.
Sources and further reading
- The cart-pole's energies, equations of motion and linearisation about the upright position: R. Tedrake, Underactuated Robotics: Algorithms for Walking, Running, Swimming, Flying, and Manipulation, course notes for MIT 6.832, Massachusetts Institute of Technology, chapter 3, Acrobots, Cart-Poles, and Quadrotors, section The Cart-Pole System. underactuated.mit.edu
- State feedback, eigenvalue (pole) assignment and the balance system: K. J. Åström and R. M. Murray, Feedback Systems: An Introduction for Scientists and Engineers, 2nd edition, Princeton University Press, 2021, chapter 7, State Feedback. Feedback Systems
- The stability criterion by sign changes in the first column: E. J. Routh, A Treatise on the Stability of a Given State of Motion, Particularly Steady Motion, Macmillan, London, 1877.
- The same criterion by determinants: A. Hurwitz, "Ueber die Bedingungen, unter welchen eine Gleichung nur Wurzeln mit negativen reellen Theilen besitzt", Mathematische Annalen, volume 46, 1895, pages 273-284.
- The bound on the magnitude of the roots of a polynomial: M. Fujiwara, "Über die obere Schranke des absoluten Betrages der Wurzeln einer algebraischen Gleichung", Tôhoku Mathematical Journal, volume 10, 1916, pages 167-171.
- Root squaring: C. H. Gräffe, Die Auflösung der höheren numerischen Gleichungen, Zürich, 1837.
- The fourth-order Runge-Kutta method: C. Runge, "Ueber die numerische Auflösung von Differentialgleichungen", Mathematische Annalen, volume 46, 1895, pages 167-178; and W. Kutta, "Beitrag zur näherungsweisen Integration totaler Differentialgleichungen", Zeitschrift für Mathematik und Physik, volume 46, 1901, pages 435-453.
- Runge-Kutta methods and their stability regions: E. Hairer, S. P. Nørsett and G. Wanner, Solving Ordinary Differential Equations I: Nonstiff Problems, 2nd edition, Springer, 1993.
No table or text from any of these publications is reproduced, and none of their authors or publishers has reviewed or endorses this laboratory.
This laboratory is for learning. Its results hold only within its stated ranges; it is not a tool for designing or tuning real control systems.
Found a problem, or have an idea?
Tell us if a result looks wrong, a label is unclear, or something is missing. We read every message.