5. Library Functions - ryan-brazeal-ufl/OpenPyLivox GitHub Wiki
There are 2 functions that are part of the OpenPyLivox library and not a method of the openpylivox class. The purpose of these functions, is to provide benefit to all OpenPyLivox objects rather than a specific object (class instance). In the future, there will certainly be more library level functions included within the OpenPyLivox library.
The library function .allDoneCapturing(sensors) is very similar to the object property, .doneCapturing(). In fact, this library function makes use of the .doneCapturing() object property within it's implementation. This function requires a single argument sensors. This argument is a list that contains 1 or more OpenPyLivox objects (i.e., a list of individual sensor objects). The purpose of this library function, is to provide a simple means of checking a group of OpenPyLivox objects to see if any of them are currently capturing data.
The function returns a boolean value. It is designed to be used within a loop and therefore called a lot during runtime. As a result, this function never displays a message and therefore is unaffected by the value of .showMessage. The function returns True if all of the included OpenPyLivox objects in the list argument are not currently capturing data, and False if any one of them is currently capturing data.
Usage Example,
import openpylivox as opl
sensors = []
sensor1 = opl.openpylivox(True)
sensor2 = opl.openpylivox(True)
connected1 = sensor1.connect("192.168.1.20", "192.168.1.41", 60001, 50001)
if connected1:
sensors.append(sensor1)
connected2 = sensor2.connect("192.168.1.20", "192.168.1.42", 60002, 50002)
if connected2:
sensors.append(sensor2)
#start collecting data from both sensors, etc., etc.
while True:
#doing more very important stuff here
if opl.allDoneCapturing(sensors):
#data capture from all sensors is complete
breakThe library function .convertBin2CSV(filePathAndName, deleteBin=False) requires a single string argument filePathAndName and a second optional boolean argument [deleteBin]. The filePathAndName argument contains the relative or absolute file path and filename of the OpenPyLivox captured binary point cloud data file. The [deleteBin] optional argument, which has a default value of False, is used to specify if the binary data file is to be deleted after successfully creating a CSV point cloud data file. This function can be called at any time, or not at all. Ideally this should help minimize the computing tasks and resources onboard a smaller 'data collection' computer (e.g., a Raspberry Pi) and allow for the collected binary point cloud data file to be converted at a later time by a more powerful desktop/laptop computer. Of course a smaller computer (i.e., RPi) can also perform the conversion, it just make take a while.
The created CSV point cloud data file will be in the same file path as the binary file, and will have the same filename but with the file extension of .csv. The CSV file format will be identical to a file captured using the .dataStart_RT() method. All firmwares are supported and both Cartesian and Spherical coordinate observations are supported.
The possible messages printed to the screen include any of the following.
CONVERTING BINARY DATA TO CSV, PLEASE WAIT...
- Data conversion was successful
- Binary file has been deleted
***ERROR: The BINARY file reported a wrong data type***
***ERROR: The BINARY file reported a wrong firmware type***
***ERROR: The file was not recognized as an OpenPyLivox Binary data file***
An unknown error occurred while converting the BINARY file to a comman delimited ASCII file
Usage Example,
import openpylivox as opl
opl.convertBin2CSV("my_fav_pc.bin")
opl.convertBin2CSV("my_least_fav_pc.bin",True)