A Simulation Optimization Method for Contact Interface

By introducing a simulation optimization method of contact interface in physical simulation technology, and dynamically adjusting the friction coefficient and control force using the backpropagation algorithm, the problems of accuracy and efficiency of the existing technology when simulating complex physical phenomena are solved, and higher precision and more efficient simulation calculations are achieved.

CN119203784BActive Publication Date: 2025-03-21CHINA JILIANG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411677158.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2025-03-21
Estimated Expiration
2044-11-22

AI Technical Summary

Technical Problem

Existing physical simulation technologies are difficult to achieve high-precision and efficient calculations when simulating complex physical phenomena, especially when friction and collision, which limits their widespread use in complex system modeling and applications.

Method used

A simulation optimization method for contact interface is proposed. By initializing input parameters, including friction coefficient, solving motion state and optimizing friction coefficient, the backpropagation algorithm is used to continuously adjust the friction coefficient and control force, and dynamically adjust the motion trajectory of the object.

Benefits of technology

It significantly improves the simulation accuracy of complex collision and friction phenomena, allowing the simulation system to more realistically simulate physical behaviors while taking into account the computing efficiency, achieving more accurate control.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119203784B_ABST
    Figure CN119203784B_ABST
Patent Text Reader

Abstract

The present invention discloses a simulation optimization method for a contact interface, comprising: initializing input parameters, wherein the input parameters include the friction coefficient between the contact interfaces of collision bodies; solving the motion state: solving the mutual friction between the collision bodies according to the initialization, and the friction impulse caused by the friction and the tangential acceleration caused by the friction, and updating the position and velocity of the collision body by using the friction impulse and the tangential acceleration; optimizing the friction coefficient: optimizing the friction coefficient by using the loss function to obtain the friction coefficient; solving the motion state and optimizing the friction coefficient again by using the friction coefficient to obtain the friction coefficient, solving the motion state and optimizing the friction coefficient again by using the friction coefficient to obtain the friction coefficient... and repeating the cycle until the loss function converges to the minimum value. The method can take into account both simulation accuracy and calculation efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of computer simulation, and in particular relates to a simulation optimization method for a contact interface. Background Art

[0002] Differentiable physics simulation technology enables gradient-based optimization and learning by allowing gradients to be back-propagated during physical simulation. In recent years, with the rapid development of machine learning and automatic differentiation technology, this technology has been widely studied and applied. In the modeling, optimization and learning of complex physical systems, differentiable physics simulation provides a powerful tool for engineering design, robotic control and scientific research.

[0003] Traditional physical simulation methods usually rely on fixed, predefined model parameters. However, these models often face bottlenecks in accuracy and computational efficiency when simulating complex physical systems (especially those involving nonlinearities, friction, and collisions). Traditional frictionless models or methods that only deal with elastic collisions are difficult to fully simulate complex physical phenomena in the real world, thus limiting their scope of application.

[0004] Differentiable physical simulation technology is proposed to solve these problems. This technology calculates the gradient of each parameter in the physical system through automatic differentiation, allowing the physical model to learn and adapt from data, greatly improving the flexibility and accuracy of the simulation. In addition, embedding the physical model into the learning system allows gradient-based methods (such as gradient descent) to be used to optimize the problems of the physical system, thereby improving the effectiveness of complex system modeling.

[0005] Most existing differentiable physics simulation studies focus on frictionless or elastic collision scenarios, which limits their ability to simulate complex phenomena in reality. In fact, friction and contact behavior between objects have a significant impact on motion trajectory and energy dissipation, but these factors are often ignored or simplified in traditional simulation methods.

[0006] With the advancement of automatic differentiation technology, researchers have begun to introduce more complex friction contact models to improve the realism of simulation. For example, continuous collision detection (CCD) technology is used to accurately calculate the collision time of objects to determine their position and speed after the collision, thereby significantly improving the accuracy and reliability of collision simulation. In addition, through detailed modeling of friction, the simulation system can more realistically reproduce physical behavior under different material and surface conditions. These technological advances have enabled differentiable physical simulation technology to show broader prospects in the research and application of complex systems.

[0007] In general, the existing physical processing collision simulation technologies include the following categories:

[0008] 1. Frictionless or elastic collision model

[0009] Traditional physical simulation research mainly focuses on frictionless or elastic collision scenarios. These methods ignore the influence of friction and only consider the rebound of objects after collision by elastic restoring force. Although this simplified processing can improve computational efficiency, it cannot accurately simulate the complex interactions between objects and the real motion trajectory. This makes the simulation limited in accuracy when dealing with physical phenomena with friction, and it is difficult to adapt to the complex situations in the real world.

[0010] 2. Linear Complementary (LCP) Method

[0011] This method solves the friction contact problem by converting it into a linear complementarity problem. In this model, the friction cone is approximated by a polyhedral cone, which can guarantee solutions for any number of contacts and configurations. Although it can simulate the friction contact phenomenon to a certain extent, the computational complexity of this method is high. Especially when dealing with multi-contact and high-dimensional collision problems, the efficiency of numerical solutions is low, and it is easy to have unstable or non-convergent solutions. Since LCP models often require specialized numerical algorithms (such as the projected Gauss-Seidel method) to solve, this further increases the computational overhead.

[0012] 3. Convex Optimization Model

[0013] Tools such as the Mujoco simulator use convex optimization methods to solve frictional contact problems. The contact impulse is solved by minimizing the post-collision kinetic energy. This method allows violations of the complementarity condition and can provide efficient and stable solutions. It is widely used in robotic control and dynamic simulation. Although convex optimization methods can provide efficient and stable solutions, in some cases, it allows violations of traditional physical complementarity conditions. This results in simulation results that are lacking in physical realism, especially in scenarios involving complex contact and collisions, and may not accurately reflect the actual physical behavior.

[0014] 4. Position-Based Dynamics (PBD)

[0015] The PBD method directly manipulates the position of the object to meet the physical constraints instead of calculating through forces and accelerations. This method is easy to implement and has high stability, but it has low accuracy when dealing with complex rigid body collision problems. The extended PBD (XPBD) method has been applied in contact dynamics simulation by introducing implicit integration to improve accuracy. Due to its good stability and easy implementation, it is widely used in computer graphics and physical animation. However, since this method omits the calculation of forces and accelerations, it has low accuracy when dealing with complex rigid body collision and friction problems, and it is difficult to accurately simulate complex physical behaviors. This makes the PBD method perform poorly under high-precision simulation requirements.

[0016] 5. Continuous Collision Detection (CCD)

[0017] CCD technology is used to accurately detect the collision time (TOI) of objects and adjust the position or speed of objects after collision according to TOI. This method effectively improves the accuracy of collision simulation, especially when dealing with problems caused by time discretization.

[0018] These existing technologies each have their own advantages and disadvantages, but when faced with complex friction contact problems, it is often necessary to strike a trade-off between accuracy and computational efficiency. Summary of the invention

[0019] In order to balance simulation accuracy and computational efficiency, the present invention provides a contact interface simulation optimization method.

[0020] The technical solution adopted by the present invention is:

[0021] The present application discloses a contact interface simulation optimization method, which is applied to the motion state simulation of collision bodies, such as the motion state simulation of objects when collision occurs in animation, and the method comprises:

[0022] Initialize input parameters, including the friction coefficient between the collision body contact interface ;

[0023] Motion state solution: According to the initialization Solve the mutual friction between colliding bodies , and by The friction impulse caused and the tangential acceleration due to friction , using friction impulse and tangential acceleration Update the position and velocity of the collider;

[0024] Friction coefficient optimization: Optimizing the friction coefficient using loss function , and obtain the friction coefficient ;

[0025] Using the coefficient of friction The motion state solution and friction coefficient optimization are performed again to obtain the friction coefficient , using the friction coefficient The motion state solution and friction coefficient optimization are performed again to obtain the friction coefficient ...This cycle is repeated until the loss function converges to a minimum value;

[0026] Wherein, the loss function includes the output loss function :

[0027] ;

[0028] The friction coefficient for each iteration satisfies:

[0029]

[0030] in, , is the learning rate, which is used to control the step size of the update; Indicates the Euclidean distance between the actual stopping position of the first collision body and the expected position. Indicates the Euclidean distance between the actual stopping position of the second collision body and the expected position; Indicated in The state variables of the collision body at time Position at the moment and speed , , Indicates the end time of the entire control time interval. Indicates the number of iterations.

[0031] As an optional technical solution, the loss function also includes an input loss function and a total loss function, and the input loss function is:

[0032]

[0033] in, is the weight constant, Indicates that at continuous time External control input, , Indicated in The state variables of the collision body at time Position at the moment and speed ; The total loss function is:

[0034]

[0035] The constraints of the total loss function are: , , , ;

[0036] in, Indicates finding the minimum value; represents the time derivative of the system state, ; is the system's dynamic equation, describing the external control input Under the action, state evolution; Indicates the occurrence of The time of the collision, Indicates The state of the collision body after the first collision occurs, Indicates The state of the collision body before the collision, function Indicates the impact of the collision on the state of the collision body. Used to describe the change in the state of the collision body after the collision; is the collision detection function. satisfy , indicating that Collisions occur all the time;

[0037] The total loss function and the constraint conditions are discretized to obtain a discretized total loss function:

[0038] };

[0039] And the discretization constraints: ;

[0040] in, is the discretized time step, ; Represents the state of the system in the Nth time step; Indicates that the system The state within a time step, Indicated in The external control input in time steps, Represents a state update function.

[0041] As an optional technical solution, the friction coefficient optimization also includes:

[0042] A new loss function is added to optimize the friction coefficient between the collision body and the ground. The new loss function is:

[0043]

[0044] It is The velocity of the collision body in the last step of the simulation, is the weight constant, and the optimization objective is the loss function Converges to its minimum ;

[0045] Another loss function is added to optimize the friction coefficient between the collision body and the wall. The new loss function is:

[0046]

[0047] in, Indicates that a total of collision events, Indicates the occurrence of The actual velocity change of the collision body after the collision, Indicates the occurrence of The expected velocity change of the collision body after the collision, the optimization target is the loss function Converges to its minimum .

[0048] As an optional technical solution, the friction coefficient after initialization is used The motion state solution includes the following process:

[0049] Calculating the penetration time of the collision body to be simulated using continuous collision detection CCD ;

[0050] Step forward one penetration time , to calculate the collision-related parameters of the collision body to be simulated, the collision-related parameters include the collision position , collision speed and the collision direction vector ;

[0051] Calculate the thrust impulse of the collision body to be simulated according to the collision related parameters ;

[0052] According to the thrust impulse And the friction coefficient after initialization Calculate the mutual friction between the collision bodies to be simulated , and determine the friction direction;

[0053] Calculation of friction The impulse caused to the collision body to be simulated ;

[0054] Friction impulse and the acceleration caused by friction It is used to update the position and velocity of the collider to be simulated, and this process is repeated at each time step.

[0055] As an optional technical solution, the penetration time Calculated according to the following formula:

[0056]

[0057] Where d is the penetration depth, For the second collision body The penetration velocity at the time step is For the first collision body The penetration velocity at the time step is represents the penetration direction; the penetration depth d is calculated according to the following formula:

[0058]

[0059] in, Indicates that the second collision body is The penetration position vector at the time step, Indicates that the first collision body is The penetration position vector at the time step, Indicates the modulus of the vector; the first collision body and the second collision body are both spheres, Indicates the radius of the first collision body, Indicates the radius of the second collision body;

[0060] The penetration direction Calculated according to the following formula:

[0061] ;

[0062] For the first collision body, its penetration position vector The calculation is performed by the symplectic Euler integration method as follows:

[0063]

[0064]

[0065] in, For the first collision body The position vector at the time step, For the first collision body The penetration velocity at the time step is represents a time step; Indicates that the first collision body is The speed at the time step, Indicates that the first collision body is The acceleration at each time step;

[0066] For the second collider, its penetration position vector The calculation is performed by the symplectic Euler integration method as follows:

[0067]

[0068]

[0069] in, For the second collision body The position vector at the time step, For the second collision body The penetration velocity at each time step; Indicates that the second collision body is The speed at the time step, Indicates that the second collision body is The acceleration at each time step.

[0070] As an optional technical solution, the thrust impulse Calculated according to the following formula:

[0071]

[0072] in, is the elastic coefficient, is the component of the relative velocity between the first collision body and the second collision body in the collision direction, represents the mass of the first collision body, Represents the mass of the second collider and the collision direction vector Calculated according to the following formula:

[0073]

[0074] in, Indicates that the second collision body is The collision position vector at time steps, Indicates that the first collision body is The collision position vector at time steps;

[0075] The collision position vector Calculated according to the following formula:

[0076]

[0077]

[0078] in, For the second collision body The collision velocity at the time step;

[0079] The collision position vector Calculated according to the following formula:

[0080]

[0081]

[0082] in, For the first collision body The collision velocity at each time step.

[0083] As an optional technical solution, the mutual friction between the collision bodies Calculated according to the following formula:

[0084]

[0085] in, is the normal pressure, calculated according to the following formula:

[0086]

[0087] in, is the normal impulse, calculated according to the following formula:

[0088] ;

[0089] Determining Friction The direction is opposite to the relative moving speed:

[0090] ;

[0091] in," " represents vector dot product, ( ) represents the relative moving speed between the first collision body and the second collision body, is the tangent direction vector, expressed as:

[0092]

[0093] in, For vector of Towards the weight, For vector of Towards the weight;

[0094] Friction impulse Calculated according to the following formula:

[0095]

[0096] for The symbol function of .

[0097] As an optional technical solution, the acceleration caused by friction Calculated according to the following formula:

[0098]

[0099] in, Indicated in Time to The friction impulse of the collision body, Indicates The mass of the collision body, Including friction impulse between colliding bodies .

[0100] As an optional technical solution, the method further includes:

[0101] Calculate the friction between the collision body and the ground :

[0102]

[0103] When the speed of the collision body is less than the predetermined speed When , the friction force is calculated using the above formula (1) ; When the speed of the collision body is greater than or equal to the predetermined speed When , the friction force is calculated using the above formula (2) ;in, is the static friction coefficient, is the coefficient of kinetic friction, , is the mass of the collision body, is the acceleration due to gravity, the predetermined speed Used to determine the dividing line between static and dynamic friction;

[0104] Calculate the friction force direction vector:

[0105]

[0106] Calculate the friction vector between the collider and the ground :

[0107]

[0108] Calculated by The friction impulse caused :

[0109]

[0110] Using friction impulse The object's position and velocity are updated again, and this process is repeated at each time step.

[0111] As an optional technical solution, the method further includes:

[0112] Calculate the friction between the collision body and the obstacle , wherein the obstacle includes a wall, friction Calculated according to the following formula:

[0113]

[0114] in, is the friction coefficient between the collision body and the wall, Represents the normal component of the force acting on the wall when the collision body collides with the wall. represents the direction of friction, is the unit vector along the X axis, and The product of determines the effect of friction in the X direction;

[0115] Normal component Calculated according to the following formula:

[0116]

[0117] in, Represents the instantaneous impulse generated by the collision between the object and the wall; Indicates the penetration time between the collision body and the wall;

[0118] Calculated according to the following formula:

[0119]

[0120] in, Is a collision body exist The velocity vector at time Directional weight;

[0121] Calculated by The friction impulse caused :

[0122]

[0123] Using friction impulse The object's position and velocity are updated again, and this process is repeated at each time step.

[0124] The beneficial effects of the present invention are as follows: the present application provides a contact interface simulation optimization method, which is optimized by a back propagation algorithm, and can reversely deduce the friction coefficient and control force according to the simulation results, thereby dynamically adjusting the motion trajectory of the object. This method significantly improves the simulation accuracy of complex collision and friction phenomena, enables the simulation system to simulate physical behaviors in reality more realistically, and achieves more precise control through continuous optimization, while taking into account computational efficiency at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0125] Figure 1 It is a flowchart of a simulation optimization method of a contact interface in an exemplary embodiment.

[0126] Figure 2 This is a schematic diagram showing the difference between ball collisions with and without friction.

[0127] Figure 3 Schematic diagram of the difference between penetration direction and collision direction when iterative collision occurs. DETAILED DESCRIPTION

[0128] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. The components and method steps of the embodiments of the present invention generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0129] Example

[0130] like Figure 1 As shown, this embodiment discloses a contact interface simulation optimization method, which is applied to the motion state simulation of collision bodies, such as the motion state simulation of objects when collision occurs in animation, so as to make the animation more realistic, and this realistic effect does not sacrifice the calculation efficiency. Specifically, the method includes:

[0131] Initialize input parameters, including the friction coefficient between the collision body contact interface Specifically, if the collision bodies to be simulated are two footballs in anime, footballs are mostly made of polyurethane or leather, initialization When considering the material and surface roughness of the football,

[0132] Motion state solution: According to the initialization Solve the mutual friction between colliding bodies , and by The friction impulse caused and the tangential acceleration due to friction , using friction impulse and tangential acceleration Update the position and velocity of the collider;

[0133] Friction coefficient optimization: Optimizing the friction coefficient using loss function , and obtain the friction coefficient ;

[0134] Using the coefficient of friction The motion state solution and friction coefficient optimization are performed again to obtain the friction coefficient , using the friction coefficient The motion state solution and friction coefficient optimization are performed again to obtain the friction coefficient ...This cycle is repeated until the loss function converges to a minimum value;

[0135] Wherein, the loss function includes the output loss function :

[0136] ;

[0137] The friction coefficient for each iteration satisfies:

[0138]

[0139] in, is the loss function. When only the friction between the collision bodies is considered, , is the learning rate, which is used to control the step size of the update; Indicates the Euclidean distance between the actual stopping position of the first collision body and the expected position. Indicates the Euclidean distance between the actual stopping position of the second collision body and the expected position; Indicated in The state variables of the collision body at time Position at the moment and speed , , Indicates the end time of the entire control time interval.

[0140] As an optional implementation, the loss function also includes an input loss function and a total loss function, and the input loss function is:

[0141]

[0142] in, is the weight constant, Indicates that at continuous time External control input, , Indicated in The state variables of the collision body at time Position at the moment and speed ; The total loss function is:

[0143]

[0144] The constraints of the total loss function are: , , , ;

[0145] in, Indicates finding the minimum value; represents the time derivative of the system state, ; is the system's dynamic equation, describing the external control input Under the action, state evolution; Indicates the occurrence of The time of the collision, Indicates The state of the collision body after the first collision occurs, Indicates The state of the collision body before the second collision, Used to describe the change in the state of the collision body after the collision; is the collision detection function. satisfy , indicating that A collision occurs at any moment; among them, the collision detection function It is a function commonly used in this field to detect whether a collision between two balls occurs. For example, if the collision body is a sphere, it is generally used to detect whether the distance between the centers of the two balls is greater than the sum of the radii of the two balls; function Represents the state update function after the collision, which is used to describe the impact of the collision on the position and velocity of the two balls (i.e., the collision body), and stores the state information before and after the collision.

[0146] The total loss function and the constraint conditions are discretized to obtain a discretized total loss function:

[0147] }

[0148] And the discretization constraints: ;

[0149] in, is the discretized time step, ; Represents the state of the system in the Nth time step; Indicates that the system The state within a time step, Indicated in The external control input is time steps, Represents a state update function.

[0150] As an optional implementation, the friction coefficient optimization further includes:

[0151] A new loss function is added to optimize the friction coefficient between the collision body and the ground. The new loss function is:

[0152]

[0153] It is The velocity of the collision body in the last step of the simulation, is the weight constant; the optimization target is the loss function Converges to its minimum , the purpose is to detect whether the speed of the last step is 0, because the effect of ground friction is to affect when the object stops.

[0154] Another loss function is added to optimize the friction coefficient between the collision body and the wall. The new loss function is:

[0155]

[0156] in, Indicates that a total of collision events, Indicates the occurrence of The actual velocity change of the collision body after the collision, Indicates the occurrence of The expected velocity change of the collision body after the collision, the optimization target is the loss function Converges to its minimum .

[0157] As an optional implementation, using the friction coefficient after initialization The motion state solution includes the following process:

[0158] Calculating the penetration time of the collision body to be simulated using continuous collision detection CCD ;

[0159] Step forward one penetration time , to calculate the collision-related parameters of the collision body to be simulated, the collision-related parameters include the collision position , collision speed and the collision direction vector ;

[0160] Calculate the thrust impulse of the collision body to be simulated according to the collision related parameters ;

[0161] According to the thrust impulse And the friction coefficient after initialization Calculate the mutual friction between the collision bodies to be simulated , and determine the friction direction;

[0162] Calculation of friction The impulse caused to the collision body to be simulated ;

[0163] Friction impulse and the acceleration caused by friction It is used to update the position and velocity of the collision body to be simulated. This process is repeated in each time step. It should be further explained that if there is no collision, there will be no friction impulse generated by the collision. If the ground is considered, there will be ground friction impulse. Therefore, if friction is considered, the impact of friction on the updated position and velocity needs to be considered. When there is no friction, it is zero.

[0164] As an optional embodiment, the penetration time Calculated according to the following formula:

[0165]

[0166] Where d is the penetration depth, For the second collision body The penetration velocity at the time step is For the first collision body The penetration velocity at the time step is represents the penetration direction; the penetration depth d is calculated according to the following formula:

[0167]

[0168] in, Indicates that the second collision body is The penetration position vector at the time step, Indicates that the first collision body is The penetration position vector at the time step, Indicates the modulus of the vector; the first collision body and the second collision body are both spheres, Indicates the radius of the first collision body, Indicates the radius of the second collision body;

[0169] The penetration direction Calculated according to the following formula:

[0170] ;

[0171] For the first collision body, its penetration position vector The calculation is performed by the symplectic Euler integration method as follows:

[0172]

[0173]

[0174] in, For the first collision body The position vector at the time step, For the first collision body The penetration velocity at the time step is represents a time step; Indicates that the first collision body is The speed at the time step, Indicates that the first collision body is The acceleration at each time step;

[0175] For the second collider, its penetration position vector The calculation is performed by the symplectic Euler integration method as follows:

[0176]

[0177]

[0178] in, For the second collision body The position vector at the time step, For the second collision body The penetration velocity at each time step; Indicates that the second collision body is The speed at the time step, Indicates that the second collision body is The acceleration at each time step.

[0179] As an optional implementation, the thrust impulse Calculated according to the following formula:

[0180]

[0181] in, is the elastic coefficient, is the component of the relative velocity between the first collision body and the second collision body in the collision direction, is the mass of the first collision body, is the mass of the second collider, the collision direction vector Calculated according to the following formula:

[0182]

[0183] in, Indicates that the second collision body is The collision position vector at time steps, Indicates that the first collision body is The collision position vector at time steps;

[0184] The collision position vector Calculated according to the following formula:

[0185]

[0186]

[0187] in, For the second collision body The collision velocity at the time step;

[0188] The collision position vector Calculated according to the following formula:

[0189]

[0190]

[0191] in, For the first collision body The collision velocity at each time step.

[0192] As an optional implementation, the mutual friction between the collision bodies Calculated according to the following formula:

[0193]

[0194] in, is the normal pressure, calculated according to the following formula:

[0195]

[0196] in, is the normal impulse, calculated according to the following formula:

[0197] ;

[0198] Determining Friction The direction is opposite to the relative moving speed:

[0199] ;

[0200] in," " represents vector dot product, ( ) represents the relative moving speed between the first collision body and the second collision body. is the tangent direction vector, expressed as:

[0201]

[0202] in, For vector of Towards the weight, For vector of Towards the weight;

[0203] Friction impulse Calculated according to the following formula:

[0204]

[0205] for The symbol function of .

[0206] As an optional embodiment, the acceleration caused by friction Calculated according to the following formula:

[0207]

[0208] in, Indicated in Time to The friction impulse of the collision body, Indicates The mass of the collision body, Including friction impulse between colliding bodies .

[0209] As an optional implementation, the method further includes:

[0210] Calculate the friction between the collision body and the ground :

[0211]

[0212] When the speed of the collision body is less than the predetermined speed When , the friction force is calculated using the above formula (1) ; When the speed of the collision body is greater than or equal to the predetermined speed When , the friction force is calculated using the above formula (2) ;in, is the static friction coefficient, is the coefficient of kinetic friction, , is the mass of the collision body, is the acceleration due to gravity; the predetermined speed It is used to determine the boundary between static friction and dynamic friction. Take 0.1 , It is the critical speed used to distinguish static friction from dynamic friction. That is, when the speed of the collision body exceeds this value, static friction will turn into dynamic friction. This is related to factors such as the material of the object, the properties of the ground, and the physical environment. Therefore, the value can be slightly adjusted according to actual conditions.

[0213] Calculate the friction force direction vector:

[0214]

[0215] Calculate the friction vector between the collider and the ground :

[0216]

[0217] Calculated by The friction impulse caused :

[0218]

[0219] Using friction impulse The object's position and velocity are updated again, and this process is repeated at each time step.

[0220] As an optional technical solution, the method further includes:

[0221] Calculate the friction between the collision body and the obstacle , wherein the obstacle includes a wall, friction Calculated according to the following formula:

[0222]

[0223] in, is the friction coefficient between the collision body and the wall, Represents the normal component of the force acting on the wall when the collision body collides with the wall. represents the direction of friction, is the unit vector along the X axis, and The product of determines the effect of friction in the X direction;

[0224] Normal component Calculated according to the following formula:

[0225]

[0226] in, It indicates the total impulse received by the collision body during the collision between the collision body and the wall. With the above The calculation principle is the same, but it is necessary to find the corresponding amount according to the collision of different objects, which will not be described in detail here; Indicates the penetration time between the collision body and the wall. With the above The calculation principle is the same, but the corresponding amount needs to be calculated according to the collision of different objects, which will not be described in detail here.

[0227] Calculated according to the following formula:

[0228]

[0229] in, Is a collision body exist The velocity vector at time Directional weight;

[0230] Calculated by The friction impulse caused :

[0231]

[0232] Using friction impulse The object's position and velocity are updated again, and this process is repeated at each time step.

[0233] In order to better understand this embodiment, the embodiment is further described below, which is roughly divided into the following parts for description.

[0234] 1. Overall concept of the invention.

[0235] like Figure 2 As shown in the figure, the difference between the collision of small balls with and without friction is shown. The solid ball 1 and ball 2 are in the initial position, and the goal is for ball 1 to hit ball 2. On the left side, in the case of no friction, ball 1 approaches ball 2 along the trajectory of the solid arrow, and the two dotted arrows represent the trajectories of ball 1 and ball 2 after the collision. On the right side, considering the case of friction when ball 1 and ball 2 collide, ball 1 approaches ball 2 along the trajectory of the solid arrow, and the two dotted arrows represent a possible trajectory of ball 1 and ball 2 after the collision.

[0236] Under frictionless conditions, the movement of an object is only affected by elastic collisions, without considering the friction between the contact surfaces. However, in real life, an absolutely frictionless situation is impossible. Therefore, this embodiment takes the friction factor into account. First, the friction effect caused by the collision between the balls is considered, along with the rotation caused by friction, and then the friction between the balls and the ground during movement is considered. Such considerations lead to different physical behaviors from the frictionless situation.

[0237] like Figure 3 As shown, it is the penetration direction when collision occurs at any iteration and collision direction Therefore, in simulation design, the time of impact (TOI) is used to mark the exact time when two objects collide. Continuous collision detection (CCD) is used to predict TOI. If TOI is less than the time step , then a collision will occur within this time interval.

[0238] Collision time backtracking: During the simulation, the movement is tracked back to the moment of collision and the collision response is processed. The penetration time is marked in real time using CCD. The collision time at the moment of collision is obtained by subtracting the penetration time from the total time. This is used to calculate the friction impulse and is applied to the movement.

[0239] If the friction coefficient and acceleration (control input) are taken as optimizable parameters on this basis, by optimizing the control input and friction coefficient, it can be ensured that the situation after ball 1 collides with ball 2 is optimized under the consideration of friction, and the optimal path for the ball to reach the target position can be better displayed, so as to be closer to the motion state in the real physical environment. The optimization of the friction coefficient is achieved through the back propagation algorithm, and its core idea is to minimize the difference between the object state and the target state.

[0240] 2. Calculation of friction.

[0241] 2.1 Calculation of collision friction between small balls (collision bodies).

[0242] Direct impulse calculation: First, the relative velocity and contact direction between the two objects are calculated, and then, based on these values ​​and the elastic coefficient, the impulse is directly calculated.

[0243] Friction processing: The symplectic Euler integration format is used in this embodiment:

[0244]

[0245]

[0246] in, For the collision body The penetration velocity at the time step is Indicates that the collision body is The speed at the time step, Indicates that the collision body is The acceleration at each time step, represents a time step; Indicates that the collision body is The penetration position vector at the time step, For the collision body The position vector at time steps.

[0247] Penetration Depth:

[0248]

[0249] In the above formula, the radii of the two spheres are the same.

[0250] Penetration direction:

[0251]

[0252] Breakthrough time:

[0253]

[0254] Consider the collision position of the collision body during the collision and the collision velocity of the collision body during the collision :

[0255]

[0256]

[0257] in, For the collision body The collision velocity at the time step is Indicates that the collision body is The collision velocity at the time step is Indicates that the collision body is The collision position vector at time steps, Indicates that the collision body is The position vector at time steps.

[0258] Determine the collision direction based on the collision position:

[0259]

[0260] Calculate impulse thrust :

[0261]

[0262] is the component of the relative velocity in the direction of the collision, e is the elastic coefficient, which determines whether it is completely elastic, and 1 is completely elastic. is the mass of the first collision body, is the mass of the second collision body, , is the velocity component of the first collision body in the collision direction, is the velocity component of the second collision body in the collision direction.

[0263] Calculate the normal impulse:

[0264]

[0265] Normal Pressure:

[0266]

[0267] Calculate the friction between colliding bodies :

[0268]

[0269] Determine the tangent direction vector :

[0270]

[0271] Determining Friction The direction is opposite to the relative moving speed:

[0272] ;

[0273] in," " represents vector dot product, ( ) represents the relative moving speed between the first collision body and the second collision body.

[0274] Friction The impulse caused :

[0275]

[0276] in, Make sure the friction force is in the opposite direction to the tangential velocity.

[0277] At this time, we also need to consider that the friction will cause the ball to rotate accordingly. The initial angular velocity of the rotation is The initial angle is .

[0278] Calculate the moment of inertia :

[0279]

[0280] Calculating the moment arm and moment: is the vector from the collision point to the center of the sphere:

[0281]

[0282] If a collision occurs at time t, express The position coordinates of the collision point at time, express The coordinates of the center of mass position of the collision body at the moment. If the collision body is a sphere, the collision point refers to the tangent point where the two spheres touch each other during the collision.

[0283] The torque is:

[0284]

[0285] in, Thrust impulse and friction impulse sum.

[0286] Update angular velocity:

[0287]

[0288] Update angle:

[0289]

[0290] Applied to the rotation matrix:

[0291]

[0292] This matrix is ​​a two-dimensional rotation matrix used to rotate a vector on a plane counterclockwise. Angle, if the original vector is , counterclockwise The vector after the angle is ,but:

[0293]

[0294] Finally, a dynamic update is performed: the friction impulse and the tangential acceleration caused by friction are used to update the position and velocity of the object, and this process is repeated in each time step.

[0295] The speed update formula is as follows:

[0296]

[0297] in, Indicates The collision body The speed of time, is Imposed on the The impulse of the collision body, is Imposed on the The control input of the collision body, is the friction acceleration, Use the following formula to calculate:

[0298]

[0299] in, Indicated in Time to The friction impulse of the collision body, Indicates The mass of the collider.

[0300] Its position update formula is:

[0301]

[0302] in, express Time collision body location, express Time collision body speed, express Time collision body The additional displacement increment is Calculated according to the following formula:

[0303]

[0304] Additional displacement increment There are two considerations:

[0305] (1) Additional adjustment of collision response: When objects collide, if the distance between the two objects is less than the sum of their diameters (i.e., they penetrate each other), the positions of the objects need to be corrected to avoid this unreasonable overlap. This correction is done by to achieve.

[0306] (2) Displacement correction due to impulse: When colliding, a collision impulse will be generated between the two objects, which causes the speed of the objects to change suddenly. In order to ensure that the position change of the object conforms to the actual physical situation, the code (the method of this embodiment is compiled into Python code during specific implementation) makes corresponding incremental adjustments to the position. This adjustment amount is This adjustment is usually determined by the force, impulse, and time step during the collision.

[0307] 2.2 Calculation of friction between the ball and the ground.

[0308] The positive pressure of the ball on the ground is gravity. Assuming that the masses of the balls are equal, they are Calculate the friction :

[0309] If the speed is less than the preset speed , using the static friction coefficient :

[0310]

[0311] When the speed is greater than or equal to the preset speed , when starting the movement, use the ground dynamic friction coefficient :

[0312]

[0313] The direction of friction force is set to [0,0,0] during static friction.

[0314] When calculating dynamic friction, the direction of friction force is:

[0315]

[0316] in, Indicated in The velocity vector of the object at that moment.

[0317] Calculate the friction vector between the ball and the ground :

[0318]

[0319] Calculated by The friction impulse caused :

[0320]

[0321] Dynamic update: The friction impulse and the tangential acceleration caused by friction are used to update the position and velocity of the object. This process is repeated in each time step. The update formula for position and velocity is the same as in 2.1. Substitute the corresponding friction impulse and the acceleration caused by friction. I will not repeat it here.

[0322] 2.3 Calculation of friction between the ball and the wall.

[0323] Calculate the normal component of the force acting on the wall when the ball collides with the wall :

[0324]

[0325] Calculate the friction direction:

[0326]

[0327] in It's a small ball exist The velocity vector at time This means that if the ball moves horizontally to the right (i.e. the velocity component is positive), the friction force will act to the left ( ),vice versa.

[0328] Calculate the friction between the ball and the wall :

[0329]

[0330] Calculated by The friction impulse caused :

[0331]

[0332] Dynamic update: The friction impulse and the tangential acceleration caused by friction are used to update the position and velocity of the object. This process is repeated in each time step. The update formula for position and velocity is the same as in 2.1. Substitute the corresponding friction impulse and the acceleration caused by friction. I will not repeat it here.

[0333] 3. Optimize the friction coefficient of friction force (differentiable).

[0334] The core idea of ​​differentiability is to minimize the difference between the current state of the object and the desired target state. This is achieved by calculating the gradient of the loss function with respect to the friction coefficient and adjusting the corresponding parameters to minimize the loss.

[0335] 3.1 Optimize the friction coefficient between the balls (i.e. the collision bodies).

[0336] The loss items are set into two categories, including input loss and output loss. The input loss is the size of the penalty input control, and the output loss is the square of the difference between the target position and the actual position of the two balls. The total loss function is:

[0337]

[0338] The constraints of the total loss function are: , , , ;in, Indicates finding the minimum value.

[0339] Transformed into a discrete total loss function and approximate conditions, the discretized total loss function for:

[0340]

[0341] The discretization approximation condition is:

[0342] The terminal cost (i.e. output loss) is: , ball 1 collides with ball 2 and they each reach their target position.

[0343] Input loss: , Set it to 0.01 to prevent the input from being too large.

[0344] 3.2 When optimizing the friction coefficient between the ball and the ground, the inventor found that the above two loss functions alone were not enough to converge the ground friction coefficient. Based on the above, a loss function was added to detect whether the speed of the last step was 0. The newly added loss function was set as:

[0345]

[0346] It is The velocity of the collision body in the last step of the simulation, is the weight constant, Appropriate weights can be set in all loss functions as needed. In this embodiment, You can take: The optimization objective is the loss function Converges to its minimum .

[0347] 3.3 Optimizing the friction coefficient of the ball colliding with the wall. The inventors found that the two losses of target position and control alone were not enough to achieve convergence. Therefore, a new loss function was introduced, which was set to compare the difference between the actual speed change of the ball and the expected speed change due to friction (in the horizontal direction). The loss function is:

[0348]

[0349] in, Indicates that a total of collision events, Indicates the occurrence of The actual velocity change of the ball after the collision is: Indicates the occurrence of The expected velocity of the ball after the collision

[0350] The optimization objective is the loss function Converges to its minimum .

[0351] 3.4 Effect of Friction Coefficient: The friction coefficient determines the amount of resistance against the motion of an object. It directly affects the velocity and position of an object over time. By calculating the gradient of the loss function with respect to the friction coefficient, we evaluate how changing these coefficients will affect the final state of the object.

[0352] 3.5 Update friction coefficient:

[0353] The step function takes the current state and control as input and calculates the next time step state based on dynamics and collision. In this embodiment, the simulation time is T=1s. The time period is discretized into N=480 steps, that is, ∆t=1 / 480. Since the simulation is differentiable, the step function can be differentiated and the optimal control sequence can be solved directly using the gradient descent method. The friction coefficient is updated as follows:

[0354]

[0355] in, is the loss function, is the friction coefficient, Represents the loss function Friction coefficient Seeking guidance, Indicates The friction coefficient at each time step.

[0356] Based on the above description, the advantages of the embodiment compared with the prior art are further described below.

[0357] 1. Higher simulation accuracy: By introducing a differentiable friction model, this solution can more accurately simulate the collision and friction phenomena between objects, improving the realism of the simulation, especially in complex physical environments.

[0358] 2. The optimization process is differentiable: The friction coefficient and physical parameters are optimized using the back-propagation algorithm, so that the model can continuously learn and improve through gradient optimization, thereby improving simulation efficiency.

[0359] 3. Wide applicability: This solution can not only handle frictionless elastic collisions, but also consider the friction in the actual environment, and is suitable for simulations of more complex physical scenes and different materials.

[0360] 4. Higher computational efficiency: Compared with traditional LCP and convex optimization methods, this solution improves computational efficiency while ensuring simulation accuracy by combining continuous collision detection (CCD) and friction optimization.

[0361] 5. Support dynamic adjustment: This solution allows dynamic adjustment of parameters such as friction and collision force during the simulation process, and can adapt to rapidly changing environments and complex engineering requirements.

[0362] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described here can be implemented by software, or by combining software with necessary hardware. Therefore, the technical solution according to the embodiment of the present application can be embodied in the form of a software product, which can be stored in a readable medium or on a network, and includes several instructions to enable an electronic device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the embodiment of the present application.

[0363] The above description is only a specific implementation mode of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. All technical solutions that fall within the scope defined by the claims of the present invention fall within the protection scope of the present invention.

Claims

1. A contact interface simulation optimization method, applied to the motion state simulation of a collision body, characterized in that: The method comprises: Initialize input parameters, including the friction coefficient between the collision body contact interface ; Motion state solution: According to the initialization Solving the mutual friction between colliding bodies , and by The friction impulse caused and the tangential acceleration due to friction , using friction impulse and tangential acceleration Update the position and velocity of the collider; Friction coefficient optimization: Optimizing the friction coefficient using loss function , and obtain the friction coefficient ; Using the coefficient of friction The motion state solution and friction coefficient optimization are performed again to obtain the friction coefficient , using the friction coefficient The motion state solution and friction coefficient optimization are performed again to obtain the friction coefficient ...This cycle is repeated until the loss function converges to a minimum value; Wherein, the loss function includes the output loss function : ; The friction coefficient for each iteration satisfies: in, , is the learning rate, which is used to control the step size of the update; Indicates the Euclidean distance between the actual stopping position of the first collision body and the expected position. Indicates the Euclidean distance between the actual stopping position of the second collision body and the expected position; Indicated in The state variables of the collision body at time Position at the moment and speed , , Indicates the end time of the entire control time interval. Indicates the number of iterations.

2. The contact interface simulation optimization method according to claim 1, characterized in that: The loss function also includes an input loss function and a total loss function, and the input loss function is: in, is the weight constant, Indicates that at continuous time External control input, , Indicated in The state variables of the collision body at time Position at the moment and speed ; The total loss function is: The constraints of the total loss function are: , , , ; in, Indicates finding the minimum value; represents the time derivative of the system state, ; is the system's dynamic equation, describing the external control input Under the action, state evolution; Indicates the occurrence of The time of the collision, Indicates The state of the collision body after the first collision occurs, Indicates The state of the collision body before the collision, function Indicates the impact of the collision on the state of the collision body. Used to describe the change in the state of the collision body after the collision; is the collision detection function. satisfy , indicating that Collisions occur all the time; The total loss function and the constraint conditions are discretized to obtain a discretized total loss function: }; And the discretization constraints: ; in, is the discretized time step, ; Represents the state of the system in the Nth time step; Indicates that the system The state within a time step, Indicated in The external control input in time steps, Represents a state update function.

3. The contact interface simulation optimization method according to claim 2, characterized in that: The friction coefficient optimization also includes: A new loss function is added to optimize the friction coefficient between the collision body and the ground. The new loss function is: It is The velocity of the collision body in the last step of the simulation, is the weight constant, and the optimization objective is the loss function Converges to its minimum ; Another loss function is added to optimize the friction coefficient between the collision body and the wall. The new loss function is: in, Indicates that a total of collision events, Indicates the occurrence of The actual velocity change of the collision body after the collision, Indicates the occurrence of The expected velocity change of the collision body after the collision, the optimization target is the loss function Converges to its minimum .

4. The contact interface simulation optimization method according to claim 3, characterized in that: Using the initialized friction coefficient Solving the motion state The process includes: Calculating the penetration time of the collision body to be simulated using continuous collision detection CCD ; Step forward one penetration time , to calculate the collision-related parameters of the collision body to be simulated, the collision-related parameters include the collision position , collision speed and the collision direction vector ; Calculate the thrust impulse of the collision body to be simulated according to the collision related parameters ; According to the thrust impulse And the friction coefficient after initialization Calculate the mutual friction between the collision bodies to be simulated , and determine the friction direction; Calculation of friction The impulse caused to the collision body to be simulated ; Friction impulse and the acceleration caused by friction It is used to update the position and velocity of the collider to be simulated, and this process is repeated at each time step.

5. The contact interface simulation optimization method according to claim 4, characterized in that: The breakthrough time Calculated according to the following formula: Where d is the penetration depth, For the second collision body The penetration velocity at the time step is For the first collision body The penetration velocity at the time step is represents the penetration direction; the penetration depth d is calculated according to the following formula: in, Indicates that the second collision body is The penetration position vector at the time step, Indicates that the first collision body is The penetration position vector at the time step, Indicates the modulus of the vector; the first collision body and the second collision body are both spheres, Indicates the radius of the first collision body, Indicates the radius of the second collision body; The penetration direction Calculated according to the following formula: ; For the first collision body, its penetration position vector The calculation is performed by the symplectic Euler integration method as follows: in, For the first collision body The position vector at the time step, For the first collision body The penetration velocity at the time step is represents a time step; Indicates that the first collision body is The speed at the time step, Indicates that the first collision body is The acceleration at each time step; For the second collider, its penetration position vector The calculation is performed by the symplectic Euler integration method as follows: in, For the second collision body The position vector at the time step, For the second collision body The penetration velocity at each time step; Indicates that the second collision body is The speed at the time step, Indicates that the second collision body is The acceleration at each time step.

6. The contact interface simulation optimization method according to claim 5, characterized in that: The thrust impulse Calculated according to the following formula: in, is the elastic coefficient, is the component of the relative velocity between the first collision body and the second collision body in the collision direction, is the mass of the first collision body, is the mass of the second collider, the collision direction vector Calculated according to the following formula: in, Indicates that the second collision body is The collision position vector at time steps, Indicates that the first collision body is The collision position vector at time steps; The collision position vector Calculated according to the following formula: in, For the second collision body The collision velocity at the time step; The collision position vector Calculated according to the following formula: in, For the first collision body The collision velocity at each time step.

7. The contact interface simulation optimization method according to claim 6, characterized in that: The mutual friction between the collision bodies Calculated according to the following formula: in, is the normal pressure, calculated according to the following formula: in, is the normal impulse, calculated according to the following formula: ; Determining Friction The direction is opposite to the relative moving speed: ; in," " represents vector dot product, ( ) represents the relative moving speed between the first collision body and the second collision body, is the tangent direction vector, expressed as: in, For vector of Towards the weight, For vector of Towards the weight; Friction impulse Calculated according to the following formula: for The symbol function of .

8. The contact interface simulation optimization method according to claim 7, characterized in that: The acceleration caused by friction Calculated according to the following formula: in, Indicated in Time to The friction impulse of the collision body, Indicates The mass of the collision body, Including friction impulse between colliding bodies .

9. The contact interface simulation optimization method according to claim 8, characterized in that: The method further comprises: Calculate the friction between the collision body and the ground : When the speed of the collision body is less than the predetermined speed When , the friction force is calculated using the above formula (1) ; When the speed of the collision body is greater than or equal to the predetermined speed When , the friction force is calculated using the above formula (2) ;in, is the static friction coefficient, is the coefficient of kinetic friction, , is the mass of the collision body, is the acceleration due to gravity, the predetermined speed Used to determine the dividing line between static and dynamic friction; Calculate the friction force direction vector: Calculate the friction vector between the collider and the ground : Calculated by The friction impulse caused : Using friction impulse The object's position and velocity are updated again, and this process is repeated at each time step.

10. The contact interface simulation optimization method according to claim 9, characterized in that: The method further comprises: Calculate the friction between the collision body and the obstacle , wherein the obstacle includes a wall, friction Calculated according to the following formula: in, is the friction coefficient between the collision body and the wall, Represents the normal component of the force acting on the wall when the collision body collides with the wall. represents the direction of friction, is the unit vector along the X axis, and The product of determines the effect of friction in the X direction; Normal Component Calculated according to the following formula: in, Represents the instantaneous impulse generated by the collision between the object and the wall; Indicates the penetration time between the collision body and the wall; Calculated according to the following formula: in, Is a collision body exist The velocity vector at time Directional weight; Calculated by The friction impulse caused : Using friction impulse The object's position and velocity are updated again, and this process is repeated at each time step.

Citation Information

Patent Citations

  • Rapid and accurate non-smooth multi-body collision simulating and animating method

    CN104217453A

  • Method and device for establishing robot flexible collision detection model

    CN116968020A