Skip to content

Commit 82eb512

Browse files
committed
reflect recent changes
1 parent 7784f4d commit 82eb512

File tree

3 files changed

+89
-17
lines changed

3 files changed

+89
-17
lines changed

tests/test_DHRobot.py

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_DHRobot(self):
1616
l0 = rp.DHLink()
1717
rp.DHRobot([l0])
1818

19-
def test_isprismatic(self):
19+
def test_prismaticjoints(self):
2020
l0 = rp.PrismaticDH()
2121
l1 = rp.RevoluteDH()
2222
l2 = rp.PrismaticDH()
@@ -26,7 +26,33 @@ def test_isprismatic(self):
2626

2727
ans = [True, False, True, False]
2828

29-
self.assertEqual(r0.isprismatic(), ans)
29+
self.assertEqual(r0.prismaticjoints, ans)
30+
31+
def test_revolutejoints(self):
32+
l0 = rp.PrismaticDH()
33+
l1 = rp.RevoluteDH()
34+
l2 = rp.PrismaticDH()
35+
l3 = rp.RevoluteDH()
36+
37+
r0 = rp.DHRobot([l0, l1, l2, l3])
38+
39+
ans = [False, True, False, True]
40+
41+
self.assertEqual(r0.revolutejoints, ans)
42+
43+
44+
def test_isprismatic(self):
45+
l0 = rp.PrismaticDH()
46+
l1 = rp.RevoluteDH()
47+
l2 = rp.PrismaticDH()
48+
l3 = rp.RevoluteDH()
49+
50+
r0 = rp.DHRobot([l0, l1, l2, l3])
51+
52+
self.assertEqual(r0.isprismatic(0), True)
53+
self.assertEqual(r0.isprismatic(1), False)
54+
self.assertEqual(r0.isprismatic(2), True)
55+
self.assertEqual(r0.isprismatic(3), False)
3056

3157
def test_isrevolute(self):
3258
l0 = rp.PrismaticDH()
@@ -38,7 +64,10 @@ def test_isrevolute(self):
3864

3965
ans = [False, True, False, True]
4066

41-
self.assertEqual(r0.isrevolute(), ans)
67+
self.assertEqual(r0.isrevolute(0), False)
68+
self.assertEqual(r0.isrevolute(1), True)
69+
self.assertEqual(r0.isrevolute(2), False)
70+
self.assertEqual(r0.isrevolute(3), True)
4271

4372
def test_todegrees(self):
4473
l0 = rp.PrismaticDH()
@@ -596,52 +625,53 @@ def test_fkine_all(self):
596625
q = [1, 2, 3, 4, 5, 6, 7]
597626
panda.q = q
598627

599-
t0 = np.array([
628+
629+
t0 = np.eye(4)
630+
t1 = np.array([
600631
[0.5403, -0.8415, 0, 0],
601632
[0.8415, 0.5403, 0, 0],
602633
[0, 0, 1, 0.333],
603634
[0, 0, 0, 1]
604635
])
605-
t1 = np.array([
636+
t2 = np.array([
606637
[-0.2248, -0.4913, -0.8415, 0],
607638
[-0.3502, -0.7651, 0.5403, 0],
608639
[-0.9093, 0.4161, 0, 0.333],
609640
[0, 0, 0, 1]
610641
])
611-
t2 = np.array([
642+
t3 = np.array([
612643
[0.1038, 0.8648, 0.4913, 0.1552],
613644
[0.4229, -0.4855, 0.7651, 0.2418],
614645
[0.9002, 0.1283, -0.4161, 0.2015],
615646
[0, 0, 0, 1]
616647
])
617-
t3 = np.array([
648+
t4 = np.array([
618649
[-0.4397, -0.2425, -0.8648, 0.1638],
619650
[-0.8555, -0.1801, 0.4855, 0.2767],
620651
[-0.2735, 0.9533, -0.1283, 0.2758],
621652
[0, 0, 0, 1]
622653
])
623-
t4 = np.array([
654+
t5 = np.array([
624655
[-0.9540, -0.1763, -0.2425, 0.107],
625656
[0.2229, -0.9581, -0.1801, 0.2781],
626657
[-0.2006, -0.2258, 0.9533, 0.6644],
627658
[0, 0, 0, 1]
628659
])
629-
t5 = np.array([
660+
t6 = np.array([
630661
[-0.8482, -0.4994, 0.1763, 0.107],
631662
[0.2643, -0.1106, 0.9581, 0.2781],
632663
[-0.4590, 0.8593, 0.2258, 0.6644],
633664
[0, 0, 0, 1]
634665
])
635-
t6 = np.array([
666+
t7 = np.array([
636667
[-0.5236, 0.6902, 0.4994, 0.08575],
637668
[0.8287, 0.5487, 0.1106, 0.3132],
638669
[-0.1977, 0.4718, -0.8593, 0.5321],
639670
[0, 0, 0, 1]
640671
])
641672

642673
Tall = panda.fkine_all(q)
643-
Tall2 = panda.fkine_all()
644-
Tall3 = panda.fkine_all(old=False)
674+
645675

646676
nt.assert_array_almost_equal(Tall[0].A, t0, decimal=4)
647677
nt.assert_array_almost_equal(Tall[1].A, t1, decimal=4)
@@ -650,8 +680,8 @@ def test_fkine_all(self):
650680
nt.assert_array_almost_equal(Tall[4].A, t4, decimal=4)
651681
nt.assert_array_almost_equal(Tall[5].A, t5, decimal=4)
652682
nt.assert_array_almost_equal(Tall[6].A, t6, decimal=4)
653-
nt.assert_array_almost_equal(Tall2[0].A, t0, decimal=4)
654-
nt.assert_array_almost_equal(Tall3[0].A, panda.base.A, decimal=4)
683+
nt.assert_array_almost_equal(Tall[7].A, t7, decimal=4)
684+
655685

656686
# def test_gravjac(self):
657687
# l0 = rp.RevoluteDH(d=2, B=3, G=2, Tc=[2, -1], alpha=0.4, a=0.2,
@@ -1345,7 +1375,6 @@ def test_perturb(self):
13451375

13461376
def test_teach(self):
13471377
panda = rp.models.DH.Panda()
1348-
panda.q = panda.qr
13491378
e = panda.teach(block=False)
13501379
e.close()
13511380

tests/test_ERobot.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,49 @@ def test_invdyn(self):
862862
nt.assert_array_almost_equal(tau, np.r_[d11 + d12, d21 + d22])
863863

864864

865+
class TestERobot2(unittest.TestCase):
866+
def test_plot(self):
867+
robot = rtb.models.ETS.Planar2()
868+
e = robot.plot(robot.qz, block=False, name=True)
869+
e.close()
870+
871+
def test_teach(self):
872+
robot = rtb.models.ETS.Planar2()
873+
e = robot.teach(block=False, name=True)
874+
e.close()
875+
876+
e = robot.teach(robot.qz, block=False, name=True)
877+
e.close()
878+
879+
def test_plot_with_vellipse(self):
880+
robot = rtb.models.ETS.Planar2()
881+
e = robot.plot(robot.qz, block=False, name=True, vellipse=True, limits=[1, 2, 1, 2])
882+
e.step()
883+
e.close()
884+
885+
886+
def test_plot_with_fellipse(self):
887+
robot = rtb.models.ETS.Planar2()
888+
e = robot.plot(robot.qz, block=False, name=True, dellipse=True, limits=[1, 2, 1, 2])
889+
e.step()
890+
e.close()
891+
892+
# def test_plot_with_vellipse2_fail(self):
893+
# panda = rtb.models.DH.Panda()
894+
# panda.q = panda.qr
895+
896+
# from roboticstoolbox.backends.PyPlot import PyPlot2
897+
# e = PyPlot2()
898+
# e.launch()
899+
# e.add(panda.fellipse(
900+
# q=panda.qr, centre=[0, 1]))
901+
902+
# with self.assertRaises(ValueError):
903+
# e.add(panda.fellipse(
904+
# q=panda.qr, centre='ee', opt='rot'))
905+
906+
# e.close()
907+
865908
if __name__ == '__main__': # pragma nocover
866909

867910
unittest.main()

tests/test_Robot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def test_ikine_con(self):
137137
# -6.98000000e-02, 1.38978915e-02, 9.62104811e-01,
138138
# 7.84926515e-01]
139139

140-
sol1 = panda.ikine_min(T.A, qlim=True, q0=np.zeros(7))
140+
sol1 = panda.ikine_min(T, qlim=True, q0=np.zeros(7))
141141
sol2 = panda.ikine_min(Tt, qlim=True)
142142

143143
self.assertTrue(sol1.success)
@@ -160,7 +160,7 @@ def test_ikine_unc(self):
160160
Tt = sm.SE3([T, T])
161161

162162
sol1 = puma.ikine_min(Tt)
163-
sol2 = puma.ikine_min(T.A)
163+
sol2 = puma.ikine_min(T)
164164
sol3 = puma.ikine_min(T)
165165

166166
self.assertTrue(sol1[0].success)

0 commit comments

Comments
 (0)