2. Sensor Connection Options - ryan-brazeal-ufl/OpenPyLivox GitHub Wiki

2.1 Introduction

There are four connection parameters used to establish the necessary UDP communication channels between a user's computer and a Livox lidar sensor. These four parameters are:

  • Computer's IP Address (v4)
  • Computer's Port Number for receiving Point Cloud Data
  • Computer's Port Number for sending/receiving Commands to/from the Sensor
  • Sensor's IP Address (v4)

There are two different connection methods that an OpenPyLivox object can use to establish a connection to a Livox lidar sensor.

2.2 Automatic Connection

The first method, attempts to automatically detect and specify all four of the required connection parameters for the user. This method works well with both dynamic and static IP based networks. The method call is:

.auto_connect([computerIP])

The optional string [computerIP] argument can be used in the cases where, the IP address of the user's computer is not being automatically detected correctly. Currently, user computer's that are connected to multiple networks (e.g., Wi-Fi and wired Ethernet) may experience a problem having their desired IP address being automatically detected. Also, some Linux based systems may experience a problem with their IP address being correctly detected (this is currently being investigated).

e.g., connected = sensor.auto_connect()
        connected = sensor.auto_connect("192.168.1.20")

The Livox sensor's IP address is searched for on the same network as the computer is on (based on the computer's IP address). Because of the documented way that Livox sensors always inform other computers that they are available on a network, it is easy to automatically detect their IP address(es). The remaining two connection parameters (computer data and command port numbers), are automatically assigned to unused ports.

2.3 Manual Connection

The second method, requires the user to specify all four of the connection parameters. Currently, the IP addresses and port numbers are only checked to make sure they are in the proper formats and within the acceptable numerical limits. The method call is:

.connect(computerIP, sensorIP, dataPort, cmdPort)

The string computerIP argument specifies the IP address of the computer. It is the still the user's responsibility to make sure that their computer's IP address is actually assigned to the value they specify. The string sensorIP argument specifies the IP address of the Livox lidar sensor they want to connect to. The integer dataPort argument specifies the port number of the user's computer that will receive the point cloud data. The integer cmdPort argument specifies the port number of the user's computer that will send/receive commands to/from the sensor.

e.g., connected = sensor.connect("192.168.1.20", "192.168.1.42", 60001, 50001)

2.4 Testing the Connection

Both sensor connection options return an integer value. In the previous examples, this returned integer value is stored in the connected variable. The value of the returned integer indicates the number of Livox lidar sensors that are available to be connected to on the user's network. The user can test if this variable is not equal to zero, in order to safely determine if the connection between their computer and the sensor has been established.

e.g.,

if connected:
   #connection has been established, safe to proceed
   sensor.serialNumber()
else:
   #do something else
   print("WTF")

If multiple Livox lidar sensors are available on the user's network, the first sensor detected will be used for the connection. This is a random result, meaning each successive execution of the user's program could connect to a different sensor each time. Assigning unique static IP addresses for each sensor, and using the manual connection option would be the way to solve this problem.

If a user wants to automatically connect to all the available Livox lidar sensors on their network using .auto_connect(), the following code example could be used,

sensors = []
connected = 0
while connected != 0:
   sensor = opl.openpylivox()
   connected = sensor.auto_connect()
   if connected:
      sensors.append(sensor)

For a detailed example of connecting to and operating multiple Livox lidar sensors, please view livox_controller_demo.py



Previous Page  |  Next Page

⚠️ **GitHub.com Fallback** ⚠️