Point cloud data sending method and device based on shared memory and electronic equipment
Through the point cloud data transmission method based on shared memory, the memory structure and data format are determined according to the lidar model, the problem of frame dropping and low efficiency in the Lidar point cloud data transmission is solved, and more efficient and stable data transmission is achieved.
Patent Information
- Application Number
- CN202411010360.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-26
- Publication Date
- 2024-12-13
AI Technical Summary
In autonomous driving scenarios, there are frame drop and low transmission efficiency problems during the point cloud data transmission process generated by lidar. The existing technology has not been effectively solved, especially in the ROS2 framework, the default message transmission mode is not optimized enough, resulting in Memory copy and network protocol processing introduce performance overhead, and the data types of different laser radars of different models lead to the inability to accurately adapt to the message delivery memory structure, affecting transmission efficiency.
Using a point cloud data transmission method based on shared memory, the most matching memory structure is determined according to the target lidar model through the preset shared memory structure library, the point cloud data is adjusted to a fixed length, and the shared memory transmission is enabled in ROS2, and data sharing is set. The mode is Atomic, the optimized message transmission mode is asynchronous sending, and the message publishing frequency is regularly checked to adjust the configuration parameters.
Reduce frame drop rate, improve data transmission efficiency, ensure consistency and stability of data during transmission, reduce data packet fragmentation, improve system responsiveness and stability, adapt to the data structure differences of different models of lidars, and improve data processing and transmission efficiency.
Smart Images

Figure CN119127520A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data communication, and in particular to a method, device and electronic device for sending point cloud data based on shared memory. Background Art
[0002] In autonomous driving scenarios, LiDAR is a key sensor used to perceive the vehicle's surroundings and generate high-resolution point cloud data. LiDAR has high reliability, accurate location information, and sensitivity to environmental changes. It can provide rich native 3D scene information, which is essential for vehicle positioning, obstacle detection, and environmental modeling. The point cloud data generated by LiDAR usually has a large amount of data, which may pose challenges during transmission and processing. In the framework of the software platform (Robot Operating System 2, ROS2) for robot development, the default message transmission mode may not be optimized enough, resulting in serious frame loss during point cloud transmission. In the same domain controller (DomainController), data transmission usually involves memory copying of data and following network protocols, which may introduce additional performance overhead.
[0003] Since different types of laser radars send different amounts of laser point cloud data, the types of data contained in the laser point cloud data are also different, resulting in the inability to accurately adapt the most suitable message passing memory structure when transmitting laser point cloud messages. For example, if a memory structure with a larger data field is selected for transmission, although compatibility is improved, the transmission efficiency will be reduced. If a memory structure with a smaller data field is selected for transmission, it will take a lot of time to merge, which will lead to reduced transmission efficiency.
[0004] However, there is currently no technical solution that can solve the above technical problems, and there is no method, device or electronic device for sending point cloud data based on shared memory. Summary of the invention
[0005] The present invention provides a point cloud data sending method, device and electronic device based on shared memory. The improved shared memory technology is adopted to select the most matching target memory structure for laser point cloud message transmission according to the model of the target laser radar, which can not only reduce the frame loss rate but also improve the transmission efficiency.
[0006] In a first aspect, the present invention provides a method for sending point cloud data based on shared memory, comprising:
[0007] According to the model of the target laser radar, determine the target memory structure from the preset shared memory structure library;
[0008] According to the target memory structure, adjusting the original point cloud data of the target laser radar into fixed-length point cloud data;
[0009] Receive a first input from a user, where the first input is used to define a DDS QoSProfile configuration file in the message middleware ROS2, and set a data sharing mode Data_Sharing to Atomic to enable shared memory transmission;
[0010] In response to the first input, sending the fixed-length point cloud data to a receiving end that subscribes to the target laser radar point cloud data;
[0011] The preset shared memory structure library includes the correspondence between different laser radar models and the memory structure corresponding to each laser radar model.
[0012] According to the shared memory-based point cloud data sending method provided by the present invention, before determining the target memory structure from a preset shared memory structure library according to the model of the target laser radar, the method includes:
[0013] For different models of laser radars, determining the maximum message length of the character string in all point cloud data according to the laser radar;
[0014] Determine a fixed-length memory structure corresponding to the laser radar according to the maximum message length;
[0015] Traverse all laser radars of different models until a fixed-length memory structure corresponding to each laser radar is determined, and store each fixed-length memory structure corresponding to all laser radars into the preset shared memory structure library.
[0016] According to the point cloud data sending method based on shared memory provided by the present invention, the maximum message length of the character string in all point cloud data is determined according to the model of the laser radar, including:
[0017] Acquire all point cloud data, and for each string data, determine the message length of the string data according to a preset field;
[0018] Traverse all string data and determine the longest message length among all string data as the maximum message length of the string;
[0019] For a point cloud message with a sparse structure, the preset field is the Width field;
[0020] For a point cloud message with a non-sparse structure, the preset field is the product of the Height field and the Width field.
[0021] According to the point cloud data sending method based on shared memory provided by the present invention, the fixed-length memory structure corresponding to the laser radar is determined according to the maximum message length, including:
[0022] When the maximum message length is within the first length interval and the laser radar has at least the ability to generate timestamp data and coordinate information, determining that the first length memory structure is a fixed length memory structure, and the first length memory structure includes timestamp data and coordinate information;
[0023] When the maximum message length is within the second length interval and the laser radar has at least the ability to generate timestamp data, coordinate information, and reflection intensity information, determining that the second length memory structure is a fixed length memory structure, and the second length memory structure includes timestamp data, coordinate information, and reflection intensity information;
[0024] When the maximum message length is within the third length interval and the laser radar has at least the ability to generate timestamp data, coordinate information, reflection intensity information and color information, determining that the third length memory structure is a fixed length memory structure, and the third length memory structure includes timestamp data, coordinate information, reflection intensity information and color information;
[0025] The first length interval is smaller than the second length interval, and the second length interval is smaller than the third length interval; the coordinate information includes three-dimensional coordinate information or two-dimensional coordinate information.
[0026] According to the point cloud data sending method based on shared memory provided by the present invention, adjusting the original point cloud data of the target laser radar to fixed-length point cloud data according to the target memory structure includes:
[0027] When the length of the original point cloud data is less than the length of the target memory structure, padding with zeros after the data bits of the original point cloud data to form the fixed-length point cloud data;
[0028] When the length of the original point cloud data is greater than the length of the target memory structure, a warning instruction is generated, wherein the warning instruction is used to issue a warning and exit the current program execution.
[0029] According to the shared memory-based point cloud data sending method provided by the present invention, before receiving the first input from the user, the method further includes:
[0030] A second input from the user is received, where the second input is used to set the message transmission mode to asynchronous sending and to set the data reliability to the Best_Effort mode.
[0031] According to the shared memory-based point cloud data sending method provided by the present invention, after sending the fixed-length point cloud data to a receiving end that subscribes to the target laser radar point cloud data, the method further includes:
[0032] When it is determined that the folder for storing the shared memory file includes a file corresponding to the real-time publish-subscribe transmission middleware library FastRTPS, it is determined that the shared memory transmission is enabled.
[0033] According to the point cloud data sending method based on shared memory provided by the present invention, after determining that shared memory transmission has been enabled, the method further includes:
[0034] At each preset time interval, receiving a third input from the user, the third input being used to check the publishing frequency of the currently transmitted message;
[0035] When it is determined that the message publishing frequency is less than the preset frequency, a check instruction is generated, where the check instruction is used to check the configuration parameters of the shared memory transmission.
[0036] In a second aspect, a point cloud data sending device based on shared memory is provided, comprising:
[0037] A determination unit, the determination unit being used to determine a target memory structure from a preset shared memory structure library according to a model of a target laser radar;
[0038] An adjustment unit, the adjustment unit being used to adjust the original point cloud data of the target laser radar into fixed-length point cloud data according to the target memory structure;
[0039] A receiving unit, the receiving unit is used to receive a first input from a user, the first input is used to define a DDS QoS Profile configuration file in the message middleware ROS2, and set the data sharing mode Data_Sharing to Atomic to enable shared memory transmission;
[0040] A response unit, the response unit being configured to send the fixed-length point cloud data to a receiving end subscribing to the target laser radar point cloud data in response to the first input;
[0041] The preset shared memory structure library includes the correspondence between different laser radar models and the memory structure corresponding to each laser radar model.
[0042] In a third aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the shared memory-based point cloud data sending method when executing the program.
[0043] The present invention simplifies the mechanism of inter-process communication by means of shared memory, reduces the high delay caused by the complex processing mechanism of network transmission, ensures that the data has a consistent size during the transmission process, helps to improve the efficiency and stability of data transmission, and reduces the possibility of data packet fragmentation. Before determining the memory structure corresponding to the laser radar model, the maximum message length of each model of radar is first determined to plan a fixed-length memory structure, so that the data storage in the shared memory is more compact and consistent, which helps to improve the data transmission efficiency and reduce the occupation of system resources;
[0044] The present invention also sets the message transmission mode to asynchronous sending, reduces transmission delay, improves the real-time and responsiveness of messages, and ensures that data can still be sent in the event of network congestion or data loss, thereby improving the stability of the system; regularly checks the message publishing frequency, and performs parameter checks when necessary to ensure the accuracy and performance of the transmission configuration, effectively optimizes the configuration parameters of shared memory transmission, ensures stable data transmission and avoids data loss or delay. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0046] Figure 1 It is a flow chart of a method for sending point cloud data based on shared memory provided by the present invention;
[0047] Figure 2 It is a structural schematic diagram of a point cloud data sending device based on shared memory provided by the present invention;
[0048] Figure 3 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] Figure 1: is a flow chart of a method for sending point cloud data based on shared memory provided by the present invention, wherein the method for sending point cloud data based on shared memory comprises:
[0051] Step 101: Determine a target memory structure from a preset shared memory structure library according to the model of the target laser radar;
[0052] Step 102: adjusting the original point cloud data of the target laser radar to fixed-length point cloud data according to the target memory structure;
[0053] Step 103: Receive a first input from a user, where the first input is used to define a DDSQoS Profile configuration file in the message middleware ROS2, and set the data sharing mode Data_Sharing to Atomic to enable shared memory transmission;
[0054] Step 104: In response to the first input, sending the fixed-length point cloud data to a receiving end that subscribes to the target laser radar point cloud data;
[0055] The preset shared memory structure library includes the correspondence between different laser radar models and the memory structure corresponding to each laser radar model.
[0056] In step 101, according to the model of the target laser radar, the target memory structure is determined from the preset shared memory structure library. The present invention pre-builds a preset shared memory structure library. Specifically, the preset shared memory structure library includes the correspondence between the models of different laser radars and the memory structures corresponding to the model of each laser radar. Then, based on the model of the target laser radar, the preset shared memory structure library is queried to find the memory structure corresponding to the target laser radar model, so as to ensure the accuracy and consistency of the storage structure of the point cloud data in the shared memory, prepare for subsequent data transmission, and help improve the efficiency and stability of data transmission.
[0057] Optionally, before determining the target memory structure from a preset shared memory structure library according to the model of the target laser radar, the method includes:
[0058] For different models of laser radars, determining the maximum message length of the character string in all point cloud data according to the laser radar;
[0059] Determine a fixed-length memory structure corresponding to the laser radar according to the maximum message length;
[0060] Traverse all laser radars of different models until a fixed-length memory structure corresponding to each laser radar is determined, and store each fixed-length memory structure corresponding to all laser radars into the preset shared memory structure library.
[0061] Optionally, for each laser radar model, the point cloud data output by it is analyzed to find the maximum message length of the string part. By counting and analyzing multiple sample data, the maximum message length of the string corresponding to each laser radar model is determined. According to the obtained maximum message length, the fixed-length memory structure that each laser radar model should correspond to is determined. At this time, the fixed-length memory structure can be used to use padding characters or other methods to pad the string message to a fixed length for subsequent processing and transmission. All known laser radar models are traversed, and the fixed-length memory structure corresponding to each laser radar is determined according to the above steps. Each laser radar model and its corresponding fixed-length memory structure are stored in a preset shared memory structure library.
[0062] Optionally, this embodiment determines the maximum message length and fixed-length memory structure by analyzing the point cloud data of each laser radar model to ensure the accuracy and completeness of data processing. Considering that different models of laser radars may have different data formats and message lengths, the fixed-length memory structure is determined by traversal, thereby enhancing the versatility and applicability of the solution. In the prior art, if a memory structure with a larger data field is selected for transmission, although compatibility is improved, the transmission efficiency will be reduced. If a memory structure with a smaller data field is selected for transmission, a lot of time will be spent on merging, which will lead to reduced transmission efficiency. The present invention comprehensively considers the data structure differences brought by different radar models, and specifically improves the most suitable memory structure for each radar model, which not only improves the adaptation compatibility, but also improves the transmission efficiency. By predetermining the fixed-length memory structure, the amount of calculation and adjustment time in the data processing process can be reduced, and the efficiency of data transmission and processing can be improved. The fixed-length memory structures of different models of laser radars are stored in a preset shared memory structure library, which improves the consistency and reliability of data transmission and helps to ensure that no errors or losses occur during data transmission.
[0063] In an optional embodiment, determining the maximum message length of the character string in all point cloud data according to the model of the laser radar includes:
[0064] Acquire all point cloud data, and for each string data, determine the message length of the string data according to a preset field;
[0065] Traverse all string data and determine the longest message length among all string data as the maximum message length of the string;
[0066] For a point cloud message with a sparse structure, the preset field is the Width field;
[0067] For a point cloud message with a non-sparse structure, the preset field is the product of the Height field and the Width field.
[0068] For example, the length has a corresponding field in the message. For a sparse point cloud message, the Width field is the point cloud length. For a non-sparse point cloud message, it is the product of the Height field and the Width field. In addition, the length of each point data is determined by Point_step, and the number of channel information contained is also inferred from the field of each channel in Pointfield to determine the position, color, reflection intensity and other information of each point, as well as the byte position and space corresponding to each field. For example, if the position information x, y, z, and reflection intensity are all Float32, 4 4-bytes should be read continuously to get the corresponding number. If color information is also included, and the color information r, g, and b values are selected as single-byte integers, 3 1-byte numbers should continue to be read. Otherwise, it is difficult for the receiving end to decode the corresponding structure efficiently and accurately, and then get wrong information.
[0069] Optionally, determining a fixed-length memory structure corresponding to the laser radar according to the maximum message length includes:
[0070] When the maximum message length is within the first length interval and the laser radar has at least the ability to generate timestamp data and coordinate information, determining that the first length memory structure is a fixed length memory structure, and the first length memory structure includes timestamp data and coordinate information;
[0071] When the maximum message length is within the second length interval and the laser radar has at least the ability to generate timestamp data, coordinate information, and reflection intensity information, determining that the second length memory structure is a fixed length memory structure, and the second length memory structure includes timestamp data, coordinate information, and reflection intensity information;
[0072] When the maximum message length is within the third length interval and the laser radar has at least the ability to generate timestamp data, coordinate information, reflection intensity information and color information, determining that the third length memory structure is a fixed length memory structure, and the third length memory structure includes timestamp data, coordinate information, reflection intensity information and color information;
[0073] The first length interval is smaller than the second length interval, and the second length interval is smaller than the third length interval; the coordinate information includes three-dimensional coordinate information or two-dimensional coordinate information.
[0074] Optionally, the present invention sets three intervals, which are respectively set as the first length interval being smaller than the second length interval, and the second length interval being smaller than the third length interval; the coordinate information includes three-dimensional coordinate information or two-dimensional coordinate information, and five intervals or even more can be set according to actual conditions. If the maximum message length is in the first length interval, and the laser radar can generate timestamp data and coordinate information, the fixed-length memory structure will include timestamp data and coordinate information; if the maximum message length is in the second length interval, and the laser radar can generate timestamp data, coordinate information and reflection intensity information, the fixed-length memory structure will include timestamp data, coordinate information and reflection intensity information; if the maximum message length is in the third length interval, and the laser radar can generate timestamp data, coordinate information, reflection intensity information and color information, the fixed-length memory structure will include timestamp data, coordinate information, reflection intensity information and reflectivity information.
[0075] Those skilled in the art understand that these length intervals can be increased according to the complexity of the data to ensure that the memory structure can accommodate the data generated by the laser radar, and the coordinate information can be three-dimensional or two-dimensional. Through the above design scheme, the present invention can ensure that the fixed-length memory structure matches the data generated by the laser radar, avoid data loss or truncation, and improve data consistency and integrity; it also determines the fixed-length memory structure through different length intervals, effectively utilizes memory resources, and avoids memory waste; the memory structure is automatically determined according to the capabilities of the laser radar and the maximum message length, which improves the flexibility and adaptability of the system; by optimizing the memory structure, data processing efficiency can be improved, processing time can be reduced, thereby improving system performance and response speed.
[0076] In step 102, the original point cloud data of the target lidar is adjusted to fixed-length point cloud data according to the target memory structure, including: when the length of the original point cloud data is less than the length of the target memory structure, padding with zeros after the data bits of the original point cloud data to form the fixed-length point cloud data; when the length of the original point cloud data is greater than the length of the target memory structure, generating a warning instruction, the warning instruction being used to issue a warning and exit the current program execution.
[0077] Optionally, the sending and receiving mode of the original point cloud message is changed from the traditional message communication mode to the shared memory message communication mode. In the shared memory structure, the data field will be defined as an array of a fixed size, such as "uint8[2097152]data", indicating that the maximum capacity of the array is 2097152 bytes (2MB), and the space corresponding to the capacity will actually be allocated to store data. The present invention also needs to specify the length of the field array and the length of the string in the string field, such as: "Char
[256] frame_id",
[0078] "PointField[8]fields", any place where a dynamic length array is used in the original message must be changed to a static length array. The adjustment method is to add the maximum length in the message definition. Since the point cloud data generated by different LiDAR models may have different sizes, multiple similar structures can be defined to set data fields of different sizes according to different models to achieve compatibility with different models of LiDAR devices. This allows more flexible processing of point cloud message data generated by different models of LiDARs, ensuring that the data can be stored and transmitted effectively.
[0079] Specifically, adjusting the original point cloud data to fixed-length point cloud data can ensure the consistency of the data format, which is helpful for subsequent data processing and analysis. Zero padding can maintain data integrity, avoid data loss or truncation, and improve data quality and reliability. Generating warning instructions and exiting the operation ensures that users can be informed of data length mismatches in a timely manner, avoid data errors being ignored, and enhance the user-friendliness of the system. Issuing warnings in a timely manner and stopping program execution can help avoid errors and exceptions caused by data length mismatches and ensure the reliability of the program.
[0080] In step 103, shared memory transmission can achieve fast data exchange and communication, which helps to support the needs of real-time systems and improve the response speed and real-time performance of the system. After converting the fixed-length point cloud data of the target laser radar, the user enters the configuration information in the preset input box to define the DDS QoS Profile configuration file in the message middleware ROS2, and sets the data sharing mode Data_Sharing to Atomic, thereby enabling shared memory transmission. The data sharing mode Data_Sharing is the process of sharing data between different modules, processes or threads in a computer system. Through data sharing, programs in different parts can access and use the same data, thereby realizing information transmission and collaboration. Data sharing can help programs in different parts communicate with each other and work together, and can improve the efficiency and performance of the system. In the configuration file, the user will set the data sharing mode to Atomic, which means that the data will be transmitted in an atomic way in shared memory during the transmission process, ensuring the atomicity and consistency of data between different modules, reducing data copying and improving transmission efficiency.
[0081] Optionally, before receiving the first input from the user, the method further includes:
[0082] A second input from the user is received, where the second input is used to set the message transmission mode to asynchronous sending and to set the data reliability to the Best_Effort mode.
[0083] Optionally, before receiving the user's first input, the user's second input is received to define the message transmission mode and data reliability. In the configuration file, the user sets the message transmission mode to asynchronous transmission, which means that the transmission of the message will not block the sender, which can improve the throughput and response speed of the system. The data reliability is set to Best_Effort mode, which means that the system will do its best to transmit data. In Best_Effort mode, the system may lose some messages or some messages may be lost during the transmission process without causing the entire system to block and wait. It is suitable for some scenarios that do not require high real-time performance and can tolerate data loss, such as video transmission, real-time monitoring, etc., and is therefore very suitable for the use scenarios of the present invention. The present invention combines asynchronous transmission, Best_Effort data reliability mode, and determines the target memory structure according to the model of the target laser radar, balances efficiency and reliability, adjusts the system's transmission mode according to specific needs, and improves the flexibility of the system.
[0084] In step 104, after the present invention completes defining the DDS QoS Profile configuration file in the message middleware ROS2 and setting the data sharing mode Data_Sharing to Atomic, shared memory transmission is enabled, and then the fixed-length point cloud data is sent to the receiving end that subscribes to the target lidar point cloud data. The receiving end can process the fixed-length point cloud data, such as real-time display, data storage, point cloud analysis, etc. The receiving end may also involve detection algorithms (such as clustering algorithms or neural network-based algorithms) or other processing modules (such as splicing, defogging, etc.) for processing the received point cloud data.
[0085] Optionally, after the original point cloud data of the target lidar is adjusted to fixed-length point cloud data, "Borrow_Loaned_Message" is used for shared memory sending when sending point cloud messages, and the subscription of the receiving end does not need to be changed, so as to realize data sharing between memories and improve efficiency and real-time performance. The subscription module of the receiving end is used to receive point cloud messages sent from the lidar. If the receiving end parses the field of static length, the reading method needs to be changed accordingly. These method definitions are also included in the specific implementation scheme of the present invention and do not affect the specific implementation of the present invention, so they will not be repeated here.
[0086] Optionally, after sending the fixed-length point cloud data to a receiving end that subscribes to the target laser radar point cloud data, the method further includes:
[0087] When it is determined that the folder for storing the shared memory file includes a file corresponding to the real-time publish-subscribe transmission middleware library FastRTPS, it is determined that the shared memory transmission is enabled.
[0088] Optionally, Fast RTPS (Fast Reliable Transport for the Real Time Publish-Subscribe) is an open source fast and reliable real-time publish-subscribe transmission middleware library. The present invention confirms whether the folder storing the shared memory file contains Fast RTPS related files, such as shared memory transmission library files, etc. The folder for storing shared memory files can be a " / dev / shm" folder, which is a directory for storing shared memory (Shared Memory) files. The present invention uses the middleware library Fast DDS to implement communication. If the folder contains Fast RTPS related files, it is determined that shared memory transmission has been enabled. If the folder does not contain Fast RTPS related files, it is determined that shared memory transmission is not enabled. Through this determination method, the working status of shared memory transmission in the current state can be effectively determined. If it is determined that shared memory transmission is not enabled, relevant adjustments are made in time to improve the efficiency of data transmission.
[0089] Optionally, the " / dev / shm" folder directory stores the process ports participating in the shared memory and serialized message transmission information. The serialization method is provided by the middleware library Fast DDS. Serialization is the process of converting data objects into byte streams for transmission on the network. Fast DDS provides the functions of serializing and deserializing messages to help realize data transmission and communication between processes.
[0090] Optionally, after determining that shared memory transmission has been enabled, the method further includes:
[0091] At each preset time interval, receiving a third input from the user, the third input being used to check the publishing frequency of the currently transmitted message;
[0092] When it is determined that the message publishing frequency is less than the preset frequency, a check instruction is generated, where the check instruction is used to check the configuration parameters of the shared memory transmission.
[0093] Optionally, the present invention can use the ROS2 command line tool "ros2 topic hz" to view the publishing frequency (Hz) of a specified topic, that is, the number of messages published per second by the topic. This command can monitor the data publishing rate of a topic. If the publishing frequency of a topic is low observed through "ros2 topic hz", it may indicate that there is a bottleneck or problem in data transmission, which may be caused by difficulties in shared memory transmission. At this time, you can consider checking the configuration and performance of shared memory transmission to solve the data transmission problem and improve the stability of the system.
[0094] Figure 2It is a structural diagram of a point cloud data sending device based on shared memory provided by the present invention. The point cloud data sending device based on shared memory includes a determination unit 1. The determination unit is used to determine the target memory structure from a preset shared memory structure library according to the model of the target laser radar. The working principle of the determination unit 1 can refer to the aforementioned step 101 and will not be repeated here.
[0095] The point cloud data sending device based on shared memory also includes an adjustment unit 2, which is used to adjust the original point cloud data of the target lidar into fixed-length point cloud data according to the target memory structure. The working principle of the adjustment unit 2 can refer to the aforementioned step 102 and will not be repeated here.
[0096] The point cloud data sending device based on shared memory also includes a receiving unit 3, which is used to receive a first input from a user. The first input is used to define a DDS QoS Profile configuration file in the message middleware ROS2, and set the data sharing mode Data_Sharing to Atomic to enable shared memory transmission. The working principle of the receiving unit 3 can refer to the aforementioned step 103 and will not be repeated here.
[0097] The shared memory-based point cloud data sending device also includes a response unit 4, which is used to respond to the first input and send the fixed-length point cloud data to the receiving end that subscribes to the target lidar point cloud data. The working principle of the response unit 4 can refer to the aforementioned step 104 and will not be repeated here.
[0098] The preset shared memory structure library includes the correspondence between different laser radar models and the memory structure corresponding to each laser radar model.
[0099] The present invention ensures that data has a consistent size during transmission by means of shared memory, which helps to improve the efficiency and stability of data transmission and reduce the possibility of data packet fragmentation. Before determining the memory structure corresponding to the laser radar model, the maximum message length of each model of radar is first determined to plan a fixed-length memory structure, so that data storage in the shared memory is more compact and consistent, which helps to improve data transmission efficiency and reduce system resource occupation;
[0100] The present invention also sets the message transmission mode to asynchronous sending, reduces transmission delay, improves the real-time and responsiveness of messages, and ensures that data can still be sent in the event of network congestion or data loss, thereby improving the stability of the system; regularly checks the message publishing frequency, and performs parameter checks when necessary to ensure the accuracy and performance of the transmission configuration, effectively optimizes the configuration parameters of shared memory transmission, ensures stable data transmission and avoids data loss or delay.
[0101] Figure 3 Schematic diagram of the structure of the electronic device provided by the present invention. Figure 3 As shown, the electronic device may include: a processor 310, a communication interface 320, a memory 330 and a communication bus 340, wherein the processor 310, the communication interface 320 and the memory 330 complete mutual communication through the communication bus 340. The processor 310 may call the logic instructions in the memory 330 to execute a point cloud data sending method based on shared memory, the method comprising: determining a target memory structure from a preset shared memory structure library according to the model of the target laser radar; adjusting the original point cloud data of the target laser radar to fixed-length point cloud data according to the target memory structure; receiving a first input from a user, the first input being used to define a DDS QoS Profile configuration file in the message middleware ROS2, setting the data sharing mode Data_Sharing to Atomic to enable shared memory transmission; in response to the first input, sending the fixed-length point cloud data to a receiving end that subscribes to the target laser radar point cloud data; the preset shared memory structure library includes a correspondence between different laser radar models and the memory structure corresponding to each laser radar model.
[0102] In addition, the logic instructions in the above-mentioned memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0103] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute a point cloud data sending method based on shared memory provided by the above methods, the method including: determining a target memory structure from a preset shared memory structure library according to the model of the target laser radar; adjusting the original point cloud data of the target laser radar to fixed-length point cloud data according to the target memory structure; receiving a first input from a user, the first input is used to define a DDS QoS Profile configuration file in the message middleware ROS2, and setting the data sharing mode Data_Sharing to Atomic to enable shared memory transmission; in response to the first input, sending the fixed-length point cloud data to a receiving end that subscribes to the target laser radar point cloud data; the preset shared memory structure library includes a correspondence between different laser radar models and the memory structure corresponding to each laser radar model.
[0104] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the point cloud data sending method based on shared memory provided by the above-mentioned methods, the method comprising: determining a target memory structure from a preset shared memory structure library according to a model of a target laser radar; adjusting the original point cloud data of the target laser radar to fixed-length point cloud data according to the target memory structure; receiving a first input from a user, wherein the first input is used to define a DDS QoSProfile configuration file in the message middleware ROS2, and setting a data sharing mode Data_Sharing to Atomic to enable shared memory transmission; in response to the first input, sending the fixed-length point cloud data to a receiving end that subscribes to the target laser radar point cloud data; the preset shared memory structure library includes a correspondence between different laser radar models and the memory structure corresponding to each laser radar model.
[0105] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0106] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0107] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for sending point cloud data based on shared memory, characterized in that: include: According to the model of the target laser radar, determine the target memory structure from the preset shared memory structure library; According to the target memory structure, adjusting the original point cloud data of the target laser radar into fixed-length point cloud data; Receive a first input from a user, where the first input is used to define a DDS QoS Profile configuration file in the message middleware ROS2, and set the data sharing mode Data_Sharing to Atomic to enable shared memory transmission; In response to the first input, sending the fixed-length point cloud data to a receiving end that subscribes to the target laser radar point cloud data; The preset shared memory structure library includes the correspondence between different laser radar models and the memory structure corresponding to each laser radar model.
2. The point cloud data sending method based on shared memory according to claim 1, characterized in that: Before determining the target memory structure from a preset shared memory structure library according to the model of the target laser radar, the method includes: For different models of laser radars, determining the maximum message length of the character string in all point cloud data according to the laser radar; Determine a fixed-length memory structure corresponding to the laser radar according to the maximum message length; Traverse all laser radars of different models until a fixed-length memory structure corresponding to each laser radar is determined, and store each fixed-length memory structure corresponding to all laser radars into the preset shared memory structure library.
3. The point cloud data sending method based on shared memory according to claim 2, characterized in that: The step of determining the maximum message length of the character strings in all point cloud data according to the model of the laser radar includes: Acquire all point cloud data, and for each string data, determine the message length of the string data according to a preset field; Traverse all string data and determine the longest message length among all string data as the maximum message length of the string; For a point cloud message with a sparse structure, the preset field is the Width field; For a point cloud message with a non-sparse structure, the preset field is the product of the Height field and the Width field.
4. The method for sending point cloud data based on shared memory according to claim 2, characterized in that: The step of determining a fixed-length memory structure corresponding to the laser radar according to the maximum message length includes: When the maximum message length is within the first length interval and the laser radar has at least the ability to generate timestamp data and coordinate information, determining that the first length memory structure is a fixed length memory structure, and the first length memory structure includes timestamp data and coordinate information; When the maximum message length is within the second length interval and the laser radar has at least the ability to generate timestamp data, coordinate information, and reflection intensity information, determining that the second length memory structure is a fixed length memory structure, and the second length memory structure includes timestamp data, coordinate information, and reflection intensity information; When the maximum message length is within the third length interval and the laser radar has at least the ability to generate timestamp data, coordinate information, reflection intensity information and color information, determining that the third length memory structure is a fixed length memory structure, and the third length memory structure includes timestamp data, coordinate information, reflection intensity information and color information; The first length interval is smaller than the second length interval, and the second length interval is smaller than the third length interval; the coordinate information includes three-dimensional coordinate information or two-dimensional coordinate information.
5. The method for sending point cloud data based on shared memory according to claim 1, characterized in that: The adjusting the original point cloud data of the target laser radar into fixed-length point cloud data according to the target memory structure includes: When the length of the original point cloud data is less than the length of the target memory structure, padding with zeros after the data bits of the original point cloud data to form the fixed-length point cloud data; When the length of the original point cloud data is greater than the length of the target memory structure, a warning instruction is generated, wherein the warning instruction is used to issue a warning and exit the current program execution.
6. The point cloud data transmission method based on shared memory according to claim 1, characterized in that: Before receiving the first input from the user, the method further includes: A second input from the user is received, where the second input is used to set the message transmission mode to asynchronous sending and to set the data reliability to the Best_Effort mode.
7. The method for sending point cloud data based on shared memory according to claim 1, characterized in that: After sending the fixed-length point cloud data to a receiving end that subscribes to the target laser radar point cloud data, the method further includes: When it is determined that the folder for storing the shared memory file includes the corresponding file of the real-time publish-subscribe transmission middleware library Fast RTPS, it is determined that the shared memory transmission is enabled.
8. The method for sending point cloud data based on shared memory according to claim 7, characterized in that: After determining that shared memory transmission is enabled, the method further includes: At each preset time interval, receiving a third input from the user, the third input being used to check the publishing frequency of the currently transmitted message; When it is determined that the message publishing frequency is less than the preset frequency, a check instruction is generated, where the check instruction is used to check the configuration parameters of the shared memory transmission.
9. A point cloud data sending device based on shared memory, characterized in that: include: A determination unit, the determination unit being used to determine a target memory structure from a preset shared memory structure library according to a model of a target laser radar; An adjustment unit, the adjustment unit being used to adjust the original point cloud data of the target laser radar into fixed-length point cloud data according to the target memory structure; A receiving unit, the receiving unit is used to receive a first input from a user, the first input is used to define a DDS QoS Profile configuration file in the message middleware ROS2, and set the data sharing mode Data_Sharing to Atomic to enable shared memory transmission; A response unit, the response unit being configured to send the fixed-length point cloud data to a receiving end subscribing to the target laser radar point cloud data in response to the first input; The preset shared memory structure library includes the correspondence between different laser radar models and the memory structure corresponding to each laser radar model.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the point cloud data sending method based on shared memory as described in any one of claims 1 to 8 is implemented.
