Input Shaping Against a Predictive Controller
Open the Overhead Crane Anti-Sway app
Advanced Control Exercise 13 of 30 in Optimal Control · All exercises · Time: 15 minutes
Moving a crane's trolley sets the load swinging. An input shaper cancels the swing open loop, by splitting each command into impulses timed to the pendulum's period. That is optimal only if the period is known. A model predictive controller plans the force against a swing limit instead. This exercise measures what a wrong cable length costs each shaper, and what planning buys over shaping.
Learning Outcomes
- Derive the timing and amplitudes of a ZV shaper from the pendulum's frequency and damping.
- Compare how ZV and ZVD shapers degrade when the assumed cable length is wrong.
- Compare a ZVD shaper with an MPC that has a swing constraint, by move time and residual swing.
Book Chapter
Nonlinear Dynamics, Oscillations, and Stabilization (Volume 7), Chapter 12, Input Shaping on an Overhead Crane Where One Actuator Serves Two Outputs. Read the chapter, open the PDF, or watch the lecture slides.
Theory in Brief
A load on a cable of length `L` swings at `\omega = \sqrt{g/L}`, damped by `\zeta`, so `\omega_d = \omega\sqrt{1-\zeta^2}`. A zero-vibration (ZV) shaper replaces each step with two impulses that cancel each other's swing:
$$A_1 = \frac{1}{1+K}, \quad A_2 = \frac{K}{1+K}, \quad t_2 = \frac{\pi}{\omega_d}, \qquad K = \exp\!\left(\frac{-\zeta\pi}{\sqrt{1-\zeta^2}}\right)$$
A ZVD shaper uses three impulses, `1/(1+K)^2`, `2K/(1+K)^2` and `K^2/(1+K)^2` at `0`, `\pi/\omega_d` and `2\pi/\omega_d`. It takes one more half period, and in exchange its residual swing has zero slope with respect to frequency error at the design point, so it tolerates a wrong `L` far better. Both are open-loop optimal commands: correct only for the `\omega` they were built for.
The MPC plans the force `F` over 6 s on the crane model and limits the swing angle `\phi`:
$$\min_{F} \sum_{k=1}^{N} \left\| x_k - x_{sp} \right\|^2_{Q} + \left\| F_k \right\|^2_{R} \quad \mathrm{s.t.} \quad |\phi_k| \le \phi_{max},\;\; |F_k| \le F_{max}$$
Model: Physics-based. A trolley and a pendulum, whose frequency depends on the cable length the controller assumes.
Decision: The trolley force, as a reference shaped by impulse timing for the PID, or a planned force for the MPC.
Learning: None. The cable length is assumed; on a real crane it would come from a drum encoder.
Exercise
Read 2 min · Predict 1 min · Run 7 min · Explain 3 min · Check your AI 2 min.
Predict. The cable is really 8 m but the shaper believes it is 4 m, so it times its impulses for a swing 41 % faster than the real one. How much of the cancellation survives for ZV, and for ZVD? Will an MPC with a 3° swing limit park before the ZVD shaper does?
Run the Overhead Crane Anti-Sway app. Use the fastest speed, 5×, and press Run again to pause at the times in each step.
- Open 5 · Shaper tuned for the wrong cable length. With Input shaper set to ZV and the shaper length at 4.00 m, press Run and pause at 13.5 s. Read Residual sway and Peak sway.
- Press Reset, set Input shaper to ZVD, and run to 13.5 s again. Read the same tiles and Shaper delay.
- Open 12 · A shaper against a predictive controller. The MPC is in charge; run to 13.5 s and read the tiles and the parking time on the Trolley position trend.
- Press Reset, set Controller to Shaped PID before the move at 1.5 s, and run to 13.5 s.
Explain.
- The ZVD shaper is fed the same wrong length as the ZV shaper. Why does it leave less swing?
- The MPC parks sooner with less force. What does it decide that the shaper cannot, and what does it still share with the shaper?
Generative AI Learning
Check the answer against your run: Check the impulse time, `\pi/\omega_d` with `\omega = \sqrt{g/L}`, about 2.0 s at 4 m, and the claim that ZVD is less sensitive. Compare its residual estimate with your step 1 and step 2 tiles. The assistant is your tutor and reviewer; you answer for every claim you turn in.
What to Turn In
A four-row table (ZV wrong, ZVD wrong, MPC, ZVD) with residual and peak sway, your written prediction, and three sentences that answer the two questions.

With the length wrong, the ZV shaper leaves 3.15° of residual sway and the ZVD shaper 1.44°. The app's case text puts the unshaped residual at 7.2°, so ZV still removes more than half the swing and ZVD about four fifths. ZVD pays for it with a longer shaper delay, 4.01 s against about 2 s. Its residual is flat in frequency at the design point, so a 41 % frequency error costs it less.
On the correct 4 m move the MPC reaches a peak swing of 3.00°, its own 3° limit, and leaves 0.04°; the ZVD-shaped PID peaks at 3.23° and leaves 0.11°. The MPC parks inside ±0.1 m at 9.7 s with a peak commanded force of 1,042 N; the shaped PID parks at 12.7 s with 1,883 N. The plan is quicker with less force because it decides from its model when to push and when to brake. The shaper's impulse times are fixed by the period whatever the move. Both still depend on the same assumed cable length, so a hoisted load defeats both until the length is measured.
Measured with the app build of December 3, 2026 by a scripted replay of the steps above. Numbers that no tile shows come from the replay's record; your readings from the trends will be close. A later app release may move the last digit.
Dynamic Control includes the crane homework in GEKKO. Solve the minimum-time move of 6 m with `|\phi| \le 3^\circ` and `|F| \le 4000` N as an optimal control problem with a free final time, and compare the force profile with the ZVD-shaped command. The optimal profile is bang-bang in the force where the swing limit is inactive.
Related
- Check yourself: three-question quiz
- Course pages: Dynamic Control Introduction, Model Predictive Control, Control Objectives
- Exercises: previous: 12 · LQR With a Kalman Filter; next: 14 · Dynamic Programming and the Four Driving Regimes
References
- Hedengren, J. D. (ed.), Nonlinear Dynamics, Oscillations, and Stabilization, Volume 7 of Interactive Control Engineering, Chapter 12, "Input Shaping on an Overhead Crane Where One Actuator Serves Two Outputs", pp. 288–314, Advanced Process Solutions, 2026. PDF (CC BY 4.0).
- Singer, N. C., Seering, W. P., Preshaping command inputs to reduce system vibration, Journal of Dynamic Systems, Measurement, and Control 112(1), 76–82, 1990.
