Introduction to Contact Modeling11

Posted by Sebastian Castro,

Today I have the great pleasure to introduce my colleague Sebastian Castro as guest blogger. He will be sharing an “Introduction to Contact Modeling”. Sebastian, the stage is yours!

– – –

In this post, I will talk about simulating mechanical contact with Simulink®, Simscape™, and Simscape Multibody™.

Motivation

Modeling mechanical contact can be useful to build realistic simulations for various engineering areas, including

• Robotic systems: Wheeled robots, walking robots, and robot grippers
• Automotive systems: Tire-ground interaction, suspension, and drivetrain components
• Industrial automation systems: Robot grippers (again), assembly line components such as conveyor belts, rollers, and other mechanisms

Modeling Contact Mechanics

Contact forces are the result of solid bodies interacting with each other. To approximate contact behavior in simulation, we use contact models.

The two main components of contact forces can be broken down into

• Normal forces: Push objects away from each other when they collide. As their name suggests, these forces are normal to the point(s) of contact.
• Friction forces: 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.

Normal forces can be modeled in several ways, including

• Impulse-based: This is a one-time event that occurs when two objects collide. Before collision, each object has a certain momentum (mass * velocity, or its rotational equivalent). After the collision, the magnitude and direction of each object’s momentum will change based on the type of collision; for example, elastic vs. inelastic. This approach works best in models where the objects do not frequently move in and out of contact.
• Force-based: Normal forces are applied to objects based on a force law. A common approach is to apply a penalty force; 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 “squishing”) 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.
• Motion constraint: 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.

Friction forces typically consist of a force law with two distinct regions.

• Static friction represents the initial force needed by an object at rest to begin sliding along its contact surface.
• Kinetic friction represents the resistive force of an object when it is moving along its contact surface.

Friction force curves can be represented using equations, or by directly using the curve data in a lookup table.

Simulink® lets you graphically implement equations. Mechanical system dynamics can be modeled using differential equations, which are commonly associated with with the Integrator block. This is because of Newton’s 2nd Law (Force = mass*acceleration). The acceleration can be integrated once to calculate velocity, and again to calculate position.

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.

[Video] MATLAB and Simulink Robotics Arena “Introduction to Contact Modeling, Part 1

1D Contact with Simscape™

Simscape™ extends Simulink® for modeling 1D physical networks (electrical, fluid, mechanical, etc.) without deriving equations of motion. Every mechanical Simscape™ component is implemented by establishing a relationship between velocity and force/torque, so you can implement 1D force-based contact in Simscape™.

Simscape™ has built-in blocks such as the Translational Friction and Translational Hard Stop 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™ blocks and customize their equations – or you can create your own component from scratch.

3D Contact with Simscape Multibody™

You can use Simscape Multibody™ to model 3D rigid-body systems. There are two types of contact that you can implement with these models.

If you’re interfacing 1D contact into a larger 3D model, for example, actuator limits or friction, you can use the Simscape Multibody™ Multiphysics Library to help you connect an individual Revolute or Prismatic Joint block to the Hard Stop and Friction blocks described above.

Else, you can implement a more generic (2D or 3D) penalty force relationship by

1. Measuring the relative motion between two objects (Transform Sensor)
2. “Doing the math” with Simulink® blocks
3. Applying the resulting contact forces/torques to the objects in contact (External Force + Torque)

The Simscape Multibody™ Contact Forces Library 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.

[Video] MATLAB and Simulink Robotics Arena “Introduction to Contact Modeling, Part 2

Conclusion

We just covered several ways to model mechanical contact in Simulink®, Simscape™, and Simscape Multibody™. To summarize,

• Simulink® 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.
• Simscape™ lets you model 1D mechanisms without deriving equations of motion, and contains basic blocks (which are customizable) to represent normal and friction contact forces.
• Simscape Multibody™ let you model 3D rigid body systems without deriving equations of motion.

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’d be interested in hearing from you.

– Sebastian

vitalram replied on : 1 of 11
How to detect the collision or contact between two bodies in sim-mechanics and feed back the collision (occurred in sim-mechanics)to Matlab.
scastro replied on : 2 of 11
@vitalram: The Contact Forces Library blocks return an output signal with all sorts of measurements, including whether or not there is a collision (0 or 1). You can log this Simulink signal to MATLAB for further analysis like you would any other signal.
Reza replied on : 3 of 11
How do you compare Simulink/simscape efficiency in contact simulation to http://www.mujoco.org/ ? I am asking because I want to evaluate whether to pay another Licence on top of Matlab/Simulink or I can do as well with simscape?
Sebastian Castro replied on : 4 of 11
Great question! MuJoCo has the benefit of providing ready-to-go contact in the form of a physics engine. This will probably make it easier to set up simulations, as you don't have to code up the contact physics for each part yourself, and the simulations will also be faster. However, the physics themselves will use a lot of approximations as the goal is fast and scalable simulation. Simulink/Simscape, on the other hand, is more for modeling high-fidelity physics. So your simulation will likely not be as fast, and the number of contact points you set should be relatively small. However, you have more control over the physical equations and you can do things like connecting to actuator models (think hydraulic, electrical, etc.), as well as using the whole MATLAB and Simulink ecosystem for scripting, controls, optimization, data analysis, etc. At the end of the day, it's a tradeoff. Do you want a fast, but approximate simulation that lets you verify algorithms at a high level, or do you need to dig down into the physical details to get a more accurate model for design purposes?
Tianle Liu replied on : 5 of 11
It seems that "Sphere to Plane" block performs differently in Matlab 2017a and 2018b. Your example "multibodySphereLib_RigidPlane" runs properly. But when I copy the blocks to a new blank model in Matlab 2018b and run it, a warning comes out that " Sphere to Plane Force/External Force and Torque PlaB' has its follower port rigidly connected to the world frame; it has no effect. You can configure this diagnostic in the Simscape Multibody Configuration Parameters dialog. " This warning is the same one I got when I was using "Sphere to Plane" block to build my own block. I wonder whether "External Force and Torque" is different in Matlab 2017a and 2018b. It is really inconvenient if I cannot set one frame fixed in the world frame (because I need ground fixed).
Sebastian Castro replied on : 6 of 11
Hi Tianle -- this is actually a Simulink default setting that conflicts with the contact blocks. So by upgrading versions, you've likely gone back to having that setting cause an error. Refer to this link for how to fix it: https://www.mathworks.com/matlabcentral/answers/378561-rigidly-connected-port-error-with-simscape-multibody-contact-forces-library
Tianle Liu replied on : 7 of 11
What a fast response!!! Thank you very much！
Connor Tinker replied on : 8 of 11
Is it possible to change the terrain over which the vehicle is traveling, and possibly add variations such as unpredictable potholes and such like that?
Sebastian Castro replied on : 9 of 11
@Connor: If you only have a few disturbances in terrain, then maybe you can just add discrete contact elements, like a box or sphere representing a bump. If this is a more complicated road profile, I would actually take a step back from the provided library and do one of two things: 1) If you can recreate this by using a rectangular plane and moving it up and down, I would just actuate the motion of the ground to simulate a disturbance profile 2) Else, I would create my own contact force computation. If you're asking about roads/potholes, then I might consider a simple calculation that compares the Z distance (height) of a wheel above ground, where that ground height is a lookup table depending on how far you've moved (so, a terrain table). For both approaches, instead of having many expensive contact calculations with various blocks, you just have one where that ground location is changing over distance, time, or both!
Sundaramoorthy Arivanantham replied on : 10 of 11
Hey Sebastian. I'm trying to model contact between a swedish wheel (mecanum wheel) and a floor. Since swedish wheels are different from normal wheels in a way that the wheel itself has different bodies or entities, namely the frame, roller axle, roller etc. How to model the contact force between these rollers and the floor ?. There are 9 rollers on the wheel. If i normally use "Sphere to plane contact force" block and connect all rollers to the floor the simulation takes an exhaustive amount of time to complete.
Sebastian Castro replied on : 11 of 11
@Sundaramoorthy -- that makes sense. You may want to implement your own contact force law for the Swedish wheel so you only need 1 block, thereby 1 computation. The general approach is described at 11:53 in the second video.

This site uses Akismet to reduce spam. Learn how your comment data is processed.