11from __future__ import division
2+ import logging
23
34import time
45
@@ -32,13 +33,16 @@ def __init__(self, slot_centers):
3233 """
3334 self ._num_slots = UnipuckTemplate .NUM_SLOTS
3435 self ._slot_centers = slot_centers
36+ self .log = logging .getLogger ("." .join ([__name__ ]))
3537
3638 def perform_alignment (self ):
3739 num_points = len (self ._slot_centers )
3840
3941 if num_points > self ._num_slots :
42+ self .log .debug ("Too many slots detected to perform Unipuck alignment" )
4043 raise GeometryAlignmentError ("Too many slots detected to perform Unipuck alignment" )
4144 elif num_points < MIN_POINTS_FOR_ALIGNMENT :
45+ self .log .debug ("Not enough slots detected to perform Unipuck alignment" )
4246 raise GeometryAlignmentError ("Not enough slots detected to perform Unipuck alignment" )
4347
4448 puck = self ._calculate_puck_alignment ()
@@ -58,6 +62,7 @@ def _calculate_puck_alignment(self):
5862 return puck
5963
6064 except Exception :
65+ self .log .error (GeometryAlignmentError ("Unipuck alignment failed" ))
6166 raise GeometryAlignmentError ("Unipuck alignment failed" )
6267
6368 @staticmethod
@@ -125,6 +130,8 @@ def _determine_puck_orientation(puck, pin_centers):
125130
126131 average_error = best_sse / (puck .radius () ** 2 ) / len (pin_centers )
127132 if average_error > 0.003 :
133+ log = logging .getLogger ("." .join ([__name__ ]))
134+ log .debug ("Unable to determine Unipuck orientation" )
128135 raise GeometryAlignmentError ("Unable to determine Unipuck orientation" )
129136
130137 return best_angle
@@ -179,6 +186,8 @@ def _partition(numbers):
179186 than the average of the first.
180187 """
181188 if len (numbers ) < 3 :
189+ log = logging .getLogger ("." .join ([__name__ ]))
190+ log .debug ("Not enought elements to run partition" )
182191 raise Exception ("Not enought elements to run partition" )
183192
184193 numbers .sort ()
@@ -187,6 +196,8 @@ def _partition(numbers):
187196
188197 while s < len (numbers ):
189198 if not numbers [:s + 1 ] or not numbers [- s - 1 :]:
199+ log = logging .getLogger ("." .join ([__name__ ]))
200+ log .debug ("Empty slice" )
190201 raise Exception ("Empty slice" )
191202
192203 gp1_average = np .mean (numbers [:s + 1 ])
0 commit comments