Model motion control method, device and medium
By segmenting the motion path and adjusting the model pose in the digital twin project, the front of the model is consistent with the motion direction, the problem of model motion control delay and visual effect distortion in the existing technology is solved, and more realistic object motion simulation and More efficient project implementation.
Patent Information
- Application Number
- CN202411409710.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-10
- Publication Date
- 2025-02-14
AI Technical Summary
When the existing technology implements model motion control in digital twin projects, there are problems such as delay caused by time difference, high network bandwidth occupation and distortion of object motion visual effects, which affects the simulation effect and project implementation efficiency.
By loading the model and the preset motion path, the path is divided into several intermediate target points, the motion direction vector is constructed, and the position of the model is adjusted according to the vector, so that its front face is consistent with the motion direction, real-time motion control is achieved.
This method calculates the coordinates of the current position and target point in real time, and realizes the synchronization of the model orientation and the direction of motion, improving the visual realism of object movement, reducing dependence on the network, and reducing delay.
Smart Images

Figure CN119442593A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of simulation technology, and more specifically, to a model motion control method, device and medium. Background Art
[0002] With the rapid development of technologies such as smart cities and smart parks, people's demand for online simulation of real scenes is constantly increasing, and digital twin projects derived from this (digital twins make full use of physical models, sensors, operation history and other data, integrate multi-disciplinary, multi-physical quantity, multi-scale, and multi-probability simulation processes, and complete mapping in virtual space, thereby reflecting the entire life cycle of the corresponding physical equipment. Digital twins are a concept beyond reality and can be regarded as a digital mapping system of one or more important and interdependent equipment systems.) are emerging in an endless stream.
[0003] In digital twin projects, the motion control of three-dimensional models is usually involved. The motion of the model is complex and changeable. In order to be as close to the real motion situation as possible, the model in motion needs to keep the front and motion direction as consistent as possible. However, the motion route of the model is constantly changing. It may be a straight route for a period of time, and a curved route for another period of time. However, the current method implemented on the market is mainly to continuously obtain information such as motion status, steering and angle from the real device side, and pass it to the web page through real-time communication to control the model to adjust the angle. This not only causes a delay caused by a time difference and occupies network bandwidth, but also has the problem of serious distortion of the visual effect of the object's motion. This seriously affects the simulation effect and project implementation efficiency of digital twin projects. Summary of the invention
[0004] In response to at least one defect or improvement need in the prior art, the present application provides a model motion control method, device and medium, which are used to at least improve the simulation effect of digital twin projects so as to better simulate the real motion state of the object.
[0005] To achieve the above objectives, in a first aspect, the present application provides a model motion control method, comprising:
[0006] S1. Load a model and obtain a first frontal vector and a corresponding first initial position of the model;
[0007] S2, loading the preset motion path of the model, and sequentially setting a number of intermediate target points on the preset motion path according to the path type to achieve path segmentation;
[0008] S3, constructing a first motion direction vector of the model with the first initial position as a starting point and the first intermediate target point as an end point;
[0009] S4. Based on the first frontal vector and taking the first motion direction vector as an adjustment target, obtaining an angle and direction in which the model needs to rotate;
[0010] S5. Adjust the posture of the model based on the angle and direction in which the model needs to rotate, and control the model to move to the first intermediate target point.
[0011] Furthermore, it also includes:
[0012] S6. Determine whether there is a second intermediate target point immediately after the first intermediate target point of the preset motion path; if not, end the process; if so, adjust the first front vector with the first motion direction vector as the adjustment target to obtain the second front vector; construct the second motion direction vector of the model with the first intermediate target point as the starting point and the second intermediate target point as the end point; repeat steps S4-S6 until the model moves to the final target point on the preset motion path.
[0013] Further, adjusting the first frontal vector to obtain a second frontal vector with the first motion direction vector as an adjustment target includes:
[0014] The direction of the first frontal vector is adjusted to be consistent with the direction of the first motion direction vector, and the first frontal vector after the direction adjustment is the second frontal vector.
[0015] Further, the second motion direction vector is a directed line segment starting from the first intermediate target point and ending at the second intermediate target point;
[0016] The first motion direction vector is a directed line segment starting from the first initial position and ending at the first intermediate target point.
[0017] Further, adjusting the posture of the model to control the model to move to the first intermediate target point includes:
[0018] Use the rotation method rotate() provided by Three.js to adjust the posture of the model;
[0019] Obtaining a movement time t according to a movement speed v of the model and a distance s between the first initial position and a first intermediate target point;
[0020] The model is controlled to move to the first intermediate target point using the translate() method within time t.
[0021] Further, adjusting the posture of the model includes:
[0022] The posture of the model is adjusted so that the direction of the first frontal vector is consistent with the direction of the first motion direction vector.
[0023] Furthermore, the method for obtaining the angle and direction in which the model needs to be rotated includes:
[0024] Calculate the angle between the first frontal vector and the first motion direction vector by using a vector dot multiplication method to obtain the angle at which the model needs to rotate;
[0025] Use the vector cross product method or the right-hand screw rule to determine the direction in which the model needs to be rotated.
[0026] Furthermore, the path type includes one or more of a line segment, a broken line and a curve.
[0027] In a second aspect, the present application provides an electronic device comprising at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program, and when the computer program is executed by the processing unit, the processing unit is enabled to perform the steps of any of the aforementioned model motion control methods.
[0028] In a third aspect, the present application provides a storage medium storing a computer program executable by an access authentication device, wherein when the computer program runs on the access authentication device, the access authentication device is enabled to execute the steps of any of the aforementioned model motion control methods.
[0029] In general, the above technical solutions conceived by the present application can achieve the following beneficial effects compared with the prior art:
[0030] This application only needs to perform real-time calculations between the coordinates of the model's current position and the target point to achieve the effect of adjusting the model's orientation to be consistent with the direction of movement, making the visual effect of the object's movement more realistic and better simulating the real movement situation. It does not rely on network requests and has lower latency. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present application, 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 application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0032] Figure 1 A core flow chart of a model motion control method provided in an embodiment of the present application;
[0033] Figure 2A path segmentation diagram when the path type provided in the embodiment of the present application is a line segment;
[0034] Figure 3 A path segmentation diagram when the path type provided in the embodiment of the present application is a broken line;
[0035] Figure 4 A path segmentation diagram when the path type provided in the embodiment of the present application is a curve;
[0036] Figure 5 A positional relationship diagram between the front vector and the motion direction vector of the model provided in an embodiment of the present application;
[0037] Figure 6 A schematic diagram of making the front of the model consistent with its movement direction provided in the embodiment of the present application;
[0038] Figure 7 A simulation diagram of the motion of a model that has not been optimized by calculation provided in the embodiment of the present application;
[0039] Figure 8 A simulation diagram of the motion of a model that has been optimized by calculation provided in an embodiment of the present application;
[0040] Fig. 9 A block diagram of an electronic device suitable for implementing the model motion control method described above provided in an embodiment of the present application. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. In addition, the technical features involved in each embodiment of the present application described below can be combined with each other as long as they do not conflict with each other.
[0042] The terms "first", "second" or "nth" in the specification, claims or drawings of the present application are used to distinguish different objects rather than to describe a specific order. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units inherent to these processes, methods, products or devices.
[0043] As described in the background technology section of the specification, the current method for simulating digital twin projects on the market is mainly to continuously obtain information such as motion status, steering and angle from the real device side, and transmit it to the web page side through real-time communication to control the model adjustment angle. This not only causes a delay caused by a time difference and occupies network bandwidth, but also has the problem of distorted visual effects of object movement, which seriously affects the simulation effect of digital twin projects and the efficiency of project implementation. In view of this, the present application proposes a model motion control method, device and medium for at least improving the simulation effect of digital twin projects, so as to better simulate the real motion state of objects.
[0044] Normally, the motion model in a three-dimensional scene should be a model that can distinguish the front, back, and side, so as to simulate the visual effects of the real scene more realistically on the web page. For example, for an inspection robot or inspection vehicle in a three-dimensional substation scene, according to the actual inspection needs, the staff will pre-plan an inspection route in the three-dimensional scene. When performing the inspection task, the model (a model that can be in motion, such as an inspection robot or inspection vehicle) will move and patrol at a certain speed on the planned inspection route. It should be noted that when planning the inspection route, the type of path needs to be saved, such as a line segment, a broken line, or a curve.
[0045] like Figure 2 As shown in Figure 2, when the inspection route is a line segment, the target point is the starting point of the path segment (i.e. Figure 2 In this case, the target point array is arr = [{x1, z1}, {x2, z2}].
[0046] like Figure 3 As shown in Figure 2, when the inspection route is a broken line, the target point is the starting point of the path (i.e. Figure 3 Target point 1 and target point 4 in the figure) plus the middle node of the polyline (i.e. Figure 3 In this case, the target point array is arr = [{x1, z1}, {x2, z2}, ...., {x n , z n}].
[0047] like Figure 4As shown, when the inspection route is a curve, the line nodes need to be segmented. The line model segmentation point method getPoints(n) provided by Three.js (Three.js is a 3D JavaScript library based on WebGL. It is a graphics engine for creating 3D programs on the Web side and is used to create and display 3D graphics on web pages. WebGL is only a low-level graphics system that can only draw points, lines and triangles. Directly using WebGL to develop applications often requires writing a lot of code. Three.js encapsulates the WebGL API, which greatly simplifies the development process of 3D graphics, allowing front-end developers to more easily achieve 3D effects on web pages.) is used. n is the number of segmentations, and the number of segmentations depends on the accuracy requirements for direction adjustment. The higher the required accuracy, the more segmentations are required; otherwise, the fewer. After the segmentation is completed, the target point array in this case is arr = [{x1, z1}, {x2, z2}, ...., {x n , z n The direction vector of the tangent line at a point on the curve can be approximately regarded as the vector generated by another point that is infinitely close to this point and this point (such as Figure 6 As shown), when there are enough points to be segmented, the vector generated between the two points (i.e. Figure 6 The vector indicated by the bold line between the two target points can be regarded as the direction vector of target point 2. Then, by continuously adjusting the front vector of the robot to be consistent with the tangent vector, the technical effect of the robot always keeping its front consistent with the direction of movement during the movement can be achieved.
[0048] refer to Figure 1 An embodiment of the present application proposes a model motion control method, which mainly includes the following steps.
[0049] Step 1: Import the 3D model of the object to be moved into the corresponding digital twin Web project, define a front vector that conforms to the actual situation for the model according to the position where the model is placed in the scene, and record the initial position coordinates of the model.
[0050] Specifically, the model to be moved is loaded into the three-dimensional scene so that the front of the model is parallel to the positive direction of the X-axis, and the initial coordinates startPoint:{x, 0, z} and the front vector frontFace:{1, 0, 0} are recorded.
[0051] The colors of the Three.js coordinate axes red R, green G, and blue B correspond to the X, Y, and Z axes of the coordinate system respectively. For the Three.js 3D coordinate system, the Y axis is upward by default, and the default Y coordinate of the moving plane in the three-dimensional scene is 0.
[0052] Step 2: Load the preset motion path of the model, and set several intermediate target points on the preset motion path according to the path type to achieve path segmentation. Figure 2-Figure 4 Path segmentation diagram for different path types.
[0053] Specifically, the preset motion path of the model is loaded, and the set of all intermediate target points is calculated according to the path type: routePoints = [{x1, 0, z1}, {x2, 0, z2}, ..., {x n , 0, z n}].
[0054] Step 3, take the first intermediate target point of all intermediate target points as the target point endPoint{x1, 0, z1}, take the center point of the model as the starting point startPoint:{x, 0, z}, and form the motion direction vector direct = endPoint.clone().sub(startPoint).normalize(), the normalize() method is the normalization of the vector, that is, only the size is changed, not the direction. At this time, the motion direction vector is a directed line segment with the center point of the model as the starting point startPoint:{x, 0, z} and the first intermediate target point as the target point endPoint{x1, 0, z1}.
[0055] Step 4: Based on the front face vector frontFace and the motion direction vector direct, obtain the angle and direction that the model needs to rotate. Figure 5 , a motion direction vector is generated between the center point of the moving model and the target point. The model itself has a front vector. The model rotation is controlled by the calculation method and the direction of its front vector is adjusted to the motion direction vector at this time.
[0056] Specifically, the angle between the model's front face vector frontFace and the movement direction vector direct is calculated using the vector dot product method: rad = Math.acos(frontFace.dot(direct)); when rad is 0, it proves that the movement direction vector is consistent with the front face vector, and there is no need to adjust the model rotation angle.
[0057] Use the vector cross product method or the right-hand screw rule to determine the rotation direction rotateDirect = frontFace.clone().cross(direct).normalize(). When the rotateDirect.y value is greater than 0, it can be determined that the target point is on the left side of the model, and the model needs to be rotated left by rad radians; when the rotateDirect.y value is less than 0, it can be determined that the target point is on the right side of the model, and the model needs to be rotated right by rad radians.
[0058] Step 5. After the calculation is completed, use the rotation method rotate() provided by Three.js to adjust the model orientation until the model's front vector is in the same direction as the movement direction vector; after the adjustment is completed, use the direct vector to replace the frontFace vector, that is, the front vector at this time is turned to the direction of the movement direction vector, thereby constructing a new front vector, which can be the second front vector mentioned in the claims; calculate the movement time t according to the model movement speed v and the distance s between startPoint and endPoint, and control the model to move to the first intermediate target point within the time t using the translate() method.
[0059] The above five steps are special scenarios when the preset motion path is not segmented. It is the simplest and most basic simulation scene unit. In reality, considering the high-precision requirements for direction adjustment, it is often necessary to segment the preset motion path into multiple segments, that is, multiple segmentation points (i.e. intermediate target points) will be generated. After reaching the first intermediate target point, the model will also move further until it reaches the final target point.
[0060] Step 6. Preferably, after the model moves to the first intermediate target point, it is determined whether there is a neighboring next node (i.e., the second intermediate target point mentioned in the claims) in the path node (several intermediate target points that divide the preset motion path). If there is a neighboring next node, repeat steps 4-6 until the model moves to the last node of the preset motion path. The second motion direction vector mentioned in the claims is a directed line segment starting from the first intermediate target point and ending at the second intermediate target point. The subsequent nth motion direction vector is analogous.
[0061] This application only needs to calculate the coordinates between the current position of the model and the target point in real time to achieve the technical effect of adjusting the model's orientation to be consistent with the direction of movement, making the visual effect of the object's movement more realistic and better able to simulate the real movement situation, without relying on network requests and with lower latency. Figure 7 and Figure 8 It can be clearly seen that through the control optimization of the model motion control method of the present application, it is possible to simulate a more realistic object motion effect diagram, and better simulate the real motion situation in order to make subsequent decision-making behaviors.
[0062] Fig. 9 A block diagram of an electronic device suitable for implementing the model motion control method described above according to an embodiment of the present application is schematically shown. Fig. 9 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0063] like Fig. 9 As shown, the electronic device 1000 described in this embodiment includes: a processor 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. The processor 1001 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), and the like. The processor 1001 may also include an onboard memory for caching purposes. The processor 1001 may include a single processing unit or multiple processing units for performing different actions of the model motion control method flow according to an embodiment of the present application.
[0064] In RAM 1003, various programs and data required for the operation of system 1000 are stored. Processor 1001, ROM 1002 and RAM 1003 are connected to each other through bus 1004. Processor 1001 performs various operations of the model motion control method flow according to the embodiment of the present application by executing the program in ROM 1002 and / or RAM 1003. It should be noted that the program can also be stored in one or more memories other than ROM 1002 and RAM 1003. Processor 1001 can also perform various operations of the model motion control method flow according to the embodiment of the present application by executing the program stored in the one or more memories.
[0065] According to an embodiment of the present application, the electronic device 1000 may further include an input / output (I / O) interface 1005, which is also connected to the bus 1004. The system 1000 may further include one or more of the following components connected to the I / O interface 1005: an input part 1006 including a keyboard, a mouse, etc.; an output part 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage part 1008 including a hard disk, etc.; and a communication part 1009 including a network interface card such as a LAN card, a modem, etc. The communication part 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that the computer program read therefrom is installed into the storage part 1008 as needed.
[0066] The model motion control method flow according to the embodiment of the present application can be implemented as a computer software program. For example, the embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the model motion control method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1009, and / or installed from the removable medium 1011. When the computer program is executed by the processor 1001, the above-mentioned functions defined in the system of the embodiment of the present application are executed. According to the embodiment of the present application, the system, equipment, device, module and / or unit described above, etc. can be implemented by a computer program module.
[0067] The embodiments of the present application also provide a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments, or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the steps of the model motion control method according to the embodiments of the present application can be implemented.
[0068] According to an embodiment of the present application, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In an embodiment of the present application, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus, or a device. For example, according to an embodiment of the present application, the computer-readable storage medium may include one or more memories other than the ROM 1002 and / or RAM 1003 described above.
[0069] It should be noted that the functional modules in the various embodiments of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above-mentioned integrated modules can be implemented in the form of hardware or in the form of software functional modules. If the integrated modules are implemented in the form of software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product.
[0070] The flowchart and / or block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flowchart and / or block diagram can represent a part of a module, program segment or code, and a part of the above-mentioned module, program segment or code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. It should also be noted that each box in the block diagram or flowchart, and the combination of the boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0071] Those skilled in the art will appreciate that the features described in the various embodiments and / or claims of the present application may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present application. In particular, without departing from the spirit and teachings of the present application, the technical features described in the various embodiments and / or claims of the present application may be combined and / or combined in a variety of ways, and all of these combinations and / or combinations fall within the scope of the present application.
[0072] Although the present application has been shown and described with reference to specific exemplary embodiments of the present application, it should be understood by those skilled in the art that various changes in form and details may be made to the present application without departing from the spirit and scope of the present application as defined by the appended claims and their equivalents. Therefore, the scope of the present application should not be limited to the above-mentioned embodiments, but should be determined not only by the appended claims, but also by the equivalents of the appended claims.
Claims
1. A model motion control method, characterized in that: include: S1. Load a model and obtain a first frontal vector and a corresponding first initial position of the model; S2, loading the preset motion path of the model, and sequentially setting a number of intermediate target points on the preset motion path according to the path type to achieve path segmentation; S3, constructing a first motion direction vector of the model with the first initial position as a starting point and the first intermediate target point as an end point; S4. Based on the first frontal vector and taking the first motion direction vector as an adjustment target, obtaining an angle and direction in which the model needs to rotate; S5. Adjust the posture of the model based on the angle and direction in which the model needs to rotate, and control the model to move to the first intermediate target point.
2. The model motion control method according to claim 1, characterized in that: Also includes: S6, determining whether there is a second intermediate target point immediately after the first intermediate target point of the preset motion path; If it does not exist, the process ends; If it exists, adjust the first front vector with the first motion direction vector as the adjustment target to obtain the second front vector; construct the second motion direction vector of the model with the first intermediate target point as the starting point and the second intermediate target point as the end point; repeat steps S4-S6 until the model moves to the final target point on the preset motion path.
3. The model motion control method according to claim 2, characterized in that: The adjusting the first frontal vector to obtain a second frontal vector by taking the first motion direction vector as an adjustment target comprises: The direction of the first frontal vector is adjusted to be consistent with the direction of the first motion direction vector, and the first frontal vector after the direction adjustment is the second frontal vector.
4. The model motion control method according to claim 2, characterized in that: The second motion direction vector is a directed line segment starting from the first intermediate target point and ending at the second intermediate target point; The first motion direction vector is a directed line segment starting from the first initial position and ending at the first intermediate target point.
5. The model motion control method according to any one of claims 1 to 4, characterized in that: The adjusting the posture of the model and controlling the model to move to the first intermediate target point comprises: Use the rotate() method provided by Three.js to adjust the pose of the model; Obtaining a movement time t according to a movement speed v of the model and a distance s between the first initial position and a first intermediate target point; The model is controlled to move to the first intermediate target point using the translate() method within time t.
6. The model motion control method according to claim 5, characterized in that: The adjusting the pose of the model comprises: The posture of the model is adjusted so that the direction of the first frontal vector is consistent with the direction of the first motion direction vector.
7. The model motion control method according to any one of claims 1 to 4, characterized in that: The method for obtaining the angle and direction in which the model needs to be rotated includes: Calculate the angle between the first frontal vector and the first motion direction vector by using a vector dot multiplication method to obtain the angle at which the model needs to rotate; Use the vector cross product method or the right-hand screw rule to determine the direction in which the model needs to be rotated.
8. The model motion control method according to any one of claims 1 to 4, characterized in that: The path type includes one or more of a line segment, a polyline, and a curve.
9. An electronic device, characterized in that: It comprises at least one processing unit and at least one storage unit, wherein the storage unit stores a computer program, and when the computer program is executed by the processing unit, the processing unit is enabled to execute the steps of the model motion control method according to any one of claims 1 to 8.
10. A storage medium, characterized in that: It stores a computer program executable by an access authentication device. When the computer program runs on the access authentication device, the access authentication device is enabled to execute the steps of the model motion control method according to any one of claims 1 to 8.