Robot high-frequency data log recording method and device and controller

By configuring a logger and using memory-mapped file technology, the problem of low efficiency in robot logging was solved, enabling orderly recording of high-frequency data and convenient troubleshooting.

CN121858408APending Publication Date: 2026-04-1458 INTELLIGENT TECH (HANGZHOU) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-27
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

In existing technologies, robot logging is inefficient, the logging sequence of different modules is inconsistent, making it difficult to adapt to high-frequency data recording needs and resulting in difficulties in troubleshooting.

Method used

By instantiating multiple loggers, configuring thresholds for log space usage, single log file size, and maximum log dwell time, data is collected at a preset frequency and written to log files using memory-mapped files, achieving efficient and orderly log recording.

Benefits of technology

It enables efficient and orderly log recording of different functional modules of the robot, ensuring the convenience of data analysis and troubleshooting, without affecting the real-time operation of other modules.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121858408A_ABST
    Figure CN121858408A_ABST
Patent Text Reader

Abstract

The invention discloses a robot high-frequency data log recording method and device and a controller, and the method comprises the steps: instantiating a plurality of corresponding log recorders according to a plurality of different log data structures, and configuring various thresholds for each log recorder; the log recording program collects corresponding to-be-recorded data from a preset shared memory area according to a preset collection frequency and each log data structure, and sends the corresponding to-be-recorded data to a cache area of the log recorder corresponding to the log data structure; after the cache region is full of the stored data, detecting the full data cache region by the log recorder, and judging whether the written data volume of the currently associated log file reaches the size threshold value of a single log file or not. The to-be-recorded data of different functional modules of the robot is efficiently and orderly recorded, the log storage occupied space is reasonably controlled, it is ensured that log records cannot affect normal operation of other program modules of the robot, and the development and debugging efficiency and maintenance convenience of the robot are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of robotics, and in particular to a method, apparatus, and controller for high-frequency data logging of robots. Background Technology

[0002] In the field of robotics, especially in the development, debugging, and maintenance of quadrupedal and humanoid robots, logging is an indispensable and crucial step. It provides core evidence for data traceability, performance evaluation, and troubleshooting, ensuring the stable operation and optimization of the robot system. Currently, robot logging primarily uses character printing. Each functional module—joint sensor communication, control algorithm, business logic, etc.—operates independently, printing logs. The printed character logs are then stored one by one into the corresponding storage devices using the operating system's I / O read / write subsystem, thus completing the recording and retention of logs. However, this existing technical solution suffers from several drawbacks. Character printing logging is inefficient and fails to meet the high-frequency recording requirements of robot data. The independent logging by each functional module lacks a unified coordination mechanism, making it difficult to ensure accurate and consistent timing of logs from different modules. Furthermore, the fragmented character logging model makes it impossible to comprehensively trace and analyze the fault occurrence process, and the relationships between relevant variables are difficult to view in a unified manner, significantly hindering efficient troubleshooting. Summary of the Invention

[0003] This invention addresses the shortcomings of existing technologies by providing a method for recording high-frequency data logs for robots, comprising the following steps:

[0004] Multiple log recorders are instantiated based on multiple different log data structures. Each log recorder is configured with a log space occupancy threshold, a single log file size threshold, and a maximum log dwell time threshold. The log data structures are used to adapt to the corresponding types of data to be recorded in the robot.

[0005] According to the preset collection frequency and based on each log data structure, the corresponding data to be recorded is collected from the preset shared memory area and sent to the cache area of ​​the log recorder corresponding to the log data structure; the shared memory area stores the data to be recorded for different functional modules of the robot.

[0006] Once the data storage area in the buffer is full, the logger detects the full data buffer and determines whether the amount of data written to the currently associated log file has reached the threshold for the size of a single log file. If it has not reached the threshold, the data in the full data buffer is written to the current log file through memory-mapped files. If it has reached the threshold, a new log file is created and the data in the full data buffer is written to the new log file through memory-mapped files.

[0007] Preferably, the data to be recorded includes commands and status data from the robot's business logic function module, the robot control algorithm function module, and the robot joint and sensor communication function module.

[0008] Preferably, the logger is configured with dual buffers, wherein sending data to be recorded to the buffer of the logger corresponding to the log data structure specifically includes:

[0009] The data to be recorded is transmitted to the buffer area in the data receiving state within the log recorder;

[0010] The logger continuously monitors whether the buffer for receiving data is full. If it is not full, it continues to record data to be recorded; otherwise, it performs a dual buffer exchange, switching the buffer currently in the data receiving state to the storage state, and switching the other buffer to the data receiving state.

[0011] Preferably, the logger uses an asynchronous thread pool to periodically check the total size of all stored log files and the residence time of each log file. If the total size of any log file exceeds the log space occupancy threshold or the residence time of any log file exceeds the maximum residence time threshold, the log file with the earliest storage time is deleted. This process continues until the total size of the log files does not exceed the log space occupancy threshold and the residence time of any log file does not exceed the maximum residence time threshold.

[0012] Preferably, the logger checks the full data buffer and determines whether the amount of data written to the currently associated log file has reached the single log file size threshold. If not, the data in the full data buffer is written to the current log file via memory-mapped files. If the threshold is reached, a new log file is created, and the data in the full data buffer is written to the new log file via memory-mapped files. Specifically, the logger uses an asynchronous thread pool to call the buffer in the pending storage state and checks whether the amount of data written to the currently associated log file has reached the single log file size threshold. If not, the data in the buffer is written to the current log file via memory-mapped files. If the threshold is reached, a new log file is created, and the data in the buffer is written to the current log file via memory-mapped files. Simultaneously, another buffer in the logger that is in the data receiving state continues to receive and write new data to be recorded with the corresponding log data structure.

[0013] Preferably, the corresponding data to be recorded is collected from the preset shared memory area according to each log data structure, and sent to the buffer area of ​​the log recorder corresponding to the log data structure. Specifically, this includes: collecting the data to be recorded from the preset shared memory area according to each log data structure at a preset collection frequency, and calling the log recording interface of the corresponding log recorder to push the data to be recorded to the buffer area in the log recorder in binary data structure.

[0014] Preferably, the log file exported from the robot side is parsed, the recorded data of the binary data structure is parsed and visualized according to the preset log data structure, and the graphical display is based on the received user-entered commands or selected status data. The displayed content includes visualization analysis information on the fault process and each command or status data.

[0015] The present invention also discloses a robot high-frequency data log recording device, comprising:

[0016] The binary logging module is configured to instantiate multiple loggers corresponding to different log data structures, and to configure log space occupancy thresholds, single log file size thresholds, and maximum log dwell time thresholds for each logger. The log data structures are used to adapt to the corresponding types of data to be recorded in the robot. The module collects the corresponding data to be recorded from a preset shared memory area according to a preset collection frequency and each log data structure, and sends it to the buffer area of ​​the logger corresponding to the log data structure. The shared memory area stores the data to be recorded for different functional modules of the robot.

[0017] The logger is configured to detect when the buffer is full, determine whether the amount of data written to the currently associated log file has reached the threshold for the size of a single log file. If it has not reached the threshold, the data in the full data buffer is written to the current log file via memory-mapped file. If it has reached the threshold, a new log file is created and the data in the full data buffer is written to the new log file via memory-mapped file.

[0018] Preferably, the log parsing module is configured to parse the log files exported from the robot side, parse and visualize the recorded data of the binary data structure according to the preset log data structure, and graphically display the received user-entered commands or selected status data. The displayed content includes visualization analysis information on the fault process and each command or status data.

[0019] Preferably, the binary log recording module is configured to transmit the data to be recorded to the buffer in the corresponding log recorder that is in the data receiving state; the log recorder is configured to detect in real time whether the buffer currently receiving data is full, and if it is not full, continue to record the data to be recorded; otherwise, perform a dual buffer exchange, switch the buffer currently in the data receiving state to the storage state, and switch the other buffer to the data receiving state.

[0020] The present invention also discloses a controller, installed on a robot, comprising: a robot business logic function module, a robot control algorithm function module, a robot joint and sensor communication function module, shared memory, and a robot high-frequency data logging device, wherein the robot high-frequency data logging device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the robot high-frequency data logging method as described above; wherein the shared memory stores commands and status data respectively from the robot business logic function module, the robot control algorithm function module, and the robot joint and sensor communication function module.

[0021] This invention discloses a method, apparatus, and controller for high-frequency data logging of a robot. It instantiates multiple loggers corresponding to different log data structures, configuring each logger with a log space occupancy threshold, a single log file size threshold, and a maximum log dwell time threshold. The logging program then collects corresponding data to be recorded from a preset shared memory area according to a preset collection frequency and each log data structure, and sends it to the buffer of the logger corresponding to that log data structure. When the buffer is full, the logger detects the full data buffer and determines whether the amount of data written to the currently associated log file has reached the single log file size threshold. If not, the data in the full data buffer is written to the current log file via memory-mapped file; if the threshold has been reached, a new log file is created, and the data in the full data buffer is written to the new log file via memory-mapped file. This effectively solves the problems of low efficiency in character printing logs and inconsistent logging sequence among different modules in existing technologies. It enables efficient and orderly recording of data from different functional modules of the robot, such as robot joint and sensor data modules, motion control command and status data modules, and business logic data modules, without affecting the real-time operation of other modules. This provides a strong guarantee for subsequent data analysis, performance analysis, or root cause investigation.

[0022] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0023] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:

[0024] Figure 1 This is a flowchart illustrating a high-frequency data log recording method for robots according to an embodiment of the present invention.

[0025] Figure 2 This is a flowchart illustrating a log recording and parsing scheme disclosed in an embodiment of the present invention.

[0026] Figure 3 This is a schematic diagram of the internal structure of a log recorder disclosed in an embodiment of the present invention.

[0027] Figure 4 This is a flowchart illustrating a log recording program disclosed in an embodiment of the present invention.

[0028] Figure 5 This is a schematic diagram of a log recorder asynchronously checking log space usage and residence time according to an embodiment of the present invention.

[0029] Figure 6 This is a schematic diagram illustrating the process of asynchronously saving data to a storage device using a log recorder, as disclosed in an embodiment of the present invention. Detailed Implementation

[0030] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the described embodiments of the present invention without creative effort are within the scope of protection of the present invention.

[0031] Unless otherwise defined, the technical or scientific terms used herein shall have the ordinary meaning as understood by one of ordinary skill in the art to which this invention pertains. The terms “first,” “second,” and similar terms used in the specification and claims of this patent application do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Similarly, the terms “an” or “a” and similar terms do not indicate a limitation of quantity, but rather indicate the presence of at least one.

[0032] In this embodiment, as shown in the appendix Figure 1 As shown, a method for recording high-frequency data logs of a robot is disclosed, including the following steps:

[0033] Step S1: Instantiate multiple log recorders corresponding to multiple different log data structures, and configure the log space occupation threshold, single log file size threshold and log maximum residence time threshold for each log recorder. The log data structure is used to adapt to the corresponding type of data to be recorded in the robot.

[0034] Specifically, based on the data involved in joint sensor communication in the robot, such as command position / actual position, command speed / actual speed, command current / actual current, temperature, and abnormal error codes, as well as the data associated with IMU sensors, such as attitude angle and angular velocity, the output current and power of the battery, the state machine information output by the motion control algorithm, and the instructions output by the business logic program, multiple log data structures are defined for each type of data, considering their parameter attributes, information dimensions, and recording requirements. These structures are used to collect different types of data. Each log data structure has a specific field design that clarifies the data storage format and scope, ensuring accurate matching of the information in the corresponding type of data to be recorded. Based on the specific definitions of each log data structure, corresponding loggers are instantiated. Considering the differences in the importance levels of different types of data to be recorded, each logger is individually configured with thresholds for log space usage, single log file size, and maximum log dwell time. All threshold configurations are based on the actual storage resources of the robot's embedded computer, and the configuration parameters of each logger are independent of each other.

[0035] In this embodiment, the data to be recorded includes commands and status data from the robot business logic function module, the robot control algorithm function module, and the robot joint and sensor communication function module.

[0036] In another embodiment, the data to be recorded includes instructions output by the robot business logic function module, state machine information output by the robot control algorithm function module, and command position / actual position, command speed / actual speed, command current / actual current, temperature, and abnormal error codes related to the robot joint and sensor communication function module, attitude angle and angular velocity associated with the IMU sensor, and output current and power corresponding to the battery, etc.

[0037] Step S2: Collect the corresponding data to be recorded from the preset shared memory area according to the preset collection frequency and the log data structure, and send it to the cache area of ​​the log recorder corresponding to the log data structure; the shared memory area stores the data to be recorded for different functional modules of the robot.

[0038] Specifically, upon starting the logging program, it collects data at a preset frequency according to the adaptation rules corresponding to each defined log data structure. These adaptation rules are based on the type attributes, parameter dimensions, and storage requirements of the data to be recorded. A pre-established shared memory area serves as the data aggregation carrier. The robot's business logic module, robot control algorithm module, and robot joint and sensor communication module continuously write the commands, state machine information, joint-related commands and status data, sensor monitoring data, battery operating parameters, and other data generated during their respective operations into this shared memory area. The logging program identifies and filters the data in the shared memory area, extracting data that meets the recording requirements according to the adaptation rules of each log data structure, and excluding redundant information that does not need to be recorded. Subsequently, the logging program transmits the collected data to the buffer area of ​​the logger that has a unique matching relationship with the corresponding log data structure, so that different types of data to be recorded are temporarily stored according to preset categories.

[0039] The logging program identifies and filters data in the shared memory area, extracts data that meets the recording requirements according to the adaptation rules of each log data structure, and excludes redundant information that does not need to be recorded. Specifically, the steps include the following:

[0040] Step S101: The log recording program loads the adaptation rule set corresponding to each log data structure. The adaptation rule set includes the data source module identifier, data type identifier, and data valid field list matching dimension. At the same time, it reads the data to be identified in batches from the preset shared memory area and extracts the basic feature information of each data, specifically including the functional module number of the data source, data type label, data generation timestamp, and key identifier of the data field composition structure.

[0041] Step S102 involves verifying the basic feature information of each extracted data entry against the preset matching conditions in the adaptation rules for each log data structure. This includes verifying whether the data source module number matches the business logic / control algorithm / joint sensor communication module specified in the adaptation rules; verifying whether the data type label conforms to the data category to be recorded as defined in the adaptation rules; and verifying whether the data field composition structure is compatible with the field definition of the log data structure. This is used to determine whether the data falls within the scope of the recording requirements.

[0042] Step S103: Retain the data that has passed the verification, extract the valid field information from the data according to the field mapping relationship of the corresponding log data structure; at the same time, mark the redundant data that has not passed the matching verification, perform the redundant information removal operation, release the temporary reading memory space occupied by the redundant data, and push only the valid data that meets the recording requirements to the cache area of ​​the corresponding log recorder.

[0043] In this embodiment, step S2 includes: collecting the data to be recorded from the preset shared memory area according to the preset collection frequency based on each log data structure, and calling the log recording interface of the corresponding log recorder to push the data to be recorded to the buffer area in the log recorder according to the binary data structure.

[0044] The logging program calls the logging interface of the logger that has a unique matching relationship with each log data structure, organizes and arranges the collected data to be recorded according to the preset binary data structure, and pushes the organized binary data to the buffer area in the corresponding logger.

[0045] In another specific embodiment, as shown in the appendix Figure 2 As shown, an embedded computer serves as the core carrier on the robot side. Its integrated robot business logic program, robot control algorithm program, and robot joint and sensor communication program establish a data interaction channel. Joint states, sensor data, motion control commands, and business logic-related data generated by each module are uniformly aggregated through shared memory and transmitted to a binary log recording program. After reading the shared memory data, the program pushes it to N dedicated log recorders (log recorder 1, log recorder 2, to log recorder N) according to preset different frequency parameters and corresponding data structures. The processed data is stored in a storage device and exported as a log file. A log parsing program deployed on the PC side receives the exported log file and parses and visualizes the binary log data according to the defined data structure. Users can select the required commands or status data for graphical display, enabling comprehensive visual analysis of the fault process and various commands or statuses, facilitating troubleshooting of the root cause of the fault.

[0046] In this embodiment, the log file exported from the robot side is parsed, the recorded data of the binary data structure is parsed and visualized according to the preset log data structure, and the graphical display is based on the received user-entered commands or selected status data. The displayed content includes visualization analysis information on the fault process and each command or status data.

[0047] In another embodiment, as shown in the appendix Figure 3 As shown, the internal structure of the logger includes dual buffers, memory-mapped files, an asynchronous thread pool, and a log file rotation module.

[0048] In this embodiment, the logger is configured with dual buffers, wherein sending the data to be recorded to the buffer of the logger corresponding to the log data structure specifically includes:

[0049] The data to be recorded is transmitted to the buffer area in the data receiving state within the log recorder;

[0050] The logger continuously monitors whether the buffer for receiving data is full. If it is not full, it continues to record data to be recorded; otherwise, it performs a dual buffer exchange, switching the buffer currently in the data receiving state to the storage state, and switching the other buffer to the data receiving state.

[0051] Specifically, the logger has two independent buffers built-in, with pre-configured initial states. One buffer is initially set to data receiving state, and the other to storage state, forming a fixed state transition basis. Data to be recorded, organized and arranged according to the corresponding log data structure, is input into the buffer currently in the data receiving state. The logger initiates real-time storage monitoring, continuously checking the storage capacity of the buffer in the data receiving state and determining in real-time whether the amount of stored data matches the preset capacity limit. If the detection result shows that the amount of stored data has not reached the preset capacity limit, the data receiving state of that buffer remains unchanged, and the remaining storage space continues to receive subsequent transmitted data to be recorded. If the detection result shows that the amount of stored data has reached the preset capacity limit, a dual-buffer exchange is immediately triggered, performing a state switching operation. This dual-buffer exchange is configured to switch the buffer currently carrying full data from the data receiving state to the storage state, and simultaneously switch the idle buffer initially in the storage state from the storage state to the data receiving state, ensuring uninterrupted continuous recording of data to be recorded.

[0052] In one embodiment, as shown in the appendix Figure 4 As shown, after the logging program starts, it first defines a log data structure, which is used to collect different types of data later. Then, it instantiates a logger according to the data structure, passing in parameters such as the total size of the log space, the size of a single log, and the maximum log dwell time. After instantiation, the logging program collects the data to be recorded from shared memory according to the required frequency and data structure, and calls the logger's logging interface to put the data into the buffer. The logger checks whether the buffer is full. If not, it returns to the shared memory data collection stage. If it is, it triggers a double buffer swap operation. The full buffer is saved by an asynchronous thread, while the empty buffer continues to receive log data to ensure uninterrupted data collection.

[0053] In this embodiment, the logger uses an asynchronous thread pool to periodically check the total size of all stored log files and the residence time of each log file. If the total size of any log file exceeds the log space occupancy threshold or the residence time of any log file exceeds the maximum residence time threshold, the log file with the earliest storage time is deleted. This process continues until the total size of the log files does not exceed the log space occupancy threshold and the residence time of any log file does not exceed the maximum residence time threshold.

[0054] The logger is configured with a dedicated asynchronous thread pool. This thread pool initiates a check task at a pre-set fixed period, including determining the total file size and residency time of all saved log files corresponding to the current logger. The total file size determination involves cumulatively calculating the storage capacity of all log files under the current logger to obtain overall space usage data. The residency time check involves extracting the generation timestamp of each log file and calculating its duration from generation to the current check time. The check process strictly adheres to the log space usage threshold and the maximum log residency time threshold configured when the logger is instantiated. If the cumulative calculated total log file size exceeds the preset log space usage threshold, or if the residency time of any log file exceeds the preset maximum log residency time threshold, a log file deletion mechanism is immediately triggered, selecting the log file with the earliest current storage time for removal. After the deletion operation is completed, the asynchronous thread pool re-determines the total size and residence time of the remaining log files, repeats the above judgment and deletion process, until the total size of the log files drops to within the log space occupation threshold range, and the residence time of all remaining log files does not exceed the maximum log residence time threshold, then this round of execution is completed.

[0055] In one embodiment, as shown in the appendix Figure 5 As shown, the asynchronous thread pool checks the space occupied by the logs and their residence time to determine whether the total size of the log files exceeds the threshold. If the result is yes, the oldest log file is deleted. If the result is no, it further checks whether the residence time of the log files exceeds the threshold. If the result is yes, the oldest log file is also deleted.

[0056] Step S3: After the data storage area in the buffer is full, the log recorder detects the full data buffer and determines whether the amount of data written to the currently associated log file has reached the threshold of the size of a single log file. If it has not reached the threshold, the data in the full data buffer is written to the current log file through memory mapping. If it has reached the threshold, a new log file is created and the data in the full data buffer is written to the new log file through memory mapping.

[0057] After the logger's asynchronous thread completes the state switch between the two buffers, it immediately responds to the full data buffer processing task, proactively connecting to the buffer and performing data storage pre-operations. First, through a preset mapping and association mechanism, it accurately locates the associated log file corresponding to the full data buffer, clarifying the file's storage path, identification information, and current read / write status to ensure the directionality and accuracy of data writing. Then, the asynchronous thread reads the storage metadata of the associated log file, calculates the total amount of data written, and precisely compares the statistical result with the single log file size threshold configured during logger instantiation to verify the data volume matching. If the verification confirms that the amount of data written to the associated log file has not reached the preset single log file size threshold, the asynchronous thread initiates the memory-mapped file technology application process, establishing a direct memory mapping association between the full data buffer and the associated log file. Through memory address mapping, it achieves direct data transfer, completely writing the binary data from the full data buffer to the corresponding storage area of ​​the associated log file, ensuring efficient and continuous data transmission. If the verification reveals that the amount of data written to the associated log file has reached the threshold for the size of a single log file, the asynchronous thread first executes the creation operation of a new log file according to the preset file creation specifications. The file name is generated using the current system time as the core identifier. At the same time, a standard file header is built for the new log file, embedding basic metadata such as version information, initial number of log records, initial value of effective data size, and start timestamp. After the new log file is created, memory-mapped file technology is also used to establish a memory mapping relationship between the full data buffer and the new log file. All data in the full data buffer is completely written to the new log file, realizing stable storage of data from the buffer to the storage device and completing this round of data storage operation.

[0058] In another embodiment, as shown in the appendix Figure 6 As shown, when the asynchronous thread pool's buffer is full, it is determined whether the data written to the current log file has reached the file size. If the determination result is yes, a new log file is created, and the current system time is used as the file name. If the determination result is no, the data in the buffer is written to the log file and saved by memory-mapped file, thereby reducing I / O overhead.

[0059] In this embodiment, step S3 specifically includes:

[0060] The logger uses an asynchronous thread pool to call the cache that is in the pending storage state and checks whether the amount of data written to the current associated log file has reached the threshold for the size of a single log file. If it has not reached the threshold, the data in the cache is written to the current log file through memory-mapped files. If it has reached the threshold, a new log file is created, and the data in the cache is written to the current log file through memory-mapped files.

[0061] Meanwhile, another buffer in the logger, which is in the data receiving state, continues to receive and write new data to be recorded with the corresponding log data structure.

[0062] Specifically, the asynchronous thread pool configured in the logger has been switched to a full data buffer in a pending storage state. The associated log file corresponding to this buffer is located, the amount of data written is counted, and the result is compared with a preset threshold for the size of a single log file. If the amount of data written has not reached the threshold, a memory mapping relationship is established between the buffer and the associated log file using a memory-mapped file, and the data in the buffer is written to the current associated log file. If the amount of data written has reached the threshold, a new log file is created, with the current system time used as the identifier to generate the filename. Metadata such as version information, the initial number of log records, the initial effective data size, and the start timestamp are embedded in the file header. A memory mapping relationship is established between the buffer and the new log file using a memory-mapped file, and the data in the buffer is completely written to the new log file. During this process, another buffer in the logger, which is in a data receiving state, continuously receives and writes new data to be recorded that is compatible with the corresponding log data structure.

[0063] In this embodiment, a high-frequency data logging device for a robot is also disclosed, characterized in that it includes:

[0064] The binary logging module is configured to instantiate multiple loggers corresponding to different log data structures, and to configure log space occupancy thresholds, single log file size thresholds, and maximum log dwell time thresholds for each logger. The log data structures are used to adapt to the corresponding types of data to be recorded in the robot. The module collects the corresponding data to be recorded from a preset shared memory area according to a preset collection frequency and each log data structure, and sends it to the buffer area of ​​the logger corresponding to the log data structure. The shared memory area stores the data to be recorded for different functional modules of the robot.

[0065] The logger is configured to detect when the buffer is full, determine whether the amount of data written to the currently associated log file has reached the threshold for the size of a single log file. If it has not reached the threshold, the data in the full data buffer is written to the current log file via memory-mapped file. If it has reached the threshold, a new log file is created and the data in the full data buffer is written to the new log file via memory-mapped file.

[0066] The logger is configured with dual buffers; the binary log recording module is configured to pass the data to be recorded into the corresponding buffer in the logger that is in the data receiving state; the logger is configured to detect in real time whether the buffer currently receiving data is full, and if it is not full, continue to record the data to be recorded; otherwise, perform dual buffer switching, switch the buffer currently in the data receiving state to the storage state, and switch the other buffer to the data receiving state.

[0067] In this embodiment, the robot high-frequency data log recording device further includes a log parsing module, which is configured to parse the log file exported from the robot side, parse and visualize the recorded data of the binary data structure according to the preset log data structure, and graphically display the received user-input commands or selected status data, wherein the displayed content includes visualization analysis information on the fault process and each command or status data.

[0068] In this embodiment, the logger is configured to periodically check the total size of all stored log files and the residence time of each log file using an asynchronous thread pool. If the total size of any log file exceeds the log space occupancy threshold or the residence time of any log file exceeds the maximum residence time threshold, the log file with the earliest storage time is deleted. This process continues until the total size of the log files does not exceed the log space occupancy threshold and the residence time of any log file does not exceed the maximum residence time threshold.

[0069] In this embodiment, a controller is also disclosed, installed on a robot, comprising: a robot business logic function module, a robot control algorithm function module, a robot joint and sensor communication function module, shared memory, and a robot high-frequency data logging device. The robot high-frequency data logging device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the robot high-frequency data logging method described above. The shared memory stores commands and status data from the robot business logic function module, the robot control algorithm function module, and the robot joint and sensor communication function module, respectively.

[0070] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

[0071] In summary, the above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made within the scope of the claims of the present invention should be covered by the present invention.

Claims

1. A method for recording high-frequency data logs for a robot, characterized in that, Includes the following steps: Multiple log recorders are instantiated based on multiple different log data structures. Each log recorder is configured with a log space occupation threshold, a single log file size threshold, and a maximum log dwell time threshold. The log data structures are used to adapt to the corresponding types of data to be recorded in the robot. According to the preset collection frequency and based on each log data structure, the corresponding data to be recorded is collected from the preset shared memory area and sent to the buffer area of ​​the log recorder corresponding to the log data structure. The shared memory area stores data to be recorded from different functional modules of the robot; Once the data storage area in the buffer is full, the logger detects the full data buffer and determines whether the amount of data written to the currently associated log file has reached the threshold for the size of a single log file. If it has not reached the threshold, the data in the full data buffer is written to the current log file through memory-mapped files. If it has reached the threshold, a new log file is created and the data in the full data buffer is written to the new log file through memory-mapped files.

2. The robot high-frequency data log recording method according to claim 1, characterized in that: The data to be recorded includes commands and status data from the robot's business logic function module, robot control algorithm function module, and robot joint and sensor communication function module.

3. The robot high-frequency data log recording method according to claim 2, characterized in that, The logger is configured with dual buffers, wherein sending data to be logged to the buffer corresponding to the log data structure specifically includes: The data to be recorded is transmitted to the buffer area in the data receiving state within the log recorder; The logger continuously monitors whether the buffer for receiving data is full. If it is not full, it continues to record data to be recorded; otherwise, it performs a dual buffer exchange, switching the buffer currently in the data receiving state to the storage state, and switching the other buffer to the data receiving state.

4. The robot high-frequency data log recording method according to claim 3, characterized in that, Also includes: The logger uses an asynchronous thread pool to periodically check the total size of all stored log files and the residence time of each log file. If the total size of any log file exceeds the log space threshold or the residence time of any log file exceeds the maximum residence time threshold, the log file with the earliest storage time is deleted. This continues until the total size of the log files does not exceed the log space occupancy threshold and the log file residence time does not exceed the maximum log residence time threshold.

5. The robot high-frequency data log recording method according to claim 4, characterized in that, The logger checks the full data buffer and determines whether the amount of data written to the currently associated log file has reached the single log file size threshold. If not, it writes the data from the full data buffer to the current log file using memory-mapped files. If the threshold has been reached, it creates a new log file and writes the data from the full data buffer to the new log file using memory-mapped files. Specifically, this includes: The logger uses an asynchronous thread pool to call the cache that is in the pending storage state and checks whether the amount of data written to the current associated log file has reached the threshold for the size of a single log file. If it has not reached the threshold, the data in the cache is written to the current log file through memory-mapped files. If it has reached the threshold, a new log file is created, and the data in the cache is written to the current log file through memory-mapped files. Meanwhile, another buffer in the logger, which is in the data receiving state, continues to receive and write new data to be recorded with the corresponding log data structure.

6. The robot high-frequency data log recording method according to claim 5, characterized in that, According to each log data structure, the corresponding data to be recorded is collected from the preset shared memory area and sent to the buffer area of ​​the log recorder corresponding to the log data structure. Specifically, this includes: According to the log data structure, the data to be recorded is collected from the preset shared memory area at the preset collection frequency. The log recording interface of the corresponding log recorder is called to push the data to be recorded to the buffer area in the log recorder in binary data structure.

7. The robot high-frequency data log recording method according to claim 6, characterized in that, It also includes the following steps: The log files exported from the robot side are parsed, and the recorded data of the binary data structure is parsed and visualized according to the preset log data structure. The data is also graphically displayed based on the received user-entered commands or selected status data. The displayed content includes visualization analysis information on the fault process and each command or status data.

8. A high-frequency data log recording device for a robot, characterized in that, include: The binary logging module is configured to instantiate multiple loggers corresponding to multiple different log data structures, and to configure log space occupancy thresholds, single log file size thresholds, and maximum log residence time thresholds for each logger. The log data structures are used to adapt to the corresponding types of data to be recorded in the robot. The module collects the corresponding data to be recorded from a preset shared memory area according to a preset collection frequency and each log data structure, and sends it to the buffer area of ​​the logger corresponding to the log data structure. The shared memory area stores data to be recorded from different functional modules of the robot; The logger is configured to detect when the buffer is full, determine whether the amount of data written to the currently associated log file has reached the threshold for the size of a single log file. If it has not reached the threshold, the data in the full data buffer is written to the current log file via memory-mapped file. If it has reached the threshold, a new log file is created and the data in the full data buffer is written to the new log file via memory-mapped file.

9. The robot high-frequency data log recording device according to claim 8, characterized in that, Also includes: The log parsing module is configured to parse log files exported from the robot side, parse and visualize the recorded data of binary data structure according to the preset log data structure, and graphically display the received user-entered commands or selected status data. The displayed content includes visualization analysis information on the fault process and various commands or status data.

10. A controller, mounted on a robot, characterized in that, include: The robot includes a business logic module, a robot control algorithm module, a robot joint and sensor communication module, shared memory, and a robot high-frequency data logging device. The robot high-frequency data logging device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the robot high-frequency data logging method as described in any one of claims 1-7. The shared memory stores commands and status data from the robot business logic function module, the robot control algorithm function module, and the robot joint and sensor communication function module, respectively.