ryan-brazeal-ufl / OpenPyLivox

Python3 driver for Livox lidar sensors
GNU General Public License v3.0
85 stars 44 forks source link

What is difference between run() and run_realtime_csv() functions in _DataCaptureThread class? #9

Closed roya-correct-ai closed 3 years ago

roya-correct-ai commented 4 years ago

Hi Ryan

Could you please tell me what is difference between run() and run_realtime_csv() functions in _DataCaptureThread class?

Thanks in advance

ryan-brazeal-ufl commented 3 years ago

To be thorough, please see my 'for information only' response below. Both run() and run_realtime_csv are members of the private class object _DataCaptureThread within an OpenPyLivox instantiated object (i.e., they are not meant to be called directly). Instead, these functions are realized by calling the dataStart() and dataStart_RT() methods of an OPL object. HOWEVER, OPL v1.1.0 has just been released and both dataStart() and dataStart_RT() have now been deprecated, and the dataStart_RT_B() method should ONLY be used moving forward.

In short, run() stores the point cloud (pc) data within growing python lists for the coordinates, intensities, times, and return numbers (if applicable). This works fine for shorter observation periods (i.e., not that much pc data) and on full-sized computers (i.e., lots of RAM). After the observation period is over, the run() function generates a CSV file with the point cloud data from the list objects in RAM. run_realtime_csv() uses the same logic, but once the python lists reach a certain (smaller) size, they are flushed out to the CSV file. The trade-off is less memory consumption but the CSV file is opened/closed many times. Overall the performance improvement is worth it!

Hope this helps clarify a few things, thanks for the question.

-RB