{"id":7086,"date":"2018-02-07T19:30:51","date_gmt":"2018-02-08T00:30:51","guid":{"rendered":"https:\/\/blogs.mathworks.com\/simulink\/?p=7086"},"modified":"2020-07-07T16:37:00","modified_gmt":"2020-07-07T20:37:00","slug":"the-simulink-curling-simulator-version-2018","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2018\/02\/07\/the-simulink-curling-simulator-version-2018\/","title":{"rendered":"The Simulink Curling Simulator&#8230; Version 2018"},"content":{"rendered":"<p>For those reading this blog for a few years, you probably remember that during the 2014 Winter Olympics, we published a <a href=\"https:\/\/blogs.mathworks.com\/simulink\/2014\/03\/07\/the-simulink-curling-simulator-we-did-it\">curling simulator<\/a> implemented in Simulink.<\/p>\n<p>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.<\/p>\n<p><strong>Original Model<\/strong><\/p>\n<p>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 <em>sweep<\/em> button and affect the friction between the stone and the ice.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q1\/curlingSteps.gif\" alt=\"The Curling simulator\" \/><\/p>\n<p>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.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2014Q1\/curling_top_model.png\" alt=\"Original Curling Simulator\" \/><\/p>\n<p><strong>Stateflow<\/strong><\/p>\n<p>Here is what the top-level of the model now looks like in R2017b.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2018Q1\/curlingTopLevel.png\" alt=\"Improved Curling Simulator\" \/><\/p>\n<p>Yes, all the computation has been moved inside a Stateflow Chart! What is inside this Stateflow Chart? A Simulink State!<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2018Q1\/curlingChart.png\" alt=\"Improved Curling Simulator\" \/><\/p>\n<p>In my opinion, this expresses more clearly that at every time-step, we call the Simulink Function <strong>detectHit<\/strong> to check if any stones come into contact. If a contact happens, we call the other Simulink Function <strong>contact<\/strong> to recompute the velocities of the stones and apply to the Integrator blocks inside the Simulink State.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2018Q1\/frictionModel.png\" alt=\"Curling Simulator\" \/><\/p>\n<p><strong>Now it's your turn<\/strong><\/p>\n<p>Give a try at the improved 2018 Curling Simulator and let us know what you think by leaving a comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/simulink\/2018Q1\/frictionModel.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>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.<br \/>\nWith the Pyeongchang Winter Olympic... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2018\/02\/07\/the-simulink-curling-simulator-version-2018\/\">read more >><\/a><\/p>\n","protected":false},"author":41,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[71,56],"tags":[366,506,518],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/7086"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/comments?post=7086"}],"version-history":[{"count":12,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/7086\/revisions"}],"predecessor-version":[{"id":9619,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/7086\/revisions\/9619"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=7086"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=7086"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=7086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}