Crab crane with a model inversion control setup


Wolfram Language



Library Dependency

This model requires the PlanarMechanics library.

  • The free PlanarMechanics library was created especially for modeling multibody systems with two-dimensional mechanical components. Compared to the MultiBody library, currently available in the Modelica Standard Library, it is simpler to use and it is more optimized to planar modeling. Planar models of mechanical systems are useful in many different applications, for example, in contact problems that are more easily modeled in 2D than in 3D.


This model shows an inversion-based controller that is used to control a hoist crane.


The hoist crane is modeled using the PlanarMechanics Modelica library. Force is applied to a prismatic joint that pushes a crab along a one-dimensional beam. Attached to the crab is a dampened revolute joint that connects to the load through a stiff rod.

In the controller, a filtered pulse is used as a reference signal to control the position of the load. Using a constrained inverse block, the force that should be applied to the crab can be calculated from the reference signal.


To simulate the model, click the Simulate button:simulate

Plot the Results

Explore how the crane is positioned relative to its reference position by examining the plot that is automatically displayed after simulating the model. The first variable describes the actual position of the crane, while the second describes the reference position that is input into the controller.

Automatic 3D Animation

PlanarMechanics and Multibody systems have visualizers to show what a real-world system would look like.

To show a 3D animation of the model, click the Animation button: animate

Use your mouse or trackpad to drag the animation to a good angle and zoom in with your scroll wheel or by using the trackpad.

Change Parameters

Changing parameters for the simulation can be done rapidly in Simulation Center. The crane_I parameter determines the "real" inertia of the load. The model used inside the controller also has an inertia parameter that determines what the controller expects the load inertia to be. When the real and the expected inertia differ from each other, the controller will not be able to accurately predict what force to apply to the crane.

Try changing the inertia for the load and see how this affects the controller:

  • Switch to the Parameter tab on the left in the Experiment Browser.
  • Cange the value next to the crane_I parameter to 1000 kg.m2.
  • Simulate again by following the steps in the Simulation section to see the effects of your changes.

You should now see the graph below:

In order to get the full experience of this example, you need a desktop Wolfram Language product. A free trial download is available at www.wolfram.com/mathematica/trial/

For the full example, open the accompanying notebook ModelInversionControl.nb.

Parameters (9)


Value: 20

Type: Time (s)

Description: Period of the input pulse, position switches every half period


Value: 0.2

Type: Frequency (Hz)

Description: Cut-off frequency of the input filter, higher values give sharper movement


Value: 0.5

Type: Inertia (kg⋅m²)

Description: Inertia of the physical crane body


Value: 0.5

Type: Inertia (kg⋅m²)

Description: Inertia of the inverted crane body model.


Value: false

Type: Boolean

Description: Complement open loop control with closed loop corrective controller.


Value: 100

Type: Real

Description: Proportional gain of corrective controller.


Value: 100

Type: Real

Description: Time constant of integrative part of corrective controller.


Value: 0.1

Type: Real

Description: Time constant of derivative part of corrective controller.


Value: Modelica.Blocks.Types.Init.SteadyState

Type: Init

Description: Type of initialization used for PID controller

Components (9)


Type: Filter

Description: Input signal filter, smoothing the signal.


Type: Pulse

Description: Load position reference, going back and forth between 0 and 1 meters along the X-axis.


Type: PlanarWorld

Description: Coordinate system.


Type: CraneCrabDamped

Description: Crab crane setup.


Type: Feedback

Description: Corrective closed loop feedback of crane position.


Type: InverseBlockConstraints

Description: Crab crane inversion block. Open loop control.


Type: PID

Description: Corrective PID-controller.


Type: Add

Description: Input force sum.


Type: CraneCrabDamped

Description: Crab crane model.