robotics-toolbox-python icon indicating copy to clipboard operation
robotics-toolbox-python copied to clipboard

IK solver wraps q even for prismatic joints

Open R2RT opened this issue 2 years ago • 0 comments

Describe the bug A clear and concise description of what the bug is.

IK solver internally wraps q vector to keep its element in <-pi, pi> range. It does so even for prismatic joints.

Version information

Did you install from PyPI or GitHub? If PyPI what version number? If GitHub what commit hash?

pip version 1.1.0

Robotics Toolbox depends heavily on two other packages: Swift (3D graphics) and SpatialMath toolbox (underpinning maths utilities). If you think your issue is related to these, then please answer the questions above for them.

To Reproduce Steps to reproduce the behavior:

  1. The shortest, complete, Python script that exhibits the bug.
  2. The script output, including error messages.
showcase = ET.tx() * ET.tx(1)
showcase.qlim=np.array([[0], [10]])
q = np.array([5])
Tep = showcase.fkine(q)
r = showcase.ikine_LM(Tep, q0=q)
assert r.q[0] == 5, r

Results in

AssertionError: IKSolution: q=[-1.283], success=False, reason=iteration and search limit reached, solution found but violates joint limits, iterations=659, searches=100, residual=0

Expected behavior

Assertion passes, q[0] == 5

Environment (please complete the following information):

  • Your OS (MacOS, Linux, Windows).
  • Your Python version.

Windows, Python 3.11.3

Additional context Add any other context about the problem here.

Commenting out line 330 of IK.py file resolves this case

# Wrap q to be within +- 180 deg
# If your robot has larger than 180 deg range on a joint
# this line should be modified in incorporate the extra range
# q = (q + np.pi) % (2 * np.pi) - np.pi

R2RT avatar Nov 15 '23 00:11 R2RT