@@ -145,9 +145,19 @@ def inverse_kinematics_spherical_wrist(target_frame, points):
145145 axis1_angle -= 2 * math .pi
146146 axis1_angles += [axis1_angle ] * 4
147147 else :
148- circle = (0 , 0 , 0 ), pln_offset
148+ circle = (( 0 , 0 , 0 ), ( 0 , 0 , 1 ) ), pln_offset
149149 point = (wrist .x , wrist .y , 0 )
150- t1 , t2 = tangent_points_to_circle_xy (circle , point )
150+ # On COMPAS v1.17+, this function correctly expects a circle to be
151+ # defined as a plane and float (in which plane needs to be a point and vector)
152+ # however, in version v1.16 and older, the function expected only a point
153+ # we default to the correct behavior for v1.17+ but if we get a TypeError
154+ # it means an older COMPAS core is installed so we revert to defining the
155+ # circle in the old, incorrect way of using just a point and float
156+ try :
157+ t1 , t2 = tangent_points_to_circle_xy (circle , point )
158+ except TypeError :
159+ circle = (0 , 0 , 0 ), pln_offset
160+ t1 , t2 = tangent_points_to_circle_xy (circle , point )
151161 a1 = Vector (0 , 1 , 0 ).angle_signed (t1 , (0 , 0 , - 1 ))
152162 a2 = Vector (0 , 1 , 0 ).angle_signed (t2 , (0 , 0 , - 1 ))
153163 axis1_angles += [a1 ] * 4
@@ -185,9 +195,9 @@ def inverse_kinematics_spherical_wrist(target_frame, points):
185195 for k in range (2 ):
186196 axis2_angles .append (- axis2_angle )
187197 axis3_angle_wrapped = - axis3_angle + math .pi
188- while ( axis3_angle_wrapped >= math .pi ) :
198+ while axis3_angle_wrapped >= math .pi :
189199 axis3_angle_wrapped -= 2 * math .pi
190- while ( axis3_angle_wrapped < - math .pi ) :
200+ while axis3_angle_wrapped < - math .pi :
191201 axis3_angle_wrapped += 2 * math .pi
192202 axis3_angles .append (axis3_angle_wrapped )
193203
@@ -208,9 +218,9 @@ def inverse_kinematics_spherical_wrist(target_frame, points):
208218 axis4_angle -= 2 * math .pi
209219
210220 axis4_angle_wrapped = axis4_angle + math .pi / 2
211- while ( axis4_angle_wrapped >= math .pi ) :
221+ while axis4_angle_wrapped >= math .pi :
212222 axis4_angle_wrapped -= 2 * math .pi
213- while ( axis4_angle_wrapped < - math .pi ) :
223+ while axis4_angle_wrapped < - math .pi :
214224 axis4_angle_wrapped += 2 * math .pi
215225 axis4_angles .append (axis4_angle_wrapped )
216226
0 commit comments