Mechanical foundation plane connecting rod online simulation system and method
Through the online simulation system of mechanical basic plane connecting rods based on WebAssembly, the problem of incompatibility of traditional software equipment is solved, and a cross-platform, high-performance simulation system is realized, which reduces costs and learning thresholds, and improves the convenience of data sharing and maintenance.
Patent Information
- Application Number
- CN202510585689.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-08
- Publication Date
- 2025-06-06
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional mechanical plane link simulation software has the problem of equipment incompatibility, cannot work in different systems, and has high installation and maintenance costs, difficult data sharing, and high learning thresholds.
A mechanical basic plane linkage online simulation system based on WebAssembly is developed, which can realize cross-platform work through a browser. The front end of the web page receives the parameters input by the user, transmits them to the WebAssembly module for kinematics and dynamics solving, and returns the results to the front end for visual display.
It realizes cross-platform compatibility, high-performance computing, installation-free and instant access, dynamic interaction and visualization, code reuse and maintenance convenience, network transmission efficiency optimization, and supports offline simulation.
Smart Images

Figure CN120105628A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of mechanical basic plane connecting rod simulation, and in particular to a mechanical basic plane connecting rod online simulation system and method based on WebAssembly, which can realize the online simulation solution of the mechanical basic plane connecting rod. Background Art
[0002] In the process of mechanical design and teaching, the kinematics and dynamics simulation of mechanical basic planar connecting rods is an important task. The traditional simulation method mainly relies on locally installed professional software for solving, but this local solution method has many problems: 1. High installation and maintenance costs: Professional simulation software is usually large in size and has a complex installation process, requiring users to have certain computer knowledge and skills. At the same time, software updates and maintenance also require users to invest extra time and energy.
[0003] 2. Device compatibility issues: Different operating systems and hardware configurations may cause the software to fail to install or run properly, causing inconvenience to users.
[0004] 3. Difficulty in data sharing: Locally solved data are usually stored in local devices, making it difficult to achieve real-time sharing and collaboration among multiple users.
[0005] 4. High learning threshold: The operating interface and functions of professional software are relatively complex. For beginners, it takes a lot of time and energy to learn and master them.
[0006] In order to solve the above problems, it is of great practical significance to develop an online simulation system for mechanical basic plane connecting rods. The online simulation system allows users to directly access and use simulation functions through a browser without installing any software, which reduces the threshold and cost of use and facilitates data sharing. Summary of the invention
[0007] In view of the problem of device incompatibility in the current traditional mechanical plane connecting rod simulation software, often, the traditional mechanical plane connecting rod simulation software cannot work in different systems. The present invention provides a mechanical basic plane connecting rod online simulation system and method, which can realize cross-platform operation through a browser.
[0008] In order to achieve the above object, the embodiment of the present invention adopts the following technical solution: A mechanical basic plane connecting rod online simulation method, the method comprising: Receive the planar connecting rod parameters input by the user through the web front end; Transmitting the planar link parameters to the WebAssembly module; In the WebAssembly environment, based on the planar link parameters, the Newton-Raphson iteration method is used to solve the kinematics and dynamics; The solution results are returned to the web front end for visual display.
[0009] According to one aspect of the present invention, the transmission of the planar link parameters to WebAssembly is achieved by: Collect input parameters through HTML form elements on the web front end; Passing arguments to WebAssembly modules through the JavaScript interface.
[0010] According to one aspect of the present invention, the computational solution method is generated by compiling C++ code and using the Newton-Raphson iteration method to perform kinematic and dynamic solutions.
[0011] According to one aspect of the present invention, the calculation method comprises: Use the Emscripten toolchain to compile the solution algorithm written in C++ into a .wasm binary file and the corresponding JavaScript glue code; Load and instantiate the .wasm file via JavaScript's WebAssembly API.
[0012] According to one aspect of the present invention, the kinematic and dynamic solutions generated by compiling C++ code and using the Wewton-Raphson iteration method include: Establish the constraint equation of the planar link; calculate the Jacobian matrix of the constraint equation; Update the iteration variable according to the Newton-Raphson iteration formula; When the convergence condition is met, the solution result is output.
[0013] According to one aspect of the present invention, returning the solution result to the webpage front end for visual display includes: Use HTML5 Canvas element to draw the two-dimensional graphics of the plane connecting rod; The motion process is visualized by controlling the animation effect through JavaScript.
[0014] A mechanical basic plane connecting rod online simulation system, the system comprising: Web front-end module, used to receive user input and visualize display; The transmission module is used to realize data transmission between the front-end and the WebAssembly solution module; The solver module performs Newton-Raphson iterative calculations in the WebAssembly environment; Visualization module, based on Canvas rendering simulation results.
[0015] According to one aspect of the present invention, the webpage front-end module comprises: A parameter input unit receives the plane connecting rod parameters input by the user through an HTML form element; The result display unit realizes the visualization rendering of simulation results through HTML5 Canvas; The transmission module comprises: The parameter transfer unit is used to convert the parameters input by the front end into structured data and pass it to the WebAssembly solver module through the JavaScript interface; The result return unit is used to return the calculation results of WebAssembly to the front-end visualization unit.
[0016] According to one aspect of the present invention, the solution module comprises: Algorithm execution unit, used to perform Newton-Raphson iterative calculations in the WebAssembly environment, including: Establish the constraint equations of the planar linkage mechanism; Calculate the Jacobian matrix and solve the kinematic / dynamic parameters by iteration; The memory management unit is used to handle the linear memory allocation and release of WebAssembly, ensuring efficient storage and exchange of data during the calculation process.
[0017] Advantages of the present invention: 1. Cross-platform compatibility Advantages: No need to adapt to different operating systems or devices, it can run on all platforms through the browser.
[0018] principle: WebAssembly is a binary instruction format that can be efficiently executed in modern browsers. By writing core algorithms (such as the Newton-Raphson iteration method) in C++ and compiling them into .wasm modules, the system can run directly in the browser sandbox environment, getting rid of dependence on the local operating system or hardware.
[0019] Technical relevance: The compilation process based on the Emscripten tool chain and the standardized loading mechanism of the WebAssembly API ensures compatibility among browsers on different platforms (Windows / macOS / Linux / mobile).
[0020] 2. High Performance Computing Advantages: Close to native computing speed, meeting the real-time requirements of complex kinematics / dynamics solutions.
[0021] principle: WebAssembly's binary code execution efficiency far exceeds that of traditional JavaScript, and is particularly suitable for numerically intensive tasks such as the Newton-Raphson iteration method. After optimized compilation, the solution algorithm written in C++ can achieve performance comparable to that of local applications in the WebAssembly environment.
[0022] Technical relevance: The .wasm file generated by Emscripten directly calls the optimized execution engine at the bottom layer of the browser, avoiding the performance loss of JavaScript interpretation and execution.
[0023] 3. No installation and instant access Advantages: Users do not need to download and install software, and can access full functions through the URL.
[0024] principle: The system is completely based on the Web technology stack (HTML5 / JavaScript / WebAssembly), and all calculations and rendering are done in the browser. The on-demand loading mechanism of WebAssembly modules further shortens the startup time.
[0025] Technical relevance: The integration of HTML form parameter input and Canvas visualization, combined with the asynchronous loading of WebAssembly (through JavaScript glue code), enables an “out-of-the-box” experience.
[0026] 4. Dynamic interaction and visualization Advantages: Supports real-time parameter adjustment and animation interaction to improve the intuitiveness of simulation.
[0027] principle: The 2D graphics rendering capability of HTML5 Canvas combined with the event-driven mechanism of JavaScript can dynamically render the numerical results (such as connecting rod position and speed) returned by WebAssembly into smooth animations. After the user modifies the parameters through the form, the system quickly triggers re-solving and rendering through the transmission module.
[0028] Technical relevance: Data transfer between the frontend and WebAssembly modules (such as ArrayBuffer shared memory) ensures low-latency interaction.
[0029] 5. Code reuse and maintenance convenience Advantages: Reuse the existing C++ algorithm library, reduce development costs, and facilitate function expansion.
[0030] principle: The core algorithms of traditional mechanical simulation software (such as kinematics solutions) are usually implemented in C++. By compiling them into WebAssembly modules through Emscripten, existing codes can be reused directly without rewriting them into JavaScript. Subsequent function upgrades only require updating the .wasm file, without the need for manual updates by users.
[0031] Technical relevance: The semantic alignment of C++ and WebAssembly (such as pointer operations being simulated through Memory objects) ensures the consistency of algorithm logic.
[0032] 6. Optimize network transmission efficiency Advantages: Reduce server load and support offline simulation.
[0033] principle: WebAssembly modules (.wasm files) are loaded once and cached in the browser. Subsequent calculations are performed entirely on the client, requiring only a small amount of input and output data to be transmitted. Compared with traditional Web applications that rely on server-side calculations, bandwidth requirements are significantly reduced.
[0034] Technical relevance: WebAssembly's offline running capability combined with Service Worker technology can further achieve offline availability. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0036] Figure 1 This is a system architecture design interface diagram of a mechanical basic plane connecting rod online simulation system and method described in the present invention; Figure 2 This is a plane connecting rod simulation interface diagram of a mechanical basic plane connecting rod online simulation system and method described in the present invention. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0038] Embodiment 1
[0039] like Figure 1 to Figure 2 As shown, a mechanical basic plane connecting rod online simulation method comprises the following steps: Step S1: receiving the planar connecting rod parameters input by the user through the web front end; The step S1 receives the planar connecting rod parameters input by the user through the web front end, and specifically includes: A web front-end display page is generated through web design and development technology. In the front-end display page, a plane connecting rod parameter input port is formed through an HTML page file and a CSS style sheet file, and the user inputs the plane connecting rod parameters.
[0040] In this embodiment, the planar connecting rod parameters include: basic geometric parameters, kinematic pair parameters, transmission characteristic parameters, mechanism evolution related parameters and design optimization parameters, etc. Planar connecting rod parameters cover the following categories: Basic geometric parameters: including the length of each connecting rod (such as crank length, connecting rod length), the coordinate position of the fixed hinge point, etc.; Kinematic pair parameters: including the type of rotating pair or translation pair, the connection relationship between kinematic pairs, etc.; Transmission characteristic parameters: including dynamic parameters such as input shaft speed and driving torque; Mechanism evolution parameters: including the topological structure type of the linkage mechanism (such as four-bar mechanism, six-bar mechanism), whether it meets the Grashof condition, etc.; Design optimization parameters: including target motion trajectory, optimization constraints, etc.
[0041] For example, the user can input relevant planar connecting rod parameters such as connecting rod length, crank length, connecting rod swing angle, joint angle, etc. in the parameter input port on the front-end display page.
[0042] In the specific implementation, the user can input relevant parameters in the parameter input port of the front-end display page, such as connecting rod length, crank length, connecting rod swing angle, joint angle, etc.; In the "Basic Geometric Parameters" area, set up a numeric input box for users to enter precise dimensional parameters such as connecting rod length (such as L1=150mm, L2=300mm), crank radius (such as R=50mm), etc. In the "Joint Configuration" area, a drop-down menu is provided for users to select the joint type (such as rotation joint, translation joint), and support to specify the joint position by clicking on the interactive schematic diagram; In the "Motion Parameters" area, use slider controls for users to enter parameter values such as initial angle (such as θ0=30°) and angular velocity (such as ω=2rad / s); In the "Mechanism Type" area, radio buttons are used for users to select common mechanism types such as four-bar mechanism, crank slider mechanism, etc., and the system automatically displays the corresponding parameter input items.
[0043] Step S2: transmitting the planar connecting rod parameters to WebAssembly; The step S2 of transmitting the planar link parameters to WebAssembly specifically includes the following sub-steps: Step S21: Collect input parameters through HTML form elements on the web front end; In step S1, after the user fills in the plane connecting rod parameters through the input interface of the web front end, the system needs to pass these parameters to the WebAssembly module for calculation. This section details how data is collected from the HTML form and passed to WebAssembly through JavaScript.
[0044] The web front end uses a standard HTML form ( <form>) elements to collect user input, such as input controls: <input type="number"> For numerical input, <input type="range"> For slider adjustment, <select>Used to select the type of kinematic pair.
[0045] After the user enters the parameters in the web form, the front end will organize these data into a structured object for subsequent processing.
[0046] These data will be encapsulated into a JSON object on the front end, and the structured data is convenient for subsequent transmission and parsing.
[0047] Step S22: Pass the parameters to WebAssembly through the JavaScript interface. Compile the WebAssembly file through C++, the types include .wasm and .js, etc., and deploy the compiled WebAssembly file to the web server. Use the JavaScript interface to call the interface function of the WebAssembly module to pass the structured data to the WebAssembly environment. In the specific implementation, JavaScript serializes the parameters into a binary format and writes them into the linear memory space of WebAssembly through a memory sharing mechanism to ensure the efficiency of data transmission.
[0048] Step S3: In the WebAssembly environment, based on the plane connecting rod parameters, the solution result is obtained by the calculation solution method; after the WebAssembly module is loaded, the numerical calculation is performed based on the input plane connecting rod parameters, which specifically includes the following process: Step S31: Constraint equations are established, and the nonlinear constraint equation group of the system is constructed according to the topological structure and kinematic pair type of the plane connecting rod mechanism. For example, for a four-bar mechanism, its closed-loop vector equation needs to be established.
[0049] Step S32: The equation group is solved by the Newton-Raphson iteration method. The implementation of this method includes the following key steps: Step S321: Calculate the Jacobian matrix of the constraint equation to reflect the coupling relationship between each variable.
[0050] Step S322: By iteratively updating the variable values, the solution of the equation group is gradually approached until the convergence condition is met (such as the error is less than the set threshold).
[0051] Step S33: After the solution is completed, the kinematic data such as the position, velocity, acceleration, etc. of the connecting rod mechanism, as well as the dynamic data such as the joint reaction force, are output.
[0052] Step S4: Return the solution result to the web page front end for visual display.
[0053] After the WebAssembly module returns the calculation result to the front end, the system realizes visualization in the following ways: Graphic drawing: Use HTML5 Canvas technology to dynamically draw the two-dimensional motion state of the planar linkage mechanism according to the returned numerical results; for example, use line segments and dots to represent the connecting rod and the kinematic pair respectively, and update their positions in real time.
[0054] Animation control: Control the animation playback through JavaScript, support interactive operations such as pause, continue, and speed adjustment; users can observe the continuous motion process of the linkage mechanism, or view the status at a specific moment in a single step.
[0055] Data display: Synchronously display key numerical results on the page, such as the trajectory curve of a specific point, the curve of joint angle change over time, etc.
[0056] Advantages of the implementation of this embodiment: Cross-platform compatibility: Based on WebAssembly technology, users do not need to install additional software and can achieve high-performance simulation through the browser, which is compatible with Windows, macOS, Linux and mobile operating systems.
[0057] Computational efficiency: The core algorithm written in C++ is compiled into a WebAssembly module, and the execution efficiency is close to that of native applications, meeting the real-time solution requirements of complex mechanisms.
[0058] Interactive friendliness: Through the intuitive parameter input interface and dynamic visualization effects, the user operation threshold is lowered and the convenience of simulation analysis is improved.
[0059] Scalability: The system architecture supports the subsequent integration of more mechanism types (such as spatial linkage mechanisms) or advanced analysis functions (such as optimization design).
[0060] Embodiment 2
[0061] As shown in FIG. 1 and FIG. 2, a mechanical basic plane connecting rod online simulation method includes the following steps: Step S1: receiving the plane connecting rod parameters input by the user through the web front end; the step S1 receiving the plane connecting rod parameters input by the user through the web front end specifically includes: generating a web front end display page through web design and development technology, in the front end display page, forming a plane connecting rod parameter input port through HTML page files and CSS style sheet files, and the user inputs the plane connecting rod parameters.
[0062] In this embodiment, the plane connecting rod parameters include: basic geometric parameters, kinematic pair parameters, transmission characteristic parameters, mechanism evolution related parameters and design optimization parameters. Planar connecting rod parameters include the following categories: basic geometric parameters: including the length of each connecting rod (such as crank length, connecting rod length), the coordinate position of the fixed hinge point, etc.; kinematic pair parameters: including the type of revolute pair or translation pair, the connection relationship between kinematic pairs, etc.; transmission characteristic parameters: including dynamic parameters such as the input shaft speed and driving torque; mechanism evolution parameters: including the topological structure type of the connecting rod mechanism (such as four-bar mechanism, six-bar mechanism), whether it meets the Grashof condition, etc.; design optimization parameters: including target motion trajectory, optimization constraint conditions, etc.
[0063] For example, the user can input relevant planar connecting rod parameters such as connecting rod length, crank length, connecting rod swing angle, joint angle, etc. in the parameter input port on the front-end display page.
[0064] In a specific implementation, the user can input relevant parameters, such as connecting rod length, crank length, connecting rod swing angle, joint angle, etc., in the parameter input port of the front display page; in the "basic geometric parameters" area, a digital input box is set for the user to input precise size parameters such as connecting rod length (such as L1=150mm, L2=300mm), crank radius (such as R=50mm), etc.; in the "kinematic pair configuration" area, a drop-down menu is provided for the user to select the kinematic pair type (such as rotation pair, translation pair), and support to specify the kinematic pair position by clicking on the interactive schematic diagram; in the "kinematic parameters" area, a slider control is used for the user to input parameter values such as initial angle (such as θ0=30°), angular velocity (such as ω=2rad / s), etc.; in the "mechanism type" area, radio buttons are used for the user to select common mechanism types such as four-bar mechanism and crank slider mechanism, and the system automatically displays the corresponding parameter input items.
[0065] Step S2: Transmit the planar connecting rod parameters to WebAssembly; Based on the first embodiment, the transmission method of the planar connecting rod parameters is further defined, specifically including: Parameter collection: Receive the parameter values input by the user through the input box, drop-down menu and other elements in the HTML form. For example, the connecting rod length is obtained through the digital input box, and the kinematic pair type is selected through the drop-down menu.
[0066] Data encapsulation: The front-end JavaScript code encapsulates the form data into an object in JSON format to ensure the structured storage of parameters.
[0067] Memory transfer: Use the interface function provided by the Emscripten tool chain to convert the JSON object into binary data and write it into the linear memory of the WebAssembly module for subsequent calculations.
[0068] The step S2 of transmitting the planar connecting rod parameters to WebAssembly specifically includes the following sub-steps: Step S21: Collect input parameters through HTML form elements on the front end of the web page; In step S1, after the user fills in the planar connecting rod parameters through the input interface of the front end of the web page, the system needs to pass these parameters to the WebAssembly module for calculation. This section details how data is collected from an HTML form and passed to WebAssembly via JavaScript.
[0069] The web front end uses standard HTML form () elements to collect user input, such as: input control:.< / select> <input type="number"> For numerical input, <input type="range"> For slider adjustment, <select>Used to select the type of kinematic pair.
[0070] After the user enters the parameters in the web form, the front end will organize these data into a structured object for subsequent processing.
[0071] These data will be encapsulated into a JSON object on the front end, and the structured data is convenient for subsequent transmission and parsing.
[0072] Step S22: Pass the parameters to WebAssembly through the JavaScript interface. Compile the WebAssembly file through C++, the types include .wasm and .js, etc., and deploy the compiled WebAssembly file to the web server. Use the JavaScript interface to call the interface function of the WebAssembly module to pass the structured data to the WebAssembly environment. In the specific implementation, JavaScript serializes the parameters into a binary format and writes them into the linear memory space of WebAssembly through a memory sharing mechanism to ensure the efficiency of data transmission.
[0073] Step S3: In the WebAssembly environment, based on the plane connecting rod parameters, the solution result is obtained by the calculation solution method; after the WebAssembly module is loaded, the numerical calculation is performed based on the input plane connecting rod parameters, which specifically includes the following processes: Step S31: Constraint equations are established, and the nonlinear constraint equation group of the system is constructed according to the topological structure and kinematic pair type of the plane connecting rod mechanism. For example, for a four-bar mechanism, its closed-loop vector equation needs to be established.
[0074] Step S32: The equation group is solved by the Newton-Raphson iteration method. The implementation of this method includes the following key steps: Step S321: Calculate the Jacobian matrix of the constraint equation to reflect the coupling relationship between each variable.
[0075] Step S322: By iteratively updating the variable values, the solution of the equation group is gradually approached until the convergence condition is met (such as the error is less than the set threshold).
[0076] Step S33: After the solution is completed, the kinematic data such as the position, velocity, acceleration, etc. of the connecting rod mechanism, as well as the dynamic data such as the joint reaction force, are output.
[0077] Step S4: Return the solution result to the web page front end for visual display.
[0078] After the WebAssembly module returns the calculation result to the front end, the system realizes visualization in the following ways: Graphic drawing: Use HTML5 Canvas technology to dynamically draw the two-dimensional motion state of the planar linkage mechanism according to the returned numerical results; for example, use line segments and dots to represent the connecting rod and the kinematic pair respectively, and update their positions in real time.
[0079] Animation control: Control the animation playback through JavaScript, support interactive operations such as pause, continue, and speed adjustment; users can observe the continuous motion process of the linkage mechanism, or view the status at a specific moment in a single step.
[0080] Data display: Synchronously display key numerical results on the page, such as the trajectory curve of a specific point, the curve of joint angle change over time, etc.
[0081] Advantages of the implementation of this embodiment: through the standardized data transmission protocol, efficient communication between the front end and the WebAssembly module is ensured, and the interaction delay is reduced.
[0082] Embodiment 3
[0083] As shown in Figures 1 and 2, a mechanical basic plane connecting rod online simulation method includes the following steps: Step S1: receiving the plane connecting rod parameters input by the user through the web front end; the step S1 receives the plane connecting rod parameters input by the user through the web front end, specifically including: generating a web front end display page through web design and development technology, in the front end display page, forming a plane connecting rod parameter input port through HTML page files and CSS style sheet files, and the user inputs the plane connecting rod parameters.
[0084] In this embodiment, the plane connecting rod parameters include: basic geometric parameters, kinematic pair parameters, transmission characteristic parameters, mechanism evolution related parameters and design optimization parameters. Planar connecting rod parameters include the following categories: basic geometric parameters: including the length of each connecting rod (such as crank length, connecting rod length), the coordinate position of the fixed hinge point, etc.; kinematic pair parameters: including the type of revolute pair or translation pair, the connection relationship between kinematic pairs, etc.; transmission characteristic parameters: including dynamic parameters such as the input shaft speed and driving torque; mechanism evolution parameters: including the topological structure type of the connecting rod mechanism (such as four-bar mechanism, six-bar mechanism), whether it meets the Grashof condition, etc.; design optimization parameters: including target motion trajectory, optimization constraint conditions, etc.
[0085] For example, the user can input relevant planar connecting rod parameters such as connecting rod length, crank length, connecting rod swing angle, joint angle, etc. in the parameter input port on the front-end display page.
[0086] In a specific implementation, the user can input relevant parameters, such as connecting rod length, crank length, connecting rod swing angle, joint angle, etc., in the parameter input port of the front-end display page; in the "basic geometric parameters" area, a digital input box is set for the user to input precise size parameters such as connecting rod length (such as L1=150mm, L2=300mm), crank radius (such as R=50mm), etc.; in the "kinematic pair configuration" area, a drop-down menu is provided for the user to select the kinematic pair type (such as rotation pair, translation pair), and support to specify the kinematic pair position by clicking on the interactive schematic diagram; in the "kinematic parameters" area, a slider control is used for the user to input parameter values such as initial angle (such as θ0=30°), angular velocity (such as ω=2rad / s), etc.; in the "mechanism type" area, radio buttons are used for the user to select common mechanism types such as four-bar mechanism and crank slider mechanism, and the system automatically displays the corresponding parameter input items.
[0087] Step S2: transmitting the plane connecting rod parameters to WebAssembly; the step S2 of transmitting the plane connecting rod parameters to WebAssembly specifically includes the following sub-steps: Step S21: collecting input parameters through HTML form elements on the web page front end; in step S1, after the user fills in the plane connecting rod parameters through the input interface of the web page front end, the system needs to pass these parameters to the WebAssembly module for calculation.This section details how data is collected from an HTML form and passed to WebAssembly via JavaScript.
[0088] The web front end uses standard HTML form () elements to collect user input, such as: input control:.< / select> <input type="number"> For numerical input, <input type="range"> For slider adjustment, <select>Used to select the type of kinematic pair.
[0089] After the user enters the parameters in the web form, the front end will organize these data into a structured object for subsequent processing.
[0090] These data will be encapsulated into a JSON object on the front end, and the structured data is convenient for subsequent transmission and parsing.
[0091] Step S22: Pass the parameters to WebAssembly through the JavaScript interface. Compile the WebAssembly file through C++, the types include .wasm and .js, etc., and deploy the compiled WebAssembly file to the web server. Use the JavaScript interface to call the interface function of the WebAssembly module to pass the structured data to the WebAssembly environment. In the specific implementation, JavaScript serializes the parameters into a binary format and writes them into the linear memory space of WebAssembly through a memory sharing mechanism to ensure the efficiency of data transmission.
[0092] Step S3: In the WebAssembly environment, based on the planar connecting rod parameters, a solution result is obtained by a calculation solution method; on the basis of the first embodiment, the specific implementation of the calculation solution method is further limited, including: Algorithm implementation: The core solution algorithm is written in C++, and the Eigen library is used to optimize matrix operations to improve the calculation efficiency of the Newton-Raphson iteration.
[0093] Compilation process: The C++ code is compiled into a .wasm binary file and the corresponding JavaScript glue code through the Emscripten tool chain to ensure the smooth loading and execution of the algorithm in the browser environment.
[0094] On the basis of the first embodiment, the loading and instantiation process of the WebAssembly module is explained, and the execution flow of the Newton-Raphson iteration method is described in detail: asynchronous loading, asynchronously loading the .wasm file through the JavaScript WebAssembly API to avoid page blocking; memory initialization, pre-allocating memory space in the instantiation stage to store input parameters and intermediate calculation results.
[0095] Initial guess, set the initial value of the variable according to the mechanism type (such as initializing the joint angle to 0); iterate and converge, update the variable value by inverting the Jacobian matrix until the position error meets the accuracy requirements.
[0096] After the WebAssembly module is loaded, numerical calculations are performed based on the incoming planar link parameters, specifically including the following processes: Step S31: Constraint equation establishment, construct a nonlinear constraint equation group of the system based on the topological structure and kinematic pair type of the planar link mechanism. For example, for a four-bar mechanism, its closed-loop vector equation needs to be established.
[0097] Step S32: Use the Newton-Raphson iteration method to solve the equation group. The implementation of this method includes the following key steps: Step S321: Calculate the Jacobian matrix of the constraint equation to reflect the coupling relationship between the variables.
[0098] Step S322: By iteratively updating the variable values, gradually approach the solution of the equation group until the convergence condition is met (such as the error is less than the set threshold).
[0099] Step S33: After the solution is completed, output the kinematic data such as the position, velocity, acceleration, and dynamic data such as the joint reaction force of the connecting rod mechanism.
[0100] Step S4: Return the solution result to the web front end for visual display.
[0101] After the WebAssembly module returns the calculation result to the front end, the system realizes visualization in the following ways: Graphic drawing: Using HTML5 Canvas technology, dynamically draw the two-dimensional motion state of the planar connecting rod mechanism according to the returned numerical results; for example, use line segments and dots to represent the connecting rod and the kinematic pair respectively, and update their positions in real time.
[0102] Animation control: Control the animation playback through JavaScript, support interactive operations such as pause, continue, and speed adjustment; users can observe the continuous motion process of the connecting rod mechanism, or view the state at a specific moment in a single step.
[0103] Data display: Synchronously display key numerical results in the page, such as the trajectory curve of a specific point, the curve of joint angle change over time, etc.
[104] Advantages of the implementation of this embodiment: reuse the existing C++ numerical calculation library, taking into account both development efficiency and execution performance; optimize resource usage and improve the stability of large-scale mechanism simulation; ensure the rapid convergence of nonlinear equations, and be suitable for complex mechanism topology.
[105] Embodiment 4
[0106] As shown in Figures 1 and 2, a mechanical basic plane connecting rod online simulation method includes the following steps: Step S1: receiving the plane connecting rod parameters input by the user through the web front end; the step S1 receives the plane connecting rod parameters input by the user through the web front end, specifically including: generating a web front end display page through web design and development technology, and in the front end display page, forming a plane connecting rod parameter input port through HTML page files and CSS style sheet files, and the user inputs the plane connecting rod parameters.
[107] In this embodiment, the plane connecting rod parameters include: basic geometric parameters, kinematic pair parameters, transmission characteristic parameters, mechanism evolution related parameters and design optimization parameters. Planar connecting rod parameters include the following categories: basic geometric parameters: including the length of each connecting rod (such as crank length, connecting rod length), the coordinate position of the fixed hinge point, etc.; kinematic pair parameters: including the type of revolute pair or translation pair, the connection relationship between kinematic pairs, etc.; transmission characteristic parameters: including dynamic parameters such as the input shaft speed and driving torque; mechanism evolution parameters: including the topological structure type of the connecting rod mechanism (such as four-bar mechanism, six-bar mechanism), whether it meets the Grashof condition, etc.; design optimization parameters: including target motion trajectory, optimization constraint conditions, etc.
[0108] For example, the user can input relevant planar connecting rod parameters such as connecting rod length, crank length, connecting rod swing angle, joint angle, etc. in the parameter input port on the front-end display page.
[0109] In a specific implementation, the user can input relevant parameters, such as connecting rod length, crank length, connecting rod swing angle, joint angle, etc., in the parameter input port of the front-end display page; in the "basic geometric parameters" area, a digital input box is set for the user to input precise size parameters such as connecting rod length (such as L1=150mm, L2=300mm), crank radius (such as R=50mm), etc.; in the "kinematic pair configuration" area, a drop-down menu is provided for the user to select the kinematic pair type (such as rotation pair, translation pair), and support to specify the kinematic pair position by clicking on the interactive schematic diagram; in the "kinematic parameters" area, a slider control is used for the user to input parameter values such as initial angle (such as θ0=30°), angular velocity (such as ω=2rad / s), etc.; in the "mechanism type" area, radio buttons are used for the user to select common mechanism types such as four-bar mechanism and crank slider mechanism, and the system automatically displays the corresponding parameter input items.
[0110] Step S2: Transmit the plane connecting rod parameters to WebAssembly; The step S2 of transmitting the plane connecting rod parameters to WebAssembly specifically includes the following sub-steps: Step S21: Collect input parameters through HTML form elements on the web front end; In step S1, after the user fills in the plane connecting rod parameters through the input interface of the web front end, the system needs to pass these parameters to the WebAssembly module for calculation. This section details how data is collected from the HTML form and passed to WebAssembly through JavaScript.
[0111] The web front end uses standard HTML form () elements to collect user input, for example: input control:.< / select> <input type="number"> For numerical input, <input type="range"> For slider adjustment, <select>Used to select the type of kinematic pair.
[0112] After the user enters the parameters in the web form, the front end will organize these data into a structured object for subsequent processing.
[0113] These data will be encapsulated into a JSON object on the front end, and the structured data is convenient for subsequent transmission and parsing.
[0114] Step S22: Pass the parameters to WebAssembly through the JavaScript interface. Compile the WebAssembly file through C++, the types include .wasm and .js, etc., and deploy the compiled WebAssembly file to the web server. Use the JavaScript interface to call the interface function of the WebAssembly module to pass the structured data to the WebAssembly environment. In the specific implementation, JavaScript serializes the parameters into a binary format and writes them into the linear memory space of WebAssembly through a memory sharing mechanism to ensure the efficiency of data transmission.
[0115] Step S3: In the WebAssembly environment, based on the plane connecting rod parameters, the solution result is obtained by the calculation solution method; after the WebAssembly module is loaded, the numerical calculation is performed based on the input plane connecting rod parameters, which specifically includes the following process: Step S31: Constraint equations are established, and the nonlinear constraint equation group of the system is constructed according to the topological structure and kinematic pair type of the plane connecting rod mechanism. For example, for a four-bar mechanism, its closed-loop vector equation needs to be established.
[0116] Step S32: The equation group is solved by the Newton-Raphson iteration method. The implementation of this method includes the following key steps: Step S321: Calculate the Jacobian matrix of the constraint equation to reflect the coupling relationship between each variable.
[0117] Step S322: By iteratively updating the variable values, the solution of the equation group is gradually approached until the convergence condition is met (such as the error is less than the set threshold).
[118] Step S33: After the solution is completed, the kinematic data such as the position, velocity, acceleration, etc. of the connecting rod mechanism, as well as the dynamic data such as the joint reaction force, are output.
[0119] Step S4: Return the solution result to the web page front end for visual display.
[0120] Based on the first embodiment, the specific technical solution for visual display is further defined: Canvas drawing: Dynamically update the screen coordinates of the connecting rod and the joint based on the solution result to achieve a smooth animation effect.
[0121] Interactive control: User-driven simulation pause, continue or parameter reset is achieved through event monitoring.
[0122] After the WebAssembly module returns the calculation result to the front end, the system realizes visualization in the following ways: Graphic drawing: Use HTML5 Canvas technology to dynamically draw the two-dimensional motion state of the planar linkage mechanism according to the returned numerical results; for example, use line segments and dots to represent the connecting rod and the kinematic pair respectively, and update their positions in real time.
[0123] Animation control: Control animation playback through JavaScript, support interactive operations such as pause, resume, and speed adjustment; users can observe the continuous motion process of the connecting rod mechanism, or view the status at a specific moment in a single step.
[0124] Data display: Synchronously display key numerical results on the page, such as the trajectory curve of a specific point, the curve of joint angle change over time, etc.
[0125] Advantages of the implementation of this embodiment: Enhance user experience, facilitate teaching demonstration and design verification.
[0126] Embodiment 5 Based on the above method embodiment, this system embodiment provides a complete implementation scheme, which mainly includes: 1. Web front-end module, providing a user interaction interface, specifically implemented as follows: Parameter input unit: Use HTML5 standard form elements to construct an input interface, including: Numerical input box: used to receive parameters such as connecting rod length and initial angle; Drop-down selection box: used to select the type of kinematic pair (rotation pair / translation pair); Range slider: used to adjust continuous variables such as input speed; Implement parameter verification function to ensure that the input value meets physical constraints (such as connecting rod length>0).
[0127] Result display unit: Visual rendering is realized based on HTML5 Canvas technology, and dynamic drawing includes: two-dimensional motion state of the connecting rod mechanism; motion trajectory of key points; real-time data display area.
[0128] 2. Transmission module, realizing data interaction between front-end and back-end, specifically including: parameter transfer unit: encapsulate the parameters collected by the front-end into JSON format; call the WebAssembly export function through the JS interface provided by Emscripten; use ArrayBuffer to realize efficient binary data transmission.
[0129] Result return unit: receive the floating-point array result calculated by WebAssembly; parse the data into a format that can be processed by the visualization module; trigger interface update through the event mechanism.
[0130] 3. Solution module, core calculation module, runs in the WebAssembly environment: algorithm execution unit, using C++ to implement the Newton-Raphson iterative algorithm, specific calculation process: establish a set of constraint equations according to the mechanism topology; calculate the Jacobian matrix and its inverse matrix; iterate and solve until the convergence condition is met (error <1e-6); support multi-threaded parallel calculation optimization.
[0131] Memory management unit: pre-allocate continuous memory space to store intermediate variables; implement custom memory pool to manage frequent memory operations; manage heap memory through Emscripten's Memory object.
[0132] 4. Visual display module implements dynamic display function and realizes 60FPS smooth animation based on requestAnimationFrame.
[0133] Provide interactive control: play / pause; speed control; single-step execution.
[0134] Supports exporting results as pictures or data files.
[0135] Advantages of the implementation of this embodiment: Full functional integration, fully realizing the full process functions from parameter input, calculation and solution to visual display; each module works together to form a closed-loop simulation system.
[0136] Technical standardization, using the W3C standard Web technology stack (HTML5 / WebAssembly) to ensure compatibility in various modern browsers.
[0137] Computational efficiency, the WebAssembly module achieves execution efficiency close to that of native code; the typical four-bar mechanism solution time is <50ms.
[0138] Interaction integrity, providing a complete user operation process, including parameter input, calculation control and result viewing.
[0139] Example 6 Based on the system example 7, this embodiment further expands the system capabilities and optimizes the solution module: 1. Web front-end module, providing a user interaction interface, specifically implemented as follows: Based on the first embodiment, the front-end module is further optimized: Parameter input unit enhancement: using responsive design, automatically adapting to different device screens; realizing parameter association verification (such as verifying Grashof conditions); providing preset mechanism templates for fast loading.
[0140] Parameter input unit: The input interface is constructed using HTML5 standard form elements, including: Numerical input box: used to receive parameters such as connecting rod length and initial angle; Drop-down selection box: used to select the type of kinematic pair (rotational pair / translation pair); Range slider: used to adjust continuous variables such as input speed; Implement parameter verification function to ensure that the input value meets physical constraints (such as connecting rod length>0).
[0141] Enhanced result display unit: Add multi-view display, such as the main view of the mechanism motion state, the secondary view of the parameter curve (angle / speed changes over time); Implement touch screen gesture interaction support.
[0142] Result display unit: Based on HTML5 Canvas technology, visual rendering is realized, and dynamic drawing includes: two-dimensional motion state of the connecting rod mechanism; motion trajectory of key points; real-time data display area.
[0143] 2. Transmission module, realizes data interaction between front-end and back-end, specifically including: Parameter transfer unit: Encapsulate the parameters collected by the front-end into JSON format; Call WebAssembly export function through the JS interface provided by Emscripten; Use ArrayBuffer to realize efficient binary data transmission.
[0144] Result return unit: receives the floating point array result of WebAssembly calculation; parses the data into a format that can be processed by the visualization module; triggers interface updates through the event mechanism.
[0145] 3. Solution module, core calculation module, runs in the WebAssembly environment: algorithm execution unit, uses C++ to implement the Newton-Raphson iterative algorithm, specific calculation process: establish a set of constraint equations based on the mechanism topology; calculate the Jacobian matrix and its inverse matrix; iterate and solve until the convergence condition is met (error <1e-6); support multi-threaded parallel calculation optimization.
[0146] Enhanced algorithm execution unit: integrated sparse matrix optimization library to improve Jacobian matrix operation efficiency; implemented adaptive step size control algorithm; added mechanism singular position detection processing.
[0147] Memory management unit: pre-allocated continuous memory space to store intermediate variables; implemented custom memory pool to manage frequent memory operations; managed heap memory through Emscripten's Memory object.
[0148] Enhanced memory management unit: adopted memory reuse strategy to reduce allocation operations; implemented calculation cache mechanism to improve repeated calculation efficiency; added memory cross-bounds detection to ensure stability.
[0149] 4. Visual display module realizes dynamic display function and realizes 60FPS smooth animation based on requestAnimationFrame.
[0150] Provides interactive control: play / pause; speed control; single-step execution.
[0151] Supports exporting results as pictures or data files.
[152] Advantages of the implementation of this embodiment: Improved user experience: responsive design makes mobile terminal operation more convenient; preset templates shorten user configuration time.
[153] Enhanced input reliability: parameter association verification to avoid invalid input; real-time verification of mechanism feasibility such as Grashof conditions.
[0154] Analysis dimension expansion: multi-view display provides a more comprehensive analysis perspective; curve view assists in understanding motion characteristics.
[0155] Rich interaction methods: support touch operation to adapt to mobile scenes; gesture zooming facilitates detailed observation.
[0156] Computational performance breakthrough: sparse matrix optimization increases the calculation speed by 40%; adaptive step size reduces invalid iterations by 30%.
[0157] Numerical stability enhancement: singular position detection avoids calculation divergence; memory out-of-bounds detection prevents runtime errors.
[0158] Resource utilization optimization: memory reuse reduces GC frequency; cache mechanism reduces repeated calculations.
[159] Large-scale simulation support: can handle complex mechanisms with 100+ degrees of freedom; memory management optimization supports long-term calculations.
[160] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by any technician familiar with the technology in the field within the technical scope disclosed in the present invention should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.< / select> < / form>
Claims
1. A mechanical basic plane connecting rod online simulation method, characterized in that: include: Receive the planar connecting rod parameters input by the user through the web front end; Transmitting the planar link parameters to WebAssembly; In the WebAssembly environment, based on the planar connecting rod parameters, a solution result is obtained by a calculation solution method; The solution result is returned to the web page front end for visual display.
2. The mechanical basic plane connecting rod online simulation method according to claim 1 is characterized in that: The transmitting the planar link parameters to WebAssembly comprises: Collect input parameters through HTML form elements on the web front end; Pass parameters to WebAssembly through the JavaScript interface.
3. The mechanical basic plane connecting rod online simulation method according to claim 1 is characterized in that: The method of obtaining a solution by a calculation method based on the planar connecting rod parameters in the WebAssembly environment includes: generating kinematic and dynamic solutions by using a Newton-Raphson iteration method through C++ code compilation.
4. The mechanical basic plane connecting rod online simulation method according to claim 3 is characterized in that: The generation of kinematic and dynamic solutions by Wewton-Raphson iteration method through C++ code compilation includes: compiling the C++ code into a .wasm binary file and corresponding JavaScript glue code through the Emscripten tool chain.
5. The mechanical basic plane connecting rod online simulation method according to claim 4 is characterized in that: The C++ code is compiled into a .wasm binary file and corresponding JavaScript glue code through the Emscripten tool chain. The compilation process includes: loading and instantiating the .wasm file through JavaScript's WebAssembly API.
6. The mechanical basic plane connecting rod online simulation method according to claim 3 is characterized in that: The kinematic and dynamic solutions generated by compiling C++ code and using the Wewton-Raphson iteration method include: Establish the constraint equation of the planar link; calculate the Jacobian matrix of the constraint equation; Update the iteration variable according to the Newton-Raphson iteration formula; When the convergence condition is met, the solution result is output.
7. The mechanical basic plane connecting rod online simulation method according to claim 1 is characterized in that: The returning the solution result to the webpage front end for visual display includes: Use HTML5 Canvas element to draw the two-dimensional graphics of the plane connecting rod; The motion process is visualized by controlling the animation effect through JavaScript.
8. A mechanical basic plane connecting rod online simulation system for implementing the method described in any one of claims 1 to 7, characterized in that: include: A web front-end module receives the planar connecting rod parameters input by the user through the web front-end; The transmission module is used to realize the data transmission between the web page front end and the solution module; The solver module uses the Newton-Raphson iteration method to solve kinematics and dynamics in the WebAssembly environment; The visualization module returns the solution result to the web page front end for visualization.
9. The mechanical basic plane connecting rod online simulation system according to claim 8, characterized in that: The webpage front-end module includes: A parameter input unit receives the plane connecting rod parameters input by the user through an HTML form element; The result display unit realizes the visualization rendering of simulation results through HTML5 Canvas; The transmission module comprises: The parameter transfer unit is used to convert the parameters input by the front end into structured data and pass it to the WebAssembly solution module through the JavaScript interface; The result return unit is used to return the calculation results of WebAssembly to the front-end visualization unit.
10. The mechanical basic plane connecting rod online simulation system according to claim 8, characterized in that: The solution module includes: Algorithm execution unit, used to perform Newton-Raphson iterative calculations in the WebAssembly environment, including: Establish the constraint equations of the planar linkage mechanism; Calculate the Jacobian matrix and solve the kinematic / dynamic parameters by iteration; The memory management unit is used to handle the linear memory allocation and release of WebAssembly, ensuring efficient storage and exchange of data during the calculation process.
Citation Information
Patent Citations
Dynamic analysis method for eight-connecting-rod mechanical press
CN110162816A
Front-end page acceleration method and device based on WebAssembly and browser
CN117786272A
Cited By
Suspension bridge cable re-checking calculation method and system based on B / S architecture
CN120893102A
Suspension bridge cable rechecking calculation method and system based on B / S architecture
CN120893102B