Skip to content

Commit d7be48f

Browse files
Fix the issue with Subproblem 2 when there is a single solution (#31)
* correct the order of the input parameters to subproblem1 from subproblem2 for single solution case. * Add a test case which verifies the fix. * Make the test case style the same as the style of the other subproblem2 test case --------- Co-authored-by: Burak Aksoy <burakaksoy20@gmail.com>
1 parent 1c56b4c commit d7be48f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/general_robotics_toolbox/general_robotics_toolbox.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,8 +763,8 @@ def subproblem2(p, q, k1, k2):
763763
if (np.abs(gamma) < eps):
764764
cm=np.array([k1, k2, np.cross(k1,k2)]).T
765765
c1 = np.dot(cm, np.hstack((a, gamma)))
766-
theta2 = subproblem1(k2, p, c1)
767-
theta1 = -subproblem1(k1, q, c1)
766+
theta2 = subproblem1(p, c1, k2)
767+
theta1 = -subproblem1(q, c1, k1)
768768
return [(theta1, theta2)]
769769

770770
cm=np.array([k1, k2, np.cross(k1,k2)]).T

test/test_general_robotics_toolbox.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,14 @@ def test_subproblems():
329329
r3=np.matmul(rox.rot(z,a3[0][0]),rox.rot(y,a3[0][1]))[:,0]
330330
np.testing.assert_allclose(r3, z, atol=1e-4)
331331

332+
# subproblem2, another test with a random scale factor
333+
scale = 0.01851852 # scale factor for random test
334+
a3_2 = rox.subproblem2(scale*np.array(z), scale*np.array(x), x, y)
335+
assert len(a3_2) == 1
336+
337+
r3_2 = np.matmul(rox.rot(x,a3_2[0][0]),rox.rot(y,a3_2[0][1]))[:,1]
338+
np.testing.assert_allclose(r3_2, y, atol=1e-4)
339+
332340
#subproblem3
333341
p4=[.5, 0, 0]
334342
q4=[0, .75, 0]

0 commit comments

Comments
 (0)