rpiRobotics / rpi_general_robotics_toolbox_py

Robotics Python toolbox containing mathematical functions and utilities
https://general-robotics-toolbox.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
21 stars 6 forks source link

Subproblem 2 Gives wrong results / errors for the single solution case #23

Open burakaksoy opened 3 months ago

burakaksoy commented 3 months ago

In the code of Subproblem 2, for single-solution case, order of the parameters to subproblem 1 is wrong.

This is the test to verify the issue:

# subproblem2 another test
a3_2 = rox.subproblem2(z, x, x, y) # Passes (apparently by luck)
a3_22 = rox.subproblem2([0, 0, 0.01851852], [0.01851852, 0, 0], x, y) # This gives the error below

"""
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/burak/.local/lib/python3.8/site-packages/general_robotics_toolbox/general_robotics_toolbox.py", line 766, in subproblem2
    # theta1 = -subproblem1(k1, q, c1)
File "/home/burak/.local/lib/python3.8/site-packages/general_robotics_toolbox/general_robotics_toolbox.py", line 706, in subproblem1
    theta = subproblem0(epp, eqp, k)
File "/home/burak/.local/lib/python3.8/site-packages/general_robotics_toolbox/general_robotics_toolbox.py", line 660, in subproblem0
    assert (np.dot(k,p) < eps) and (np.dot(k,q) < eps), \
AssertionError: k must be perpendicular to p and q
"""

assert len(a3_2) == 1
assert len(a3_22) == 1
a3_2_check = [(0.0, 1.5707963267948966)]
np.testing.assert_allclose(a3_2, a3_2_check, atol=1e-4)
np.testing.assert_allclose(a3_22, a3_2_check, atol=1e-4)
burakaksoy commented 3 months ago

PR #24 resolves the issue