Skip to content

Commit fe521ce

Browse files
Nicholas Backshallstepjam
Nicholas Backshall
authored andcommitted
Fix joints during arm IK calculations
1 parent cd9830b commit fe521ce

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pyrep/robots/arms/arm.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ def solve_ik_via_jacobian(
201201
self, position: Union[List[float], np.ndarray],
202202
euler: Union[List[float], np.ndarray] = None,
203203
quaternion: Union[List[float], np.ndarray] = None,
204-
relative_to: Object = None) -> List[float]:
204+
relative_to: Object = None,
205+
locked_joints: List[int] = None,
206+
) -> List[float]:
205207
"""Solves an IK group and returns the calculated joint values.
206208
207209
This IK method performs a linearisation around the current robot
@@ -226,8 +228,15 @@ def solve_ik_via_jacobian(
226228
elif quaternion is not None:
227229
self._ik_target.set_quaternion(quaternion, relative_to)
228230

231+
joints = self.joints
232+
if locked_joints is not None and len(locked_joints) > 0:
233+
joints = []
234+
for idx, j in enumerate(self.joints):
235+
if idx not in locked_joints:
236+
joints.append(j)
237+
229238
ik_result, joint_values = sim.simCheckIkGroup(
230-
self._ik_group, [j.get_handle() for j in self.joints])
239+
self._ik_group, [j.get_handle() for j in joints])
231240
if ik_result == sim.sim_ikresult_fail:
232241
raise IKError('IK failed. Perhaps the distance was between the tip '
233242
' and target was too large.')

0 commit comments

Comments
 (0)