diff --git a/src/roboticstoolbox/robot/DHLink.py b/src/roboticstoolbox/robot/DHLink.py index 4b570901e..827a214dd 100644 --- a/src/roboticstoolbox/robot/DHLink.py +++ b/src/roboticstoolbox/robot/DHLink.py @@ -616,7 +616,7 @@ def A(self, q: float) -> SE3: sa = _sin(self.alpha) ca = _cos(self.alpha) - if self.ets[-1].isflip: + if self.v is not None and self.v.isflip: q = -q + self.offset else: q = q + self.offset diff --git a/tests/test_DHRobot.py b/tests/test_DHRobot.py index f76706561..307a8de7a 100644 --- a/tests/test_DHRobot.py +++ b/tests/test_DHRobot.py @@ -168,6 +168,33 @@ def test_qlim(self): nt.assert_array_almost_equal(r0.qlim, ans) nt.assert_array_almost_equal(r1.qlim, np.c_[qlim]) + def test_A_flip_standard_dh(self): + q = 0.3 + + flipped = rp.RevoluteDH( + d=0.2, a=0.3, alpha=0.4, offset=0.1, flip=True + ) + normal = rp.RevoluteDH( + d=0.2, a=0.3, alpha=0.4, offset=0.1 + ) + + nt.assert_array_almost_equal( + flipped.A(q).A, + normal.A(-q).A, + ) + + flipped = rp.PrismaticDH( + theta=0.2, a=0.3, alpha=0.4, offset=0.1, flip=True + ) + normal = rp.PrismaticDH( + theta=0.2, a=0.3, alpha=0.4, offset=0.1 + ) + + nt.assert_array_almost_equal( + flipped.A(q).A, + normal.A(-q).A, + ) + def test_fkine(self): l0 = rp.PrismaticDH() l1 = rp.RevoluteDH()