@@ -90,11 +90,6 @@ def __init__(
90
90
mask: A 6 vector which assigns weights to Cartesian degrees-of-freedom
91
91
problems: Total number of IK problems within the experiment
92
92
joint_limits: Reject solutions with joint limit violations
93
-
94
- λΣ: The gain for joint limit avoidance. Setting to 0.0 will remove this completely from the solution
95
- λm: The gain for maximisation. Setting to 0.0 will remove this completely from the solution
96
- ps: The minimum angle/distance (in radians or metres) in which the joint is allowed to approach to its limit
97
- pi: The influence angle/distance (in radians or metres) in null space motion becomes active
98
93
"""
99
94
100
95
# Solver parameters
@@ -131,27 +126,32 @@ def solve(
131
126
"""
132
127
133
128
if q0 is None :
134
- q0 = ets .random_q (self .slimit )
129
+ q0 = self .random_q (ets , self .slimit )
135
130
elif not isinstance (q0 , np .ndarray ):
136
131
q0 = np .array (q0 )
137
132
138
133
if q0 .ndim == 1 :
139
- q0_new = ets .random_q (self .slimit )
134
+ q0_new = self .random_q (ets , self .slimit )
140
135
q0_new [0 ] = q0
141
136
q0 = q0_new
142
137
143
138
# Iteration count
144
139
i = 0
145
140
total_i = 0
146
141
142
+ # Error flags
143
+ found_with_limits = False
144
+ linalg_error = 0
145
+
147
146
# Initialise variables
148
147
E = 0.0
149
148
q = q0 [0 ]
150
149
151
150
for search in range (self .slimit ):
152
151
q = q0 [search ].copy ()
152
+ i = 0
153
153
154
- while i <= self .ilimit :
154
+ while i < self .ilimit :
155
155
i += 1
156
156
157
157
# Attempt a step
@@ -160,6 +160,7 @@ def solve(
160
160
161
161
except np .linalg .LinAlgError :
162
162
# Abandon search and try again
163
+ linalg_error += 1
163
164
break
164
165
165
166
# Check if we have arrived
@@ -175,6 +176,7 @@ def solve(
175
176
176
177
if not jl_valid and self .joint_limits :
177
178
# Abandon search and try again
179
+ found_with_limits = True
178
180
break
179
181
else :
180
182
return IKSolution (
@@ -185,17 +187,16 @@ def solve(
185
187
residual = E ,
186
188
reason = "Success" ,
187
189
)
188
-
189
190
total_i += i
190
- i = 0
191
191
192
192
# If we make it here, then we have failed
193
- reason = "ilimit and slimit reached"
193
+ reason = "iteration and search limit reached"
194
194
195
- if E < self .tol :
195
+ if linalg_error :
196
+ reason += f", { linalg_error } np.LinAlgError encountered"
197
+
198
+ if found_with_limits :
196
199
reason += ", solution found but violates joint limits"
197
- else :
198
- reason += ", no solution found"
199
200
200
201
return IKSolution (
201
202
q = q ,
@@ -358,6 +359,12 @@ def calc_qnull(
358
359
return qnull .flatten ()
359
360
360
361
362
+ # λΣ: The gain for joint limit avoidance. Setting to 0.0 will remove this completely from the solution
363
+ # λm: The gain for maximisation. Setting to 0.0 will remove this completely from the solution
364
+ # ps: The minimum angle/distance (in radians or metres) in which the joint is allowed to approach to its limit
365
+ # pi: The influence angle/distance (in radians or metres) in null space motion becomes active
366
+
367
+
361
368
class IK_NR (IKSolver ):
362
369
def __init__ (
363
370
self ,
0 commit comments