Skip to content

Commit c075f91

Browse files
committed
add IK random seed as a block argument
1 parent 0e2ca66 commit c075f91

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

roboticstoolbox/blocks/arm.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class IKine(FunctionBlock):
101101
outlabels = ('q',)
102102

103103
def __init__(
104-
self, robot=None, q0=None, useprevious=True, ik=None, **blockargs
104+
self, robot=None, q0=None, useprevious=True, ik=None, seed=None, **blockargs
105105
):
106106
"""
107107
:param robot: Robot model, defaults to None
@@ -112,6 +112,8 @@ def __init__(
112112
:type useprevious: bool, optional
113113
:param ik: Specify an IK function, defaults to 'ikine_LM'
114114
:type ik: callable f(T)
115+
:param seed: random seed for solution
116+
:type seed: int
115117
:param blockargs: |BlockOptions|
116118
:type blockargs: dict
117119
:return: an INVERSE_KINEMATICS block
@@ -140,6 +142,7 @@ def __init__(
140142
self.qprev = q0
141143
self.useprevious = useprevious
142144
self.ik = None
145+
self.seed = 0
143146

144147
self.inport_names(("T",))
145148
self.outport_names(("q",))
@@ -156,7 +159,7 @@ def output(self, t=None):
156159
q0 = self.q0
157160

158161
if self.ik is None:
159-
sol = self.robot.ikine_LM(self.inputs[0], q0=q0)
162+
sol = self.robot.ikine_LM(self.inputs[0], q0=q0, seed=self.seed)
160163
else:
161164
sol = self.ik(self.inputs[0])
162165

0 commit comments

Comments
 (0)