File Exchange

image thumbnail

Simscape Multibody Contact Forces Library

version 3.7 (19.1 MB) by

Contact force models and force laws for use with Simscape Multibody (formerly SimMechanics).

4.81818
15 Ratings

95 Downloads

Updated

View License

This library contains contact force models and force laws for multibody modeling in Simscape Multibody. They cover 2-dimensional and 3-dimensional problems with or without friction. More than 35 example models are provided, including basic contact force examples (bouncing ball) and more complex applications such as a cam-follower mechanism, differential drive robot, and a robot arm with a gripper. Both linear and nonlinear force laws are included, and you can easily add your own custom force law.

Please read the README.txt file to get started.

See how to use these forces to model a cam-follower mechanism:
https://www.mathworks.com/videos/modeling-contact-forces-in-a-cam-follower-94291.html

Learn more about multibody simulation with Simscape Multibody by watching this webinar
https://www.mathworks.com/videos/multibody-simulation-with-simmechanics-81877.html

Find other Simscape examples by searching posts for the keyword "physical modeling"
https://www.mathworks.com/matlabcentral/fileexchange/?term=%22physical+modeling%22

Learn more about MathWorks Simscape Products:
https://www.mathworks.com/physical-modeling/

You may reuse this content, with or without modification, in your work.
Please follow the conditions of the license file and use the following citation:
[1] Miller, Steve (2017), Simscape Multibody Contact Forces Library (https://www.mathworks.com/matlabcentral/fileexchange/47417) MATLAB Central File Exchange. Retrieved on <date you downloaded submission>

Comments and Ratings (35)

Steve Miller

Steve Miller (view profile)

For your use case, I believe you would like to model an uneven 3D surface. I think to do this more efficiently, a triangular contact force element would be good. It would be easier to create a tesselated surface could be created that would only require 1 force per reference point instead of 3.

As with many modeling and simulation scenarios, you either "pay" during the modeling and compilation phase or pay during the simulation phase. Put another way, you either expend extra time during the modeling and compilation phase to create an efficient model that runs quickly, or you use a generic but expensive collision detection algorithm during simulation. For the time being, this submission is focused on the first method. Thanks -- Steve

Thanks!
Wow, in retrospect it is really obvious.
Last question, if you don't mind: is it in any way possible to model an uneven surface with this lib? I understand that i can, theoretically, assemble whatever surface i want from lots of small planes and balls. But when i as much as try to add lots of contact blocks - the model begins to take forever to compile.
I recognize that this is a complex subject and i guess there is no magical solution, but maybe you have any hints for me.
Thank you for great work.

Steve Miller

Steve Miller (view profile)

Hi Anton - to prevent the sphere from entering at the edge of the plane, you need to add another contact force. With 3 Sphere to plane contact forces oriented along the X, Y, and Z axes of a cube, you can create a "Sphere to Cube" contact force. --Steve

Hello, Steve and Richard.
Yes, the error was due to rigid transforms in a loop, and now i have found a workaround for it. Turns out the contact forces don't have to be connected to the actual planes.
Here is the screenshot of how i have connected them https://puu.sh/xbJdQ/68920d5cb2.png Inside the FE blocks there are parallel contact forces https://puu.sh/xbJj2/bafeacf2c2.png
This basically creates 4 balls in the same location and 4 planes in different locations (i can correct locations with rigid transform).

Now i have another issue: contact planes are represented as two planes with a space between them https://puu.sh/xbJs1/0927fa52c2.png When a ball contacts with the outer side of these planes it works as intended. But in case when the ball gets in between these planes and touches one of them from the inside my model freezes. And since there is no "side" planes, nothing prevents the ball from going in between the planes. Is there any possible solution for it? I'd be happy if the plane was treated as a square, if it is possible.

Steve Miller

Steve Miller (view profile)

Hi Anton and Richard - Weld Joints are only rarely needed in Simscape Multibody, and I don't expect you would need them here. Can you upload a screenshot of the error, and perhaps the model? I suspect you have connected rigid transforms in a loop and all you would need to do is delete one of the connection lines, but I would need to see the error message and model to be sure. Thanks, --Steve

Hi Anton, I have encountered a similar issue and using weld joint to connect to the contact block helped me to solve the issue.

Hi, can you help me with a certain problem?
I'm trying to build a model of a platform with four legs, which is landing on four "tables". I placed contact forces on the ends of the legs, and currently it looks like this https://puu.sh/x5Knq/498696785f.png
But in this model each leg can only interact with it's respective plane, because I connected them this way https://puu.sh/x5Kta/0a938c9a43.png
I need several contact forces to be connected to several planes, but when I try to do so I'm getting an error (rigid cycle).
What should i do? Thanks in advance,
Anton.

Xu Zhang

Cjjb Gh

plz,help me. I don't quite understand the the friction force in the library. your friction force in always a product of the coefficient of the friction times the Normal force. If the ball purely rolls, the velocity at point of contact is zero. Then,the coefficient is zero,there would be no friction.

Hi Steve,

First off, awesome library, this was definitely missing from simbody.

For that project I am trying to model a car. I have 2 free rear wheels and two steering wheels in the front. The weight of the car is 1500kg. When I apply a constant torque of 250Nm on the front wheels, the car gain speed, but the wheel rotation speed seem to oscillate around a ramp. It is slow at first but the frequency of the oscillation seems to increase at the vehicle speed increases as well.

Is it a natural behaviour in any car? Are there oscillations in the wheel rotation speed that are not really a problem? Is it something coming from your library? I am a bit new to mechanics so I cannot really tell.

You can reproduce all that in your 2 wheel robots buy applying a constant torque of 0.05 and plotting the angle rate from the revolute joint directly.

In my case I get the oscillations with any torque value, say from 100 to 500 for example.

Any help or tip on that would be much appreciated.

Again, thanks for your work.

Cheers

Steve Miller

Steve Miller (view profile)

Daniel - thanks for catching the problem with the signal outputs. That is fixed in latest update (v3.4, both R16a and R16b).

Jing -- the Simscape blocks could be used for contact along one dimension, such as a hardstops in a cylinder or backlash in gears. These models are intended for 2D or 3D contacts. See this File Exchange Submission:

http://www.mathworks.com/matlabcentral/fileexchange/37636-simscape-multibody-3d---1d-interface-examples

Qing -- anisotropic friction, good request. These models assume friction is the same in all directions. Do you have an animation of the movement you are expecting? There might be a way to use multiple forces at right angles to get the desired effect, but it would require some thought.

Thanks for all the comments and feedback!

Qing Xiao

Hi Steve,
This library is awesome! But I got some trouble when I used it to model the snake robot. The snake robots need anisotropic friction to move forward. If I used Sphere-to-Plane Force to model the contact force and friction force between the wheels and plane, the friction became isotropic. So the robot just rolled on the floor and did not move a bit. Could you give me some advice about how to achieve anisotropic friction between wheels and plane? Thank you so much!

Jing Liu

Hi Steve,

This library is great! But I found there is some friction blocks in Simscape, like the Rotational Friction/Damper blocks in the Foundation Library of Simscape. What is the difference between your library and those simple blocks? Is it possible to build the same contact model with these original Simscape blocks?

Thanks for your sharing!

Daniel Stuewe

This library has been a great asset for the work that I'm doing. Thank you very much for this!

(now for the "But...")

I'm using the 2D library and I've noticed what I believe is an error with the output forces for the Circle to Ring block. I think the forces are applied to the joints correctly, but the output force does not "turn off" when the circle has passed beyond the active range. Therefore my plots are showing a constant ring force once the circle is beyond the ring (my model transitions from a ring to a circle to a line).

Normally this would be essentially a cosmetic problem, but I need the contact forces so I'm having to put my own logic in to zero out the force at the appropriate location.

Thanks again for these powerful tools.

Lei Gao

Hi Steve,
I found that there might something wrong with the friction force law.
When v_th < v < 1.5v_th, I think the function should be:
u = 3*us - 2*uk - (us-uk)*v/(0.5*v_th)
rather than
u = us - (us-uk)*v/(0.5*v_th).
However I checked the "Friction Law" block and it should works correctly.

Many thanks,
Lei

Hey Steve
I wonder your lib allow me to use multiple point on one elements. I try to achieve it by putting 4 sphere at the corner of the lower side of a cube(which was imported from solidwork). I thought I will see four ball connected to each other through the cube and bounce when it hit the plane. However, it turns out that only one sphere does the correct reaction.

Lei Gao

This library is really helpful!
I wonder if someone has modeled contact between two surfaces whose geometries are determined by splines. If this library suitable in such a case?
I will appreciate it if anyone can help.

Hi, thanks Steve For the library ...
i am searching for a way to determine the collision detection between two bodies,
would guide me please ...
best regards

Tudor

Tudor (view profile)

Hey Steve,

The error is not there actually. I just made a minimum working example and it works as it should :) So your model works very well. I might have made a mistake somewhere in my previous project where it seemed that there was an error in the contact block.

Steve Miller

Steve Miller (view profile)

Hi Tudor - not sure which blocks you are referring to. Damping behavior appears correct in Frict3D_04_Ball_on_Ball. Will follow up with you separately.

Vinay - sorry it took me a while to react to your post. Feel free to contact me via my author page.

Janmejaya - yes, you can measure force per leg.

Prof Liebgott - Converting the internals of the force blocks to an S-Function would likely create a model with less than 1000 blocks. I will give this a try.

Thanks for all the interest and use of the library! --Steve

Tudor

Tudor (view profile)

Hey Steve,

The damping force in the sphere-to-sphere is not correct. You are applying it to the norm of the speed, which can never be negative, so after the saturator the result is always 0.

Zafb

Zafb (view profile)

Hi Steve..
Can I use it to find magnitude of Ground Reaction Force acting on a leg of hexapod ?
OR
If I am going to vary weight on each leg, by adding some mass block, is GRF calculated using this library is going to vary?

Ivan Liebgott

Thanks a lot,
This library is very useful and correspond to classical mechanical enginneering problems. Unfortunatly most of examples use more than 1000 blocs and it is not possible to use them with the MATLAB Pass licence with my students...Is there any solution to run these models on MATLAB pass licence?
Thanks for your answer.
Professor Ivan LIEBGOTT

liu lei

Well, it's very useful,thanks a lot. I met a problem on 08 July and this file update to 3D one day later ,I'm so lucky and thank to Steve Miller.

Tudor

Tudor (view profile)

Hello,

I am very happy to have found this library, as it helped me a lot in my simulations.

I will, however, need a version of this library that works in 3D; is there any such thing? If not, would you be interested in providing some tips for me to create one, based on this current submission (which is great btw)?

Under what license is your work published? Can I modify it? Would I be able to publish a new library, based on yours, if I ever get it to work?

Thank you,
Tudor

Montassar

Hello Steve, My name is Montassar and I m a young PhD Student from France.
i have seen your work the 2D contact library, i really find it very interesting and innovating, but i do have a question, how did you find information about the variables "k" and "b" for the spring and the dumper, i know it is related to the material used and k=the young modulus, but how can you be "sure" of the values of the k and b that you are using.
thank you very much for you time and your help.
kind regards

OK, I had to make a new File Exchange submission.

http://www.mathworks.com/matlabcentral/fileexchange/49374-rolling-ball-on-plane

Thanks Steve for your help!

Steve Miller

Steve Miller (view profile)

The models in this submission are for use with SimMechanics Second Generation Technology. SimMechanics is being actively developed with new features each release (every six months) -- see the release notes online:

http://www.mathworks.com/products/simmechanics/whatsnew.html

New features are added to Second Generation Technology (2G). First Generation Technology (1G) will be supported as long as is necessary.

Thanks for your update. Will these models work for the First-Generation SimMech or the Second-Generation technology ?

I'm not feeling comfortable to use a product in which is not being actively developed anymore. Sure it will work for a few next releases, but for how long ?

Steve Miller

Steve Miller (view profile)

3D contacts and contacts with splines are possible with SimMechanics. We've done that with other users, using both Simulink and MATLAB for custom contact detection and force calculation. Though I cannot share those confidential models, I'm working on versions that can be shared. Thanks for your interest and questions.

As far as I understand no 3D contacts are possible. Only line to line, line to circle etc.

For more complex cam geometries simmechanics is pretty useless. You can't use a cubic spline for instance.

We used Adams for this, a real multi body package.

Great library. However, I would need a 3D contact, for example "Circle to Finite Plane Force". It could be used to model a ball on a plane. Are you going to provide that?

Updates

3.7

Added Sphere-to-Cone, fixed error in Sphere-to-Tube, many other updates. Submission includes versions for R17a, R16b, R16a, contact me for earlier releases. Recommend updating to this version.

3.6

Updated for R2017a. Added MATLAB code to extract a copy of just the libraries for use in other projects.

3.5

Added Face-to-Plane and Face-to-Belt (3D Composite Forces), Sphere-to-Plane Enabled (3D). Added "Gripper with Conveyor Belts" example (3D application). Re-added R14b version, removed GIF files, removed STL files from R14b and R15b.

3.4

Added R2016b version; Fixed reported output force signals for Circle-to-Ring, Sphere-to-Tube, Sphere-to-Plane (not calculation, just outputted value); Dropped R2014b version due to 20MB file size limitation on File Exchange.

3.3.0.1

Updated license

3.3

Hid the contact force surfaces in conveyor belt example.

3.3

Added ability to visualize contact surfaces to all contact forces. Helps you make sure you positioned, oriented, and sized the surfaces appropriately.

3.2

Disabled one zero crossing in Circle-to-Finite Line, two in Sphere-to-Plane. Better performance in a few cases.

3.1

Added R2016a version.

3.0

Includes v3.0 for R2015b, R2015a, and R2014b.

3.0

Includes v3.0 for R2015b, R2015a, and R2014b.

3.0

Version 3.0 Added 3D contact models (Sphere-to-Sphere, Sphere to Plane, Sphere-to-Tube) with friction. Added composite 2D forces (Box to Box, Box to Belt). New examples include box on conveyor belts, two wheel robot. See README.txt in zip file.

1.6

Version 2.0. Added friction to contact models; added many friction examples, fixed two mistakes in force laws (Contact_Forces_Lib.slx); added box-to-box contact force (Spinning_Boxes.slx). See README.txt in zip file for details.

1.4

Added video links

1.3

Updated submission name

MATLAB Release
MATLAB 9.2 (R2017a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

SM_Contact_Forces_Lib_R16a_v3p7/Examples/2D/Cam_Follower/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/2D/Cam_Follower/UI/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/2D/Geneva_Drive/CAD/Export/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/2D/Geneva_Drive/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/2D/Simple/Collision/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/2D/Simple/Friction/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/2D/Spinning_Boxes/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/3D/Gripper_2Belts/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/3D/Robot_2_Whl/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/3D/Simple/Collision/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/3D/Simple/Friction/

SM_Contact_Forces_Lib_R16a_v3p7/Libraries/

SM_Contact_Forces_Lib_R16a_v3p7/Scripts_Data/

SM_Contact_Forces_Lib_R16a_v3p7/Scripts_Data/Doc/

SM_Contact_Forces_Lib_R16a_v3p7/Scripts_Data/Extrusions/

SM_Contact_Forces_Lib_R16a_v3p7/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/2D/Cam_Follower/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/2D/Cam_Follower/UI/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/2D/Geneva_Drive/CAD/Export/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/2D/Geneva_Drive/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/2D/Simple/Collision/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/2D/Simple/Friction/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/2D/Spinning_Boxes/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/3D/Gripper_2Belts/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/3D/Robot_2_Whl/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/3D/Simple/Collision/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/3D/Simple/Friction/

SM_Contact_Forces_Lib_R16b_v3p7/Libraries/

SM_Contact_Forces_Lib_R16b_v3p7/Scripts_Data/

SM_Contact_Forces_Lib_R16b_v3p7/Scripts_Data/Doc/

SM_Contact_Forces_Lib_R16b_v3p7/Scripts_Data/Extrusions/

SM_Contact_Forces_Lib_R16b_v3p7/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/2D/Cam_Follower/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/2D/Cam_Follower/UI/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/2D/Geneva_Drive/CAD/Export/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/2D/Geneva_Drive/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/2D/Simple/Collision/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/2D/Simple/Friction/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/2D/Spinning_Boxes/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/3D/Gripper_2Belts/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/3D/Robot_2_Whl/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/3D/Simple/Collision/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/3D/Simple/Friction/

SM_Contact_Forces_Lib_R17a_v3p7/Libraries/

SM_Contact_Forces_Lib_R17a_v3p7/Scripts_Data/

SM_Contact_Forces_Lib_R17a_v3p7/Scripts_Data/Doc/

SM_Contact_Forces_Lib_R17a_v3p7/Scripts_Data/Extrusions/

SM_Contact_Forces_Lib_R17a_v3p7/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/2D/Cam_Follower/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/2D/Conveyor_Belts/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/2D/Geneva_Drive/CAD/Export/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/2D/Geneva_Drive/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/2D/Simple/Collision/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/2D/Simple/Friction/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/2D/Spinning_Boxes/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/3D/Gripper_2Belts/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/3D/Robot_2_Whl/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/3D/Simple/Collision/

SM_Contact_Forces_Lib_R16a_v3p7/Examples/3D/Simple/Friction/

SM_Contact_Forces_Lib_R16a_v3p7/Libraries/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/2D/Cam_Follower/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/2D/Conveyor_Belts/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/2D/Geneva_Drive/CAD/Export/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/2D/Geneva_Drive/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/2D/Simple/Collision/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/2D/Simple/Friction/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/2D/Spinning_Boxes/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/3D/Gripper_2Belts/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/3D/Robot_2_Whl/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/3D/Simple/Collision/

SM_Contact_Forces_Lib_R16b_v3p7/Examples/3D/Simple/Friction/

SM_Contact_Forces_Lib_R16b_v3p7/Libraries/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/2D/Cam_Follower/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/2D/Conveyor_Belts/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/2D/Geneva_Drive/CAD/Export/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/2D/Geneva_Drive/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/2D/Simple/Collision/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/2D/Simple/Friction/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/2D/Spinning_Boxes/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/3D/Gripper_2Belts/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/3D/Robot_2_Whl/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/3D/Simple/Collision/

SM_Contact_Forces_Lib_R17a_v3p7/Examples/3D/Simple/Friction/

SM_Contact_Forces_Lib_R17a_v3p7/Libraries/

SM_Contact_Forces_Lib_R16a_v3p7/Libraries/Help/html/

SM_Contact_Forces_Lib_R16b_v3p7/Libraries/Help/html/

SM_Contact_Forces_Lib_R17a_v3p7/Libraries/Help/html/