@@ -118,6 +118,7 @@ def ikine_LM(
118
118
search = False ,
119
119
slimit = 100 ,
120
120
transpose = None ,
121
+ end = None ,
121
122
):
122
123
"""
123
124
Numerical inverse kinematics by Levenberg-Marquadt optimization
@@ -248,6 +249,9 @@ def ikine_LM(
248
249
if not isinstance (T , SE3 ):
249
250
raise TypeError ("argument must be SE3" )
250
251
252
+ if isinstance (self , rtb .DHRobot ):
253
+ end = None
254
+
251
255
solutions = []
252
256
253
257
if search :
@@ -323,14 +327,14 @@ def ikine_LM(
323
327
failure = f"iteration limit { ilimit } exceeded"
324
328
break
325
329
326
- e = base .tr2delta (self .fkine (q ).A , Tk .A )
330
+ e = base .tr2delta (self .fkine (q , end = end ).A , Tk .A )
327
331
328
332
# Are we there yet?
329
333
if base .norm (W @ e ) < tol :
330
334
break
331
335
332
336
# Compute the Jacobian
333
- J = self .jacobe (q )
337
+ J = self .jacobe (q , end = end )
334
338
335
339
JtJ = J .T @ W @ J
336
340
@@ -356,7 +360,7 @@ def ikine_LM(
356
360
qnew = q + dq
357
361
358
362
# And figure out the new error
359
- enew = base .tr2delta (self .fkine (qnew ).A , Tk .A )
363
+ enew = base .tr2delta (self .fkine (qnew , end = end ).A , Tk .A )
360
364
361
365
# Was it a good update?
362
366
if np .linalg .norm (W @ enew ) < np .linalg .norm (W @ e ):
@@ -404,7 +408,9 @@ def ikine_LM(
404
408
405
409
# --------------------------------------------------------------------- #
406
410
407
- def ikine_LMS (self , T , q0 = None , mask = None , ilimit = 500 , tol = 1e-10 , wN = 1e-3 , Lmin = 0 ):
411
+ def ikine_LMS (
412
+ self , T , q0 = None , mask = None , ilimit = 500 , tol = 1e-10 , wN = 1e-3 , Lmin = 0 , end = None
413
+ ):
408
414
"""
409
415
Numerical inverse kinematics by Levenberg-Marquadt optimization
410
416
(Robot superclass)
@@ -512,6 +518,9 @@ def ikine_LMS(self, T, q0=None, mask=None, ilimit=500, tol=1e-10, wN=1e-3, Lmin=
512
518
if not isinstance (T , SE3 ):
513
519
raise TypeError ("argument must be SE3" )
514
520
521
+ if isinstance (self , rtb .DHRobot ):
522
+ end = None
523
+
515
524
solutions = []
516
525
517
526
if q0 is None :
@@ -545,15 +554,15 @@ def ikine_LMS(self, T, q0=None, mask=None, ilimit=500, tol=1e-10, wN=1e-3, Lmin=
545
554
failure = f"iteration limit { ilimit } exceeded"
546
555
break
547
556
548
- e = _angle_axis (self .fkine (q ).A , Tk .A )
557
+ e = _angle_axis (self .fkine (q , end = end ).A , Tk .A )
549
558
550
559
# Are we there yet?
551
560
E = 0.5 * e .T @ W @ e
552
561
if E < tol :
553
562
break
554
563
555
564
# Compute the Jacobian and projection matrices
556
- J = self .jacob0 (q )
565
+ J = self .jacob0 (q , end = end )
557
566
WN = E * np .eye (self .n ) + wN * np .eye (self .n )
558
567
H = J .T @ W @ J + WN # n x n
559
568
g = J .T @ W @ e # n x 1
@@ -607,6 +616,7 @@ def ikine_min(
607
616
stiffness = 0 ,
608
617
costfun = None ,
609
618
options = {},
619
+ end = None ,
610
620
):
611
621
r"""
612
622
Inverse kinematics by optimization with joint limits (Robot superclass)
@@ -715,6 +725,9 @@ def ikine_min(
715
725
if not isinstance (T , SE3 ):
716
726
raise TypeError ("argument must be SE3" )
717
727
728
+ if isinstance (self , rtb .DHRobot ):
729
+ end = None
730
+
718
731
if q0 is None :
719
732
q0 = np .zeros ((self .n ))
720
733
else :
@@ -745,7 +758,7 @@ def ikine_min(
745
758
746
759
def cost (q , T , weight , costfun , stiffness ):
747
760
# T, weight, costfun, stiffness = args
748
- e = _angle_axis (self .fkine (q ).A , T ) * weight
761
+ e = _angle_axis (self .fkine (q , end = end ).A , T ) * weight
749
762
E = (e ** 2 ).sum ()
750
763
751
764
if stiffness > 0 :
@@ -785,7 +798,7 @@ def cost(q, T, weight, costfun, stiffness):
785
798
# --------------------------------------------------------------------- #
786
799
787
800
def ikine_global (
788
- self , T , qlim = False , ilimit = 1000 , tol = 1e-16 , method = None , options = {}
801
+ self , T , qlim = False , ilimit = 1000 , tol = 1e-16 , method = None , options = {}, end = None
789
802
):
790
803
r"""
791
804
.. warning:: Experimental code for using SciPy global optimizers.
@@ -804,6 +817,9 @@ def ikine_global(
804
817
if not isinstance (T , SE3 ):
805
818
raise TypeError ("argument must be SE3" )
806
819
820
+ if isinstance (self , rtb .DHRobot ):
821
+ end = None
822
+
807
823
solutions = []
808
824
809
825
# wr = 1 / self.reach
@@ -833,7 +849,7 @@ def ikine_global(
833
849
834
850
def cost (q , T , weight ):
835
851
# T, weight, costfun, stiffness = args
836
- e = _angle_axis (self .fkine (q ).A , T ) * weight
852
+ e = _angle_axis (self .fkine (q , end = end ).A , T ) * weight
837
853
return (e ** 2 ).sum ()
838
854
839
855
for _ in T :
0 commit comments