### OpenPyLivox Object Initialization and Data Collection Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Example demonstrating how to initialize an OpenPyLivox object, connect to a sensor, start data capture, save data to a file, and disconnect. ```APIDOC ## OpenPyLivox Initialization and Data Collection Example ### Description This example shows the basic workflow for collecting point cloud data from a Livox sensor using the OpenPyLivox library. It covers sensor initialization, automatic connection, starting data capture, saving data to a CSV file for a specified duration, and proper disconnection. ### Method This is a usage example combining multiple methods. ### Endpoint N/A (This is a library usage example) ### Request Example ```python import openpylivox as opl # Initialize OpenPyLivox object, enabling verbose messages sensor = opl.openpylivox(True) # Automatically connect to the sensor sensor.auto_connect() # Start real-time data capture sensor.dataStart_RT() # Collect data for exactly 10.0 seconds and save to 'points.csv' sensor.saveDataToFile("points.csv", 0, 10.0) # Keep the script running until data capture is complete while True: if sensor.doneCapturing(): break # Disconnect from the sensor sensor.disconnect() ``` ### Response This example does not have a direct API response. The outcome is the creation of a 'points.csv' file containing the collected lidar data. ``` -------------------------------- ### Collect Point Cloud Data Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods A complete example demonstrating how to connect to a sensor, start real-time data collection for 10 seconds, and save the output to a CSV file. ```python import openpylivox as opl sensor = opl.openpylivox(True) sensor.auto_connect() sensor.dataStart_RT() sensor.saveDataToFile("points.csv",0,10.0) #collect exactly 10.0 seconds of data while True: if sensor.doneCapturing(): break sensor.disconnect() ``` -------------------------------- ### Install OpenPyLivox from GitHub Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/1.-Getting-Started Use this command to install OpenPyLivox directly from its GitHub repository using pip. This is the primary method for installation as it's not available on PyPI. ```bash pip install git+https://github.com/ryan-brazeal-ufl/openpylivox.git ``` -------------------------------- ### Start DHCP Server on macOS Source: https://github.com/ryan-brazeal-ufl/openpylivox/blob/master/Mac OS X DHCP server configuration and usage.txt Loads the DHCP server service (`bootps.plist`) and enables it to start automatically on boot. This command requires administrator privileges. ```bash sudo /bin/launchctl load -w /System/Library/LaunchDaemons/bootps.plist ``` -------------------------------- ### Start Lidar Data Stream (Real-Time) Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Starts a lidar data stream and a separate thread for receiving data, improving performance for CSV file capture. Ensure the sensor is connected. ```python sensor.dataStart_RT() ``` -------------------------------- ### Start Lidar Data Stream (Binary) Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Starts a lidar data stream and a separate thread for receiving data, optimized for simple binary file capture. Use `.convertBin2CSV()` to convert the binary file later. ```python sensor.dataStart_RT_B() ``` -------------------------------- ### Recommended dataStart_RT() Method Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Initiates the lidar sensor's point cloud data stream transmission and starts a synchronous receiving thread. Introduced in v1.0.1 to improve performance for capturing point cloud data in CSV files. ```APIDOC ## .dataStart_RT() ### Description Sends a command to the lidar sensor to begin transmitting its point cloud data stream to a specified IP address and data port. It also starts a new synchronous thread on the user's computer to handle the data stream, allowing the main program to continue execution. This method was introduced in v1.0.1 to improve performance for capturing point cloud data in CSV files. ### Method `dataStart_RT()` ### Endpoint N/A (This is a method call on a sensor object) ### Parameters None ### Request Example ```python sensor.dataStart_RT() ``` ### Response N/A (This method primarily controls sensor behavior and initiates background threads. Success/failure messages are printed to the console if `showMessage` is True.) ### Possible Console Messages (if showMessage is True) ``` 192.168.1.42 <-- sent start data stream request 192.168.1.42 --> FAILED to start data stream 192.168.1.42 --> incorrect start data stream response 192.168.1.42 --> data stream already started Not connected to Mid-40 sensor at IP: 192.168.1.42 ``` ``` -------------------------------- ### Recommended dataStart_RT_B() Method Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Initiates the lidar sensor's point cloud data stream transmission and starts a synchronous receiving thread. Introduced in v1.0.2 to improve performance for capturing data in simple binary files, which can later be converted to CSV. ```APIDOC ## .dataStart_RT_B() ### Description Sends a command to the lidar sensor to begin transmitting its point cloud data stream to a specified IP address and data port. It also starts a new synchronous thread on the user's computer to handle the data stream, allowing the main program to continue execution. This method was introduced in v1.0.2 to improve performance for capturing point cloud data in a simple binary data file. The `.convertBin2CSV()` method can be used later to convert this binary file to CSV. ### Method `dataStart_RT_B()` ### Endpoint N/A (This is a method call on a sensor object) ### Parameters None ### Request Example ```python sensor.dataStart_RT_B() ``` ### Response N/A (This method primarily controls sensor behavior and initiates background threads. Success/failure messages are printed to the console if `showMessage` is True.) ### Possible Console Messages (if showMessage is True) ``` 192.168.1.42 <-- sent start data stream request 192.168.1.42 --> FAILED to start data stream 192.168.1.42 --> incorrect start data stream response 192.168.1.42 --> data stream already started Not connected to Mid-40 sensor at IP: 192.168.1.42 ``` ``` -------------------------------- ### Capture Data to CSV Source: https://context7.com/ryan-brazeal-ufl/openpylivox/llms.txt A minimal workflow to start real-time data streaming and save it to a CSV file. ```python import openpylivox as opl sensor = opl.openpylivox(True) sensor.auto_connect() sensor.dataStart_RT() sensor.saveDataToFile("points.csv", 0, 10.0) # Wait 0 seconds, capture for 10 seconds while True: if sensor.doneCapturing(): break sensor.disconnect() # Output file 'points.csv' can be opened directly in CloudCompare ``` -------------------------------- ### Deprecated: Start Lidar Data Stream Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Use `.dataStart_RT()` or `.dataStart_RT_B()` instead. This method starts a data stream and a separate thread for receiving data. Performance issues led to its deprecation. ```python sensor.dataStart() ``` -------------------------------- ### Manual Sensor Connection Source: https://context7.com/ryan-brazeal-ufl/openpylivox/llms.txt Explicitly define connection parameters for static IP configurations or multi-sensor setups. ```python import openpylivox as opl sensor = opl.openpylivox(True) # Manual connection with explicit parameters # connect(computerIP, sensorIP, dataPort, cmdPort, [imuPort]) connected = sensor.connect("192.168.1.20", "192.168.1.42", 60001, 50001, 40001) if connected: # Verify connection parameters params = sensor.connectionParameters() # Output: Computer IP: 192.168.1.20, Sensor IP: 192.168.1.42, Data Port: 60001, Command Port: 50001 else: print("Connection failed") ``` -------------------------------- ### Deprecated dataStart() Method Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Initiates the lidar sensor's point cloud data stream transmission and starts a synchronous receiving thread. This method is deprecated as of version 1.0.1 due to performance issues with CSV file handling and should be replaced by `.dataStart_RT()` or `.dataStart_RT_B()`. ```APIDOC ## .dataStart() ### Description Sends a command to the lidar sensor to begin transmitting its point cloud data stream to a specified IP address and data port. It also starts a new synchronous thread on the user's computer to handle the data stream, allowing the main program to continue execution. Note that this method is deprecated due to poor performance when capturing data in ASCII CSV files. ### Method `dataStart()` ### Endpoint N/A (This is a method call on a sensor object) ### Parameters None ### Request Example ```python sensor.dataStart() ``` ### Response N/A (This method primarily controls sensor behavior and initiates background threads. Success/failure messages are printed to the console if `showMessage` is True.) ### Possible Console Messages (if showMessage is True) ``` 192.168.1.42 <-- sent start data stream request 192.168.1.42 --> FAILED to start data stream 192.168.1.42 --> incorrect start data stream response 192.168.1.42 --> data stream already started Not connected to Mid-40 sensor at IP: 192.168.1.42 ``` ``` -------------------------------- ### Instantiate OpenPyLivox Sensor Object Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/1.-Getting-Started Create an instance of the OpenPyLivox sensor object. The optional boolean argument `showMessages` controls whether informational messages are printed to the console. It is recommended to set this to True when starting. ```python sensor = opl.openpylivox([showMessages]) ``` ```python sensor = opl.openpylivox(True) ``` -------------------------------- ### Get Connection Parameters Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/3.-Object-Properties Retrieve a list of 4 strings representing the computer IP, sensor IP, data port, and command port. This property is read-only. ```python connParamsStrList = sensor.connectionParameters() ``` -------------------------------- ### Data Capture and Conversion Source: https://context7.com/ryan-brazeal-ufl/openpylivox/llms.txt Methods for starting, stopping, and saving point cloud data streams from the sensor. ```APIDOC ## dataStart_RT() ### Description Starts real-time data streaming in ASCII format. ## dataStart_RT_B() ### Description Starts real-time data streaming in binary format for improved performance. ## saveDataToFile() ### Description Captures point cloud data and saves it to a file. ### Parameters - **filename** (string) - Required - Path to save the output file. - **delay** (float) - Required - Time in seconds to wait before starting capture. - **duration** (float) - Required - Time in seconds to capture data. ## convertBin2LAS() ### Description Converts a binary capture file to LAS format compatible with CloudCompare. ### Parameters - **filename** (string) - Required - Path to the binary file. - **deleteBin** (boolean) - Optional - If true, deletes the .bin file after conversion. ``` -------------------------------- ### Example Messages for Data Saving Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Displays potential messages shown when saving data, including warnings and status updates. These messages help in debugging and monitoring the data saving process. ```text 192.168.1.42 --> unknown firmware version 192.168.1.42 --> * ISSUE: saving data, negative duration 192.168.1.42 --> * ISSUE: saving data, duration too big 192.168.1.42 --> * ISSUE: saving data, negative time to wait 192.168.1.42 --> * ISSUE: saving data, time to wait too big 192.168.1.42 --> * ISSUE: saving data, file path and name missing 192.168.1.42 --> WARNING: data stream not started, no CSV file created 192.168.1.42 --> CAPTURING DATA... 192.168.1.42 --> writing data to file: *points.csv* (DEPRECATED in v1.0.1) 192.168.1.42 --> writing real-time data to file: *points.csv* 192.168.1.42 --> WARNING: no point cloud data was captured 192.168.1.42 --> Incorrect lidar packet version ``` ```text 192.168.1.42 --> unknown firmware version 192.168.1.42 --> * ISSUE: saving data, negative duration 192.168.1.42 --> * ISSUE: saving data, duration too big 192.168.1.42 --> * ISSUE: saving data, negative time to wait 192.168.1.42 --> * ISSUE: saving data, time to wait too big 192.168.1.42 --> * ISSUE: saving data, file path and name missing 192.168.1.42 --> WARNING: data stream not started, no CSV file created (DEPRECATED in v1.0.2) 192.168.1.42 --> WARNING: data stream not started, no data file created 192.168.1.42 --> CAPTURING DATA... 192.168.1.42 --> writing data to file: *points.csv* (DEPRECATED in v1.0.1) ``` ```text 192.168.1.42 --> closed CSV file: *points.csv* (points: 123456 good, 9876 null, 133332 total) ``` -------------------------------- ### Upgrade OpenPyLivox to Latest Version Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/1.-Getting-Started Run this command to upgrade your existing OpenPyLivox installation to the most recent version available on GitHub. ```bash pip install --upgrade git+https://github.com/ryan-brazeal-ufl/openpylivox.git ``` -------------------------------- ### Get Firmware Version Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/3.-Object-Properties Retrieve a string value representing the firmware version of the sensor. This property is read-only. ```python firmwareStr = sensor.firmware() ``` -------------------------------- ### Get Extrinsic Parameters Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/3.-Object-Properties Retrieve a list of 6 floats representing the X, Y, Z position and Roll, Pitch, Yaw orientation. This property is read-only. ```python extParamsFloatList = sensor.extrinsicParameters() ``` -------------------------------- ### saveDataToFile Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Informs the data handling thread to write received point cloud data to a specified file. Data capture starts after a delay and continues for a set duration. The data type (ASCII or BINARY) depends on the preceding `.dataStart_...` method call. Extrinsic parameters are not currently utilized. ```APIDOC ## saveDataToFile ### Description Informs the data handling thread to capture and write point cloud data to a specified file. Data capture begins after a delay defined by `secsToWait` and continues for the duration specified by `duration`. If `duration` is 0, capturing continues indefinitely until manually stopped. The type of data collected (ASCII or BINARY) depends on the preceding `.dataStart_...` method call. Extrinsic parameter values are not currently used. ### Method `saveDataToFile(filePathAndName, secsToWait, duration)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters 1. `filePathAndName` (string) - Required - The absolute or relative path and filename for the data file. 2. `secsToWait` (float) - Required - The number of seconds to delay the start of data capturing after the command has been sent. 3. `duration` (float) - Required - The total number of seconds for data capturing. A value of 0 means indefinite capturing, requiring manual stopping. ### Request Example ```python sensor.saveDataToFile("output_data", 2.0, 30.5) ``` ### Response #### Success Response (200) None explicitly defined. Success is indicated by the absence of error messages and the creation of the data file. #### Response Example None ``` -------------------------------- ### Get Lidar Status Codes Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/3.-Object-Properties Retrieve a list of 8 integers representing various system status codes for the lidar. This property is read-only. Note the order difference for System Status Code compared to Livox SDK documentation. ```python statusCodesIntList = sensor.lidarStatusCodes() ``` -------------------------------- ### Stop DHCP Server on macOS Source: https://github.com/ryan-brazeal-ufl/openpylivox/blob/master/Mac OS X DHCP server configuration and usage.txt Unloads the DHCP server service (`bootps.plist`), stopping it and preventing it from starting on subsequent boots. This command requires administrator privileges. ```bash sudo /bin/launchctl unload -w /System/Library/LaunchDaemons/bootps.plist ``` -------------------------------- ### Instantiate Sensor Object Source: https://context7.com/ryan-brazeal-ufl/openpylivox/llms.txt Create a sensor object to interface with the hardware. Enabling messages is recommended for beginners. ```python import openpylivox as opl # Create sensor object with messages enabled (recommended for learning) sensor = opl.openpylivox(True) # Create sensor object with messages disabled (for production) sensor = opl.openpylivox(False) # Default: messages disabled sensor = opl.openpylivox() ``` -------------------------------- ### Method: connect Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/2.-Sensor-Connection-Options Manually establishes a connection by specifying all required network parameters. ```APIDOC ## .connect(computerIP, sensorIP, dataPort, cmdPort) ### Description Manually configures the connection using specific IP addresses and port numbers. The user must ensure the computer IP is correctly assigned to the interface. ### Parameters #### Request Body - **computerIP** (string) - Required - The IP address of the user's computer. - **sensorIP** (string) - Required - The IP address of the Livox lidar sensor. - **dataPort** (integer) - Required - The port number for receiving point cloud data. - **cmdPort** (integer) - Required - The port number for sending/receiving commands. ### Response - **Return Value** (integer) - Returns the number of Livox lidar sensors available on the network. A non-zero value indicates a successful connection. ``` -------------------------------- ### Get Serial Number Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/3.-Object-Properties Retrieve a string value representing the serial number of the sensor. This property is read-only. ```python serialNumStr = sensor.serialNumber() ``` -------------------------------- ### Capture Binary Data and Convert to LAS Source: https://context7.com/ryan-brazeal-ufl/openpylivox/llms.txt Use binary capture for better performance, then convert the resulting file to LAS format. ```python import openpylivox as opl sensor = opl.openpylivox(True) connected = sensor.auto_connect() if connected: sensor.lidarSpinUp() # Ensure sensor is in normal power mode # Start binary data stream (best performance) sensor.dataStart_RT_B() # Capture 5 seconds of data after 0.1 second delay sensor.saveDataToFile("scan.bin", 0.1, 5.0) while not sensor.doneCapturing(): pass # Wait for capture to complete sensor.dataStop() sensor.lidarSpinDown() # Power-saving mode sensor.disconnect() # Convert binary to LAS file (deletes .bin file after conversion) opl.convertBin2LAS("scan.bin", deleteBin=True) # Creates: scan.las ``` -------------------------------- ### Connect to Livox Sensor using openpylivox Source: https://github.com/ryan-brazeal-ufl/openpylivox/blob/master/Mac OS X DHCP server configuration and usage.txt Uses the `auto_connect()` function from the `openpylivox` library to establish a connection with the sensor. Ensure the DHCP server is running and the sensor is connected. ```python auto_connect() ``` -------------------------------- ### Establish Manual Connection Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/2.-Sensor-Connection-Options Requires explicit specification of computer IP, sensor IP, data port, and command port. The user must ensure the computer IP is correctly assigned to the specified value. ```python connected = sensor.connect("192.168.1.20", "192.168.1.42", 60001, 50001) ``` -------------------------------- ### Network Configuration Source: https://context7.com/ryan-brazeal-ufl/openpylivox/llms.txt Configure sensor IP settings; note that these operations require a sensor reboot and will terminate the program. ```python import openpylivox as opl sensor = opl.openpylivox(True) sensor.auto_connect() # Set sensor to use dynamic IP (DHCP assigned) # WARNING: Program will exit after this command - sensor needs reboot # sensor.setDynamicIP() # Output: Changed IP from 192.168.1.42 to dynamic IP (DHCP assigned) # Output: ************ PROGRAM ENDED - MUST REBOOT SENSOR ************ # Set sensor to use static IP address (must be 192.168.1.11 to .80) # WARNING: Program will exit after this command - sensor needs reboot # sensor.setStaticIP("192.168.1.50") ``` -------------------------------- ### Deprecated: Save Lidar Data to CSV Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Use `.saveDataToFile()` instead. This method was used to store incoming point cloud data in memory for a specified duration, starting after a delay. ```python sensor.saveDataToCSV(filePathAndName, secsToWait, duration) ``` -------------------------------- ### Sensor Connection Methods Source: https://context7.com/ryan-brazeal-ufl/openpylivox/llms.txt Methods for establishing communication with Livox sensors via automatic discovery or manual configuration. ```APIDOC ## auto_connect() ### Description Automatically discovers Livox sensors on the network and establishes UDP communication channels. ### Parameters - **computerIP** (string) - Optional - Specify computer IP if auto-detection fails (useful for multiple network interfaces). ### Response - **connected** (int) - Returns the number of sensors found. ## connect() ### Description Allows explicit specification of all connection parameters for multi-sensor setups or static IP configurations. ### Parameters - **computerIP** (string) - Required - The IP address of the host computer. - **sensorIP** (string) - Required - The IP address of the Livox sensor. - **dataPort** (int) - Required - The UDP port for data streaming. - **cmdPort** (int) - Required - The UDP port for command communication. - **imuPort** (int) - Optional - The UDP port for IMU data. ``` -------------------------------- ### Method: auto_connect Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/2.-Sensor-Connection-Options Automatically detects and configures connection parameters for a Livox lidar sensor. ```APIDOC ## .auto_connect(computerIP) ### Description Attempts to automatically detect the sensor IP and assign unused ports for data and command communication. Works with both dynamic and static IP networks. ### Parameters #### Query Parameters - **computerIP** (string) - Optional - The IP address of the user's computer. Useful if automatic detection fails on multi-network systems. ### Response - **Return Value** (integer) - Returns the number of Livox lidar sensors available on the network. A non-zero value indicates a successful connection. ``` -------------------------------- ### DHCP Server Configuration (bootpd.plist) Source: https://github.com/ryan-brazeal-ufl/openpylivox/blob/master/Mac OS X DHCP server configuration and usage.txt This XML plist file configures the DHCP server on macOS. Ensure the 'dhcp_enabled' string matches your Ethernet interface name (e.g., 'en7'). The 'Subnets' section defines the IP address range for leased IPs. ```xml bootp_enabled detect_other_dhcp_server 1 dhcp_enabled en7 reply_threshold_seconds 0 Subnets allocate lease_max 86400 lease_min 86400 name 192.168.33 net_address 192.168.33.0 net_mask 255.255.255.0 net_range 192.168.33.2 192.168.33.254 ``` -------------------------------- ### Extrinsic Parameters Configuration Source: https://context7.com/ryan-brazeal-ufl/openpylivox/llms.txt Read, write, and reset position and orientation offsets for the sensor. ```python import openpylivox as opl sensor = opl.openpylivox(True) sensor.auto_connect() # Read current extrinsic parameters from sensor sensor.readExtrinsic() # Get extrinsic values as list [X, Y, Z, Roll, Pitch, Yaw] extrinsics = sensor.extrinsicParameters() print(f"Position: ({extrinsics[0]}, {extrinsics[1]}, {extrinsics[2]}) meters") print(f"Orientation: Roll={extrinsics[3]}, Pitch={extrinsics[4]}, Yaw={extrinsics[5]} degrees") # Set specific extrinsic parameters (meters and degrees) sensor.setExtrinsicTo(12.345, -23.456, 34.567, -0.05, 8.77, -174.14) # Output: 192.168.1.42 <-- sent sent extrinsic parameters request # Reset all extrinsic parameters to zero sensor.setExtrinsicToZero() sensor.disconnect() ``` -------------------------------- ### Lidar Spin Up Method Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Information about the `.lidarSpinUp()` method to power on the sensor. ```APIDOC ## .lidarSpinUp() ### Description The `.lidarSpinUp()` method sends a command to the Livox sensor to switch to its normal power state. If the sensor is in a low-power mode, this method will pause execution until the sensor is fully operational. If the sensor is already active, this method has no effect. ### Method ``` sensor.lidarSpinUp() ``` ### Endpoint N/A (This is a library method) ### Parameters None ### Request Example ```python sensor.lidarSpinUp() ``` ### Response **Success Response (None)** This method does not return a specific success response object. Its success is indicated by the absence of errors and the sensor entering the normal operating mode. **Possible Messages (if showMessage is True):** - `[IP_ADDRESS] <-- sent lidar spin up request` - `[IP_ADDRESS] --> FAILED to spin up the lidar` - `[IP_ADDRESS] --> lidar is spinning up, please wait...` - `[IP_ADDRESS] --> lidar is ready` - `[IP_ADDRESS] --> incorrect lidar spin up response` - `Not connected to Mid-40 sensor at IP: [IP_ADDRESS]` ``` -------------------------------- ### Set Static IP for Livox Sensor using openpylivox Source: https://github.com/ryan-brazeal-ufl/openpylivox/blob/master/Mac OS X DHCP server configuration and usage.txt Sets a static IP address for the Livox sensor using the `setStaticIP()` function from the `openpylivox` library. After applying, the sensor must be rebooted, and the computer's IP address reconfigured. ```python setStaticIP() ``` -------------------------------- ### Spin Up Lidar Sensor Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Transitions the sensor to normal power mode. Execution pauses until the sensor is ready. ```python sensor.lidarSpinUp() ``` -------------------------------- ### Multiple Sensors Operation with OpenPyLivox Source: https://context7.com/ryan-brazeal-ufl/openpylivox/llms.txt Connect and operate multiple Livox sensors simultaneously using the allDoneCapturing() utility function. Ensure proper connection parameters for each sensor. ```python import openpylivox as opl sensors = [] filenames = [] # Connect to multiple sensors with manual configuration sensor1 = opl.openpylivox(True) if sensor1.connect("192.168.1.20", "192.168.1.41", 60001, 50001, 40001): sensors.append(sensor1) filenames.append("sensor1.bin") sensor2 = opl.openpylivox(True) if sensor2.connect("192.168.1.20", "192.168.1.42", 60002, 50002, 40002): sensors.append(sensor2) filenames.append("sensor2.bin") if sensors: # Spin up all sensors for sensor in sensors: sensor.lidarSpinUp() # Start data streams for sensor in sensors: sensor.dataStart_RT_B() # Start capturing from all sensors for i, sensor in enumerate(sensors): sensor.saveDataToFile(filenames[i], 0.0, 5.0) # Wait for ALL sensors to complete using utility function while not opl.allDoneCapturing(sensors): pass # Continue doing other work # Stop and disconnect all sensors for i, sensor in enumerate(sensors): sensor.dataStop() sensor.lidarSpinDown() sensor.disconnect() # Convert binary files to LAS opl.convertBin2LAS(filenames[i], deleteBin=True) ``` -------------------------------- ### Import OpenPyLivox Library Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/1.-Getting-Started Import the OpenPyLivox library into your Python 3 project with this statement. It is aliased as 'opl' for brevity. ```python import openpylivox as opl ``` -------------------------------- ### Property: firmware Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/3.-Object-Properties Retrieves the firmware version of the sensor. ```APIDOC ## Property: firmware ### Description Returns the firmware version of the sensor as a string. ### Return Value string ### Usage Example ```python firmwareStr = sensor.firmware() ``` ``` -------------------------------- ### Sensor Network Methods Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Methods for configuring the sensor's network settings. ```APIDOC ## POST /api/sensors/{id}/network/dynamic ### Description Configures the lidar sensor to use a dynamic IP address assigned by a DHCP server. This command requires a reboot of the sensor to take effect. ### Method POST ### Endpoint /api/sensors/{id}/network/dynamic ### Parameters #### Query Parameters - **showMessage** (boolean) - Optional - If True, displays status messages. ### Request Example ```json { "showMessage": true } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message of the IP change or failure. #### Response Example ```json { "message": "Changed IP from 192.168.1.42 to dynamic IP (DHCP assigned)" } ``` ``` ```APIDOC ## POST /api/sensors/{id}/network/static ### Description Configures the lidar sensor to use a specified static IP address. This command requires a reboot of the sensor to take effect. ### Method POST ### Endpoint /api/sensors/{id}/network/static ### Parameters #### Query Parameters - **showMessage** (boolean) - Optional - If True, displays status messages. #### Request Body - **ipAddress** (string) - Required - The static IP address to assign to the sensor. ### Request Example ```json { "ipAddress": "192.168.1.43", "showMessage": true } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message of the IP change or failure. #### Response Example ```json { "message": "Changed IP from 192.168.1.42 to a static IP of 192.168.1.43" } ``` ``` -------------------------------- ### Binary to LAS Conversion with OpenPyLivox Source: https://context7.com/ryan-brazeal-ufl/openpylivox/llms.txt Convert OpenPyLivox binary point cloud files to LAS format for use with GIS software. Optionally delete the original binary file. IMU data is saved to a separate CSV if captured. ```python import openpylivox as opl # Convert binary file to LAS format opl.convertBin2LAS("scan.bin") # Creates: scan.las # Convert and delete original binary file opl.convertBin2LAS("scan.bin", deleteBin=True) # Creates: scan.las, deletes: scan.bin # If IMU data was captured, it will be saved to a separate CSV file # Creates: scan.las and scan_IMU.csv (if IMU data present) ``` -------------------------------- ### Establish Automatic Connection Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/2.-Sensor-Connection-Options Automatically detects connection parameters. Use the optional computerIP argument if automatic detection fails on multi-network systems. ```python connected = sensor.auto_connect() ``` ```python connected = sensor.auto_connect("192.168.1.20") ``` -------------------------------- ### Set Dynamic IP Address Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Instructs the lidar sensor to obtain an IP address from a DHCP server. The program will exit after execution, requiring a sensor reboot for the change to take effect. Ensure a DHCP server is available on the network. ```python sensor.setDynamicIP() ``` -------------------------------- ### Indefinite Duration Capture with OpenPyLivox Source: https://context7.com/ryan-brazeal-ufl/openpylivox/llms.txt Capture LiDAR data for an indefinite duration and manually close the file when ready. Requires importing openpylivox and time modules. ```python import openpylivox as opl import time sensor = opl.openpylivox(True) sensor.auto_connect() sensor.lidarSpinUp() sensor.dataStart_RT_B() # Duration = 0 means capture indefinitely until manually closed sensor.saveDataToFile("continuous.bin", 0, 0) # Capture for some time (e.g., until a condition is met) time.sleep(10) # Or wait for some external trigger # Manually close the file to stop capture sensor.closeFile() # Output: 192.168.1.42 --> closed BINARY file: *continuous.bin* # (points: 123456 good, 9876 null, 133332 total) sensor.dataStop() sensor.lidarSpinDown() sensor.disconnect() opl.convertBin2LAS("continuous.bin", deleteBin=True) ``` -------------------------------- ### Binary to CSV Conversion with OpenPyLivox Source: https://context7.com/ryan-brazeal-ufl/openpylivox/llms.txt Convert OpenPyLivox binary point cloud files to CSV format. The original binary file can be kept or deleted. ```python import openpylivox as opl # Convert binary file to CSV, keep original binary file opl.convertBin2CSV("scan.bin") # Output: CONVERTING BINARY DATA TO CSV, PLEASE WAIT... # - Data conversion was successful # Creates: scan.csv # Convert binary file to CSV and delete the binary file opl.convertBin2CSV("scan2.bin", deleteBin=True) # Output: CONVERTING BINARY DATA TO CSV, PLEASE WAIT... # - Data conversion was successful # - Binary file has been deleted # Creates: scan2.csv, deletes: scan2.bin ``` -------------------------------- ### Connect to Multiple Sensors Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/2.-Sensor-Connection-Options Iteratively connects to all available sensors on the network using the auto_connect method. ```python sensors = [] connected = 0 while connected != 0: sensor = opl.openpylivox() connected = sensor.auto_connect() if connected: sensors.append(sensor) ``` -------------------------------- ### Lidar Return Mode Configuration Source: https://context7.com/ryan-brazeal-ufl/openpylivox/llms.txt Set the sensor to single or dual return modes, depending on firmware compatibility. ```python import openpylivox as opl sensor = opl.openpylivox(True) sensor.auto_connect() sensor.dataStart_RT_B() # Set return mode: 0 = single 1st return, 1 = single strongest return, 2 = dual returns sensor.setLidarReturnMode(0) # Single first return sensor.setLidarReturnMode(1) # Single strongest return sensor.setLidarReturnMode(2) # Dual returns (requires special firmware) sensor.saveDataToFile("dual_return.bin", 0, 5.0) while not sensor.doneCapturing(): pass sensor.dataStop() sensor.disconnect() ``` -------------------------------- ### Save sensor data to file Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Saves real-time point cloud data to a specified file format. The duration parameter determines the capture time, where a value of 0 requires a manual call to closeFile(). ```python sensor.saveDataToFile("points.csv", 1.5, 12.34) ``` -------------------------------- ### Coordinate System Selection Source: https://context7.com/ryan-brazeal-ufl/openpylivox/llms.txt Configure the sensor to output point data in either Cartesian or Spherical coordinate systems. ```python import openpylivox as opl sensor = opl.openpylivox(True) sensor.auto_connect() # Set output to Cartesian coordinates (default) sensor.setCartesianCS() # Output: 192.168.1.42 <-- sent change to Cartesian coordinates request # Set output to Spherical coordinates sensor.setSphericalCS() # Output: 192.168.1.42 <-- sent change to Spherical coordinates request sensor.disconnect() ``` -------------------------------- ### Convert binary data to CSV Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/5.-Library-Functions Converts captured binary point cloud files into CSV format. Optionally deletes the source binary file after conversion to save storage space. ```text 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 ``` ```python import openpylivox as opl opl.convertBin2CSV("my_fav_pc.bin") opl.convertBin2CSV("my_least_fav_pc.bin",True) ``` -------------------------------- ### Property: connectionParameters Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/3.-Object-Properties Retrieves the connection details for the sensor. ```APIDOC ## Property: connectionParameters ### Description Returns a list of 4 string elements containing connection details. ### Return Value List of strings: [computerIP, sensorIP, dataPort, cmdPort] ### Usage Example ```python connParamsStrList = sensor.connectionParameters() ``` ``` -------------------------------- ### Set ShowMessages Property Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/3.-Object-Properties Control whether information messages are printed to sys.stdout during runtime. Recommended to set to True when first using the library. ```python sensor.showMessages = True ``` ```python sensor.showMessages = False ``` ```python if sensor.showMessages: print("The sensor is currently set to display information messages") else: print("The sensor is currently not set to display information messages") ``` -------------------------------- ### Lidar Standby Method Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Information regarding the `.lidarStandBy()` method for placing the sensor in standby mode. ```APIDOC ## .lidarStandBy() ### Description The `.lidarStandBy()` method sends a command to the Livox sensor to enter a stand-by state. The exact functionality of stand-by mode is not fully detailed, but it is suggested that the laser may be shut off while other components might remain active. If the sensor is already in stand-by mode, this method has no effect. ### Method ``` sensor.lidarStandBy() ``` ### Endpoint N/A (This is a library method) ### Parameters None ### Request Example ```python sensor.lidarStandBy() ``` ### Response **Success Response (None)** This method does not return a specific success response object. Its success is indicated by the absence of errors and the sensor entering stand-by mode. **Possible Messages (if showMessage is True):** - `[IP_ADDRESS] <-- sent lidar stand-by request` - `[IP_ADDRESS] --> FAILED to set lidar to stand-by` - `[IP_ADDRESS] --> incorrect lidar stand-by response` - `Not connected to Mid-40 sensor at IP: [IP_ADDRESS]` ``` -------------------------------- ### Sensor Power Control Source: https://context7.com/ryan-brazeal-ufl/openpylivox/llms.txt Manage sensor spin states and power modes using spin up, spin down, and stand-by methods. ```python import openpylivox as opl sensor = opl.openpylivox(True) sensor.auto_connect() # Bring sensor to normal operating mode (starts spinning) sensor.lidarSpinUp() # Output: 192.168.1.42 --> lidar is spinning up, please wait... # Output: 192.168.1.42 --> lidar is ready # Perform data capture operations... sensor.dataStart_RT_B() sensor.saveDataToFile("data.bin", 0, 3.0) while not sensor.doneCapturing(): pass sensor.dataStop() # Put sensor in power-saving mode (stops spinning, stays powered) sensor.lidarSpinDown() # Output: 192.168.1.42 <-- sent lidar spin down request # Or put sensor in stand-by mode # sensor.lidarStandBy() sensor.disconnect() ``` -------------------------------- ### Save Data to File Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Saves captured point cloud data to a specified file. The extrinsic parameter values are not utilized in this version. If duration is 0, data capture continues indefinitely until manually stopped. ```python sensor.saveDataToFile(filePathAndName, secsToWait, duration) ``` -------------------------------- ### Rain and Fog Suppression Source: https://context7.com/ryan-brazeal-ufl/openpylivox/llms.txt Toggle the built-in rain and fog suppression algorithm for different environmental conditions. ```python import openpylivox as opl sensor = opl.openpylivox(True) sensor.auto_connect() # Enable rain/fog suppression for outdoor scanning sensor.setRainFogSuppression(True) # Output: 192.168.1.42 <-- sent turn on/off rain/fog suppression request # Disable rain/fog suppression for indoor scanning sensor.setRainFogSuppression(False) sensor.disconnect() ``` -------------------------------- ### Set Lidar to Standby Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Sends a command to set the sensor to standby mode. ```python sensor.lidarStandBy() ``` -------------------------------- ### Verify Connection Status Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/2.-Sensor-Connection-Options Checks the integer return value of connection methods to confirm if a sensor is available and the connection is established. ```python if connected: #connection has been established, safe to proceed sensor.serialNumber() else: #do something else print("WTF") ``` -------------------------------- ### IMU Data Capture Source: https://context7.com/ryan-brazeal-ufl/openpylivox/llms.txt Enable IMU data streaming and convert binary capture files to CSV format. ```python import openpylivox as opl sensor = opl.openpylivox(True) sensor.auto_connect() # Enable IMU data push (only for Horizon and Tele-15 sensors) sensor.setIMUdataPush(True) sensor.dataStart_RT_B() sensor.saveDataToFile("scan_with_imu.bin", 0, 5.0) while not sensor.doneCapturing(): pass sensor.dataStop() sensor.disconnect() # Convert to CSV - creates both point cloud CSV and IMU CSV opl.convertBin2CSV("scan_with_imu.bin", deleteBin=True) # Creates: scan_with_imu.csv (point cloud) and scan_with_imu_IMU.csv (IMU data) ``` -------------------------------- ### Sensor Status and Capture Control Source: https://context7.com/ryan-brazeal-ufl/openpylivox/llms.txt Retrieve sensor status codes and monitor data capture completion. ```python # Get lidar status codes [system, temp, voltage, motor, dirty, firmware, pps, device] status = sensor.lidarStatusCodes() # Output: System Status: OK, Temperature Status: OK, Voltage Status: OK, etc. # Check if data capture is complete if sensor.doneCapturing(): print("Capture finished") sensor.disconnect() ``` -------------------------------- ### Property: showMessages Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/3.-Object-Properties Controls whether information messages are printed to stdout during runtime. ```APIDOC ## Property: showMessages ### Description A boolean property used to indicate whether information messages should be printed to the screen (sys.stdout) during runtime. Error messages are always printed regardless of this setting. ### Type boolean ### Usage Example ```python sensor.showMessages = True ``` ``` -------------------------------- ### Set Extrinsic Parameters Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Sends a command to the lidar sensor to set extrinsic parameters to specific values and updates the OpenPyLivox object. Automatically calls `.readExtrinsic()` to verify. ```APIDOC ## PUT /api/sensor/extrinsic ### Description Sends a command to the lidar sensor to set the extrinsic parameters to specific values. The OpenPyLivox sensor object's extrinsic parameters are also set to the same specific values. The `.readExtrinsic()` method is automatically called to verify the command was successful. ### Method PUT ### Endpoint /api/sensor/extrinsic ### Parameters #### Request Body - **x** (float) - Required - The x cartesian coordinate of the sensor, in meters. - **y** (float) - Required - The y cartesian coordinate of the sensor, in meters. - **z** (float) - Required - The z cartesian coordinate of the sensor, in meters. - **roll** (float) - Required - The roll orientation angle of the sensor, in degrees. - **pitch** (float) - Required - The pitch orientation angle of the sensor, in degrees. - **yaw** (float) - Required - The yaw orientation angle of the sensor, in degrees. - **showMessage** (boolean) - Optional - If true, prints messages to the screen. ### Request Example ```json { "x": 12.345, "y": -23.456, "z": 34.567, "roll": -0.05, "pitch": 8.77, "yaw": -174.14, "showMessage": true } ``` ### Response #### Success Response (200) - **status** (string) - Indicates success or failure of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Saving Data to File Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Saves captured point cloud data to either an ASCII or BINARY file. The duration parameter controls how long data is captured before the file is closed. ```APIDOC ## POST /api/sensor/saveDataToFile ### Description Saves real-time data to an ASCII or BINARY file. ### Method POST ### Endpoint /api/sensor/saveDataToFile ### Parameters #### Query Parameters - **filename** (string) - Required - The name of the file to save data to (e.g., "points.csv", "points.bin"). - **duration** (float) - Required - The duration in seconds to capture data. If 0, the file is closed immediately after capture. - **interval** (float) - Optional - The interval in seconds for data capture. ### Request Example ```json { "filename": "points.csv", "duration": 1.5, "interval": 12.34 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation (e.g., "Data saved successfully"). #### Response Example ```json { "status": "Data saved successfully to points.csv" } ``` ``` -------------------------------- ### Monitor multiple sensors with allDoneCapturing Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/5.-Library-Functions Checks a list of OpenPyLivox objects to determine if all sensors have finished capturing data. This function is intended for use in runtime loops and does not output messages. ```python 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 break ``` -------------------------------- ### Save Data to CSV Source: https://github.com/ryan-brazeal-ufl/openpylivox/wiki/4.-Object-Methods Saves captured point cloud data to a CSV file. The extrinsic parameter values are not utilized in this version. If duration is 0, data capture continues indefinitely until manually stopped. ```python sensor.saveDataToCSV("points", 1.5, 12.34) ```