A file organization and index positioning method for unmanned aerial vehicle flight data
By using a dual-file structure of data files and index files, along with a binary search algorithm, the problem of low efficiency in searching and replaying long-term UAV flight data recordings is solved, enabling rapid positioning and efficient playback.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHENGDU BOOSTOR TECH
- Filing Date
- 2026-03-20
- Publication Date
- 2026-06-30
Smart Images

Figure CN122309460A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a method for organizing and indexing UAV flight data. Background Technology
[0002] During drone flight, the flight control and telemetry systems continuously output a large amount of flight data, including attitude information, GPS location, flight status, and remote control commands. This data is typically recorded for flight playback and process analysis, fault diagnosis and accident reconstruction, performance evaluation and parameter tuning, and maintenance, supervision, and evidence collection. The current standard practice is to write all flight data directly to a log file in chronological order. When replaying or searching for a specific time point, it is usually necessary to read and parse the file sequentially from the beginning until reaching the target time. When the flight duration is long and the data volume is large, the response time for searching and playback becomes significantly longer. Summary of the Invention
[0003] The purpose of this invention is to overcome the shortcomings of the prior art and provide a method for organizing and indexing UAV flight data.
[0004] The objective of this invention is achieved through the following technical solution: a method for organizing and indexing UAV flight data, comprising the following steps:
[0005] S1: Write the received flight data to a data file and generate an index file record and an event log file;
[0006] S2: Read and cache the index file, select the playback file and enter playback mode, and initialize the time interval control;
[0007] S3: Read the first data record, calculate the time interval for the next data record, and replay the data according to the time interval;
[0008] S4: Using binary search based on the index file to locate time;
[0009] S5: Set the data file read position based on the result of the binary search and perform local parsing;
[0010] S6: Parse the event log file and locate the time using event parameters;
[0011] S7: Locate the data position using the index file based on the timestamp.
[0012] Preferably, in step S1, the received flight data is written to a data file as an 8-byte timestamp, an N-byte data body, and a 5-byte end marker.
[0013] Preferably, in step S1, the specific process of generating index file records involves recording the end position of the current data in the data file when writing each data record, and sequentially writing the timestamp of the record and its corresponding end position into the index file to form an index file. Yes, and the index file forms an index sequence arranged in ascending order of time.
[0014] Preferably, in step S1, the specific process of generating the event log file is as follows: when the parsed data contains any event or parameter in the list of events of interest, the timestamp of the data record is obtained from the data storage, and the timestamp is combined with the parsed event parameters of interest and written into the event log file according to the record format of the data file to form an event log of event parameters and timestamps.
[0015] Preferably, in step S3, the 8-byte timestamp of the first data is read and cached. The data body is read again according to the record format until the end marker is read. Then, the difference between the current data timestamp and the previous data timestamp is calculated to calculate the time interval between the two data. Based on the calculated time interval, the playback is either waited or accelerated to simulate the time process in real flight.
[0016] Preferably, in step S4, the specific operation of using binary search to locate the time is to find the two time points closest to the target time and their corresponding data positions in the index cache. If the timestamp found is exactly equal to the target time point, it is considered that the target time point has been found; if they are not completely equal, the two index records before and after the target time point are determined, and the positions of these two records in the data file and the length between them are obtained.
[0017] The present invention has the following advantages: The present invention adopts a dual file structure of data file and index file, and uses a binary search algorithm for time positioning, so that it does not need to scan sequentially from the file header, and can determine the position near the target time in logarithmic time complexity, which greatly reduces IO and parsing overhead, and is suitable for long-term flight recording. Attached Figure Description
[0018] Figure 1 This is a schematic diagram of the process for organizing and indexing UAV flight data. Detailed Implementation
[0019] 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 embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0020] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0021] It should be noted that, unless otherwise specified, the embodiments and features described in this invention can be combined with each other.
[0022] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0023] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, or the orientation or positional relationship commonly used when the product of this invention is in use, or the orientation or positional relationship commonly understood by those skilled in the art. They are used only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this invention. In addition, the terms "first," "second," etc., are only used to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0024] In the description of this invention, it should also be noted that, unless otherwise explicitly specified and limited, the terms "set," "install," "connect," and "link" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.
[0025] In this embodiment, as Figure 1 As shown, a method for organizing and indexing UAV flight data includes the following steps:
[0026] S1: Write the received flight data into a data file and generate an index file record and an event log file. Specifically, during the UAV's flight, flight data from sources such as flight control and telemetry is continuously received. A timestamp is generated for each data record, which is the number of milliseconds from the start of data recording to the receipt of that data. Further, in step S1, the received flight data is written into the data file as an 8-byte timestamp, an N-byte data body, and a 5-byte end marker. Specifically, the milliseconds from the start of data recording to the receipt of this data record are used as an 8-byte timestamp field. The received data body is an N-byte variable-length field. The end marker occupies 5 bytes and is used to mark the end of a data record. That is, each data record in the data file is sequentially [8-byte timestamp] + [N-byte data body] + [5-byte end marker]. Further still, in step S1, the specific processing for generating the index file record involves recording the end position of the current data in the data file when writing each data record, and sequentially writing the timestamp of that record and its corresponding end position into the index file to form... Yes, and the index file forms an index sequence arranged in ascending order of time; the specific process for generating the event log file is as follows: when the parsed data contains any event or parameter in the list of events of interest, the timestamp of the data record is obtained from the data storage, and the timestamp is combined with the parsed event parameters of interest and written into the event log file according to the record format of the data file to form an event log of event parameters and timestamps.
[0027] S2: Read and cache the index file, select the playback file and enter playback mode, and initialize the time interval control; specifically, before opening a flight data file for playback, the playback module first reads and parses the corresponding index file from the beginning, and caches the records in the index file as a dictionary or array structure of <time, data location> to support fast lookup; after the user selects the path of the data file to be played back, the playback system enters playback mode; initialize the "time interval with the next data" to 0 to control the initial reading and playback rhythm.
[0028] S3: Read the first data record, calculate the time interval for the next data record, and play it back according to the time interval. In this embodiment, in step S3, the 8-byte timestamp of the first data record is read and cached. The data body is read according to the record format until the end marker is read. Then, the difference between the current data timestamp and the previous data timestamp is calculated to calculate the time interval between the two data records. The playback is accelerated or waited according to the calculated time interval to simulate the time process in real flight. Then, the process of reading the next data record, parsing, and displaying is repeated until the end.
[0029] S4: Locate the time using a binary search based on the index file. Specifically, the user specifies a target time point by dragging the progress bar in the playback interface. If the target time point is at or before the start time of the file, the data reading position is directly positioned at the first line of the data file, and the process returns to step S3 to start reading again. If the target time point is not at the first line, the cached <time, data position> index data is used, and a binary search method is employed. Further, the specific operation of locating the time using binary search involves searching in the index cache for the two time points closest to the target time and their corresponding data positions. If the found timestamps are exactly equal to the target time point, the target time point is considered to have been found. If they are not completely equal, the two index records surrounding the target time point are determined, and the positions of these two records in the data file and the length between them are obtained.
[0030] S5: Set the data file read position based on the result of the binary search and perform local parsing; specifically, based on the result of the binary search, set the data file read position to the data position corresponding to the earlier time point in the selected index, and read the data file sequentially from that position according to the data file format until the target time is reached or the user's playback requirements are met. Then continue with normal playback according to step S3.
[0031] S6: Parse the event log file and locate the time using event parameters; specifically, when it is necessary to jump to a specific event (GPS location, flight event, flight phase, etc.), the event log file is first parsed, the event parameters are analyzed, and duplicate parameter values can be deduplicated and cached. When the user selects a specific event parameter value (such as a flight phase, an obstacle event, or a GPS point), the system finds the timestamp corresponding to that event parameter based on the cached event log. This invention generates event log files for events of interest during the parsing process and finds the timestamp through event parameters during playback, then locates the data position using a time index. This allows for quick jumps to the location of critical events such as takeoff, landing, and obstacle encounters without rescanning the entire original data file, supporting efficient accident analysis and demonstration playback.
[0032] S7: Locate the data position using the index file based on the timestamp. That is, using the binary search method described in step S4, locate the specific position in the data file within the cache index using the timestamp, thus enabling playback from the event to the data. This invention employs a dual-file structure of a data file and an index file, and uses a binary search algorithm for time location. This eliminates the need for sequential scanning from the file header, allowing the determination of the location near the target time within logarithmic time complexity, significantly reducing I / O and parsing overhead, and making it suitable for long-duration flight recordings.
[0033] Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for organizing and indexing UAV flight data, characterized in that: Includes the following steps: S1: Write the received flight data to a data file and generate an index file record and an event log file; S2: Read and cache the index file, select the playback file and enter playback mode, and initialize the time interval control; S3: Read the first data record, calculate the time interval for the next data record, and replay the data according to the time interval; S4: Using binary search based on the index file to locate time; S5: Set the data file read position based on the result of the binary search and perform local parsing; S6: Parse the event log file and locate the time using event parameters; S7: Locate the data position using the index file based on the timestamp.
2. The method for organizing and indexing UAV flight data according to claim 1, characterized in that: In step S1, the received flight data is written into a data file with an 8-byte timestamp, an N-byte data body, and a 5-byte end marker.
3. The method for organizing and indexing UAV flight data according to claim 2, characterized in that: In step S1, the specific process for generating index file records involves recording the end position of the current data in the data file when writing each data record, and sequentially writing the timestamp of the record and its corresponding end position into the index file to form an index file. Yes, and the index file forms an index sequence arranged in ascending order of time.
4. The method for organizing and indexing UAV flight data according to claim 3, characterized in that: In step S1, the specific process of generating the event log file is as follows: when the parsed data contains any event or parameter in the list of events of interest, the timestamp of the data record is obtained from the data storage, and the timestamp is combined with the parsed event parameters of interest and written into the event log file according to the record format of the data file to form an event log of event parameters and timestamps.
5. The method for organizing and indexing UAV flight data according to claim 4, characterized in that: In step S3, the 8-byte timestamp of the first data is read and cached. The data body is read again according to the record format until the end marker is read. Then, the difference between the current data timestamp and the previous data timestamp is calculated to calculate the time interval between the two data. Based on the calculated time interval, the playback is either waited or accelerated to simulate the time process in real flight.
6. The method for organizing and indexing UAV flight data according to claim 5, characterized in that: In step S4, the specific operation of using binary search to locate the time is to find the two time points closest to the target time and their corresponding data positions in the index cache. If the timestamp found is exactly equal to the target time point, it is considered that the target time point has been found; if they are not completely equal, the two index records before and after the target time point are determined, and the positions of these two records in the data file and the length between them are obtained.