{"id":19129794,"url":"https://github.com/mathworks/simscape-multibody-contact-forces-library","last_synced_at":"2025-12-25T16:54:37.475Z","repository":{"id":92436578,"uuid":"218305902","full_name":"mathworks/Simscape-Multibody-Contact-Forces-Library","owner":"mathworks","description":"Contact force examples and library.","archived":false,"fork":false,"pushed_at":"2024-08-22T12:51:21.000Z","size":72554,"stargazers_count":56,"open_issues_count":5,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-03T10:46:52.875Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mathworks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-29T14:24:48.000Z","updated_at":"2024-12-17T22:13:58.000Z","dependencies_parsed_at":"2023-03-13T17:29:05.607Z","dependency_job_id":"90a0c939-468d-4300-9001-7b578e39cdfc","html_url":"https://github.com/mathworks/Simscape-Multibody-Contact-Forces-Library","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"240b2593b5326d9c5bb1d9060d68ba110eec0db8"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2FSimscape-Multibody-Contact-Forces-Library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2FSimscape-Multibody-Contact-Forces-Library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2FSimscape-Multibody-Contact-Forces-Library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2FSimscape-Multibody-Contact-Forces-Library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathworks","download_url":"https://codeload.github.com/mathworks/Simscape-Multibody-Contact-Forces-Library/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240206968,"owners_count":19765036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T06:08:32.196Z","updated_at":"2025-12-25T16:54:37.407Z","avatar_url":"https://github.com/mathworks.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **Simscape Multibody Contact Forces Library**\nCopyright 2014-2023 The MathWorks, Inc.\n\nThis library contains contact force models for use with Simscape Multibody.\nThey can be used for intermittent contact (parts bouncing off each other)\nand persistent contact (parts resting on each other).\n\n**Please note that the Spatial Contact Force block has been added in R2019b.**\n**You should see if this block meets your needs before using this library.**\n\n**See File Exchange submission [Spatial Contact Force Examples Simscape Multibody](https://www.mathworks.com/matlabcentral/fileexchange/109680-spatial-contact-force-examples-simscape-multibody)**\n\nView on File Exchange [![View Simscape Multibody Contact Forces Library on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/47417-simscape-multibody-contact-forces-library)  \nYou can also open in MATLAB Online: [![Open in MATLAB Online](https://www.mathworks.com/images/responsive/global/open-in-matlab-online.svg)](https://matlab.mathworks.com/open/github/v1?repo=mathworks/Simscape-Multibody-Contact-Forces-Library\u0026project=Contact_Forces_Library.prj) \n\nYou are welcome to use these models in your own projects. If you need to \ninclude the library in your own example, I recommend you use just the \nproject Contact_Forces_Core.prj in subfolder Core.  You can either use it\ndirectly, or include it as a Referenced Project just as is done \nin this project.\n\nGeneral approach for using this library\n   1. Identify the parts in your system that will hit each other during simulation\n   2. Figure out which edges or surfaces will touch.  \n      The contact models provided allow you to model contact between combinations\n      of connected circular arcs with straight lines (2D) \n      and spheres with flat planes or cylinders (3D).\n   3. Add reference frames for the lines and arcs that will touch.\n   4. Add the correct contact force model between the two frames.\n\nSee the examples to understand how they are used.\n\nRecommendations:\n   1. Start with stiffness of 1e4 and damping of 1e2 and adjust from there.\n   2. Use solver ode23t, Relative Tolerance = 1e-4, Absolute Tolerance = 1e-5\n       and set the maximum step size to 1e-2.\n   3. If you get unexpected behavior (parts flying through one another, \n       system gaining energy) your tolerances are not small enough.\n       Reduce tolerances by a factor of 10 and max step size by a factor of 10\n       until you get expected behavior.  Reducing stiffness and increasing damping\n       can also help.\n \n### **Release History**\n**v5.0 Sep 2024** (R2019b through R2024b)\n1. Updated v5p0 for R2024b\n\n**v5.0 Mar 2024** (R2019b through R2024a)\n1. Updated v5p0 for R2024a\n\n**v5.0 Sep 2023** (R2019b through R2023b)\n1. Updated v5p0 for R2023b\n\n**v5.0 Mar 2023** (R2019b through R2023a)\n1. Updated v5p0 for R2023a\n\n**v5.0 Sep 2022** (R2019b through R2022b)\n1. Updated v5p0 for R2022a\n\n**v5.0 Mar 2022** (R2019b through R2022a)\n1. Updated v5p0 for R2022a\n\n**v5.0 Sep 2021** (R2019b through R2021b)\n1. Updated v5p0 for R2021b\n\n**v5.0 Mar 2021** (R2019b through R2021a)\n1. Updated v5p0 for R2021a\n\n**v5.0 Sep 2020** (R2019b through R2020b)\n1. Updated v5p0 for R2020b\n\n**v5.0 Mar 2020** (R2019b through R2020a)\n1. Updated v5p0 for R2020a\n\n**v5.0 Sep 2019**  (R2019b through R2020a)\n1. Move to MATLAB Projects\n\n**v4.1 Mar 2019** (R2015a through R2019a)\n1. Updated v4.1 for R2019a\n2. Minor changes to accommodate physical signal units\n\n**v4.1 Nov 2018** (R2015a through R2018b)\n1. New example Caster_4_Whl.slx\n   Models a four-wheel cart with casters on front wheels \n2. New example sm_build_spheres_in_sphere\n   MATLAB code to automatically assemble a model that has \n   a user-defined number of spheres inside a sphere with\n   contact forces between all inner spheres and between \n   inner spheres and outer sphere.\n\n**v4.1 Sep 2018** (R2015a through R2018b)\n1. Updated v4.1 for R2018b\n2. All v4p1 have updated Extr_Data_Cam_Roller_Curve.m\n\n**v4.1 Mar 2018** (R2015a through R2018a)\n1. Adjusted Sphere to Belt Force (in 3D, Composite Forces)\n   Changed orientation of reference frame for the two\n   Sphere to Tube Enabled Forces. Z-axis flipped 180 deg\n   so that vx and wz inputs have the same sign. \n2. Adjusted sm_tread_drive example.slx\n   Uses adjusted Sphere to Belt Force, test sequence altered\n   to show turning and show both treads striking bump in \n   forward and reverse. \n3. New example sm_robot_6legs_4bar.slx \n   Models 6-legged robot. Legs on each side are a pair of\n   connected four-bar linkages. Shows how to model robot\n   walking on uneven surface.   \n4. Added CFL_contact_setModel.m\n   Function to select force law in all contact forces in model.\n5. Additions to support Parts_Lib.slx \n   Extrusion file Extr_Data_TriangleRounded_Holes.m and \n   various images for masking parts.\n\n**v4.0 Mar 2018** (R2015a through R2018a)\n1. Added Sphere to Tube Enabled Force\n   Sphere to Tube force that can be enabled/disabled\n   and can be used to model the ends of a driven conveyor belt.\n2. Added Sphere to Belt Force (in 3D, Composite Forces)\n   Used to models spheres on a moving conveyor belt.  Can\n   also be used to model vehicles that ride on treads\n   like a bulldozer.  See sm_tread_drive  \n3. New examples sm_tread_drive, Frict3D_Balls_on_Driven_Tube \n   These examples use Sphere to Tube Enabled Force and\n   Sphere to Belt Force. \n4. Added sm_ball_bearing_testrig example\n   Models a ball bearing with variants that use\n   Common Gear Constraint (ideal) and contact forces\n   (permits vibration).\n5. Added extrusion script Extr_Data_Block_NotchCircle.m \n   Used to calculate cross-sectional profile for inner and\n   outer race in Ball Bearing Testrig example\n\n**v3.9 Jan 2018**  (R2017b)     \n1. Added Cam Roller Constraint.  \n   Uses Point-on-Curve Constraint to model circular\n   roller on a cam with arbitrary profile.\n2. Added Extr_Data_Cam_Roller_Curve.m to calculate\n   path of Point-on-Curve Constraint.\n3. Added Cam_Follower_Constraint example.\n\n**v3.8 Sept 2017** (R2017b)\n1. Updated for R2017b\n\n**v3.7 July 2017** (R2015b through R2017a)\n1. Added Sphere to Cone Force.  Contact force is active on\n   inside and outside of cone.  Also added extrusion script\n   Extr_Data_Frustrum_Conical.m and example \n   Coll3D_08_Ball_in_Spinning_Cone.slx\n2. Sphere to Tube Force - fixed relative velocity calculation in\n   Contact_Forces_Lib/3D/Sphere to Tube Force/Forces/Ff/vTan\n   Previous releases delivered incorrect results if the cylinder\n   could spin.  Added new example Coll3D_07_Balls_and_Sliding_Tube.slx\n3. Extr_Data_Box.m: functional change, parameters are full width\n   and height instead of half width and half height.  Affected\n   parameters within a few examples, such as Spinning Boxes\n4. Extr_Data_Cam.m: Changed to Extr_Data_Cam_Circles.m, which has\n   two additional parameters (radii of holes).  Affected example\n   Cam Follower and the UI for parameterizing the cam.\n5. Many 2D contact forces have been modified so that they\n   no longer refer to the World frame.  This permits them to be\n   used in any plane, not just the x-y plane.\n6. Circle to Ring Force: calculations adjusted to use consistent\n   distance to contact point for circle and ring.  May result in\n   minor changes to simulation results.\n7. Mask commands adjusted - eliminated imread(), use option\n   \"Opaque with ports\" (R16a and above), and other settings.\n\n**v3.6\tMar  2017** (R2016b through R2017a) \t\n1. New example: Ball on Wheel with Controller (2D Friction Examples)\n   Models a ball balanced on a wheel.\n2. Removed MATLAB variables from blocks in Contact_Forces_Lib.slx\n   Some library elements contained MATLAB variables in the dialog box\n   parameters on the Dimensions and Visual tab.  These were replaced\n   with hardcoded default values to avoid warnings about undefined variables.\n3. Additional parameters were added to the Sphere block in Parts_Lib.slx \n   to enable the marks to be shown or hidden per axis. \n4. New script CFL_SaveLibsOnly.m that copies only the critical files \n   of this repository to a new folder so you can include them in\n   your own project.\n\n**v3.5 Jan  2017** (R2016b)\n1. Added Face-to-Plane in 3D/Composite Forces.  This is useful for\n   two flat square surfaces that may contact each other at arbitrary \n   angles.  It assumes no edges will intersect (one square is \n   significantly larger than the other\n2. Added Face-to-Belt-Faces forces in 3D/Composite Forces.  This is\n   useful for modeling 3D boxes on conveyor belts where only one\n   face of the box will encounter the belt.  It accepts the \n   speed of the belt as an input signal (vx and/or vy)\n3. Added Sphere-to-Plane Enabled Force.  This is used within the\n   composite force Face-to-Belt-Faces composite force\n4. Added example Gripper with Conveyor Belts (3D Applications). \n   Uses the new forces to model a box that is transferred by a \n   gripper between two conveyor belts.  One belt brings the box\n   to the gripper, the other moves it away.\n5. Additional parameters were added to the Cylinder block \n   in Parts_Lib.slx to enable arbitrary colors for the cylinders.\n\n**v3.4 Sep  2016** (R2016b)\n1. Fixed outputs for Circle-to-Ring, Sphere-to-Tube, Sphere-to-Plane\n   Force output signals for these signals now go to zero when \n   circle/sphere leaves active range for force, where active range is \n   an arc of the ring/tube or length of the plane. Previously, the\n   measured value for the force would be held if the force was active\n   as the circle/sphere left the active range for the force.\n2. Copy for Merge block added in Sphere-to-Plane block\n   This block is necessary in some configurations.\n\n\n**v3.3 Apr  2016** (R2016a)\n1. Added optional visualization for contact surfaces\n   The surfaces associated with the contact forces can now be visualized.\t\n   This helps you confirm you have oriented the surfaces properly and\n   defined them to be an appropriate length or active range of angles.\n2. All contact forces now have an additional tab labeled \"Visual\".  On\n   this tab you can enable a visualization of the surface, which is done\n   using a Solid with density set to 0.  For the 2D contact forces you \n   will need to define the length of the surface along the z-axis of\n   the contact force and it is used for visualization purposes only. \n   You can show/hide all contact surfaces in the model using the\n   new function CFL_visual_setOnOff.m in the Scripts_Data directory.\n\n   Additionally in this release, a number of plotting scripts have been\n   added to the examples, and in many cases the variables used by\n   the example were moved to the Model Workspace.\n\n**v3.2 Mar  2016** (R2015b through R2016a)\t\n1. Disabled zero crossings in some Abs blocks\n   Affects Circle-to-Finite Line, Sphere to Finite Plane\n   The zero-crossings in Abs blocks used to check the displacement\n   of the circle/sphere reference frame from the line/plane\n   reference frame along the line/surface (y / xy) direction is\n   not necessary.  When the line/plane can move along the (y / xy)\n   direction, it can lead to excessive zero crossings, slowing down\n   the simulation.\n\n**v3.1 Mar  2016** (R2016a)\n1. Renamed Simscape Multibody Contact Forces Library\n2. Geneva drive model imported from CAD is now parameterized\n\t\t\n\n**v3.0 Sept 2015** (R2015b)\n1. Updated to R2015b\n\n**v3.0 July 2015** (R2015a)\n\n**(3D Models)**\n\n1. Sphere-to-Sphere, Sphere-in-Sphere, Sphere-to-Plane, \n   Sphere-to-Tube added, all with optional friction model\n2. Added 3D collision and friction examples\n3. Added Two Wheel Robot example (3D Applications)\n\n**(2D Models)**\n\n4. Modified 2D enabled forces\n   ** Change from v2.0 -- may require you to update your models ** \n   Modified Circle to Circle Force Enabled, \n   Circle to Finite Line Force Enabled to use a bus as the\n   input signal instead of signal input.  Bus permits user to\n   optionally define enabled/disabled, and to set velocity\n   perpendicular to normal force (vy).  Primary use is for ideal \n   models of conveyor belts.\n5. Added 2D/Composite forces (Box to Box force, Box to Belt force)\n6. Added Belts_01_Two_Belts.slx (simple conveyor belt example)\n                \n**(Documentation, Dialog boxes)**\n\n7. Updates to all dialog boxes (added images, fixed prompts and description)\n8. Documentation revised                \n\n\n**v2.0 September 2014** (R2014a) \n1. Added optional friction model (Stick-Slip Continuous)\n   to Circle to Circle, Circle to Finite Line, Circle to Ring\n2. Added all Friction_* examples \n3. Added Spinning Boxes example \n   Shows box-to-box contact force\n4. Fixed callback commands, all contact force blocks\n   Set variant in Initialization commands instead of mask callbacks\n5. Fixed Circle to Finite Line, Circle to Finite Line Enabled\n   Force on line was applied in wrong reference frame\n\n**v1.0  August 2014** (R2014a)\n1. Circle-Circle (Enabled), Circle-Line (Enabled), Circle-Ring\n2. Examples: 7 Simple , Cam Follower, Geneva Drive. Mini Golf compatible\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks%2Fsimscape-multibody-contact-forces-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathworks%2Fsimscape-multibody-contact-forces-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks%2Fsimscape-multibody-contact-forces-library/lists"}