Sensing execution synchronization method and apparatus, electronic device, and storage medium
By combining device node binding and circular buffer with DMA technology, the problem of large synchronization errors between real-time acquisition of multiple sensors and actuators is solved, achieving low-latency process communication and meeting the accuracy requirements of industrial automation and robot control.
Patent Information
- Application Number
- CN202511211587.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-28
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2045-08-28
AI Technical Summary
Existing technologies suffer from large synchronization errors and high delays in real-time acquisition of data from multiple sensors and precise control of actuators, especially in high-frequency control scenarios, which leads to a deterioration in the synchronization accuracy of industrial robotic arm joints.
By binding the interaction between real-time and non-real-time processes to device nodes through the kernel, using the pre-allocated buffers of the device nodes as data interaction carriers, and employing circular buffers and DMA technology, combined with asynchronous I/O and interrupt triggering mechanisms, direct data transmission and control instruction generation between processes can be achieved.
It effectively reduces communication latency, improves the real-time performance and stability of the system, ensures the accuracy of the actuator, and meets the needs of complex industrial automation and robot control.
Smart Images

Figure CN120729879B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of communication control, in particular to a perception-execution synchronization method and device, electronic equipment and storage medium. BACKGROUND
[0002] In the fields of modern industrial automation, robot control, automatic driving, etc., the real-time collection of multiple sensors and the accurate control of actuators have very high requirements for system real-time performance and synchronization. Perception devices such as cameras and radars need to be accurately coordinated with actuators such as motors and steering engines to quickly respond to environmental changes. In general operating systems (such as standard Linux) and soft real-time environments, the existing synchronization schemes have fundamental limitations. The communication between traditional implementation processes and non-real-time processes causes unpredictable delays due to memory copying and priority inversion. Especially in high-frequency control scenarios, the synchronization error of existing schemes increases exponentially, leading to a deterioration in the synchronization accuracy of high-end industrial robot joints. SUMMARY
[0003] To overcome the defects in the prior art, the present application provides a perception-execution synchronization method, device, electronic equipment and storage medium. In the method, the kernel binds the interaction between real-time processes and non-real-time processes through a device node, so that the non-real-time processes can directly read real-time process data, eliminating the delay loss caused by traditional data copying and protocol conversion, and achieving a two-order-of-magnitude reduction in communication delay compared to the standard Linux scheme.
[0004] To achieve the above-mentioned purpose, the technical scheme adopted by the present application is as follows: a perception-execution synchronization method, comprising the following steps:
[0005] The kernel binds the interaction between real-time processes and non-real-time processes through a device node, pre-allocates a buffer for the device node as a data interaction carrier, and sets up a communication mechanism in the kernel space;
[0006] The driver program completes sensor data collection under the scheduling of the real-time operating system, and writes the sensor data into the buffer based on the communication mechanism;
[0007] The non-real-time processes read the sensor data from the buffer based on the device node and the communication mechanism, analyze and process the data to generate control instructions, and write the control instructions back into the buffer of the real-time memory;
[0008] The real-time processes read the control instructions from the buffer of the real-time memory based on the device node and the communication mechanism, and synchronously output the control instructions to each actuator to perform operations.
[0009] By the technical solution, the kernel binds the interaction between the real-time process and the non-real-time process through a device node, so that the non-real-time process can directly read the real-time process data, eliminates the delay loss caused by traditional data copying and protocol conversion, and realizes a two-order-of-magnitude reduction in communication delay compared with a standard Linux solution.
[0010] Further, the kernel binds the interaction between the real-time process and the non-real-time process through a device node, and pre-allocates a buffer for the device node as a data interaction carrier.
[0011] The kernel allocates a device number for the sensor, creates a device class, and generates a device node based on the device class and the device number.
[0012] The real-time process opens the device node, and the kernel associates the real-time process and the device node through a file descriptor.
[0013] The non-real-time process opens the device node, and the kernel associates the non-real-time process and the device node through a file descriptor.
[0014] The device node permission is configured to enable the real-time process and the non-real-time process to access the device node.
[0015] A buffer is pre-allocated for the device node as a data interaction carrier, and the real-time process and the non-real-time process perform data interaction in the buffer.
[0016] By the technical solution, the real-time process runs in the kernel space, the non-real-time process runs in the user space, the device node is used as an isolation layer to avoid interference of non-real-time operation on real-time tasks, direct communication through the kernel device node is used to reduce context switching overhead and realize low delay, device file permission is used to precisely control access and enhance system security, and the device node is used as a standardized interface to facilitate integration and expansion between different components.
[0017] Further, the communication mechanism includes:
[0018] A ring buffer is allocated for the device node, and the driver, the non-real-time process, and the real-time process access the ring buffer through read and write pointers.
[0019] An asynchronous I / O interface is configured to realize non-blocking read and write of the ring buffer by the non-real-time process.
[0020] Access of the driver, the non-real-time process, and the real-time process to the ring buffer is controlled through a semaphore.
[0021] The driver notifies the non-real-time process to read through an interrupt trigger mechanism after writing sensor data into the buffer, and the non-real-time process notifies the real-time process to read through an interrupt trigger mechanism after writing control instructions into the ring buffer.
[0022] Further, the driver completes sensor data collection under the scheduling of the real-time operating system, and writes sensor data into the buffer area of the real-time memory based on the communication mechanism, including:
[0023] The driver completes sensor data collection under the scheduling of the real-time operating system, and requests the kernel to allocate space for the ring buffer;
[0024] The driver writes sensor data into the ring buffer through the DMA controller;
[0025] After the sensor data is written, a hardware interrupt is triggered, and a semaphore is sent to notify the non-real-time process to read the sensor data.
[0026] Compared with the traditional scheme, the device node simplifies process communication, the ring buffer and DMA improve read-write efficiency, reduce CPU overhead, effectively reduce system delay, and enhance the real-time performance and stability of data processing in industrial scenarios.
[0027] Further, the non-real-time process reads the sensor data from the buffer area of the real-time memory based on the device node and the communication mechanism, analyzes and processes to generate control instructions, and writes them back to the buffer area of the real-time memory:
[0028] The non-real-time process opens the device node based on the communication mechanism to access the ring buffer. If there is no new sensor data in the ring buffer, the non-real-time process enters the kernel waiting queue and releases the CPU resource;
[0029] When the non-real-time process receives the notification, the kernel wakes up the non-real-time process from the waiting queue, and the non-real-time process reads the sensor data from the ring buffer through asynchronous I / O;
[0030] The non-real-time process performs sliding window analysis on the time series data based on a state machine algorithm to generate control instructions;
[0031] The non-real-time process writes the control instructions back to the ring buffer based on the communication mechanism.
[0032] Compared with the traditional scheme, the application avoids blocking through asynchronous I / O, improves analysis efficiency through a state machine, guarantees consistency through memory barriers, reduces delay in industrial control, improves real-time performance and reliability, and reduces resource consumption.
[0033] Further, the real-time process reads control instructions from the buffer area of the real-time memory based on the device node and the communication mechanism, and synchronously outputs them to each actuator to perform operations, including:
[0034] The real-time process is deployed in at least two master stations, and each master station opens the device node to access the ring buffer to read control instructions;
[0035] The preset master station initiates a data synchronization task at a preset time interval, the data synchronization task including updating data of the shared data area by the master station initiating the data synchronization task, and sending a data update notification to other master stations, the other master stations accessing the shared data area based on the data update notification to obtain the latest data.
[0036] Further, the real-time process reads the control instruction from the buffer area of the real-time memory based on the communication mechanism, and synchronously outputs to each actuator to perform an operation, and the method further includes:
[0037] The preset master station initiates a time synchronization task at a preset time interval, the time synchronization task including generating a time synchronization message and sending the time synchronization message to other master stations;
[0038] After receiving the time synchronization message, the other master stations trigger a hardware interrupt, perform a time synchronization task, calculate a time offset based on the time synchronization message, and adjust a local clock based on the time offset.
[0039] The above technical solution takes multi-master station communication as a basic clock, realizes synchronous control of multiple actuators, ensures the accuracy of actuator action, and meets the needs of complex industrial automation and robot control scenarios.
[0040] A perception execution synchronization device includes:
[0041] A task generation module generates a sensor data collection task once every preset time.
[0042] A communication module binds the interaction between the real-time process and the non-real-time process through a device node.
[0043] A real-time data writing module writes sensor data into a buffer area of a real-time memory for reading by a non-real-time process.
[0044] A non-real-time data acquisition module reads the sensor data from the buffer area of the real-time memory and analyzes and processes the sensor data to obtain a control instruction.
[0045] A non-real-time data writing module writes the control instruction into the buffer area of the real-time memory.
[0046] A real-time data acquisition module reads the control instruction from the buffer area of the real-time memory and synchronously outputs the control instruction to each actuator.
[0047] An electronic device comprises at least one communication interface, at least one bus connected with the at least one communication interface, at least one processor connected with the at least one bus, and at least one memory connected with the at least one bus, wherein the memory stores a computer program, and the processor implements the above-mentioned perception execution synchronization method when executing the computer program.
[0048] A storage medium is a computer-readable storage medium, and the storage medium stores a computer program, and the computer program is executed by a multi-core processor to implement the above-mentioned perception execution synchronization method.
[0049] By means of the above technical solutions, the application has the following beneficial effects:
[0050] The perception execution synchronization method disclosed in the application binds the interaction between the real-time process and the non-real-time process through the device node, so that the non-real-time process can directly read the real-time process data, eliminates the delay loss caused by the traditional data copying and protocol conversion, and realizes a reduction of two orders of magnitude in communication delay compared with the standard Linux scheme.
[0051] The perception execution synchronization method disclosed in the application takes EtherCAT multi-master communication as a basic clock, realizes the synchronous control of multiple actuators, ensures the accuracy of the actuator action, and meets the needs of complex industrial automation and robot control scenes.
[0052] In order to make the above and other objects, features and advantages of the present application more apparent, the following will describe a preferred embodiment in detail, and the accompanying drawings will be described as follows. BRIEF DESCRIPTION OF DRAWINGS
[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor.
[0054] Figure 1 It is a flowchart of the perception execution synchronization method in the embodiments of the present application. DETAILED DESCRIPTION
[0055] The technical solutions in the embodiments of the present application will be described in detail below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0056] It should be noted that in the description of the present application, the terms "first", "second" and the like are only used for descriptive purposes and to distinguish similar objects, and there is no prior and posterior order between them, nor can it be understood or implied as indicating or implying relative importance. In addition, in the description of the present application, unless otherwise specified, the meaning of "a plurality of" is two or more.
[0057] Embodiment: In this embodiment, a perception execution synchronization method is disclosed, which performs data interaction according to the flow shown in the figure, and specifically includes the following steps: Figure 1
[0058] S1: Initialize the hard real-time operating system and the driver.
[0059] The hard real-time operating system initialization includes preloading the kinematics algorithm library and the EtherCAT bus configuration; the driver initialization includes configuring the device register, the interrupt vector and the port address, so that the hardware is converted from a physical connection to a logically operable state.
[0060] The hard real-time operating system adopts preemptive priority scheduling, allowing high-priority tasks to interrupt low-priority tasks immediately; supports the earliest deadline first algorithm, dynamically allocates task execution order; and has a built-in deadline monitoring module, which triggers an error callback or system recovery when the timeout occurs. Therefore, the hard real-time operating system can strictly guarantee that the task is completed within a certain time window. Compared with the soft real-time operating system which allows a certain delay, the hard real-time operating system requires strong time constraints. If the task is not completed before the deadline, the system will determine that it is a critical failure, trigger an interrupt to forcibly terminate the fault task, and start a preset recovery process, such as restarting the task or calling an emergency handling program. In this application, the hard real-time operating system is NECRO industrial real-time operating system;
[0061] The driver is a special software in a computer, and its core function is to act as a "translator" and "communication bridge" between the operating system and the hardware device.
[0062] S2: The kernel binds the interaction between real-time processes and non-real-time processes through device nodes, and pre-allocates buffer areas for device nodes, specifically including:
[0063] The kernel allocates a device number for the sensor, creates a device class, and generates a device node based on the device class and the device number, including registering a character device through a kernel module and implementing file operation interfaces such as read / write / ioctl;
[0064] The real-time process opens the device node, and the kernel associates the real-time process with the device node through a file descriptor;
[0065] The non-real-time process opens the device node, and the kernel associates the non-real-time process and the device node through a file descriptor;
[0066] The device node permissions are configured to enable the real-time process and the non-real-time process to access the device node, specifically including: setting access rules through a kernel device permission configuration interface (such as a device access control module): the real-time process is granted read and write permissions to ensure real-time data interaction, and the non-real-time process is granted read-only permissions (to read sensor data) and write permissions under specific conditions (to write control instructions), to ensure process isolation and data security;
[0067] Kernel parameters are optimized, such as disabling CPU frequency scaling and turning off NUMA automatic balancing, to reduce the scheduling delay of real-time tasks.
[0068] In some possible embodiments, event notification is realized through a method combining a device node binding mechanism and a ring buffer state monitoring, specifically including: the kernel initializes a wait list in the ring buffer associated with the device node, the non-real-time process enters the wait list and releases CPU resources when there is no new data in the buffer, the real-time process triggers an event after writing data through DMA, and the kernel wakes up the corresponding non-real-time process from the wait list to enable it to read data through asynchronous I / O.
[0069] The device node is an interface used by an operating system to abstract physical or virtual hardware devices, serving as a bridge for interaction between a user layer and a kernel driver;
[0070] The device number is a coding system used in computer systems and industrial control fields to uniquely identify hardware devices or software resources, and includes a major device number and a minor device number. The major device number uniquely identifies a driver program of a type of device, and the kernel matches the corresponding device driver program in a global driver hash table through the major device number. The minor device number is used by the driver program to distinguish multiple specific devices managed by the same driver program;
[0071] A buffer is a memory area used for temporarily storing data in a computer system, and its core function is to coordinate data interaction between components with different speeds or different time sequences. In a real-time system, a buffer plays a key role in ensuring data integrity, reducing delay, and improving throughput;
[0072] A ring buffer, also known as a circular buffer or a ring queue, is a fixed-size data structure connected at the head and tail, suitable for high-speed data flow processing, asynchronous communication, and resource-constrained scenarios. Its core principle is to achieve efficient data access by recycling pre-allocated memory space.
[0073] A first priority is assigned to a sensor data collection task, and a sensor hardware interrupt is directly bound in an interrupt service program.
[0074] S3: Collect sensor data and write into buffer, specifically including: deploying sensor data collection task in hard real-time operating system, running sensor data collection task every preset time.
[0075] When the hard real-time operating system schedules the sensor module to run the data collection task, the driver controls the sensor to collect sensor data and convert the sensor data into electrical signals.
[0076] When the data collection task is triggered, if the system is processing other tasks, the sensor triggers a hardware interrupt, the system suspends the current task and collects sensor data, and after the sensor data collection is completed, the system returns to the previous task for processing.
[0077] The sensor module includes a camera, a radar, an IMU, etc.
[0078] After the real-time operating system schedules the driver to complete sensor data collection and conversion into electrical signals, the electrical signals are written into the buffer for reading by non-real-time processes, specifically including:
[0079] The driver controls the sensor to collect sensor data and convert the sensor data into electrical signals, and the sensor uses DMA technology to directly write the electrical signals into the kernel pre-allocated ring buffer.
[0080] The DMA (Direct Memory Access) technology is a mechanism that allows external hardware devices to exchange data with system memory directly without CPU intervention, and achieves high-speed data transmission through a dedicated controller (DMAC), significantly improving system efficiency. Specifically:
[0081] The driver applies for a physically address-continuous ring buffer through dma_alloc_coherent(), ensuring that the DMA controller can directly access it;
[0082] The CPU configures DMA parameters, including sensor registers, ring buffer physical addresses, transmission length, and cycle mode flags;
[0083] dmaengine_slave_config() is called to set the DMA controller parameters;
[0084] dma_map_single() is called to establish the DMA mapping relationship between the sensor and the buffer, generate a bus address recognizable by the hardware, and activate the DMA channel ready state;
[0085] After the sensor data (i.e., electrical signals) is ready, a request signal is sent to the DMA controller;
[0086] The DMA controller sends a HOLD signal to the CPU to request the bus, and the CPU releases the bus control and responds to the HLDA signal;
[0087] The controller directly reads and writes the memory and writes the electrical signal into the ring buffer.
[0088] Compared with the traditional scheme, the device node simplifies the process communication, the ring buffer and the DMA improve the reading and writing efficiency, reduce the CPU overhead, effectively reduce the system delay, and enhance the real-time performance and stability of data processing in industrial scenarios.
[0089] The DMA controller writes the electrical signal into the ring buffer and triggers an interrupt request according to a preset condition, and the preset condition includes that the ring buffer is half full or the data transmission is completed.
[0090] S4: The non-real-time process reads sensor data, analyzes and processes to generate control instructions and writes back to the buffer, specifically including: the interrupt service program notifies the non-real-time process to read the data in the ring buffer based on the interrupt request.
[0091] In some possible embodiments, after receiving the notification, the non-real-time process reads the sensor data from the ring buffer and analyzes and processes to obtain control instructions, specifically including:
[0092] The non-real-time process configures an asynchronous I / O mode through an ioctl interface of the device node and registers a callback function of the ring buffer data readiness. When the real-time process writes data through DMA to make the used space of the ring buffer reach a preset threshold, the kernel triggers a semaphore notification, and the asynchronous I / O task of the non-real-time process is activated. The non-real-time process reads data directly from the ring buffer through an aio_read system call. After the asynchronous I / O is completed, the callback function triggers a state machine algorithm to start sliding window analysis on the time series data.
[0093] The state machine algorithm is used to perform sliding window analysis on the time series data and generate control instructions.
[0094] Among them, asynchronous I / O is an efficient data processing mechanism, and its core is to allow the process to return to execute other tasks immediately after initiating the I / O operation, and the kernel completes the I / O and notifies the process of the result through callback, signal or event;
[0095] The state machine algorithm (also known as finite state machine, FSM) is a mathematical model for describing state transitions of a system, which realizes modeling and control of complex logic by defining state sets and their transition rules;
[0096] Sliding window is an algorithm technique for operating on linear data structures such as arrays, strings or time series, which efficiently solves problems by dynamically maintaining a subinterval (window).
[0097] Compared with the traditional scheme, the asynchronous I / O avoids blocking, the state machine improves analysis efficiency, the memory barrier guarantees consistency, reduces delay in industrial control, improves real-time performance and reliability, and reduces resource consumption.
[0098] After the control instruction is generated, the non-real-time process writes the control instruction into the buffer area of the real-time memory, specifically including:
[0099] The non-real-time process opens the node to access the ring buffer, and ensures that the control instruction is written into the ring buffer atomically through the memory barrier.
[0100] The memory barrier (Memory Barrier) is a hardware or software mechanism for forcing the processor to perform memory access operations in a specific order, solving the problem of data inconsistency and instruction rearrangement caused by multi-core processors or compiler optimization.
[0101] S5: The real-time process reads the control instruction and outputs it to the actuator, specifically including: after the control instruction is written into the ring buffer, the real-time process reads the control instruction from the buffer area of the real-time memory and synchronizes it to each actuator module, wherein the real-time process is deployed in at least two master stations, specifically including:
[0102] Each master station opens the device node to access the ring buffer to read the control instruction, and the synchronization process is as follows:
[0103] A second priority is set for each master station, and the second priority is the highest priority.
[0104] The master station that starts the time synchronization task starts the time synchronization task every 1ms, and the time synchronization task includes the master station that starts the time synchronization task generating a time synchronization message containing a local timestamp. Due to the high priority of the master station process, the time synchronization message can be quickly sent to other master stations. When the other master stations receive the time synchronization message, the interrupt controller triggers a hardware interrupt, the system suspends the current task, saves the context, the time synchronization task preempts the current task, and the other master stations calculate the time deviation between the local time and the timestamp in the time synchronization message according to the time synchronization message, and adjust the local clock according to the time deviation. After the time synchronization task is completed, the system context is restored and the original task is continued.
[0105] After the other master stations receive the time synchronization message, if the other master stations are executing a regular data processing task, the interrupt response mechanism preempts the current task quickly, so that the system enters the time synchronization task processing flow. Through this preemption mechanism, the time synchronization message can be processed in a very short time, and combined with the microsecond-level operating system jitter characteristics of the hard real-time operating system, the error in the time synchronization process is greatly reduced, and the time synchronization accuracy reaches the nanosecond level.
[0106] In some possible embodiments, the PLC controller can be configured as a master station.
[0107] The interrupt controller is an independent hardware module in the computer system, in the form of a dedicated chip or integrated inside the processor, and a register group of the interrupt controller supports dynamic configuration of an interrupt triggering mode, a target core and a priority.
[0108] The above technical solution takes multi-master station communication as a basic clock, realizes synchronous control of multiple actuators, ensures the accuracy of actuator action, and meets the needs of complex industrial automation and robot control scenarios.
[0109] The step that the master station reads the control instruction from the buffer area of the real-time memory and synchronizes to each actuator further includes:
[0110] The master station that starts the data synchronization task starts the data synchronization task once every 1 ms, and the data synchronization task includes that the master station that starts the data synchronization task acquires access permission of the shared data area through an atomic access mechanism. The atomic access mechanism regards the shared data area as an indivisible whole. If the access permission is in an idle state, the access permission can be immediately acquired, otherwise, the access permission needs to be waited to be released. The master station that starts the data synchronization task acquires access permission of the shared data area through an atomic access mechanism includes judging whether the shared data area is used by the actuator. If the shared data area is used by the actuator, the master station that starts the data synchronization task requests to acquire access permission of the shared data area according to a preset time interval until the access permission is successfully acquired. After the access permission is acquired, the master station that starts the data synchronization task performs an update operation on data in the shared data area and generates a new data version number. Until the data in the shared data area is updated and the new data version number is generated, the master station releases the access permission.
[0111] After the data is updated and the new data version number is generated, the master station that starts the data synchronization task releases the access permission, and the hard real-time operating system sends a data update notification to other master stations by using a data change notification mechanism, that is, the hard real-time operating system immediately notifies other master stations to acquire access permission through a semaphore.
[0112] When other master stations receive the data update notification, the access right of the shared data area is acquired through the atomic access mechanism, including judging whether the shared data area is used by other executors, if the shared data area is used by other executors, the master station requests to acquire the access right of the shared data area according to the preset time interval until the access right is successfully acquired, the master station updates the local data version number according to the new data version number in the data update notification, and the data synchronization is completed.
[0113] After the data synchronization is completed, each master station synchronizes the control command to the executor module. The executor module includes a rotary executor for driving the shoulder or hip joint of the robot to act, a linear executor for driving the knee joint or mechanical arm of the robot to stretch and retract, and the like.
[0114] The semaphore realizes the quantitative management of the access right through the built-in permission counter (the initial value is usually the maximum concurrency of the resource). When the master station starting the data synchronization task releases the right, the release() operation is performed to atomically increase the counter value, triggering other master stations to acquire the right through the acquire() operation. When the master station starting the data synchronization task releases the right, if other master stations in the waiting queue are blocked due to the execution of acquire(), the semaphore will immediately wake up the other master stations and allocate resources. If there is no waiting, the counter keeps increasing until other master stations initiate a request.
[0115] The shared data area is a centralized data storage area commonly accessed by the master stations and the child nodes, supports the master stations to efficiently distribute the update content to each child node, and guarantees the data consistency, security and availability. In the present application, the shared data area is used to realize the mutual data sharing of multiple master station processes.
[0116] The atomic access mechanism realizes the non-interruptibility of the operation in a single instruction cycle through the CPU atomic instruction, ensures that the operation is completely executed or not executed at all. This atomic access mechanism effectively avoids the additional overhead caused by the process context switching, and is suitable for the scene with short data operation time and high real-time requirement. Since the hard time operating system has the efficient feature, the time for the master station to wait for the data access right is extremely short, thereby guaranteeing the independence of the data operation and preventing the data conflict caused by the simultaneous operation of multiple master stations on the same data.
[0117] When the master station updates the data of the shared data area, other master stations are included in the waiting queue of the data update notification, and the waiting queue of the data update notification is provided with a hard time limit to ensure that the data update notification is delivered to the receiving master station within the deadline.
[0118] The application also discloses a perception execution synchronization device, which comprises:
[0119] The task generation module is configured to generate a data collection task every preset time.
[0120] The communication module is configured to bind the interaction between the real-time process and the non-real-time process through a device node.
[0121] The real-time data writing module is configured to write sensor data by the real-time process into a buffer of a real-time memory for reading by the non-real-time process.
[0122] The non-real-time data acquisition module is configured to read the sensor data from the buffer of the real-time memory by the non-real-time process and analyze and process the sensor data to obtain a control instruction.
[0123] The non-real-time data writing module is configured to write the control instruction by the non-real-time process into the buffer of the real-time memory.
[0124] The real-time data acquisition module is configured to read the control instruction from the buffer of the real-time memory by the master station and synchronize the control instruction to each actuator.
[0125] The application further discloses an electronic device, including: at least one communication interface; at least one bus connected with the at least one communication interface; at least one processor connected with the at least one bus; at least one memory connected with the at least one bus, wherein the memory stores a computer program, and the processor executes the computer program to realize the above-mentioned perception execution synchronization method.
[0126] The application further discloses a storage medium, which is a computer readable storage medium, and the storage medium stores a computer program, and the computer program is executed by a multi-core processor to realize the above-mentioned perception execution synchronization method.
[0127] The principles and implementation manners of the application are described in the specific embodiments, and the above embodiment descriptions are only used to help understand the method and core idea of the application; meanwhile, for those skilled in the art, according to the idea of the application, the specific implementation manners and application ranges will be changed, and the above descriptions should not be understood as the limitation of the application.
Claims
1. A method for synchronizing perception and execution, characterized in that, The method comprises the following steps: The kernel binds the interaction between the real-time process and the non-real-time process through a device node, pre-allocates a buffer for the device node as a data interaction carrier, and comprises the following steps: the kernel allocates a device number for the sensor, creates a device class, and generates a device node based on the device class and the device number; a kernel module registers a character device and implements read / write / ioctl file operation interfaces; the real-time process opens the device node; the kernel associates the real-time process and the device node through a file descriptor; the non-real-time process opens the device node; and the kernel associates the non-real-time process and the device node through a file descriptor; The device node permission is configured: an access rule is set through a kernel device permission configuration interface; the real-time process is given read and write permissions to ensure real-time data interaction; and the non-real-time process is given read-only permission and conditional write permission; The driver program completes sensor data collection under the scheduling of a real-time operating system, and the sensor directly writes sensor data into a pre-allocated physical address continuous ring buffer through DMA technology; The non-real-time process reads the sensor data from the physical address continuous ring buffer based on the device node and a communication mechanism, analyzes and processes the sensor data to generate control instructions, and writes the control instructions into the buffer; The real-time process reads the control instructions from the buffer based on the device node and the communication mechanism, and synchronously outputs the control instructions to each actuator to perform an operation.
2. The method of claim 1, wherein the synchronization is performed by a perception system. The kernel binds the interaction between the real-time process and the non-real-time process through a device node, pre-allocates a buffer for the device node as a data interaction carrier, and comprises the following steps: The kernel allocates a device number for the sensor, creates a device class, and generates a device node based on the device class and the device number; The real-time process opens the device node; and the kernel associates the real-time process and the device node through a file descriptor; The non-real-time process opens the device node; and the kernel associates the non-real-time process and the device node through a file descriptor; The device node permission is configured to enable the real-time process and the non-real-time process to access the device node; A buffer is pre-allocated for the device node as a data interaction carrier, and the real-time process and the non-real-time process perform data interaction in the buffer.
3. The method of claim 2, wherein the synchronization is performed by the perception system. The communication mechanism comprises: A ring buffer is allocated for the device node, and the driver program, the non-real-time process, and the real-time process access the ring buffer through read and write pointers; An asynchronous I / O interface is configured to realize non-blocking read and write of the ring buffer by the non-real-time process; Access of the driver program, the non-real-time process, and the real-time process to the ring buffer is controlled through a semaphore; After the driver program writes sensor data into a physical address continuous ring buffer, the driver program notifies the non-real-time process to read through an interrupt triggering mechanism; and after the non-real-time process writes control instructions into the ring buffer, the non-real-time process notifies the real-time process to read through an interrupt triggering mechanism.
4. The method of claim 3, wherein the synchronization is performed by the perception system. The driver program completes sensor data collection under the scheduling of a real-time operating system, and the sensor directly writes sensor data into a pre-allocated physical address continuous ring buffer through DMA technology, and comprises the following steps: The driver program completes sensor data collection under the scheduling of a real-time operating system, and requests the kernel to allocate space for a physical address continuous ring buffer; The sensor writes sensor data into a physical address continuous ring buffer through a DMA controller; After the sensor data writing is completed, a hardware interrupt is triggered, and a semaphore is sent to notify a non-real-time process to read the sensor data.
5. The method of claim 4, wherein the synchronization is performed by the perception system. The non-real-time process reads the sensor data from the physical address continuous ring buffer based on a device node and a communication mechanism, generates control instructions through analysis and processing, and writes the control instructions into the buffer, including: If there is no new sensor data in the physical address continuous ring buffer, the non-real-time process enters a kernel waiting queue and releases CPU resources; When the non-real-time process receives the notification, the kernel wakes up the non-real-time process from the waiting queue, and the non-real-time process reads the sensor data from the physical address continuous ring buffer through an asynchronous I / O mode; The non-real-time process performs sliding window analysis on the time series data based on a state machine algorithm to generate control instructions; The non-real-time process writes the control instructions back into the ring buffer based on the communication mechanism.
6. The method of claim 5, wherein the synchronization is performed by the perception system. The real-time process reads the control instructions from the buffer based on the device node and the communication mechanism, and synchronously outputs the control instructions to each actuator to perform an operation, including: The real-time process is deployed in at least two master stations, and each master station opens a device node to access the ring buffer to read the control instructions; A preset master station starts a data synchronization task at a preset time interval, and the data synchronization task includes updating data in a shared data area by the master station that starts the data synchronization task, and sending a data update notification to other master stations, and other master stations access the shared data area based on the data update notification to obtain the latest data.
7. The method of claim 6, wherein the synchronization is performed by the perception system. The real-time process reads the control instructions from the buffer based on the communication mechanism, and synchronously outputs the control instructions to each actuator to perform an operation, further including: The preset master station starts a time synchronization task at a preset time interval, and the time synchronization task includes generating a time synchronization message and sending the time synchronization message to other master stations; After receiving the time synchronization message, other master stations trigger a hardware interrupt, perform a time synchronization task, calculate a time deviation based on the time synchronization message, and adjust a local clock based on the time deviation.
8. A perception execution synchronization apparatus, comprising: including: a task generation module for generating a sensor data collection task every preset time; a communication module for binding the interaction between the real-time process and the non-real-time process through a device node, pre-allocating a buffer for the device node as a data interaction carrier; specifically including allocating a device number for the sensor by the kernel, creating a device class, generating a device node based on the device class and the device number, registering a character device by the kernel module and implementing read / write / ioctl file operation interfaces, opening the device node by the real-time process, associating the real-time process and the device node by the kernel through a file descriptor, opening the device node by the non-real-time process, associating the non-real-time process and the device node by the kernel through a file descriptor, and granting the real-time process read and write permissions to ensure real-time data interaction, and granting the non-real-time process only read permissions and conditional write permissions; a real-time data writing module for driving the sensor data collection under the scheduling of a real-time operating system, and directly writing the data into a pre-allocated physical address continuous buffer by the sensor using a DMA technology; A non-real-time data acquisition module for reading the sensor data from the buffer based on the device node and the communication mechanism by a non-real-time process, and generating control instructions through analysis and processing; A non-real-time data writing module for writing the control instructions into the buffer by the non-real-time process; A real-time data acquisition module for reading the control instructions from the buffer based on the device node and the communication mechanism by a real-time process, and synchronously outputting to each actuator to perform operations.
9. An electronic device, comprising: Comprise: At least one communication interface; At least one bus connected with the at least one communication interface; At least one processor connected with the at least one bus; At least one memory connected with the at least one bus, wherein the memory has stored a computer program, and the processor executes the computer program to realize the perception execution synchronization method in any one of claims 1-7.
10. A storage medium, characterized by The storage medium is a computer readable storage medium, and the storage medium has stored a computer program, and the computer program is executed by the multi-core processor to realize the perception execution synchronization method in any one of claims 1-7. The storage medium is a computer readable storage medium, and the storage medium has stored a computer program, and the computer program is executed by the multi-core processor to realize the perception execution synchronization method in any one of claims 1-7.
Citation Information
Patent Citations
Method for synchronizing kernel data of real-time system and non-real-time system of industrial Ethernet numerical control system
CN101819426A
Multi-master-station synchronization method and device and storage medium
CN120281421A