by Alexandre Fournier, Simon Pino-Buisson and Justin Veilleux
This project implements a Model Predictive Control (MPC) framework for a simulated Ship-to-Shore (STS) container crane. It solves a nonlinear optimal control problem to move a payload from point A to point B while minimizing time and energy, avoiding obstacles, and suppressing sway.
We based our implementation on the work presented by Barbosa and al..
The solver uses a Spatial Formulation, where the independent variable is the trolley position xp rather than time t. This allows for easier implemented obstacle avoidance over a fixed geometric horizon.
We optimize over the nonlinear dynamics of a full 2D crane simulation including hoist length variation, sway angles, and coupling effects.
The obstacle avoidance problem is handled throught dynamic constraint generation based on variable terrain/container stack heights.
We use a configurable trade-off (α) between Time Minimization (α=1) and Energy Minimization (α=0) to explore the balance between the two.
We use the CasADi optimizer with the IPOPT solver, featuring smooth power approximations and reduced-state formulations for numerical stability.
Crane2D: Defines the physical dynamics of the crane (equations of motion and power calculations) and RK4 integration.
Port: Manages the environment, including obstacle course generation and height lookups.
MPC: The core controller class. Formulates the OCP (Optimal Control Problem), sets up constraints/objectives, and interfaces with the CasADi solver.
CraneParams: Dataclass containing physical constants (mass, gravity, max forces, limits).
State Vector: The formulation was reduced from the paper to ensure numerical stability with the spatial formulation by removing the y and yd (payload height) since it can be derived from the cable length l. This avoids redundant constraints.
x=[$t$,
Control Vector
u=[$F_t$,
This repository implements a Nonlinear Model Predictive Controller (NMPC) for a ship-mounted crane operating in a 3D environment. The system is designed to transport a payload to a specific target on a ship deck while compensating for wave disturbances and avoiding obstacles.The core feature of this controller is the use of Robust Adaptive Zeroing Control Barrier Functions (R-ZOCBF). This allows the controller to dynamically tighten safety constraints based on state uncertainty, ensuring collision avoidance even when the sea state induces unpredictable motion.
Our work is a simplified version of the work of Das and al.
3D Nonlinear Dynamics: Models the crane payload as a damped spherical pendulum attached to a rigid boom with variable luffing and slewing angles.
CasADi & IPOPT: Uses the CasADi framework with the IPOPT solver for fast, gradient-based trajectory optimization.
Wave/Wind Disturbance Simulation: Injects sinusoidal wave accelerations into the angular velocities of the payload to test robustness.
Adaptive Safety (R-ZOCBF): Uses Monte Carlo sampling within the control loop to estimate the necessary safety margin (
3D Visualization: Includes a fully interactive Matplotlib-based 3D animator to visualize the boom, tether, payload, obstacles, and the MPC "ghost" trajectory plan.
State Vector:
x=[$\beta$,
Control Vector:
u=[$\dot{\beta}$,