def connect_and_configure(ip="192.168.0.20", data_thread_delay=1000, callback=echoes_callback): dev = leddar.Device() if not dev.connect(ip, leddar.device_types["LeddarAuto"], 48630): print("connection failed!") raise RuntimeError("Connection failed!") dev.set_callback_echo(callback) dev.set_data_mask(leddar.data_masks["PDM_ECHOES"]) dev.set_data_thread_delay(data_thread_delay) return dev
def connect_and_set_apd_bias(value=170): ''' use this after you performed a './LCA3 -b all' on your unit. 160 to 190 range seems right for the 3DF ''' dev = leddar.Device() if not dev.connect("192.168.0.20", leddar.device_types["LeddarAuto"], 48630): raise RuntimeError("Connection failed!") dev.set_property_value(leddar.property_ids['ID_APD_VBIAS_VOLTAGE_T0'], str(value)) print("ID_SENSIVITY:" + dev.get_property_value(leddar.property_ids['ID_SENSIVITY'])) print( "ID_APD_VBIAS_VOLTAGE_T0:" + dev.get_property_value(leddar.property_ids['ID_APD_VBIAS_VOLTAGE_T0'])) print("ID_APD_VBIAS_MULTI_FACTOR:" + dev.get_property_value( leddar.property_ids['ID_APD_VBIAS_MULTI_FACTOR'])) print("ID_APD_VBIAS_T0:" + dev.get_property_value(leddar.property_ids['ID_APD_VBIAS_T0'])) dev.disconnect()
print("Channel - Timestamp - Distance - Amplitude - Flag") for i in range(0, len(data), increment): print( str(data[i]["indices"]) + " - " + str(data[i]["distances"]) + " - " + str(data[i]["amplitudes"]) + " - " + str(data[i]["flags"])) def states_callback(states): print("timestamp: " + str(states["timestamp"])) print("cpu_load " + str(states["cpu_load"]) + "%") print("system_temp " + str(states["system_temp"]) + " C") #Create device dev = leddar.Device() #Connect to the device sensorlist = leddar.get_devices("Usb") dev.connect(sensorlist[0]['name'], leddar.device_types["Usb"]) #Get properties value print("ID_BASE_POINT_COUNT = " + dev.get_property_value(leddar.property_ids["ID_BASE_POINT_COUNT"])) print("ID_LED_INTENSITY = " + dev.get_property_value(leddar.property_ids["ID_LED_INTENSITY"])) #Property available values values = dev.get_property_available_values( leddar.property_ids["ID_LED_INTENSITY"]) print(values["type"])
def _update(self): if not self._running: return if self._dev is None or not self._connected: self._dev = leddar.Device() if not self._dev.connect(self._ip): self._connected = False self.connectedChanged.emit() self._dev = None return self._connected = True self.connectedChanged.emit() self._emitConnectedChanged = True if self._specs is None: self._specs = utils.get_specs(self._dev) else: self._overriden_specs = True self._handle_specs_changed() def echo_callback(new_echoes): if not self._locked: self._received_echoes.append(new_echoes) self.makeDirty() self._dev.set_callback_echo(echo_callback) self._dev.set_data_mask(leddar.data_masks["PDM_ECHOES"]) def state_callback(new_state): if not self._locked: self._received_states.append(new_state) self.makeDirty() self._dev.set_callback_state(state_callback) self._dev.set_data_mask(self._dev.get_data_mask() | leddar.data_masks["PDM_STATES"]) self._update_traces_mode() self._update_data_thread() self._n_received = 0 if self._received_echoes: self._n_received += 1 self._locked = True self._nDroppedPackages = len(self._received_echoes) - 1 last_received = self._received_echoes[-1] last_received['data'] = last_received['data'][np.isin(last_received['data']['flags'], self._rejectedFalgs, invert = True)] if self._calibrating: self._calibration_samples.append(last_received) else: if (self._dTCorrection) and (self._states is not None): T = self._states['system_temp'] last_received = calibration.distance_correction_temperature(last_received, T, self._dTGainFactor, self._dTFix) if (self._aTCorrection) and (self._states is not None): T = self._states['system_temp'] last_received = calibration.amplitude_correction_temperature(last_received, T, self._aTGainFactor, self._aTThreshold) self._received_echoes = [] self._locked = False self.nDroppedPackagesChanged.emit() if self._ts_prev is None: self._ts_prev = time.time() ts = time.time()#last_received['timestamp'] if self._n_received%10 == 0: self._fps = 10 /(ts - self._ts_prev) self.fpsChanged.emit() self._ts_prev = ts if self._emitConnectedChanged: #important for those watching properties. properties seem only valid after the first echo self._emitConnectedChanged = False self.connectedChanged.emit() self._update_with_last_received(last_received) if self._received_states: last_received = self._received_states[-1] self.set_states(self, last_received) self._received_states = [] if self._calibrating: self._calibration_states_samples.append(last_received) if self._calibrating: self.set_calibrationProgress(self, len(self._calibration_samples)/(self._n_calibration_samples+self._n_drop_calib_samples)) if self._calibrationProgress >= 1.0: self._calibration_samples = self._calibration_samples[-self._n_calibration_samples::] self._calibration_states_samples = self._calibration_states_samples[-self._n_calibration_samples::] offsets = calibration.calibrate(self._calibration_samples, self._calibration_wall_distance, self._specs, self._interpCal) if self._dTCorrection: offsets = calibration.set_offset_to_base_temperature(self._calibration_states_samples, offsets, self._dTGainFactor, self._dTFix) self._dev.set_calib_values(leddar.calib_types['ID_TIMEBASE_DELAY'], offsets.tolist()) self.saveCalibration(offsets = offsets.tolist()) self.set_calibrating(self, False) if self._received_traces_raw: self._update_traces_with_last_recieved(self._received_traces_raw[-1]) self._received_traces_raw = []