## Use Contact Proxies to Simulate Contact

Contact proxies are simple shapes that are used to represent the contact parts of actual bodies. For example, in the Train Humanoid Walker example, red spheres are used to represent the bottoms of the robotic feet.

By using contact proxies, you can increase the speed and robustness of a contact simulation. For example, using contact proxies can speed up models that involve complex geometries and prevent the discontinuous jumping of contact force locations in static contact simulations.

### How to Use Contact Proxies

Contact proxies can be used in many cases. However, adding contact proxies requires a greater modeling effort, and it is hard to leverage the proxies in several cases. If the contact interaction involves all the features of the actual bodies, then proxies may not be able to completely represent every element of the bodies. If your model is simple and you only need to run it once, you can use the actual bodies to model contact.

#### How to Choose Proxies

To choose the appropriate proxies for a contact problem, you need to indicate what parts of the actual bodies will interact and then select the simplest proxies for these parts. Note that the proxies should be enough to cover all the contact regions.

Simscape™ Multibody™ supports a variety of geometries and bodies for contact modeling. Based on complexity, these geometries and bodies can be categorized into three groups.

• The geometries defined by the Point, Infinite Plane, and Spherical Solid blocks. These geometries are the best candidates to act as proxies due to their simple shapes and high modeling efficiency.

• The bodies defined by Brick Solid, Cylindrical Solid, and Ellipsoidal Solid blocks. They are more computationally expensive than the geometries of the first group. If you can't use the geometries in the first group, try to use bodies in this group as proxies.

• The geometries created by extrusions, revolutions, and CAD imports. Typically, these geometries are not suitable to be used as proxies due to their complex shapes, high computational costs, and simplified representations. Note that Simscape Multibody represents some of these geometries with convex hulls instead of actual bodies when modeling contacts.

#### Tips for Using Contact Proxies in Complex Models

Simscape Multibody models contact between bodies by using the Spatial Contact Force block. Each pair of potentially contacting parts needs one Spatial Contact Force block. Consequently, a complex model that includes many proxies could lead to a plethora of Spatial Contact Force blocks and geometry lines. Use the following techniques to keep your block diagram organized. See the first example for how to use these techniques.

• Place each actual body and its proxies in one subsystem. The subsystem should also include all the relevant Rigid Transform blocks needed to properly place the proxies relative to the actual body.

• Copy and paste subsystems or use referenced subsystems to create identical subsystems.

• Use the Simscape Bus block to bundle the geometry lines of a complex model.

Usually, the actual body and its proxies occupy some common regions in the 3-D space. You should render only the actual body and hide the proxies in the final version of the simulation. However, during a modeling or debugging step, it is helpful to view the proxies to verify whether all the contacts are modeled as expected. Consider defining two variables to adjust the transparency of the actual body and proxies. Use the mass of the actual body for simulation and set the mass or density of the contact proxies to zero to avoid any effects on dynamics.

### Examples

#### Using Proxies in Contact Models that Include Complex Shapes

Modeling contact between bodies with complex shapes is computationally expensive and time consuming. To speed up the model, you can decompose the complex shapes into simpler parts and use proxies to represent the parts involved in contact, then model the contacts between these proxies.

In the Ratchet Lifter example, the traveler climbs up along the toothed rack as the traveler handle is pumped up and down. Only the horizontal and slanted surfaces of the rack teeth and climber cylinders are involved in the contact. Also, the traveler only exhibits planar motion. In other words, only the center parts of the climber cylinders are involved in the contact interactions. Therefore, the example uses the proxies to represent only these parts and models contacts among the proxies.

This example uses cylinders to represent the horizontal and slanted surfaces of the rack teeth and spheres to represent the center parts of the climber cylinders. The advantage of using a sphere instead of the entire climber cylinder is that spheres are simpler than cylinders and provide more efficient contact modeling.

The toothed rack is symmetrical and has 15 teeth on each side. Consequently, this example uses 60 cylinders to represent the teeth. The model includes a subsystem called Toothed Rack that includes the actual body of the rack, all the proxies of the teeth, and relevant Rigid Transform blocks. The following figure shows the Toothed Rack subsystem.

Because the toothed rack is symmetrical, only the proxies on one side of the rack were created manually and grouped into the Left Slant Cylinders and Left Horiz Cylinders subsystems. Then these subsystems were copied, pasted, and then rotated 180 degrees around the `y`-axis to represent the right-side teeth.

The following image shows the Left Horiz Cylinders subsystem. The model uses 15 identical cylinders to represent the horizontal surfaces of the left-side teeth. To minimize the number of blocks that were manually created, one parameterized referenced subsystem was created to model one of the cylinders. Then the parameterized referenced subsystem was copied 14 times. The parameterized referenced subsystems use the cylinders’ indices to specify the locations of the cylinders. Finally, the geometry lines of the cylinders are bundled using a Simscape Bus block. The same method is used to model the subsystem of the teeth’s slant surfaces.

The Simscape Bus block helps avoid a complex web of lines throughout the model. The following image shows that two Simscape Bus lines connect the 60 proxies of the rack teeth with the climbers' proxies via the Contacts Left and Contacts Right subsystems.

The Contacts Left and Contacts Right subsystems include all the Spatial Contact Force blocks for this simulation. The following image shows the diagram of the contact between the horizontal surface of the left-side teeth and the cylinder of the left climber.

#### Using Proxies to Model Static Contact

Simscape Multibody employs a point-based penalty method for modeling contact between bodies. This method means that the Spatial Contact Force block applies necessary contact forces to its connected bodies at the points with the maximum penetration between the two bodies. Each Spatial Contact Force block only applies a single contact force for each body at each time step.

This point-based method has challenges when modeling static contact between the flat surfaces of bodies. For example, consider modeling the contact between two bricks. For the purposes of simplicity, the following image shows the 2-D version of the problem. Suppose Brick A is dropped onto Brick B, which has a fixed position. The left image shows the configuration of the bricks when the contact is first detected. At this point, the Spatial Contact Force block applies a contact force to the lower-left corner of Brick A because it has the maximum penetration. Over time, the force decelerates the downward motion of Brick A and rotates it in a clockwise direction. Then, the configuration appears like the right image, and the force is applied to the lower right corner of Brick A. As Brick A settles into static contact with Brick B, the location of the contact force rapidly and discontinuously jumps among the corners of Brick A. This behavior is challenging for the solver and can significantly decrease the simulation speed.

Using contact proxies is one effective way to avoid the above modeling challenges. Eight small spheres can be rigidly attached to the corners of Brick A. With these proxies, the contact is modeled as eight brick-sphere pairs instead of a single brick-brick pair. As the contact stabilizes, the normal force at each bottom corner will be one-fourth of the weight of Brick A.