Robot motion control method based on same-frequency asynchronous double threads and related device

CN123000878APending Publication Date: 2026-10-30CHINA WEST NORMAL UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611517723.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-29
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0004]然而,现有技术按照串行架构执行对机器人的运动控制,当传感器数据量增大或模型推理计算量增加时,多个数据处理任务在单一执行流程中需要排队等待,并且推理任务耗时存在不确定性,易引发数据拥堵,无法保证控制频率,使得机器人在实际应用中运动控制的稳定性下降

Benefits of technology

推理线程获取机器人运行状态数据并执行运动控制模型推理,将生成的机器人动作预测数据写入线程间共享数据区域,控制线程从线程间共享数据区域获取机器人动作预测数据并生成机器人运动控制指令,同时获取机器人执行机构反馈的运动控制反馈数据并更新至线程间共享数据区域,由于推理线程和控制线程分别按照第一预设循环周期和第二预设循环周期运行,且第一预设循环周期与第二预设循环周期相同,推理线程和控制线程基于各自独立的循环计时机制确定对应循环周期的执行时序,使推理线程和控制线程能够按照相同频率独立执行,避免由于推理线程与控制线程的循环执行时序相互依赖而导致控制指令发送周期发生波动,减少模型推理过程对机器人运动控制过程造成的影响,从而使机器人执行机构能够按照相对稳定的时间间隔接收运动控制指令,提高机器人关节运动的平滑性和机器人运动控制的稳定性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123000878A_ABST
    Figure CN123000878A_ABST
Patent Text Reader

Abstract

The application discloses a robot motion control method based on a same-frequency asynchronous double thread and a related device, and is used for improving the stability of robot motion control. The method comprises the following steps: creating a robot motion control task, wherein the robot motion control task comprises an inference thread and a control thread which are independent of each other; obtaining robot running state data through the inference thread, generating robot action prediction data through reasoning, and writing the robot action prediction data into an inter-thread shared data area; obtaining the robot action prediction data from the inter-thread shared data area through the control thread, generating robot motion control instructions, sending the robot motion control instructions to a robot actuator, simultaneously obtaining motion control feedback data, and updating the motion control feedback data to the inter-thread shared data area; the inference thread runs according to a first preset cycle period, the control thread runs according to a second preset cycle period, the first preset cycle period is the same as the second preset cycle period, and the inference thread and the control thread run based on independent cycle timing mechanisms.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of robot motion control technology, and in particular to a robot motion control method and related apparatus based on synchronous asynchronous dual-thread. Background Technology

[0002] With the rapid development of robotics technology, robots are able to move stably in unstructured environments such as steps, gravel, and steep slopes. Therefore, the performance requirements for the motion control system of robots are increasing.

[0003] Currently, in existing technologies, this method deploys a reinforcement learning policy network in the robot controller and an inference network in the robot controller. It sequentially executes sensor data reading, model inference calculation, and motor command sending according to a fixed control cycle, and finally sends the motion commands to the motor drivers of each joint to drive the motors to operate.

[0004] However, existing technologies execute robot motion control according to a serial architecture. When the amount of sensor data increases or the computational load of model inference increases, multiple data processing tasks need to queue up in a single execution process. Furthermore, the time taken for inference tasks is uncertain, which can easily lead to data congestion and make it impossible to guarantee the control frequency. This results in a decrease in the stability of robot motion control in practical applications. Summary of the Invention

[0005] To address the aforementioned technical issues, this application provides a robot motion control method and related apparatus based on synchronous asynchronous dual threads, which can improve the stability of robot motion control.

[0006] The technical solution provided in this application is described below: The first aspect of this application provides a robot motion control method based on synchronous asynchronous dual-threaded operation, including: Create a robot motion control task, which includes independent inference threads and control threads; The inference thread acquires robot running status data, performs motion control model inference based on the robot running status data, generates robot motion prediction data, and writes the robot motion prediction data into the inter-thread shared data area. The robot running status data includes sensor acquisition data and motion control feedback data. The inter-thread shared data area is used to realize data interaction between the inference thread and the control thread. The control thread obtains the robot motion prediction data from the inter-thread shared data area, generates robot motion control instructions based on the robot motion prediction data, sends the robot motion control instructions to the robot actuator, and simultaneously obtains the motion control feedback data fed back by the robot actuator and updates the motion control feedback data to the inter-thread shared data area for the inference thread to perform subsequent motion state inference. The inference thread runs according to a first preset cycle, and the control thread runs according to a second preset cycle. The first preset cycle and the second preset cycle are the same. The inference thread and the control thread run based on their respective independent loop timing mechanisms, so that the inference thread and the control thread execute asynchronously at the same frequency.

[0007] Optionally, the robot motion prediction data carries an inference timestamp. The step of obtaining the robot motion prediction data from the inter-thread shared data area through the control thread, generating robot motion control commands based on the robot motion prediction data, and sending the robot motion control commands to the robot actuator includes: The control thread acquires the action data mutex lock, and under the protection of the action data mutex lock, it obtains the robot action prediction data and the corresponding inference timestamp from the shared data area between threads. After obtaining the robot action prediction data and the corresponding inference timestamp, it releases the action data mutex lock. Calculate the time difference between the current timestamp and the corresponding inference timestamp, and compare the time difference with a preset time threshold; When the time difference does not exceed the preset time threshold, a robot motion control command is generated based on the robot motion prediction data, and the robot motion control command is sent to the robot actuator. When the time difference exceeds the preset time threshold and exceeds the preset number of times consecutively, the generation of robot motion control commands based on the robot motion prediction data is rejected, and the robot motion control commands are generated according to the preset safety mode.

[0008] Optionally, before acquiring the motion data mutex lock through the control thread, and obtaining the robot motion prediction data and the corresponding inference timestamp from the inter-thread shared data area under the protection of the motion data mutex lock, and releasing the motion data mutex lock after acquiring the robot motion prediction data and the corresponding inference timestamp, the robot motion control method further includes: The inference flag is detected by the control thread, and the inference flag is used to characterize the running state of the inference thread; When the inference flag is true and the control thread meets the thread task execution condition, the action data mutex is acquired through the control thread. The thread task execution condition is that the control thread completes the preset start delay task and acquires the first sensor data. When the inference flag is false or the control thread does not meet the thread task execution conditions, the control thread is controlled to generate robot motion control instructions according to the preset safety mode.

[0009] Optionally, before acquiring robot running state data through the inference thread, the robot motion control method further includes: The inference flag is detected through the inference thread; When the inference flag is true, the inference thread is allowed to obtain robot running status data to perform motion control model inference; When the inference flag is false, the inference thread is controlled to exit the loop.

[0010] Optionally, obtaining robot operating status data through the inference thread includes: The inference thread acquires a sensor data mutex lock, and under the protection of the sensor data mutex lock, it acquires sensor data collected from the robot's operating status data from the shared data area between threads. After acquiring the sensor data, it releases the sensor data mutex lock. The inference thread acquires a feedback data mutex lock, and under the protection of the feedback data mutex lock, retrieves motion control feedback data from the robot's running status data from the shared data area between threads. After retrieving the motion control feedback data, the feedback data mutex lock is released.

[0011] Optionally, the step of acquiring the motion control feedback data fed back by the robot actuator and updating the motion control feedback data to the inter-thread shared data area includes: The control thread acquires motion control feedback data from the robot actuator and obtains a feedback data mutex lock. Under the protection of the feedback data mutex lock, the motion control feedback data is updated to the inter-thread shared data area. After writing the motion control feedback data, the feedback data mutex lock is released.

[0012] Optionally, the robot motion control method further includes: When the inference thread or the control thread starts executing the thread task of the current cycle, the start timestamp is recorded, and the target sleep end timestamp is determined according to the start timestamp and the corresponding preset cycle. When the inference thread or the control thread completes the thread task of the current cycle, the inference thread or the control thread is controlled to perform a sleep operation based on the target sleep end timestamp, so that the current cycle of the inference thread or the control thread is aligned with the corresponding preset cycle.

[0013] A second aspect of this application provides a robot motion control device based on synchronous and asynchronous dual-threaded operation, the robot motion control device comprising: A creation unit is used to create a robot motion control task, which includes independent inference threads and control threads. The generation unit is used to acquire robot running status data through the inference thread, perform motion control model inference based on the robot running status data, generate robot motion prediction data, and write the robot motion prediction data into the inter-thread shared data area. The robot running status data includes sensor acquisition data and motion control feedback data. The inter-thread shared data area is used to realize data interaction between the inference thread and the control thread. The control unit is configured to obtain the robot motion prediction data from the inter-thread shared data area through the control thread, generate robot motion control instructions based on the robot motion prediction data, send the robot motion control instructions to the robot actuator, obtain the motion control feedback data fed back by the robot actuator, and update the motion control feedback data to the inter-thread shared data area for the inference thread to perform subsequent motion state inference. The inference thread runs according to a first preset cycle, and the control thread runs according to a second preset cycle. The first preset cycle and the second preset cycle are the same. The inference thread and the control thread run based on their respective independent loop timing mechanisms, so that the inference thread and the control thread execute asynchronously at the same frequency.

[0014] Optionally, the control unit is specifically used for: The control thread acquires the action data mutex lock, and under the protection of the action data mutex lock, it obtains the robot action prediction data and the corresponding inference timestamp from the shared data area between threads. After obtaining the robot action prediction data and the corresponding inference timestamp, it releases the action data mutex lock. Calculate the time difference between the current timestamp and the corresponding inference timestamp, and compare the time difference with a preset time threshold; When the time difference does not exceed the preset time threshold, a robot motion control command is generated based on the robot motion prediction data, and the robot motion control command is sent to the robot actuator. When the time difference exceeds the preset time threshold and exceeds the preset number of times consecutively, the generation of robot motion control commands based on the robot motion prediction data is rejected, and the robot motion control commands are generated according to the preset safety mode.

[0015] Optionally, it also includes a first detection unit, specifically used for: The inference flag is detected by the control thread, and the inference flag is used to characterize the running state of the inference thread; When the inference flag is true and the control thread meets the thread task execution condition, the action data mutex is acquired through the control thread. The thread task execution condition is that the control thread completes the preset start delay task and acquires the first sensor data. When the inference flag is false or the control thread does not meet the thread task execution conditions, the control thread is controlled to generate robot motion control instructions according to the preset safety mode.

[0016] Optionally, a second detection unit may also be included, specifically for: The inference flag is detected through the inference thread; When the inference flag is true, the inference thread is allowed to obtain robot running status data to perform motion control model inference; When the inference flag is false, the inference thread is controlled to exit the loop.

[0017] Optionally, the generation unit is specifically used for: The inference thread acquires a sensor data mutex lock, and under the protection of the sensor data mutex lock, it acquires sensor data collected from the robot's operating status data from the shared data area between threads. After acquiring the sensor data, it releases the sensor data mutex lock. The inference thread acquires a feedback data mutex lock, and under the protection of the feedback data mutex lock, retrieves motion control feedback data from the robot's running status data from the shared data area between threads. After retrieving the motion control feedback data, the feedback data mutex lock is released.

[0018] Optionally, the control unit is specifically used for: The control thread acquires motion control feedback data from the robot actuator and obtains a feedback data mutex lock. Under the protection of the feedback data mutex lock, the motion control feedback data is updated to the inter-thread shared data area. After writing the motion control feedback data, the feedback data mutex lock is released.

[0019] Optionally, a hibernation unit may also be included, specifically for: When the inference thread or the control thread starts executing the thread task of the current cycle, the start timestamp is recorded, and the target sleep end timestamp is determined according to the start timestamp and the corresponding preset cycle. When the inference thread or the control thread completes the thread task of the current cycle, the inference thread or the control thread is controlled to perform a sleep operation based on the target sleep end timestamp, so that the current cycle of the inference thread or the control thread is aligned with the corresponding preset cycle.

[0020] A third aspect of this application provides a robot motion control device based on synchronous and asynchronous dual-thread operation, the robot motion control device comprising: Processor, memory, input / output units, and bus; The processor is connected to the memory, the input / output unit, and the bus; The memory stores a program, which the processor invokes to execute the first aspect and any one of the optional methods in the first aspect.

[0021] A fourth aspect of this application provides a computer-readable storage medium on which a program is stored, which, when executed on a computer, performs the methods of the first aspect and any one of the first aspects.

[0022] As can be seen from the above technical solutions, this application has the following beneficial effects: The inference thread acquires robot operating status data and executes motion control model inference, writing the generated robot motion prediction data into the inter-thread shared data area. The control thread acquires robot motion prediction data from the inter-thread shared data area and generates robot motion control commands. Simultaneously, it acquires motion control feedback data from the robot actuator and updates it to the inter-thread shared data area. Since the inference thread and control thread run according to the first preset cycle and the second preset cycle, respectively, and the first preset cycle and the second preset cycle are the same, the inference thread and control thread determine the execution sequence of the corresponding cycle based on their respective independent cycle timing mechanisms. This allows the inference thread and control thread to execute independently at the same frequency, avoiding fluctuations in the control command sending cycle due to the interdependence of the cycle execution sequence of the inference thread and the control thread. This reduces the impact of the model inference process on the robot motion control process, enabling the robot actuator to receive motion control commands at relatively stable time intervals, thereby improving the smoothness of robot joint movements and the stability of robot motion control.

[0023] Furthermore, by sharing a data area between threads, robot motion prediction data can be transmitted from the inference thread to the control thread, and motion control feedback data from the robot actuator can be updated by the control thread to the shared data area between threads for the inference thread to perform subsequent motion state inference. This forms a continuous interaction between robot operating state data, motion control model inference results, and motion control feedback data, improving the motion control model's responsiveness to changes in robot operating state. Attached Figure Description

[0024] To more clearly illustrate the technical solutions in this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0025] Figure 1 This is a flowchart illustrating an embodiment of the robot motion control method based on synchronous asynchronous dual threads provided in this application. Figure 2 This is another flowchart illustrating an embodiment of the robot motion control method based on synchronous asynchronous dual threads provided in this application; Figure 3 This is a schematic flowchart of one embodiment of the robot motion control method based on synchronous asynchronous dual threads in this application; Figure 4 This is a flowchart illustrating Embodiment 3 of the robot motion control method based on synchronous asynchronous dual threads in this application; Figure 5 This is a flowchart illustrating Embodiment 4 of the robot motion control method based on synchronous asynchronous dual threads in this application; Figure 6 This is a flowchart of Embodiment 5 of the robot motion control method based on synchronous asynchronous dual threads in this application; Figure 7 A schematic diagram of a sixth embodiment of the robot motion control device based on synchronous asynchronous dual threads provided in this application; Figure 8 This is a schematic diagram of a seventh embodiment of the robot motion control device based on synchronous asynchronous dual threads provided in this application. Detailed Implementation

[0026] This application provides a robot motion control method and related apparatus based on synchronous asynchronous dual-threading, which improves the stability of robot motion control. It should be noted that the robot motion control method based on synchronous asynchronous dual-threading provided in this application can be applied to a robot terminal. For ease of explanation, this application uses a system as the execution subject for illustrative purposes.

[0027] Example 1, please refer to Figure 1 This application first provides an embodiment of a robot motion control method based on synchronous asynchronous dual-thread, which includes: S101. Create a robot motion control task. The robot motion control task includes independent inference threads and control threads. Before creating a robot motion control task or during its initialization, a reinforcement learning inference control state machine can be selected via the terminal, and the corresponding state machine initialization process can be initiated. During state machine initialization, a pre-trained motion control model is first loaded, and independent inference and control threads are established within the motion control task. The motion control model can be loaded using different model formats to adapt to different computing hardware. For example, when the motion control model uses the Open Neural Network Exchange (ONNX) format, it can be loaded using the corresponding ONNX runtime; when it uses TorchScript, it can be loaded using LibTorch. The dual-threaded architecture is independent of the specific network structure of the motion control model; for example, the motion control model can use neural network structures such as Multilayer Perceptron (MLP) or Long Short-Term Memory (LSTM). After the model is loaded, the inference and control threads are established.

[0028] It should be noted that the inference thread runs according to the first preset cycle period, and the control thread runs according to the second preset cycle period. The first preset cycle period and the second preset cycle period are the same, and the inference thread and the control thread run based on their own independent loop timing mechanism so that the inference thread and the control thread execute asynchronously at the same frequency.

[0029] The inference thread is used to acquire robot operating state data and perform motion control model inference. The control thread is used to generate robot motion control commands based on the robot motion prediction data output by the motion control model and to interact with the robot actuators. Since the inference thread and control thread respectively handle motion control model inference and underlying motion control tasks, and each thread executes its tasks according to its own independent loop sequence, they achieve synchronous and asynchronous operation. For example, the first preset loop period is 10ms, and the second preset loop period is 10ms, which are the same. When the inference thread starts, it executes its tasks in a 10ms loop. The control thread starts 3ms after the inference thread and executes its tasks in a 10ms loop. Therefore, while the inference thread is performing motion control model inference, the control thread does not need to wait for the inference thread to complete the inference. Instead, it executes the robot motion control command generation and sending tasks according to the second preset loop period. This ensures that the motion control model inference process and the robot motion control process remain independent in terms of task execution, forming a synchronous and asynchronous dual-thread operation mode.

[0030] S102. Obtain robot running status data through the inference thread, and perform motion control model inference based on the robot running status data to generate robot motion prediction data. Write the robot motion prediction data into the inter-thread shared data area. The robot running status data includes sensor acquisition data and motion control feedback data. The inter-thread shared data area is used to realize data interaction between the inference thread and the control thread. The inference thread executes inference tasks according to a first preset cycle. Within each first preset cycle, the inference thread acquires the current robot's operational status data. Sensor-collected data may include body angular velocity, body Euler angles, and user control commands acquired by the Inertial Measurement Unit (IMU). Motion control feedback data may include joint positions, joint velocities, joint torques, and temperature data fed back by the robot's actuators. In some specific embodiments, the inference thread constructs current observation data based on the acquired robot operational status data and combines it with historical observation data corresponding to multiple consecutive first preset cycles to form the input data for the motion control model. For example, 15 consecutive frames of observation data are stitched together and input into the motion control model. Each frame of observation data includes gait phase, user control commands, joint positions, joint velocities, previous action output, body angular velocity, and body Euler angles. Subsequently, the motion control model performs forward inference on the input data to obtain motion data, and then performs pruning and de-standardization processing on the motion data to obtain robot motion prediction data that conforms to the standard.

[0031] After completing the motion control model inference, the inference thread writes the robot motion prediction data into the inter-thread shared data area. The inter-thread shared data area is used to temporarily store the robot motion prediction data generated by the inference thread, and allows the control thread to retrieve it within its corresponding second preset cycle. This enables the inference thread to continue executing the next inference task according to the first preset cycle after completing the inference task of the current cycle.

[0032] S103. The control thread obtains robot motion prediction data from the shared data area between threads, generates robot motion control commands based on the robot motion prediction data, sends the robot motion control commands to the robot actuator, obtains motion control feedback data from the robot actuator, and updates the motion control feedback data to the shared data area between threads for the inference thread to perform subsequent motion state inference.

[0033] The control thread executes control tasks according to a second preset cycle. Within each second preset cycle, the control thread obtains robot motion prediction data from the shared data area between threads and determines the motion control targets corresponding to each robot actuator based on the robot motion prediction data. For example, the robot motion prediction data can correspond to the target positions of each robot joint. The control thread generates corresponding robot motion control commands based on the target positions of each joint and sends these commands to the corresponding control motors (i.e., the robot actuators in this application). After receiving the robot motion control commands, the robot actuators execute the corresponding movements and feed back motion state feedback data reflecting the motion state during execution to the control thread. After obtaining the motion control feedback data, the control thread updates the shared data area between threads, enabling subsequent inference threads, when running according to the first preset cycle, to obtain the updated motion control feedback data and combine it with new sensor data to form the robot running state data required for subsequent motion control model inference.

[0034] Specifically, please refer to Figure 2 , Figure 2 This is another flowchart illustrating an embodiment of the robot motion control method based on synchronous asynchronous dual-threading provided in this application. After the robot motion control task is started, it first enters the initialization state and completes the loading of the motion control model. Subsequently, the inference thread and the main control thread (i.e., the control thread in this application) are started respectively. The inference thread sequentially completes the collection of observation data, gait phase calculation, data standardization processing, motion control model inference, and motion data update according to a preset cycle. It provides the generated motion data to the main control thread through the shared data domain (i.e., the thread-to-thread shared data area in this application). The main control thread reads the motion data according to an independent cycle and uses it to generate robot motion control commands, which are sent to the motors (i.e., the robot actuators in this application). At the same time, it receives motor feedback data (i.e., motion control feedback data in this application) and updates it to the shared data domain. In addition, the external hardware driver layer is responsible for the interaction of sensor data, user remote control commands, and motor control and feedback data, thereby realizing motion control.

[0035] In this embodiment, the inference thread acquires robot operating status data and executes motion control model inference, writing the generated robot motion prediction data into the inter-thread shared data area. The control thread acquires robot motion prediction data from the inter-thread shared data area and generates robot motion control commands. Simultaneously, it acquires motion control feedback data from the robot actuator and updates it to the inter-thread shared data area. Since the inference thread and the control thread run according to a first preset cycle and a second preset cycle, respectively, and the first preset cycle and the second preset cycle are the same, the inference thread and the control thread determine the execution sequence of the corresponding cycle based on their respective independent cycle timing mechanisms. This allows the inference thread and the control thread to execute independently at the same frequency, avoiding fluctuations in the control command sending cycle due to the interdependence of the cycle execution sequences of the inference thread and the control thread. This reduces the impact of the model inference process on the robot motion control process, enabling the robot actuator to receive motion control commands at relatively stable time intervals, thereby improving the smoothness of robot joint movements and the stability of robot motion control.

[0036] Furthermore, by sharing a data area between threads, robot motion prediction data can be transmitted from the inference thread to the control thread, and motion control feedback data from the robot actuator can be updated by the control thread to the shared data area between threads for the inference thread to perform subsequent motion state inference. This forms a continuous interaction between robot operating state data, motion control model inference results, and motion control feedback data, improving the motion control model's responsiveness to changes in robot operating state.

[0037] In Example 2, since the inference thread executes model inference and updates robot motion prediction data according to a first preset cycle, and the control thread reads this data and generates motion control commands according to a second preset cycle, to avoid the control thread obtaining outdated or distorted motion prediction data due to abnormalities or delays in the inference thread, the timeliness of the robot motion prediction data is verified when the control thread obtains the robot motion prediction data. Please refer to [link to example]. Figure 3 , Figure 3 This is a flowchart illustrating Embodiment 2 of the robot motion control method based on synchronous asynchronous dual threads in this application. The embodiment includes: S301. The control thread acquires the action data mutex lock, and under the protection of the action data mutex lock, it acquires the robot action prediction data and the corresponding inference timestamp from the shared data area between threads. After acquiring the robot action prediction data and the corresponding inference timestamp, it releases the action data mutex lock. A mutex lock is a synchronization mechanism that controls the mutual exclusion of multiple concurrent execution units accessing shared resources or critical sections by locking and unlocking, ensuring that at most one thread can enter the shared resource or critical section at any given time. Since both the inference thread and the control thread need to access robot motion prediction data in the shared data area between threads, the access process for robot motion prediction data needs to be protected to prevent data inconsistency caused by one thread reading data while another thread updates it. In this application, a motion data mutex lock is introduced when the control thread reads robot motion prediction data to ensure the integrity of the data reading process. For example, the action data mutex is called `actionmutex`. When the control thread needs to read robot action prediction data, it first acquires the `actionmutex`. After successful acquisition, the control thread, protected by the `actionmutex`, copies the robot action prediction data and the corresponding inference timestamp from the inter-thread shared data area to its local variable. After completing the data copy, the control thread immediately releases the `actionmutex`, allowing it to continue executing subsequent data processing tasks. If the inference thread needs to update the robot action prediction data in the inter-thread shared data area, it must wait for the control thread to release the `actionmutex` before acquiring it and performing the update operation. When the inference thread acquires the `actionmutex` and updates the robot action prediction data, the control thread must wait for the inference thread to release the `actionmutex` before acquiring it, thus performing the robot action prediction data reading operation. This avoids concurrent interleaving of the reading and updating processes of robot action prediction data in the inter-thread shared data area between the control thread and the inference thread.

[0038] In some specific embodiments, corresponding mutex locks are set for different types of data in the shared data area between threads to restrict concurrent access of the inference thread and the control thread to the same shared data during the reading and writing processes at the same time. Each mutex lock is held only during data copying or writing and is released immediately after the corresponding operation is completed. The following is a detailed explanation: 1. Acquire the sensor data mutex lock through the inference thread, and under the protection of the sensor data mutex lock, obtain the sensor data collected from the robot's running status data from the shared data area between threads. After obtaining the sensor data, release the sensor data mutex lock. For example, the inference thread acquires the sensor data mutex (the sensor data mutex in this application). Under the protection of the sensor data mutex, the current sensor acquisition data is read from the shared data area between threads and copied to the local variable of the inference thread. Since the sensor acquisition data may be continuously updated by the external hardware driver layer, if the data is updated while the inference thread is reading the data, the acquisition time corresponding to different data items in the same set of sensor acquisition data may be inconsistent. Protecting the access process with the sensor data mutex allows the inference thread to obtain a complete copy of the data in a single read. After the data copy is completed, the sensor data mutex is released immediately. Subsequent observation data construction and motion control model inference are all based on the local variable and no longer continuously occupy the sensor data mutex.

[0039] 2. Acquire the feedback data mutex lock through the inference thread, and under the protection of the feedback data mutex lock, obtain motion control feedback data from the robot's running status data in the shared data area between threads. After obtaining the motion control feedback data, release the feedback data mutex lock.

[0040] For example, after completing the reading of sensor data, the inference thread acquires the feedback mutex, which is the feedback data mutex in this application, and reads motion control feedback data from the shared data area between threads under the protection of the feedback mutex. The motion control feedback data is updated by the control thread after sending the robot motion control command. Therefore, the reading process of the inference thread may be time-interleaved with the data update process of the control thread. Using the feedback mutex to protect the reading process can prevent the inference thread from reading incomplete data during the update process. After the data copying is completed, the feedback mutex is released so that the control thread can continue to update the subsequently generated motion control feedback data.

[0041] 3. Obtain motion control feedback data from the robot actuator through the control thread, and acquire a feedback data mutex lock. Under the protection of the feedback data mutex lock, update the motion control feedback data to the shared data area between threads. After writing the motion control feedback data, release the feedback data mutex lock.

[0042] For example, after the control thread sends the robot's motion control commands to the robot's actuator, it obtains the motion control feedback data generated by the actual execution from the robot's actuator and protects the update process of this data through a feedback mutex. Specifically, after obtaining the feedback mutex, the control thread writes the latest motion control feedback data completely into the shared data area between threads; after completing the write, it immediately releases the feedback mutex; the next time the inference thread obtains the feedback mutex, it can read the most recently updated motion control feedback data from the control thread and use it to construct subsequent robot operating state data.

[0043] It's important to note that, taking the feedback mutex as an example, the feedback mutex is used to protect both the reading and updating of motion control feedback data. However, the inference thread or control thread will not continue executing motion control model inference or sending robot motion control commands while holding the feedback mutex. Instead, it releases the mutex immediately after completing data copying or writing. Therefore, the mutex has a relatively small scope, preventing time-consuming model inference or hardware communication operations from being placed within its protection range. This helps reduce waiting between two threads due to shared data access. Furthermore, since the inference thread and control thread execute their tasks according to independent cycle times, there is a difference in the time required to acquire the mutex. Typically, they do not need to wait for the mutex to be released, thus reducing mutex contention.

[0044] S302. Calculate the time difference between the current timestamp and the corresponding inference timestamp, and compare the time difference with a preset time threshold; The inference thread requires a certain processing time to execute motion control model inference, and this processing time may fluctuate due to factors such as the computational load of the motion control model and the operating environment. In practical applications, the processing time may exceed one or two first preset cycle periods, resulting in a significant time interval between the generation time of robot motion prediction data and the time when the control thread reads the robot motion prediction data. Therefore, it is necessary to determine the timeliness of the acquired robot motion prediction data.

[0045] Specifically, after the control thread completes the reading of the robot motion prediction data and the corresponding inference timestamp, it obtains the current timestamp corresponding to the current control moment and calculates the time difference between the current timestamp and the inference timestamp. Subsequently, the time difference is compared with a preset time threshold to determine whether the currently acquired robot motion prediction data is within the preset time threshold, for example, whether the time difference is less than two first preset cycle periods.

[0046] S303. When the time difference does not exceed the preset time threshold, generate robot motion control instructions based on robot motion prediction data and send the robot motion control instructions to the robot actuator. If the acquired motion prediction data is still within the preset time threshold, it means that the currently acquired robot motion prediction data can still meet the timeliness requirements of robot motion control, and the motion prediction data will continue to be used to generate robot motion control commands.

[0047] S304. When the time difference exceeds the preset time threshold and the number of consecutive exceedances reaches the preset number, refuse to generate robot motion control commands based on robot motion prediction data, and generate robot motion control commands according to the preset safety mode.

[0048] When the time difference exceeds a preset time threshold, the system further assesses the continuity of the timeout, rather than immediately ceasing the use of the current robot motion prediction data. For example, the preset number of times might be set to 3. When the time difference corresponding to the acquired robot motion prediction data exceeds the preset time threshold, the consecutive timeout count is only increased by one. This is because the single inference time of the motion control model may fluctuate due to factors such as processor load and computational tasks, and a single timeout does not indicate a continuous abnormality in the inference process. In this case, robot motion control commands can still be generated based on the robot motion prediction data. If the time difference corresponding to the next acquired robot motion prediction data does not exceed the preset time threshold, the consecutive timeout count is reset to zero, and robot motion control commands continue to be generated based on the acquired robot motion prediction data. When the time difference corresponding to the acquired robot motion prediction data exceeds the preset time threshold for three consecutive times, it indicates that the timeout has been continuously occurring. Continuing to generate robot motion control commands based on the robot motion prediction data may lead to a significant deviation between the control result and the robot's current operating state. In this case, the control thread refuses to generate robot motion control commands based on the robot motion prediction data and instead generates robot motion control commands according to a preset safety mode. Among them, the preset safety mode can generate robot motion control commands according to the fixed standing state, so that the robot's joints can be adjusted to the preset standing position and maintain the standing state, thereby improving the safety of motion control in abnormal situations.

[0049] In this embodiment, by including an inference timestamp in the robot motion prediction data, and having the control thread determine the timeliness of the robot motion prediction data based on the time difference between the current timestamp and the inference timestamp, the control thread can identify time lag in the inference results before generating robot motion control commands. Simultaneously, by setting a consecutive exceedance limit, fluctuations in single inference time consumption will not directly trigger a preset safety mode, avoiding unnecessary control state switching due to occasional data timeouts during robot motion control. Only when multiple consecutive robot motion prediction data acquisitions exceed a preset time threshold will robot motion control commands be generated according to the preset safety mode. This ensures the robot remains stable even when inference delays in the motion control model persist, reducing robot damage caused by unstable actions controlled by lagging robot motion prediction data, thereby improving the stability and safety of robot motion control.

[0050] In Example 3, to prevent the control thread from mistakenly generating robot motion control commands using unreliable data when the inference thread exits abnormally or the motion control model initialization is incomplete, the system checks the inference flag and thread task execution conditions before executing motion control to determine whether to start the thread task in the current cycle. Please refer to [link to example]. Figure 4 , Figure 4 This is a flowchart illustrating Embodiment 3 of the robot motion control method based on synchronous asynchronous dual threads in this application. This embodiment includes: S401. The inference flag is detected by controlling the thread. The inference flag is used to characterize the running status of the inference thread. Inference flags are typically set in the state control program of a robot motion control task to control and characterize the current running state of the inference thread. For example, when the motion control task is initialized and ready to start the inference thread, the inference flag is set to true as a condition for the inference thread to begin its loop. During the inference thread's operation, if an error occurs in the motion control model inference, the inference thread sets the inference flag to false. When the robot motion control task receives an exit command, the state control program can also set the inference flag to false. Therefore, a true inference flag indicates that the inference thread is currently allowed to continue executing its task, while a false inference flag indicates that the inference thread needs to stop and exit its subsequent loop.

[0051] Since the inference thread and the control thread run independently, when the control thread executes the thread task according to the second preset cycle, it cannot directly determine whether the inference thread is still executing motion control model inference normally by the current running state of the control thread. Therefore, after the control thread enters the second preset cycle and before executing the thread task, the inference flag is checked first to obtain the current running state of the inference thread.

[0052] S402. When the inference flag is true and the control thread meets the thread task execution conditions, the control thread acquires the action data mutex lock. The thread task execution conditions are that the control thread completes the preset start-up delay task and acquires the first sensor data. When the inference flag is true, it indicates that the inference thread is in normal operation. At this time, the control thread further determines whether it meets the thread task execution conditions, avoiding directly entering normal motion control based solely on the inference thread's running status. Specifically, after completing the preset start-up delay task and acquiring the first piece of sensor data, the control thread considers that it has the basic conditions to execute normal motion control. For example, a 3-second delay after entering the current second preset cycle can be set as the preset start-up delay task, allowing the motion control model sufficient start-up inference time while waiting for the sensors to start outputting valid sensor data. Only after the preset start-up delay task is completed and the first piece of sensor data has been acquired does the control thread acquire the motion data mutex lock and enter the subsequent robot motion prediction data reading process. This avoids prematurely using robot motion prediction data to drive the robot actuator when the robot has just started, before the model has stabilized or the sensors have generated valid data.

[0053] S403. When the inference flag is false or the control thread does not meet the thread task execution conditions, the control thread generates robot motion control instructions according to the preset safety mode.

[0054] When the inference flag is false or the control thread fails to meet the thread task execution conditions, it indicates that the conditions for normal motion control using robot motion prediction data are not currently met. In this case, the control thread no longer acquires or uses the current robot motion prediction data, but instead generates robot motion control commands according to a preset safety mode. For example, if the control thread has not yet completed the preset start-up delay task or has not yet acquired the first piece of sensor data, it can maintain the robot in a fixed standing state or its current motion state according to the preset safety mode. When the inference flag becomes false, it indicates that the inference thread has exited operation and cannot continue to provide new robot motion prediction data; in this case, it also switches to the preset safety mode.

[0055] In this embodiment, the control thread checks the inference flag before executing the thread task and judges the execution conditions of the control thread in combination with the preset start-up delay task and the first sensor data. This allows the control thread to execute the thread task only after the inference thread is running normally and the robot motion control task has completed the necessary initialization. This avoids unreasonable motion control caused by the motion control model not being stable or the sensors not generating valid data when the robot is first started. At the same time, when the inference thread encounters an abnormality, exits, or the control thread fails to meet the thread task execution conditions, the control thread can stop using robot motion prediction data in time and generate robot motion control instructions according to the preset safety mode. This avoids the continuous output of inapplicable robot motion control instructions due to inference thread abnormalities or incomplete initialization, thereby improving the safety and reliability of the robot motion control process.

[0056] In Example 4, after the inference thread enters a new cycle and before acquiring robot running status data, it also needs to read the inference flag to confirm the running status before the start of the thread task in this cycle. Please refer to [link / reference]. Figure 5 , Figure 5 This is a flowchart illustrating Embodiment 4 of the robot motion control method based on synchronous asynchronous dual threads in this application. This embodiment includes: S501, Detect the inference flag bit through the inference thread; Because the inference thread runs continuously using an independent loop timing mechanism, its running state may change after the previous loop cycle ends. Therefore, it cannot continue executing subsequent tasks solely based on its state when entering the current loop. By checking the inference flag before the thread task is executed in each loop cycle, the inference thread can decide whether to continue executing the current loop based on its latest running state.

[0057] S502. When the inference flag is true, the inference thread is allowed to obtain robot running status data to perform motion control model inference. When the inference flag is detected to be true, the inference thread is allowed to continue executing the inference task of the current cycle. Specifically, the inference thread is allowed to obtain the current sensor acquisition data and motion control feedback data from the inter-thread shared data area, and construct the current observation data based on the acquired robot running status data. It further combines the historical observation data to form the input data of the motion control model, so as to perform motion control model inference and generate robot motion prediction data. Subsequently, the robot motion prediction data is updated to the inter-thread shared data area.

[0058] S503. When the inference flag is false, control the inference thread to exit the loop.

[0059] When the inference flag is detected as false, it indicates that the current loop no longer meets the conditions for continuing motion control model inference. At this point, the inference thread stops acquiring new robot running state data and exits the current loop. For example, if a runtime exception occurs during motion control model inference, the state control program sets the inference flag to false. When the inference thread enters the next loop cycle, it detects the inference flag and exits the loop, ceasing new data acquisition and motion control model inference. Similarly, when the robot motion control task voluntarily exits, the inference flag can also be set to false, allowing the inference thread to terminate normally in the next loop cycle. In this way, the inference thread can exit according to its own loop boundary, rather than being forcibly terminated in the midst of an ongoing thread task, thus avoiding incomplete shared data writing or other thread resource access problems during the exit process.

[0060] In this embodiment, by setting an inference flag at the task execution entry point of each cycle of the inference thread, the inference thread can decide whether to continue executing subsequent tasks based on the latest running state. When running is allowed and running normally, the thread task continues to be executed. When running abnormally or receiving an exit request, the thread exits according to the complete cycle boundary. At the same time, this works in conjunction with the control thread's safety control in abnormal states by detecting the inference flag. This prevents the inference thread from continuing to obtain robot running state data and execute motion control model inference in abnormal states. It also enables the control thread to promptly detect when the inference thread stops running and execute the corresponding preset safety mode, reducing mutual influence between threads in abnormal states and improving the fault isolation capability and operational safety of the robot's motion control task.

[0061] Example 5: Because the execution time of the inference thread or control thread's tasks may fluctuate, if the thread immediately enters the next loop after completing its task, the timing fluctuations will accumulate cycle by cycle, causing loop cycle drift and resulting in unstable data output. Therefore, the inference thread or control thread performs a sleep operation after completing its task to stabilize the thread's loop cycle. Please refer to [link to relevant documentation]. Figure 6 , Figure 6 This is a flowchart illustrating Embodiment 5 of the robot motion control method based on synchronous asynchronous dual threads in this application. This embodiment includes: S601. When the inference thread or control thread starts executing the thread task of the current cycle, record the start timestamp and determine the target sleep end timestamp based on the start timestamp and the corresponding preset cycle. The inference thread and control thread execute thread tasks according to their respective preset cycle periods. To avoid cumulative offsets in subsequent cycle periods due to fluctuations in the execution time of thread tasks within the current cycle, a target sleep end timestamp is determined at the beginning of each cycle period. Specifically, when the inference thread or control thread begins executing the thread task of the current cycle period, it first records the current time as the start timestamp, and then adds the corresponding preset cycle period to this to obtain the target sleep end timestamp. For example, when the preset cycle period is 10ms, if a cycle period starts at 0ms, then 10ms is determined as the target sleep end timestamp for that cycle period; the next cycle period then uses 10ms as the new start time to continue determining subsequent target sleep end timestamps.

[0062] S602. When the inference thread or control thread completes the thread task of the current cycle, control the inference thread or control thread to perform a sleep operation based on the target sleep end timestamp, so that the cycle of the inference thread or control thread is aligned with the corresponding preset cycle.

[0063] After completing the thread task of the current cycle, the system checks whether the target sleep end timestamp has been reached. If the current thread task completes ahead of schedule, the corresponding thread enters a sleep state and remains so until the target sleep end timestamp before entering the next cycle. If the current thread task takes longer than the target sleep end timestamp, no further waiting is required, and the system directly enters the next cycle. By using the absolute time point determined at the beginning of the cycle as the time base for the next cycle, instead of simply entering the next cycle immediately after task completion or waiting a fixed amount of time after task completion, the system avoids the accumulation of execution time fluctuations from a single cycle into subsequent cycles. This also ensures a more uniform output of robot motion prediction data, guaranteeing a consistent time interval between robot motion control commands issued by the control thread and reducing jitter in the robot's actuators.

[0064] In this embodiment, by using target sleep end timestamps based on start timestamps for cyclic scheduling in the inference thread and control thread respectively, the two threads can maintain relatively stable cycle periods under their respective independent timing mechanisms. Even if there are certain execution time fluctuations in tasks such as robot running state data acquisition, motion control model inference, or robot motion control command sending in a certain cycle, these fluctuations will not be directly accumulated into subsequent cycles, thereby reducing timing jitter caused by gradual cycle drift. This allows the inference thread to continuously and uniformly generate robot motion prediction data, while enabling the control thread to send robot motion control commands at stable time intervals.

[0065] Example 6, please refer to Figure 7 This application also provides a robot motion control device based on synchronous and asynchronous dual-threaded operation, including: Creation unit 701 is used to create robot motion control tasks, which include independent inference threads and control threads. The generation unit 702 is used to acquire robot running status data through the inference thread, and perform motion control model inference based on the robot running status data to generate robot motion prediction data, and write the robot motion prediction data into the inter-thread shared data area. The robot running status data includes sensor acquisition data and motion control feedback data. The inter-thread shared data area is used to realize data interaction between the inference thread and the control thread. The control unit 703 is used to obtain robot motion prediction data from the inter-thread shared data area through the control thread, generate robot motion control commands based on the robot motion prediction data, send the robot motion control commands to the robot actuator, obtain motion control feedback data fed back by the robot actuator, and update the motion control feedback data to the inter-thread shared data area for the inference thread to perform subsequent motion state inference. The inference thread runs according to a first preset cycle, and the control thread runs according to a second preset cycle. The first preset cycle and the second preset cycle are the same, and the inference thread and the control thread run based on their own independent loop timing mechanism so that the inference thread and the control thread execute asynchronously at the same frequency.

[0066] Optionally, the control unit 703 is specifically used for: The control thread acquires the action data mutex lock, and under the protection of the action data mutex lock, it obtains robot action prediction data and corresponding inference timestamps from the shared data area between threads. After obtaining the robot action prediction data and corresponding inference timestamps, it releases the action data mutex lock. Calculate the time difference between the current timestamp and the corresponding inference timestamp, and compare the time difference with a preset time threshold; When the time difference does not exceed the preset time threshold, robot motion control commands are generated based on robot motion prediction data and sent to the robot actuator. When the time difference exceeds a preset time threshold and exceeds the preset number of consecutive times, the robot motion control command based on the robot motion prediction data is rejected, and the robot motion control command is generated according to the preset safety mode.

[0067] Optionally, it also includes a first detection unit 704, specifically used for: The inference flag is detected by controlling the thread, and the inference flag is used to characterize the running status of the inference thread; When the inference flag is true and the control thread meets the thread task execution conditions, the control thread acquires the action data mutex lock. The thread task execution conditions are that the control thread completes the preset start-up delay task and acquires the first sensor data. When the inference flag is false or the control thread does not meet the thread task execution conditions, the control thread generates robot motion control instructions according to the preset safety mode.

[0068] Optionally, a second detection unit 705 is also included, specifically for: Detect the inference flag bit through the inference thread; When the inference flag is true, the inference thread is allowed to obtain robot running status data in order to perform motion control model inference; When the inference flag is false, the control inference thread exits the loop.

[0069] Optionally, generation unit 702 is specifically used for: The inference thread acquires the sensor data mutex lock, and under the protection of the sensor data mutex lock, it retrieves the sensor data collected from the robot's operating status data from the shared data area between threads. After acquiring the sensor data, it releases the sensor data mutex lock. The inference thread acquires the feedback data mutex lock, and under the protection of the feedback data mutex lock, retrieves motion control feedback data from the robot's running status data in the shared data area between threads. After retrieving the motion control feedback data, the feedback data mutex lock is released.

[0070] Optionally, the control unit 703 is specifically used for: The control thread obtains motion control feedback data from the robot's actuator and acquires a feedback data mutex lock. Under the protection of the feedback data mutex lock, the motion control feedback data is updated to the shared data area between threads. After writing the motion control feedback data, the feedback data mutex lock is released.

[0071] Optionally, a hibernation unit 706 is also included, specifically for: When the inference thread or control thread begins to execute the thread task of the current cycle, the start timestamp is recorded, and the target sleep end timestamp is determined based on the start timestamp and the corresponding preset cycle. When the inference thread or control thread completes its thread task for the current cycle, it performs a sleep operation based on the target sleep end timestamp, so that the cycle of the inference thread or control thread is aligned with the corresponding preset cycle.

[0072] For specific implementation methods, please refer to [the example]. Figure 1 and Figure 6Examples are not detailed here.

[0073] In the foregoing embodiments, the specific implementation process of the method provided in this application has been described in detail. It should be understood that, to implement the above method, this application also provides corresponding devices and computer-readable storage media, the technical concepts of which are consistent with the foregoing method embodiments, and both are used to implement all or part of the steps in the foregoing method. The technical solutions of the devices and computer-readable storage media involved in this application will be further described below in conjunction with specific embodiments.

[0074] Example 7, please refer to Figure 8 This application also provides a robot motion control device based on synchronous and asynchronous dual-threaded operation, including: Processor 801, memory 802, input / output unit 803, bus 804; The processor 801 is connected to the memory 802, the input / output unit 803, and the bus 804; The memory 802 stores a program, and the processor 801 calls the program to execute any of the methods described above.

[0075] This application also relates to a computer-readable storage medium on which a program is stored, which, when run on a computer, causes the computer to perform any of the methods described above.

[0076] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0077] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.

[0078] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0079] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0080] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, 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. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

Claims

1. A robot motion control method based on synchronous and asynchronous dual-threaded operation, characterized in that, include: Create a robot motion control task, which includes independent inference threads and control threads; The inference thread acquires robot running status data, performs motion control model inference based on the robot running status data, generates robot motion prediction data, and writes the robot motion prediction data into the inter-thread shared data area. The robot running status data includes sensor acquisition data and motion control feedback data. The inter-thread shared data area is used to realize data interaction between the inference thread and the control thread. The control thread obtains the robot motion prediction data from the inter-thread shared data area, generates robot motion control instructions based on the robot motion prediction data, sends the robot motion control instructions to the robot actuator, and simultaneously obtains the motion control feedback data fed back by the robot actuator and updates the motion control feedback data to the inter-thread shared data area for the inference thread to perform subsequent motion state inference. The inference thread runs according to a first preset cycle, and the control thread runs according to a second preset cycle. The first preset cycle and the second preset cycle are the same. The inference thread and the control thread run based on their respective independent loop timing mechanisms, so that the inference thread and the control thread execute asynchronously at the same frequency.

2. The robot motion control method according to claim 1, characterized in that, The robot motion prediction data carries an inference timestamp. The process of obtaining the robot motion prediction data from the inter-thread shared data area via the control thread, generating robot motion control commands based on the robot motion prediction data, and sending the robot motion control commands to the robot actuator includes: The control thread acquires the action data mutex lock, and under the protection of the action data mutex lock, it obtains the robot action prediction data and the corresponding inference timestamp from the shared data area between threads. After obtaining the robot action prediction data and the corresponding inference timestamp, it releases the action data mutex lock. Calculate the time difference between the current timestamp and the corresponding inference timestamp, and compare the time difference with a preset time threshold; When the time difference does not exceed the preset time threshold, a robot motion control command is generated based on the robot motion prediction data, and the robot motion control command is sent to the robot actuator. When the time difference exceeds the preset time threshold and exceeds the preset number of times consecutively, the generation of robot motion control commands based on the robot motion prediction data is rejected, and the robot motion control commands are generated according to the preset safety mode.

3. The robot motion control method according to claim 2, characterized in that, Before acquiring the motion data mutex lock through the control thread, and obtaining the robot motion prediction data and the corresponding inference timestamp from the inter-thread shared data area under the protection of the motion data mutex lock, and releasing the motion data mutex lock after acquiring the robot motion prediction data and the corresponding inference timestamp, the robot motion control method further includes: The inference flag is detected by the control thread, and the inference flag is used to characterize the running state of the inference thread; When the inference flag is true and the control thread meets the thread task execution condition, the action data mutex is acquired through the control thread. The thread task execution condition is that the control thread completes the preset start delay task and acquires the first sensor data. When the inference flag is false or the control thread does not meet the thread task execution conditions, the control thread is controlled to generate robot motion control instructions according to the preset safety mode.

4. The robot motion control method according to claim 1, characterized in that, Before acquiring robot running state data through the inference thread, the robot motion control method further includes: The inference flag is detected through the inference thread; When the inference flag is true, the inference thread is allowed to obtain robot running status data to perform motion control model inference; When the inference flag is false, the inference thread is controlled to exit the loop.

5. The robot motion control method according to claim 1, characterized in that, The process of obtaining robot operating status data through the inference thread includes: The inference thread acquires a sensor data mutex lock, and under the protection of the sensor data mutex lock, it acquires sensor data collected from the robot's operating status data from the shared data area between threads. After acquiring the sensor data, it releases the sensor data mutex lock. The inference thread acquires a feedback data mutex lock, and under the protection of the feedback data mutex lock, retrieves motion control feedback data from the robot's running status data from the shared data area between threads. After retrieving the motion control feedback data, the feedback data mutex lock is released.

6. The robot motion control method according to claim 1, characterized in that, The step of acquiring the motion control feedback data from the robot actuator and updating the motion control feedback data to the inter-thread shared data area includes: The control thread acquires motion control feedback data from the robot actuator and obtains a feedback data mutex lock. Under the protection of the feedback data mutex lock, the motion control feedback data is updated to the inter-thread shared data area. After writing the motion control feedback data, the feedback data mutex lock is released.

7. The robot motion control method according to any one of claims 1 to 6, characterized in that, The robot motion control method further includes: When the inference thread or the control thread starts executing the thread task of the current cycle, the start timestamp is recorded, and the target sleep end timestamp is determined according to the start timestamp and the corresponding preset cycle. When the inference thread or the control thread completes the thread task of the current cycle, the inference thread or the control thread is controlled to perform a sleep operation based on the target sleep end timestamp, so that the current cycle of the inference thread or the control thread is aligned with the corresponding preset cycle.

8. A robot motion control device based on synchronous and asynchronous dual-thread operation, characterized in that, The robot motion control device includes: A creation unit is used to create a robot motion control task, which includes independent inference threads and control threads. The generation unit is used to acquire robot running status data through the inference thread, perform motion control model inference based on the robot running status data, generate robot motion prediction data, and write the robot motion prediction data into the inter-thread shared data area. The robot running status data includes sensor acquisition data and motion control feedback data. The inter-thread shared data area is used to realize data interaction between the inference thread and the control thread. The control unit is configured to obtain the robot motion prediction data from the inter-thread shared data area through the control thread, generate robot motion control instructions based on the robot motion prediction data, send the robot motion control instructions to the robot actuator, obtain the motion control feedback data fed back by the robot actuator, and update the motion control feedback data to the inter-thread shared data area for the inference thread to perform subsequent motion state inference. The inference thread runs according to a first preset cycle, and the control thread runs according to a second preset cycle. The first preset cycle and the second preset cycle are the same. The inference thread and the control thread run based on their respective independent loop timing mechanisms, so that the inference thread and the control thread execute asynchronously at the same frequency.

9. A robot motion control device based on synchronous and asynchronous dual-thread operation, characterized in that, The robot motion control device includes: a processor, a memory, an input / output unit, and a bus; The processor is connected to the memory, the input / output unit, and the bus; The memory stores a program, which the processor invokes to perform the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium contains a program that, when executed on a computer, performs the method as described in any one of claims 1 to 7.