do not crash in tracker when math3d is not installed
This commit is contained in:
		| @@ -2,8 +2,13 @@ import time | |||||||
| from multiprocessing import Process, Queue, Event | from multiprocessing import Process, Queue, Event | ||||||
|  |  | ||||||
| from urx import urrtmon | from urx import urrtmon | ||||||
| from math3d import Transform |  | ||||||
|  |  | ||||||
|  | MATH3D = True | ||||||
|  | try: | ||||||
|  |     import math3d | ||||||
|  | except ImportError: | ||||||
|  |     MATH3D = False | ||||||
|  |     print("pymath3d library could not be found on this computer, disabling use of matrices") | ||||||
|  |  | ||||||
| class Tracker(Process): | class Tracker(Process): | ||||||
|     def __init__(self, robot_host): |     def __init__(self, robot_host): | ||||||
| @@ -13,6 +18,7 @@ class Tracker(Process): | |||||||
|         self._stop = Event() |         self._stop = Event() | ||||||
|         self._finished = Event() |         self._finished = Event() | ||||||
|         self._data = [] |         self._data = [] | ||||||
|  | 	if MATH3D: | ||||||
|             self.calibration = Transform() |             self.calibration = Transform() | ||||||
|             self.inverse = self.calibration.inverse() |             self.inverse = self.calibration.inverse() | ||||||
|  |  | ||||||
| @@ -20,10 +26,12 @@ class Tracker(Process): | |||||||
|         print(self.__class__.__name__, ": ".join([str(i) for i in args])) |         print(self.__class__.__name__, ": ".join([str(i) for i in args])) | ||||||
|  |  | ||||||
|     def set_calibration_matrix(self, cal): |     def set_calibration_matrix(self, cal): | ||||||
|  | 	if MATH3D: | ||||||
|             self.calibration = cal |             self.calibration = cal | ||||||
|             self.inverse = self.calibration.inverse() |             self.inverse = self.calibration.inverse() | ||||||
|  |  | ||||||
|     def _save_data(self): |     def _save_data(self): | ||||||
|  | 	if MATH3D: | ||||||
|             for data in self._data: |             for data in self._data: | ||||||
|                 data["transform"] = self.inverse * Transform(data["tcp"]) |                 data["transform"] = self.inverse * Transform(data["tcp"]) | ||||||
|         self._queue.put(self._data) |         self._queue.put(self._data) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user