@@ -63,6 +63,85 @@ def test_init4(self):
63
63
self .assertEqual (robot .manufacturer , "I made it" )
64
64
self .assertEqual (robot .comment , "other stuff" )
65
65
66
+ def test_init5 (self ):
67
+
68
+ base = SE3 .Trans (0 , 0 , 0.1 ).A
69
+ ets = ETS (rtb .ET .Rz ())
70
+ robot = Robot (ets , base = base , tool = base )
71
+ nt .assert_almost_equal (robot .base .A , base )
72
+ nt .assert_almost_equal (robot .tool .A , base )
73
+
74
+ def test_init6 (self ):
75
+
76
+ base = SE3 .Trans (0 , 0 , 0.1 )
77
+ ets = ETS (rtb .ET .Rz ())
78
+ robot = Robot (ets , base = base , tool = base )
79
+ nt .assert_almost_equal (robot .base .A , base .A )
80
+ nt .assert_almost_equal (robot .tool .A , base .A )
81
+
82
+ def test_init7 (self ):
83
+
84
+ keywords = 2
85
+ ets = ETS (rtb .ET .Rz ())
86
+
87
+ with self .assertRaises (TypeError ):
88
+ Robot (ets , keywords = keywords ) # type: ignore
89
+
90
+ def test_init8 (self ):
91
+
92
+ links = [2 , 3 , 4 , 5 ]
93
+
94
+ with self .assertRaises (TypeError ):
95
+ BaseRobot (links = links ) # type: ignore
96
+
97
+ def test_init9 (self ):
98
+
99
+ robot = rtb .models .Panda ()
100
+ robot2 = rtb .models .PR2 ()
101
+
102
+ self .assertTrue (robot2 ._hasdynamics )
103
+ self .assertTrue (robot ._hasgeometry )
104
+ self .assertTrue (robot ._hascollision )
105
+
106
+ def test_init10 (self ):
107
+
108
+ links = [Link (name = "link1" ), Link (name = "link1" ), Link (name = "link1" )]
109
+
110
+ with self .assertRaises (ValueError ):
111
+ Robot (links )
112
+
113
+ def test_init11 (self ):
114
+
115
+ l1 = Link (parent = "l3" )
116
+ l2 = Link (parent = l1 )
117
+ l3 = Link (parent = l2 , name = "l3" )
118
+
119
+ links = [l1 , l2 , l3 ]
120
+
121
+ with self .assertRaises (ValueError ):
122
+ Robot (links )
123
+
124
+ def test_init12 (self ):
125
+
126
+ l1 = Link (jindex = 1 , ets = rtb .ET .Rz ())
127
+ l2 = Link (jindex = 2 , parent = l1 , ets = rtb .ET .Rz ())
128
+ l3 = Link (parent = l2 , ets = rtb .ET .Rz ())
129
+
130
+ links = [l1 , l2 , l3 ]
131
+
132
+ with self .assertRaises (ValueError ):
133
+ Robot (links )
134
+
135
+ def test_iter (self ):
136
+ robot = rtb .models .Panda ()
137
+ for link in robot :
138
+ self .assertIsInstance (link , Link )
139
+
140
+ def test_get (self ):
141
+ panda = rtb .models .ETS .Panda ()
142
+ self .assertIsInstance (panda [1 ], Link )
143
+ self .assertIsInstance (panda ["link0" ], Link )
144
+
66
145
def test_init_ets (self ):
67
146
68
147
ets = (
@@ -278,6 +357,59 @@ def test_manuf(self):
278
357
279
358
self .assertIsInstance (panda .manufacturer , str )
280
359
360
+ def test_str (self ):
361
+ panda = rtb .models .Panda ()
362
+ pr2 = rtb .models .PR2 ()
363
+ self .assertIsInstance (str (panda ), str )
364
+ self .assertIsInstance (str (pr2 ), str )
365
+ self .assertIsInstance (repr (panda ), str )
366
+ self .assertIsInstance (repr (pr2 ), str )
367
+
368
+ def test_nlinks (self ):
369
+ panda = rtb .models .Panda ()
370
+ self .assertEqual (panda .nlinks , 12 )
371
+
372
+ def test_configs (self ):
373
+ panda = rtb .models .Panda ()
374
+ configs = panda .configs
375
+
376
+ nt .assert_equal (configs ["qr" ], panda .qr )
377
+ nt .assert_equal (configs ["qz" ], panda .qz )
378
+
379
+ def test_keywords (self ):
380
+ panda = Robot (
381
+ ETS ([ET .Rz (qlim = [- 1 , 1 ]), ET .tz (qlim = [- 1 , 1 ]), ET .SE3 (SE3 .Trans (1 , 2 , 3 ))]),
382
+ keywords = ["test" ],
383
+ )
384
+ self .assertEqual (panda .keywords , ["test" ])
385
+ self .assertFalse (panda .symbolic )
386
+ self .assertFalse (panda .hasdynamics )
387
+ self .assertFalse (panda .hasgeometry )
388
+ self .assertFalse (panda .hascollision )
389
+ self .assertEqual (panda .default_backend , None )
390
+ panda .default_backend = "Swift"
391
+
392
+ self .assertEqual (panda .qlim [0 , 0 ], - 1.0 )
393
+
394
+ def test_qlim (self ):
395
+ panda = Robot (ETS ([ET .Rz (qlim = [- 1 , 1 ]), ET .tz ()]), keywords = ["test" ])
396
+
397
+ with self .assertRaises (ValueError ):
398
+ panda .qlim
399
+
400
+ def test_joint_types (self ):
401
+ panda = Robot (
402
+ ETS ([ET .Rz (qlim = [- 1 , 1 ]), ET .tz (qlim = [- 1 , 1 ]), ET .SE3 (SE3 .Trans (1 , 2 , 3 ))]),
403
+ )
404
+
405
+ self .assertTrue (panda .prismaticjoints [1 ])
406
+ self .assertTrue (panda .revolutejoints [0 ])
407
+
408
+ def test_urdf_string (self ):
409
+ panda = rtb .models .Panda ()
410
+ self .assertIsInstance (panda .urdf_string , str )
411
+ self .assertIsInstance (panda .urdf_filepath , str )
412
+
281
413
# def test_yoshi(self):
282
414
# puma = rtb.models.Puma560()
283
415
# q = puma.qn
0 commit comments