Method for processing sensing data of multiple data types and related device
By using a macro-defined generic mean filtering function to adapt to sensor data of various types, the problem of high complexity and low efficiency in sensor data processing is solved, achieving more efficient data processing and reducing maintenance costs.
Patent Information
- Application Number
- CN202411228511.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-03
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2044-09-03
AI Technical Summary
Existing technologies require setting specific data reading functions for each type of sensor, resulting in high complexity and poor sensor data processing efficiency. Furthermore, the code needs to be re-edited when the sensor device changes.
A generic mean filtering function implemented using macro definitions is used to adapt to sensor data of different types. By defining a read address pointer, a numerical summation variable, a numerical storage variable, and a return value address pointer, a generic mean filtering function is constructed to calculate the mean.
It improves the versatility and scalability of sensor data processing, reduces maintenance costs, improves sensor data processing efficiency, and avoids code duplication and memory waste.
Smart Images

Figure CN119356790B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of handling robot technology, and in particular to a sensor data processing method, system, device and medium adapted to multiple data types. Background Technology
[0002] Currently, automated guided vehicles (AGVs) involve various sensors during operation, such as temperature sensors, humidity sensors, cable sensors (height sensors), and obstacle detection sensors (radar sensors). Different batches of robots are equipped with different types and numbers of sensors, and the data types of these sensors are also different. Existing technologies usually require setting up matching data reading functions for each type of sensor, which is highly complex. Furthermore, in this mode, whenever the sensor device changes, the code needs to be re-edited to read the data, resulting in poor sensor data processing efficiency. Summary of the Invention
[0003] This application provides a sensor data processing method that adapts to multiple data types. This method can adapt to sensor data of different types by using a generic mean filtering function implemented with macro definitions. It does not require writing specific code for each sensor, has better versatility and scalability, and can effectively improve the efficiency of sensor data processing.
[0004] To achieve the above objectives, a first aspect of this application provides a sensor data processing method adaptable to multiple data types, applied to a communication terminal. The communication terminal is equipped with sensors of multiple data types. The method includes: acquiring a sensor data queue received by the communication terminal; determining a target data type corresponding to the sensor data queue; obtaining multiple sensor numerical data of the target data type from the sensor data queue based on a preset target filtering quantity; generating a read address pointer, a sum of values variable, a storage variable, and a return value address pointer corresponding to the multiple sensor numerical data based on the target data type; and passing the read address pointer, the target filtering quantity, the sum of values variable, the storage variable, the return value address pointer, and a preset data byte size as parameters to a generic mean filtering function constructed based on a preset parameter encoding rule; replacing the macro definition code text in the generic mean filtering function according to the read address pointer, the target filtering quantity, the sum of values variable, the storage variable, the return value address pointer, and the data byte size, to compile the generic mean filtering function to calculate the mean of the multiple sensor numerical data, thereby obtaining the mean calculation result of the target data type.
[0005] In some embodiments, the method of obtaining multiple sensor numerical data of the target data type from the sensor data queue based on a preset target filtering quantity includes: determining a target function from multiple function functions according to the target data type; creating an initialization array of the target data type through the target function; reading multiple sensor numerical data corresponding to the target data type from the sensor data according to the preset target filtering quantity; storing the multiple sensor numerical data in the initialization array to obtain a local variable array.
[0006] In some embodiments, generating the read address pointer, summation variable, storage variable, and return value address pointer corresponding to the plurality of sensor numerical data based on the target data type includes: calling the target processing function corresponding to the target data type from a plurality of preset data type processing functions through the target function; and generating the read address pointer, summation variable, storage variable, and return value address pointer corresponding to the local variable array of the target data type through the target processing function.
[0007] In some embodiments, passing the read address pointer, the target filtering quantity, the numerical sum variable, the numerical storage variable, the return value address pointer, and the preset data byte size to a generic mean filtering function constructed based on a preset parameter encoding rule includes: setting the initial values of the numerical sum variable and the numerical storage variable to 0; and calling the generic mean filtering function constructed based on the preset parameter encoding rule through the target processing function to pass the read address pointer, the target filtering quantity, the numerical sum variable, the numerical storage variable, the return value address pointer, and the preset data byte size to the generic mean filtering function according to a preset parameter order.
[0008] In some embodiments, constructing a generic mean filter function based on a preset parameter encoding rule includes the following steps: naming the input parameters according to their parameter types to obtain the code text of the macro definition corresponding to each input parameter; and using a loop statement to encode the code text of the macro definition for mean calculation to obtain the generic mean filter function.
[0009] In some embodiments, replacing the code text of the macro definition in the generic mean filtering function according to the read address pointer, the target filtering quantity, the numerical sum variable, the numerical storage variable, the return value address pointer, and the bytes occupied by the data includes: determining the parameter order corresponding to the read address pointer, the target filtering quantity, the numerical sum variable, the numerical storage variable, the return value address pointer, and the bytes occupied by the data in the generic mean filtering function; and replacing the code text of the macro definition in the generic mean filtering function according to the code text position corresponding to the parameter order.
[0010] In some embodiments, compiling the generic mean filtering function to calculate the mean of the plurality of sensor numerical data to obtain the mean calculation result of the target data type includes: compiling the generic mean filtering function to read the sensor numerical data into the numerical storage variable multiple times based on the read address pointer and the bytes occupied by the data according to the target filtering quantity, and accumulating the read numerical storage variable into the numerical sum variable; calculating the mean of the numerical sum variable according to the target filtering quantity, and storing the mean calculation result in the memory pointed to by the return value address pointer.
[0011] To achieve the above objectives, a second aspect of this application provides a sensor data processing system adaptable to multiple data types. The system includes: an application layer, configured to acquire a sensor data queue received by a communication terminal, determine the target data type corresponding to the sensor data queue, and obtain multiple sensor numerical data of the target data type from the sensor data queue based on a preset target filtering quantity; a constraint layer, configured to generate a read address pointer, a sum of values variable, a storage variable, and a return value address pointer corresponding to the multiple sensor numerical data based on the target data type, and pass the read address pointer, the target filtering quantity, the sum of values variable, the storage variable, the return value address pointer, and a preset data byte size as parameters to a generic mean filtering function constructed based on a preset parameter encoding rule; and an execution layer, configured to replace the macro definition code text of the generic mean filtering function according to the read address pointer, the target filtering quantity, the sum of values variable, the storage variable, the return value address pointer, and the data byte size, to compile the generic mean filtering function to calculate the mean of the multiple sensor numerical data, thereby obtaining the mean calculation result of the target data type.
[0012] To achieve the above objectives, a third aspect of the present application provides an electronic device, comprising: at least one processor; at least one memory for storing at least one program; and, when at least one of the programs is executed by at least one of the processors, implementing the sensor data processing method adapted to multiple data types as described in any one of the first aspects.
[0013] To achieve the above objectives, a fourth aspect of the present application provides a computer-readable storage medium storing computer-executable instructions for performing a sensor data processing method adapted to multiple data types as described in any one of the fourth aspects.
[0014] This application provides a sensor data processing method, system, device, and storage medium adaptable to multiple data types. It can obtain a sensor data queue received by a communication terminal, determine the target data type corresponding to the sensor data queue, and obtain multiple sensor numerical data of the target data type from the sensor data queue based on a preset target filtering quantity. Based on the target data type, it generates a read address pointer, a numerical sum variable, a numerical storage variable, and a return value address pointer corresponding to the multiple sensor numerical data. The read address pointer, target filtering quantity, numerical sum variable, numerical storage variable, return value address pointer, and preset data byte size are passed as parameters to a generic mean filtering function constructed based on preset parameter encoding rules. In the generic mean filtering function, the macro definition code text is replaced according to the read address pointer, target filtering quantity, numerical sum variable, numerical storage variable, return value address pointer, and data byte size to compile the generic mean filtering function and calculate the mean of the multiple sensor numerical data to obtain the mean calculation result of the target data type. The aforementioned communication terminal may include a handling robot. Based on the different types of sensor data received by the communication terminal, this application can define pointers and variables of different data types to substitute into the generic mean filtering function defined by the macro for macro replacement of the code text, thereby realizing the output of the mean calculation results of different data types. It is understood that by defining variables and pointers before macro replacement to constrain the type of the input parameters, the risk of runtime errors of this application can be effectively reduced. Furthermore, through macro code text replacement, the generic mean filtering function can be adapted to sensor data of multiple data types, so there is no need to set multiple different types of mean summation functions. Since the processing functions of all data types reuse the macro replacement of the same generic mean filtering function, code duplication is avoided, memory space is saved, and this application has better versatility and scalability. Moreover, when the data type of the sensor changes, this application can adapt to the new data type without re-editing a large amount of code, which can effectively reduce maintenance costs and improve the efficiency of sensor data processing. Attached Figure Description
[0015] Figure 1 Another method flowchart of a sensor data processing method adapted to multiple data types provided in an embodiment of this application;
[0016] Figure 2 Another method flowchart of a sensor data processing method adapted to multiple data types provided in an embodiment of this application;
[0017] Figure 3 Another method flowchart of a sensor data processing method adapted to multiple data types provided in an embodiment of this application;
[0018] Figure 4 Another method flowchart of a sensor data processing method adapted to multiple data types provided in an embodiment of this application;
[0019] Figure 5 Another method flowchart of a sensor data processing method adapted to multiple data types provided in an embodiment of this application;
[0020] Figure 6 Another method flowchart of a sensor data processing method adapted to multiple data types provided in an embodiment of this application;
[0021] Figure 7 Another method flowchart of a sensor data processing method adapted to multiple data types provided in an embodiment of this application;
[0022] Figure 8 A schematic diagram of a sensor data processing system adapted to multiple data types provided in an embodiment of this application;
[0023] Figure 9 A schematic diagram of the sensor data processing system provided in one embodiment of this application when it is installed on the AGV motherboard;
[0024] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0026] In some embodiments, although functional modules are divided in the system diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the system or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the foregoing drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0027] Furthermore, unless otherwise explicitly specified and limited, the term "connection / linkage" should be interpreted broadly, for example, it can be a fixed connection or a movable connection, a detachable connection or a non-detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection or a connection that can communicate with each other; it can be a direct connection or an indirect connection through an intermediate medium.
[0028] In the description of the embodiments in this application, the terms "one embodiment / implementation," "another embodiment / implementation," or "some embodiments / implementations," "in the above embodiments / implementations," etc., refer to specific features, structures, materials, or characteristics described in conjunction with embodiments or examples that are included in at least two embodiments or implementations disclosed in this application. In this application disclosure, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or implementation. It should be noted that although a logical order is shown in the flowcharts, in some cases, the steps shown or described may be performed in a different order than that shown in the flowcharts.
[0029] Currently, automated guided vehicles (AGVs) involve various sensors during operation, such as temperature sensors, humidity sensors, cable sensors (height sensors), and obstacle detection sensors (radar sensors). Different batches of robots are equipped with different types and numbers of sensors, and the data types of these sensors are also different. Existing technologies usually require setting up matching data reading functions for each type of sensor, which is highly complex. Furthermore, in this mode, whenever the sensor device changes, the code needs to be re-edited to read the data, resulting in poor sensor data processing efficiency.
[0030] Therefore, in order to overcome the limitations of the prior art, this application provides a sensor data processing method that adapts to multiple data types. The method includes obtaining multiple sensor numerical data of a target data type from a sensor data queue based on a preset target filtering quantity, and generating read address pointers, summation variables, storage variables, and return value address pointers corresponding to the multiple sensor numerical data, so as to pass the parameters to a generic mean filtering function constructed based on preset parameter encoding rules; in the generic mean filtering function, the code text of the macro definition is replaced according to the read address pointer, target filtering quantity, summation variable, storage variable, return value address pointer, and the bytes occupied by the data, thereby obtaining the mean calculation result of the target data type of the multiple sensor numerical data. In this application, the generic mean filtering function implemented by macro definition can adapt to sensor data of different data types and can effectively improve the sensor data processing efficiency.
[0031] The embodiments of this application will be further described below with reference to the accompanying drawings.
[0032] refer to Figure 1 , Figure 1 This is another flowchart illustrating a sensor data processing method adapted to multiple data types, provided in one embodiment of this application. A first aspect of this application provides a sensor data processing method adapted to multiple data types, applied to a communication terminal. The communication terminal is equipped with sensors of multiple data types. The method includes, but is not limited to, the following steps:
[0033] Step S110: Obtain the sensor data queue received by the communication terminal, determine the target data type corresponding to the sensor data queue, and obtain multiple sensor numerical data of the target data type from the sensor data queue based on the preset target filtering quantity.
[0034] Step S120: Generate read address pointers, sum of values, storage variables and return value address pointers corresponding to multiple sensor numerical data based on the target data type, and pass the read address pointers, target filtering quantity, sum of values, storage variables, return value address pointers and the preset data byte size to the generic mean filtering function constructed based on the preset parameter encoding rules.
[0035] In step S130, the code text of the macro definition in the generic mean filtering function is replaced according to the read address pointer, target filtering quantity, numerical sum variable, numerical storage variable, return value address pointer, and the bytes occupied by the data. The generic mean filtering function is compiled to calculate the mean of multiple sensor numerical data to obtain the mean calculation result of the target data type.
[0036] The aforementioned communication terminal may include a handling robot. Based on the different types of sensor data received by the communication terminal, this application can define pointers and variables of different data types to substitute into the generic mean filtering function defined by the macro for macro replacement of the code text, thereby achieving the output of the mean calculation results of different data types. It is understood that by defining variables and pointers before macro replacement to constrain the type of the input parameters, the risk of runtime errors in this application can be effectively reduced. Furthermore, through macro code text replacement, the generic mean filtering function can be adapted to sensor data of multiple data types, so there is no need to set multiple different types of mean summation functions. Since the processing functions of all data types reuse the macro replacement of the same generic mean filtering function, code duplication is avoided, memory space is saved, and this application has better versatility and scalability. Moreover, when the data type of the sensor changes, this application can adapt to the new data type without re-editing a large amount of code, which can effectively reduce maintenance costs and improve the efficiency of sensor data processing.
[0037] In some embodiments, the method of this application is a sensor data processing method applicable to different data types, aiming to simplify the processing flow of different sensor data. It is applied to a communication terminal, which refers to a device with data receiving capability, specifically a device equipped with multiple sensors, such as an AGV. The communication terminal is equipped with sensors of multiple data types, which means that multiple types of sensors are installed on the communication terminal, such as temperature sensors, humidity sensors, height sensors (wire sensors), radar sensors, etc.
[0038] In some embodiments, a sensor data queue refers to a set of sensor data arranged in sequence. This data is collected by a communication terminal. The specific type of data in the queue needs to be determined, such as integers or floating-point numbers, in order to perform appropriate processing. Multiple sensor numerical data of the target data type are obtained from the sensor data queue based on a preset target filtering quantity, where the target filtering quantity refers to the number of data points that need filtering processing. A certain number of data points are selected from the sensor data queue for processing.
[0039] In some embodiments, multiple sensor numerical data corresponding to the target data type are generated, including a read address pointer, a numerical sum variable, a numerical storage variable, and a return value address pointer. The read address pointer points to the address of the input data; the numerical sum variable stores the sum of all data; the numerical storage variable stores a copy of the original data; and the return value address pointer points to the memory address where the filtering result is stored. Furthermore, the read address pointer, the target filtering quantity, the numerical sum variable, the numerical storage variable, the return value address pointer, and the preset data size in bytes can be passed as parameters to a generic mean filtering function constructed based on a preset parameter encoding rule. The data size in bytes refers to the number of bytes occupied by each data item in memory.
[0040] In some embodiments, a generic mean filtering function is constructed based on preset parameter encoding rules. By replacing the code text of the macro definition, a mean filtering function can be dynamically constructed to process different types of sensor data. Here, "macro definition" can be understood as using a fixed string text to replace the input parameters during encoding; "macro replacement" can be understood as replacing the "string text" with the actual parameters passed to the function when the function is called, so that the function can realize the reading and writing process of the input parameters based on the original code segment. The difference from traditional procedural interface functions is that the type of the parameter needs to be set during interface encoding, while the macro definition in this application uses a string, and the parameter type does not need to be determined during encoding. The code is replaced with text before compilation to realize the corresponding function function.
[0041] refer to Figure 2 , Figure 2 Another flowchart of a sensor data processing method adapted to multiple data types provided in an embodiment of this application; in some embodiments, multiple sensor numerical data of a target data type are obtained from the sensor data queue based on a preset target filtering quantity, and the method includes, but is not limited to, the following steps:
[0042] Step S210: Determine the target function from multiple function functions based on the target data type;
[0043] Step S220: Create an initialization array for the target data type through the target function, and read multiple sensor values corresponding to the target data type from the sensor data according to the preset target filtering quantity, store the multiple sensor values in the initialization array, and obtain the local variable array.
[0044] In some embodiments, steps S210 and S220 describe how to select a specific number of data points from the sensor data queue for subsequent processing. A target function is determined from multiple function functions based on the target data type. These multiple function functions refer to a pre-prepared set of functions, each corresponding to a data type. The target function selects a suitable function from this set of functions based on the determined target data type. An initialization array for the target data type is created using the target function. This initialization array is a suitable data structure, typically an array, created based on the target data type to store the data to be processed. Further, multiple sensor numerical data points corresponding to the target data type are read from the sensor data according to a preset target filtering quantity. The target filtering quantity is the number of data points that need filtering, as mentioned above. A specified number of data points are read from the sensor data queue, and the multiple sensor numerical data are stored in the initialization array to obtain a local variable array. The read data points are stored in the initialization array, which becomes the local variable array and is only valid within the scope of the current function.
[0045] In some embodiments, the target function `GenericFilter_AverageFlow()` can be as follows:
[0046]
[0047] Here, `float` is the target data type, `GenericQueue_Float` is a generic queue storing `float` values, `pOut_FLOAT` is a pointer to the return value address of the target function, `Number` is the target filtering quantity defined by the target function, and `temp` is the initialization array. It can be understood that the above process is implemented by the application layer, which encapsulates the functions of the constraint layer. Its main function is to add corresponding functional code when other extended functions need to be added. Corresponding to the code above, its function is to read the raw filtering data from the queue and send it to the rule constraint layer for mean filtering. In the specific implementation, the code first reads the data from the queue and stores it in a local variable array, then passes the first address of this array to the rule constraint layer for mean filtering, ultimately obtaining the filtered result.
[0048] refer to Figure 3 , Figure 3 Another flowchart of a sensor data processing method adapted to multiple data types provided in one embodiment of this application; in some embodiments, a read address pointer, a total value variable, a value storage variable, and a return value address pointer corresponding to multiple sensor numerical data are generated based on the target data type. The method includes, but is not limited to, the following steps:
[0049] Step S310: Call the target processing function corresponding to the target data type from among the preset multiple data type processing functions through the target function;
[0050] Step S320: Generate the read address pointer, total value variable, value storage variable, and return value address pointer corresponding to the local variable array of the target data type through the target processing function.
[0051] In some embodiments, steps S310 to S320 describe how to generate variables related to a specific data type. The target function calls the target processing function corresponding to the target data type from a set of preset data type processing functions. The multiple data type processing functions are similar to multiple function functions. These functions are used to process data of different data types. The target processing function selects a suitable processing function from this set of functions according to the target data type. Then, the target processing function can generate the read address pointer, numerical sum variable, numerical storage variable and return value address pointer corresponding to the local variable array of the target data type.
[0052] refer to Figure 4 , Figure 4 Another flowchart of a sensor data processing method adapted to multiple data types provided in an embodiment of this application; in some embodiments, the read address pointer, target filter quantity, numerical sum variable, numerical storage variable, return value address pointer, and preset data byte size are passed as parameters to a generic mean filter function constructed based on preset parameter encoding rules. The method includes, but is not limited to, the following steps:
[0053] Step S410: Set the initial values of the total numerical variable and the numerical storage variable to 0;
[0054] Step S420: The generic mean filtering function, constructed based on preset parameter encoding rules, is called through the target processing function to pass the read address pointer, target filtering quantity, numerical sum variable, numerical storage variable, return value address pointer, and preset data byte size to the generic mean filtering function according to the preset parameter order.
[0055] In some embodiments, steps S410 and S420 illustrate how to pass the required parameters to the generic mean filter function. In step S410, the initial values of the numerical sum variable and the numerical storage variable are set to 0. The numerical sum variable is used to store the sum of all read data, and the numerical storage variable is used to store the result of intermediate calculations or a copy of the original data. Both variables need to be cleared to zero before calculation to avoid the result of the previous calculation affecting the current calculation. In step S420, the generic mean filter function constructed based on the preset parameter encoding rules is called through the target processing function. The preset parameter order specifies the order in which the parameters are passed to the generic mean filter function.
[0056] In some embodiments, the specific multiple data type processing functions can be:
[0057]
[0058]
[0059] In this code, the target data type of `Filter_AverageFloat` is `Float`, and the target data type of `Filter_AverageInt32` is `int`. "pData,Number,DATA_BYTE_4,sum,combine,pOut_int32" correspond to the read address pointer, the target filtering quantity, the number of bytes occupied by the data, the total numerical variable, the numerical storage variable, and the return value address pointer, respectively. This order is the preset parameter order, corresponding to the constraint layer in the system of this application's method. The constraint layer encapsulates the functions of the execution layer, aiming to avoid potential problems when directly calling the unconstrained layer by utilizing the data type checks of the functions. The code above demonstrates two mean filtering functions, one for single-precision floating-point (Float) and the other for 32-bit integer (Int32). The commonality between these two functions is that they both call the generic mean filter function AVERAGE in the same execution layer on their penultimate line. The difference lies in the parameter types passed to this generic mean filter function AVERAGE in the same execution layer: the single-precision floating-point processing function has 'float' or 'float*' type parameters except for the constant parameter (16-bit unsigned integer 'Number'); while the 32-bit integer processing function has 'int' or 'int*' type parameters except for the constant parameter (16-bit unsigned integer 'Number').
[0060] It is conceivable that if a mean filtering function of other data types is required in practical applications, it is only necessary to re-encapsulate a processing function of the corresponding data type and modify the parameters passed to the random layer to the corresponding data type. Since all mean filtering functions call the same macro replacement, code block duplication will not occur, thus avoiding memory waste, effectively reducing maintenance costs, and improving the efficiency of sensor data processing.
[0061] refer to Figure 5 , Figure 5 Another method flowchart for a sensor data processing method adaptable to multiple data types provided in one embodiment of this application; in some embodiments, the method for constructing a generic mean filter function based on preset parameter encoding rules includes, but is not limited to, the following steps:
[0062] Step S510: Name the input parameters according to their parameter types to obtain the code text of the macro definition corresponding to each input parameter;
[0063] Step S520: Use a loop statement to encode the code text of the macro definition into a mean calculation code to obtain the generic mean filtering function.
[0064] In some embodiments, the input parameters refer to the read address pointer, the target filter quantity, the numerical sum variable, the numerical storage variable, the return value address pointer, and the bytes occupied by the preset data; the code text of the macro definition is to make the function more general. Macro definitions can be used to replace specific variable names, so that code can be dynamically generated for different data types. For example, a macro PARAMETER_TYPE can be defined to represent the data type of the input parameter, or other similar macros can be used to represent different parameters.
[0065] In some embodiments, loop statements are used to iterate through each data point in the array and accumulate it, for example, do{...}wh i le(0). The mean calculation code is the code logic written to calculate the mean, which usually involves accumulating all values and then dividing by the number of values. The generic mean filtering function is the final generated function that can accept parameters of different data types and can dynamically adjust the calculation logic according to the type of the input parameter.
[0066] In some embodiments, the input parameters are named according to their parameter types. This includes naming each parameter according to its type (pointer, variable, constant) and following a prescribed naming convention, and generating a corresponding macro definition for each parameter so that it can be correctly referenced in subsequent macro replacement processes. Specifically, pointer parameters begin with a lowercase letter 'p', such as pInput, which represents the address of the input data; variable parameters begin with a lowercase letter 'v', such as vSum, which represents a variable; and constant parameters begin with a lowercase letter 'c', such as cNumber, which represents a constant or variable. It is understood that in this application, the read address pointer and return value address pointer are pointers, the target filtering quantity and the number of bytes occupied by the data are constants, and the numerical sum variable and numerical storage variable are variables.
[0067] In some embodiments, the parameter encoding rules may also include using the do{...}while(0) statement to wrap the code block of macro substitution to ensure the atomicity of macro substitution. The parameters or variables in the macro need to be protected with a pair of separate parentheses. The use of compound statements should be minimized in each line. Use while() instead of for() for looping to compile the generic mean filter function to calculate the mean of multiple sensor numerical data and obtain the mean calculation result of the target data type. This achieves generic programming by using macro substitution technology, so that a mean filter function can handle sensor data of multiple data types. In this way, the code can be simplified, maintenance costs can be reduced, and the reusability and flexibility of the code can be improved.
[0068] In some embodiments, the specific generic mean filtering function is as follows:
[0069]
[0070] Among them, pInput, cNumber, cDataByte, vsum, vCombine, and pOut are the macro definition code text corresponding to the read address pointer, the target filtering quantity, the number of bytes occupied by the data, the total value variable, the value storage variable, and the return value address pointer, respectively. Corresponding to the execution layer of the system in this application, the macro definition first defines two empty type pointers pDistine and pSource, and then uses the memcpy() function in the loop to copy the original data into vCombine in sequence according to the specified basic memory unit size. At the same time, after each copy, vCombine is accumulated into vsum until all data has been processed. Finally, the average of vsum with respect to the number of data is written to the memory location pointed to by pOut to complete the filtering operation. The entire process uses the do...while(0) syntax structure to protect macro replacement, ensuring the portability and security of the code.
[0071] refer to Figure 6 , Figure 6 Another flowchart of a sensor data processing method adapted to multiple data types provided in an embodiment of this application; in some embodiments, the code text of the macro definition in the generic mean filtering function is replaced according to the read address pointer, the target filtering quantity, the numerical sum variable, the numerical storage variable, the return value address pointer, and the bytes occupied by the data. The method includes, but is not limited to, the following steps:
[0072] Step S610: In the generic mean filtering function, determine the order of parameters corresponding to the read address pointer, target filtering quantity, numerical summation variable, numerical storage variable, return value address pointer, and the bytes occupied by the data.
[0073] Step S620: Replace the code text of the macro definition in the generic mean filter function according to the code text position corresponding to the parameter order.
[0074] In some embodiments, the parameter order can be read address pointer, target filter quantity, data byte size, numerical sum variable, numerical storage variable, and return value address pointer. Determining the order of these parameters in the function allows for the execution of macro substitution and actual function calls in subsequent steps.
[0075] It is understandable that the code text of the macro definition is the macro definition related to each parameter generated in step S510. The substitution operation can ensure that the macro definition is replaced with the correct variable name or expression in the actual function body.
[0076] refer to Figure 7 , Figure 7 Another flowchart of a sensor data processing method adapted to multiple data types provided in one embodiment of this application; in some embodiments, a generic mean filtering function is compiled to calculate the mean of multiple sensor numerical data to obtain the mean calculation result of the target data type, and the method includes, but is not limited to, the following steps:
[0077] Step S710: Compile a generic mean filter function to read sensor numerical data into numerical storage variables multiple times based on the read address pointer and the bytes occupied by the data, according to the target filtering quantity, and accumulate the numerical storage variables read multiple times into the numerical sum variable;
[0078] Step S720: Calculate the mean of the total numerical variable according to the target filtering quantity, and store the mean calculation result in the memory pointed to by the return value address pointer.
[0079] In some embodiments, a loop structure is used to read a specified number of data points, reading one data point at a time into a numerical storage variable. After each read, the value of the numerical storage variable is accumulated into a numerical sum variable. If the target filtering quantity is n, this process will be repeated n times to ensure that all the required data is accumulated. Further, the mean of the numerical sum variable is calculated based on the target filtering quantity, and the mean calculation result is stored in the memory pointed to by the return value address pointer. The mean calculation is to calculate the mean by dividing the value of the numerical sum variable by the target filtering quantity, and the calculated mean result will be stored in the memory location pointed to by the return value address pointer.
[0080] refer to Figure 8 , Figure 8 This is a schematic diagram of a sensor data processing system adapted to multiple data types provided in an embodiment of this application. To achieve the above objective, a second aspect of this application provides a sensor data processing system adapted to multiple data types. The system includes: an application layer, used to acquire a sensor data queue received by a communication terminal, determine the target data type corresponding to the sensor data queue, and obtain multiple sensor numerical data of the target data type from the sensor data queue based on a preset target filtering quantity; a constraint layer, used to generate a read address pointer, a numerical sum variable, a numerical storage variable, and a return value address pointer corresponding to the multiple sensor numerical data based on the target data type, and pass the read address pointer, the target filtering quantity, the numerical sum variable, the numerical storage variable, the return value address pointer, and the preset data byte size as parameters to a generic mean filtering function constructed based on a preset parameter encoding rule; and an execution layer, used to replace the macro definition code text of the generic mean filtering function according to the read address pointer, the target filtering quantity, the numerical sum variable, the numerical storage variable, the return value address pointer, and the data byte size in the generic mean filtering function, so as to compile the generic mean filtering function to calculate the mean of the multiple sensor numerical data to obtain the mean calculation result of the target data type.
[0081] refer to Figure 9 , Figure 9 This is a schematic diagram of the sensor data processing system provided in one embodiment of the present application when it is set on the AGV motherboard; in some embodiments, different sensor opening interface modules are connected to the AGV motherboard, and the sensor interface modules are connected to a generic mean filtering module that includes a sensor data processing system that adapts to multiple data types. The sensor data processing system reads the sensor data and sends it to the central processing unit for subsequent data processing.
[0082] Some embodiments of this application provide an electronic device. Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, with reference to... Figure 10The electronic 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 sensor data processing method adapted to multiple data types according to any of the above embodiments. For example, it executes the above-described... Figure 1 Method steps S110 to S130, Figure 2 Method steps S210 to S220, Figure 3 Method steps S310 to S320, Figure 4 Method steps S410 to S420, Figure 5 Method steps S510 to S520, Figure 6 Method steps S610 to S620, Figure 7 Method steps S710 to S720.
[0083] The electronic device 1000 of this application embodiment includes one or more processors 1010 and memory 1020. Figure 10 The example uses a processor 1010 and a memory 1020.
[0084] The processor 1010 and the memory 1020 can be connected via a bus or other means. Figure 10 Taking the example of a connection between China and Israel via a bus.
[0085] Memory 1020, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory 1020 may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory 1020 may optionally include memory 1020 remotely located relative to processor 1010. These remote memories can be connected to electronic device 1000 via a network, and examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0086] In some embodiments, when the processor executes a computer program, it executes the sensor data processing method adapted to multiple data types of any of the above embodiments at preset intervals.
[0087] Those skilled in the art will understand that Figure 10 The device structure shown does not constitute a limitation on the electronic device 1000, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0088] exist Figure 10In the electronic device 1000 shown, the processor 1010 can be used to call the sensor data processing method adapted to multiple data types stored in the memory 1020, thereby realizing the sensor data processing method adapted to multiple data types.
[0089] Based on the hardware structure of the above-mentioned electronic device 1000, various embodiments of the sensor data processing device adapted to multiple data types of this application are proposed. At the same time, the non-transient software program and instructions required to implement the sensor data processing method adapted to multiple data types of the above embodiments are stored in the memory. When executed by the processor, the sensor data processing method adapted to multiple data types of the above embodiments is executed.
[0090] This application also provides a computer-readable storage medium storing computer-executable instructions for performing the aforementioned sensor data processing method adapted to multiple data types. These instructions enable one or more processors to execute the sensor data processing method adapted to multiple data types described in any of the above embodiments, for example, executing the methods described above. Figure 1 Method steps S110 to S130, Figure 2 Method steps S210 to S220, Figure 3 Method steps S310 to S320, Figure 4 Method steps S410 to S420, Figure 5 Method steps S510 to S520, Figure 6 Method steps S610 to S620, Figure 7 Method steps S710 to S720.
[0091] This application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, causing the computer device to perform a sensor data processing method adapted to multiple data types that implements any of the above embodiments, for example, performing the above-described... Figure 1 Method steps S110 to S130, Figure 2 Method steps S210 to S220, Figure 3 Method steps S310 to S320, Figure 4 Method steps S410 to S420, Figure 5 Method steps S510 to S520, Figure 6 Method steps S610 to S620, Figure 7 Method steps S710 to S720.
[0092] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network nodes. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0093] It will be understood by those skilled in the art that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include computer-readable storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer-readable storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer-readable storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, as is known to those skilled in the art, communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
[0094] The above is a detailed description of the preferred embodiments of this application. However, this application is not limited to the above embodiments. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of this application. All such equivalent modifications or substitutions are included within the scope defined by the claims of this application.
Claims
1. A sensor data processing method adaptable to multiple data types, characterized in that, Applied to a communication terminal, the communication terminal being equipped with sensors of multiple data types, the method includes: The sensor data queue received by the communication terminal is obtained, the target data type corresponding to the sensor data queue is determined, and multiple sensor numerical data of the target data type are obtained from the sensor data queue based on a preset target filtering quantity. Based on the target data type, generate the read address pointer, sum of values variable, storage variable and return value address pointer corresponding to the multiple sensor numerical data, and pass the read address pointer, the target filtering quantity, the sum of values variable, the storage variable, the return value address pointer and the preset data byte size to the generic mean filtering function constructed based on the preset parameter encoding rules; In the generic mean filtering function, the code text of the macro definition is replaced according to the read address pointer, the target filtering quantity, the numerical sum variable, the numerical storage variable, the return value address pointer, and the bytes occupied by the data, so as to compile the generic mean filtering function to calculate the mean of the multiple sensor numerical data and obtain the mean calculation result of the target data type.
2. The sensor data processing method adaptable to multiple data types according to claim 1, characterized in that, The method of obtaining multiple sensor numerical data of the target data type from the sensor data queue based on a preset target filtering number includes: The target function is determined from multiple function functions based on the target data type. An initialization array for the target data type is created through the target function, and multiple sensor values corresponding to the target data type are read from the sensor data according to the preset target filtering quantity. The multiple sensor values are stored in the initialization array to obtain a local variable array.
3. The sensor data processing method adaptable to multiple data types according to claim 2, characterized in that, The step of generating the read address pointer, summation variable, storage variable, and return value address pointer corresponding to the multiple sensor numerical data based on the target data type includes: The target function calls the target processing function corresponding to the target data type from a set of preset data type processing functions. The target processing function generates the local variable array of the target data type, including the read address pointer, the sum of values variable, the value storage variable, and the return value address pointer.
4. The sensor data processing method adaptable to multiple data types according to claim 3, characterized in that, The step of passing the read address pointer, the target filtering quantity, the numerical sum variable, the numerical storage variable, the return value address pointer, and the preset data byte size to the generic mean filtering function constructed based on the preset parameter encoding rules includes: Set the initial values of the total numerical variable and the numerical storage variable to 0; The target processing function calls a generic mean filtering function constructed based on preset parameter encoding rules, so as to pass the read address pointer, the target filtering quantity, the numerical sum variable, the numerical storage variable, the return value address pointer, and the preset data byte size to the generic mean filtering function according to the preset parameter order.
5. The sensor data processing method adaptable to multiple data types according to claim 1, characterized in that, The steps for constructing a generic mean filter function based on preset parameter encoding rules are as follows: The input parameters are named according to their parameter types to obtain the code text of the macro definition corresponding to each input parameter; The code text of the macro definition is encoded using a loop statement to calculate the mean, thereby obtaining a generic mean filtering function.
6. The sensor data processing method adaptable to multiple data types according to claim 5, characterized in that, In the generic mean filtering function, the code text of the macro definition is replaced according to the read address pointer, the target filtering quantity, the numerical sum variable, the numerical storage variable, the return value address pointer, and the bytes occupied by the data, including: In the generic mean filtering function, the order of parameters corresponding to the read address pointer, the target filtering quantity, the numerical sum variable, the numerical storage variable, the return value address pointer, and the bytes occupied by the data is determined; The code text of the macro definition in the generic mean filter function is replaced according to the code text position corresponding to the parameter order.
7. The sensor data processing method adaptable to multiple data types according to claim 6, characterized in that, The step of compiling the generic mean filtering function to calculate the mean of the multiple sensor numerical data to obtain the mean calculation result of the target data type includes: Compile the generic mean filtering function to read the sensor numerical data into the numerical storage variable multiple times based on the target filtering quantity according to the read address pointer and the bytes occupied by the data, and accumulate the numerical storage variable read multiple times into the numerical sum variable; The mean of the total numerical variable is calculated based on the target filtering quantity, and the mean calculation result is stored in the memory pointed to by the return value address pointer.
8. A sensor data processing system adaptable to multiple data types, characterized in that, The system includes: The application layer is used to acquire the sensor data queue received by the communication terminal, determine the target data type corresponding to the sensor data queue, and obtain multiple sensor numerical data of the target data type from the sensor data queue based on a preset target filtering quantity. The constraint layer is used to generate a read address pointer, a sum of values variable, a storage variable, and a return value address pointer corresponding to the multiple sensor numerical data based on the target data type, and to pass the read address pointer, the target filtering quantity, the sum of values variable, the storage variable, the return value address pointer, and the preset data byte size to a generic mean filtering function constructed based on a preset parameter encoding rule. The execution layer is used to replace the macro definition code text of the generic mean filtering function according to the read address pointer, the target filtering quantity, the numerical sum variable, the numerical storage variable, the return value address pointer, and the bytes occupied by the data, so as to compile the generic mean filtering function to calculate the mean of the multiple sensor numerical data to obtain the mean calculation result of the target data type.
9. An electronic device, characterized in that, include: At least one processor; At least one memory for storing at least one program; When at least one of the programs is executed by at least one of the processors, the sensor data processing method adaptable to multiple data types as described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing computer-executable instructions for performing a sensor data processing method adapted to multiple data types as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Apparatus and method for performing non-local means filtering using motion estimation circuitry of a graphics processor
CN113409435A
Method and system for generating and installing multi-platform customized system package, and medium
CN116932041A