File tree Expand file tree Collapse file tree 2 files changed +60
-10
lines changed Expand file tree Collapse file tree 2 files changed +60
-10
lines changed Original file line number Diff line number Diff line change @@ -2578,8 +2578,8 @@ def ikine_LM(
2578
2578
** kwargs ,
2579
2579
)
2580
2580
2581
- if isinstance (Tep , SE3 ):
2582
- Tep = Tep .A
2581
+ # if isinstance(Tep, SE3):
2582
+ # Tep = Tep.A
2583
2583
2584
2584
return solver .solve (ets = self , Tep = Tep , q0 = q0 )
2585
2585
@@ -2717,8 +2717,8 @@ def ikine_NR(
2717
2717
** kwargs ,
2718
2718
)
2719
2719
2720
- if isinstance (Tep , SE3 ):
2721
- Tep = Tep .A
2720
+ # if isinstance(Tep, SE3):
2721
+ # Tep = Tep.A
2722
2722
2723
2723
return solver .solve (ets = self , Tep = Tep , q0 = q0 )
2724
2724
@@ -2871,8 +2871,8 @@ def ikine_GN(
2871
2871
** kwargs ,
2872
2872
)
2873
2873
2874
- if isinstance (Tep , SE3 ):
2875
- Tep = Tep .A
2874
+ # if isinstance(Tep, SE3):
2875
+ # Tep = Tep.A
2876
2876
2877
2877
return solver .solve (ets = self , Tep = Tep , q0 = q0 )
2878
2878
@@ -3068,8 +3068,8 @@ def ikine_QP(
3068
3068
** kwargs ,
3069
3069
)
3070
3070
3071
- if isinstance (Tep , SE3 ):
3072
- Tep = Tep .A
3071
+ # if isinstance(Tep, SE3):
3072
+ # Tep = Tep.A
3073
3073
3074
3074
return solver .solve (ets = self , Tep = Tep , q0 = q0 )
3075
3075
Original file line number Diff line number Diff line change @@ -238,12 +238,62 @@ def solve(
238
238
239
239
q0 = q0_method
240
240
241
+ traj = False
242
+
243
+ methTep : np .ndarray
244
+
241
245
if isinstance (Tep , SE3 ):
242
- Tep : np .ndarray = Tep .A
246
+ if len (Tep ) > 1 :
247
+ traj = True
248
+ methTep = np .empty ((len (Tep ), 4 , 4 ))
243
249
244
- if Tep .shape != (4 , 4 ):
250
+ for i , T in enumerate (Tep ):
251
+ methTep [i ] = T .A
252
+ else :
253
+ methTep = Tep .A
254
+ elif Tep .ndim == 3 :
255
+ traj = True
256
+ methTep = Tep
257
+ elif Tep .shape != (4 , 4 ):
245
258
raise ValueError ("Tep must be a 4x4 SE3 matrix" )
259
+ else :
260
+ methTep = Tep
261
+
262
+ if traj :
263
+ q = np .empty ((methTep .shape [0 ], ets .n ))
264
+ success = True
265
+ interations = 0
266
+ searches = 0
267
+ residual = np .inf
268
+ reason = ""
269
+
270
+ for i , T in enumerate (methTep ):
271
+ sol = self ._solve (ets , T , q0 )
272
+ q [i ] = sol .q
273
+ if not sol .success :
274
+ success = False
275
+ reason = sol .reason
276
+ interations += sol .iterations
277
+ searches += sol .searches
278
+
279
+ if sol .residual < residual :
280
+ residual = sol .residual
281
+
282
+ return IKSolution (
283
+ q = q ,
284
+ success = success ,
285
+ iterations = interations ,
286
+ searches = searches ,
287
+ residual = residual ,
288
+ reason = reason ,
289
+ )
290
+
291
+ else :
292
+ sol = self ._solve (ets , methTep , q0 )
293
+
294
+ return sol
246
295
296
+ def _solve (self , ets : "rtb.ETS" , Tep : np .ndarray , q0 : np .ndarray ) -> IKSolution :
247
297
# Iteration count
248
298
i = 0
249
299
total_i = 0
You can’t perform that action at this time.
0 commit comments