{"id":194,"date":"2017-09-12T06:11:16","date_gmt":"2017-09-12T04:11:16","guid":{"rendered":"https:\/\/blogs.mathworks.com\/student-lounge\/?p=194"},"modified":"2020-05-28T16:34:48","modified_gmt":"2020-05-28T14:34:48","slug":"introduction-to-contact-modeling","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/student-lounge\/2017\/09\/12\/introduction-to-contact-modeling\/","title":{"rendered":"Introduction to Contact Modeling"},"content":{"rendered":"<p><!--more-->Today I have the great pleasure to introduce my colleague <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3069683-sebastian-castro\">Sebastian Castro<\/a> as guest blogger. He will be sharing an <em>&#8220;Introduction to Contact Modeling&#8221;<\/em>. Sebastian, the stage is yours!<\/p>\n<p>&#8211; &#8211; &#8211;<\/p>\n<p>In this post, I will talk about simulating mechanical contact with Simulink\u00ae, Simscape\u2122, and Simscape Multibody\u2122.<\/p>\n<h2>Motivation<\/h2>\n<p>Modeling mechanical contact can be useful to build realistic simulations for various engineering areas, including<\/p>\n<ul>\n<li><strong>Robotic systems:<\/strong> Wheeled robots, walking robots, and robot grippers<\/li>\n<li><strong>Automotive systems:<\/strong> Tire-ground interaction, suspension, and drivetrain components<\/li>\n<li><strong>Industrial automation systems:<\/strong> Robot grippers (again), assembly line components such as conveyor belts, rollers, and other mechanisms<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>Modeling Contact Mechanics<\/h2>\n<p>Contact forces are the result of solid bodies interacting with each other. To approximate contact behavior in simulation, we use contact models.<\/p>\n<p>The two main components of contact forces can be broken down into<\/p>\n<ul>\n<li><strong>Normal forces: <\/strong>Push objects away from each other when they collide. As their name suggests, these forces are normal to the point(s) of contact.<\/li>\n<li><strong>Friction forces:<\/strong> Prevent objects in contact from perfectly sliding off each other. These forces act along the contact surface, and are related to the smoothness or roughness of contact surfaces.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/blogs.mathworks.com\/racing-lounge\/files\/2017\/09\/contact_forces.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-198 size-full\" src=\"https:\/\/blogs.mathworks.com\/racing-lounge\/files\/2017\/09\/contact_forces-e1507126701668.jpg\" width=\"500\" height=\"254\" \/><\/a><\/p>\n<p>Normal forces can be modeled in several ways, including<\/p>\n<ul>\n<li><strong>Impulse-based:<\/strong> This is a one-time event that occurs when two objects collide. Before collision, each object has a certain momentum (<em>mass * velocity<\/em>, or its rotational equivalent). After the collision, the magnitude and direction of each object\u2019s momentum will change based on the <a href=\"https:\/\/www.khanacademy.org\/science\/physics\/linear-momentum\/elastic-and-inelastic-collisions\/v\/elastic-and-inelastic-collisions\">type of collision<\/a>; for example, elastic vs. inelastic. This approach works best in models where the objects do not frequently move in and out of contact.<\/li>\n<\/ul>\n<ul>\n<li><strong>Force-based:<\/strong> Normal forces are applied to objects based on a force law. A common approach is to apply a <em>penalty force<\/em>; for example, treating contact surfaces as springs and dampers whose coefficients approximate real world behavior. Penalty forces allow objects to overlap, which can approximate the deformation (or \u201csquishing\u201d) of these objects when they collide. Unlike the impulse-based approach, a force-based collision may take multiple simulation time steps to reach steady-state.<\/li>\n<\/ul>\n<ul>\n<li><strong>Motion constraint:<\/strong> Here, we assume that objects are always in contact, so we do not have to worry about collision dynamics. For example, if we assume that a wheel is always on the ground, we do not need to model the normal forces; we only need a friction model to relate the rotation of the wheel with its linear motion.<\/li>\n<\/ul>\n<p>Friction forces typically consist of a force law with two distinct regions.<\/p>\n<ul>\n<li><strong>Static friction<\/strong> represents the initial force needed by an object at rest to begin sliding along its contact surface.<\/li>\n<li><strong>Kinetic friction<\/strong> represents the resistive force of an object when it is moving along its contact surface.<\/li>\n<\/ul>\n<p>Friction force curves can be represented using equations, or by directly using the curve data in a lookup table.<\/p>\n<p><a href=\"https:\/\/blogs.mathworks.com\/racing-lounge\/files\/2017\/09\/friction_curve.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-203 size-full\" src=\"https:\/\/blogs.mathworks.com\/racing-lounge\/files\/2017\/09\/friction_curve-e1507126682932.jpg\" width=\"480\" height=\"400\" \/><\/a><\/p>\n<h2>Contact with Simulink\u00ae<\/h2>\n<p>Simulink\u00ae lets you graphically implement equations. Mechanical system dynamics can be modeled using differential equations, which are commonly associated with with the <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/slref\/integrator.html\">Integrator<\/a> block. This is because of Newton\u2019s 2<sup>nd<\/sup> Law (<em>Force = mass*acceleration<\/em>). The acceleration can be integrated once to calculate velocity, and again to calculate position.<\/p>\n<p><a href=\"https:\/\/blogs.mathworks.com\/racing-lounge\/files\/2017\/09\/simulink_model_force.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-206 size-large\" src=\"https:\/\/blogs.mathworks.com\/racing-lounge\/files\/2017\/09\/simulink_model_force-1024x408.jpg\" width=\"1024\" height=\"408\" \/><\/a><\/p>\n<p>To implement force-based contact and friction forces, you can represent the force laws using blocks for mathematical operations or by directly representing the friction curves as lookup tables. These forces can then be summed up and passed into the Integrator blocks as shown below.<\/p>\n<p><a href=\"https:\/\/blogs.mathworks.com\/racing-lounge\/files\/2017\/09\/simulink_model_collision.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-207 size-large\" src=\"https:\/\/blogs.mathworks.com\/racing-lounge\/files\/2017\/09\/simulink_model_collision-1024x438.jpg\" width=\"1024\" height=\"438\" \/><\/a><\/p>\n<h2>1D Contact with Simscape\u2122<\/h2>\n<p>Simscape\u2122 extends Simulink\u00ae for modeling 1D physical networks (electrical, fluid, mechanical, etc.) without deriving equations of motion. Every mechanical Simscape\u2122 component is implemented by establishing a relationship between velocity and force\/torque, so you can implement 1D force-based contact in Simscape\u2122.<\/p>\n<p>Simscape\u2122 has built-in blocks such as the <a href=\"https:\/\/www.mathworks.com\/help\/physmod\/simscape\/ref\/translationalfriction.html\">Translational Friction<\/a> and <a href=\"https:\/\/www.mathworks.com\/help\/physmod\/simscape\/ref\/translationalhardstop.html\">Translational Hard Stop<\/a> blocks that provide a good starting point for contact modeling. If you want to implement a different normal or friction force law, you can view the source code of Simscape\u2122 blocks and customize their equations \u2013 or you can <a href=\"https:\/\/www.mathworks.com\/help\/physmod\/simscape\/lang\/creating-custom-components.html\">create your own component from scratch<\/a>.<\/p>\n<p><a href=\"https:\/\/blogs.mathworks.com\/racing-lounge\/files\/2017\/09\/simscape_model.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-211 size-large\" src=\"https:\/\/blogs.mathworks.com\/racing-lounge\/files\/2017\/09\/simscape_model-1024x367.jpg\" width=\"1024\" height=\"367\" \/><\/a><\/p>\n<h2>3D Contact with Simscape Multibody\u2122<\/h2>\n<p>You can use Simscape Multibody\u2122 to model 3D rigid-body systems. There are two types of contact that you can implement with these models.<\/p>\n<p>If you\u2019re interfacing 1D contact into a larger 3D model, for example, actuator limits or friction, you can use the <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/37636-simscape-multibody-multiphysics-library\">Simscape Multibody\u2122 Multiphysics Library<\/a> to help you connect an individual Revolute or Prismatic Joint block to the Hard Stop and Friction blocks described above.<\/p>\n<p><a href=\"https:\/\/blogs.mathworks.com\/racing-lounge\/files\/2017\/09\/simscape_multibody_1D.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-212 size-full\" src=\"https:\/\/blogs.mathworks.com\/racing-lounge\/files\/2017\/09\/simscape_multibody_1D-e1507126643145.jpg\" width=\"500\" height=\"548\" \/><\/a><\/p>\n<p>Else, you can implement a more generic (2D or 3D) penalty force relationship by<\/p>\n<ol>\n<li>Measuring the relative motion between two objects (<a href=\"https:\/\/www.mathworks.com\/help\/physmod\/sm\/ref\/transformsensor.html\">Transform Sensor<\/a>)<\/li>\n<li>\u201cDoing the math\u201d with Simulink\u00ae blocks<\/li>\n<li>Applying the resulting contact forces\/torques to the objects in contact (<a href=\"https:\/\/www.mathworks.com\/help\/physmod\/sm\/ref\/externalforceandtorque.html\">External Force + Torque<\/a>)<\/li>\n<\/ol>\n<p>The <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/47417-simscape-multibody-contact-forces-library\">Simscape Multibody\u2122 Contact Forces Library<\/a> already implements these forces for certain basic shapes, like spheres, planes, and tubes. I strongly recommend using this library a starting point, and if you need to implement something different you can customize these blocks.<\/p>\n<p><a href=\"https:\/\/blogs.mathworks.com\/racing-lounge\/files\/2017\/09\/simscape_multibody_3D.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-213 size-large\" src=\"https:\/\/blogs.mathworks.com\/racing-lounge\/files\/2017\/09\/simscape_multibody_3D-1024x451.jpg\" width=\"1024\" height=\"451\" \/><\/a><\/p>\n<h2>Conclusion<\/h2>\n<p>We just covered several ways to model mechanical contact in Simulink\u00ae, Simscape\u2122, and Simscape Multibody\u2122. To summarize,<\/p>\n<ul>\n<li><strong>Simulink\u00ae<\/strong> is the most flexible tool and lets you implement impulse-based and force-based contact. However, you need to derive all the equations of motion.<\/li>\n<li><strong>Simscape\u2122<\/strong> lets you model 1D mechanisms without deriving equations of motion, and contains basic blocks (which are customizable) to represent normal and friction contact forces.<\/li>\n<li><strong>Simscape Multibody<\/strong>\u2122 let you model 3D rigid body systems without deriving equations of motion.\n<ul>\n<li>The <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/37636-simscape-multibody-multiphysics-library\">Simscape Multibody\u2122 Multiphysics Library<\/a> helps you interface individual rotational or translational degrees of freedom with 1D Simscape\u2122 blocks.<\/li>\n<li>The <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/47417-simscape-multibody-contact-forces-library\">Simscape Multibody\u2122 Contact Forces Library<\/a> contains blocks for 2D or 3D contact forces between simple shapes.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>For more information, watch the videos in this blog post. You can also download example models from the <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/64001-matlab-and-simulink-robotics-arena--introduction-to-contact-modeling\">File Exchange<\/a>.<\/p>\n<p>Are you planning, or working on, simulations with mechanical contact? Do you have any comments about the approaches or libraries we shared in this post? We\u2019d be interested in hearing from you.<\/p>\n<p>&#8211; Sebastian<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/racing-lounge\/files\/2017\/09\/simscape_multibody_3D-1024x451.jpg\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>&#8230;<\/p>\n","protected":false},"author":155,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,14,9,8,11,12],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/posts\/194"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/users\/155"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/comments?post=194"}],"version-history":[{"count":35,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/posts\/194\/revisions"}],"predecessor-version":[{"id":4165,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/posts\/194\/revisions\/4165"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/media?parent=194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/categories?post=194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/tags?post=194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}