Guy on Simulink

Simulink & Model-Based Design

The Simulink Curling Simulator… Version 2018

For those reading this blog for a few years, you probably remember that during the 2014 Winter Olympics, we published a curling simulator implemented in Simulink.

With the Pyeongchang Winter Olympic coming soon, I decided to re-visit the Curling Simulator and see if it could be improved by taking advantages of new features.

Original Model

First, let's go with a short refresher of what we did in 2014. The main idea is that we created a MATLAB App where you can specify direction, force and spin of your throw. We then use Simulink to simulate the motion of the stones. While the simulation is running, you can click the sweep button and affect the friction between the stone and the ice.

The Curling simulator

At the top level, the model looked like the following, where we had a Second-Order Integrator block driven by a Subsystem entirely made of Simulink blocks. Using Switches, Logical Operator and Enabled Subsystem, we would detect when there is a contact between the stones and reset the Integrator with updated velocities.

Original Curling Simulator

Stateflow

Here is what the top-level of the model now looks like in R2017b.

Improved Curling Simulator

Yes, all the computation has been moved inside a Stateflow Chart! What is inside this Stateflow Chart? A Simulink State!

Improved Curling Simulator

In my opinion, this expresses more clearly that at every time-step, we call the Simulink Function detectHit to check if any stones come into contact. If a contact happens, we call the other Simulink Function contact to recompute the velocities of the stones and apply to the Integrator blocks inside the Simulink State.

Curling Simulator

Now it's your turn

Give a try at the improved 2018 Curling Simulator and let us know what you think by leaving a comment below.

|
  • print

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.