@@ -4235,6 +4235,111 @@ def test_partial_fkine(self):
42354235 nt .assert_almost_equal (fk , ans )
42364236 nt .assert_almost_equal (fk2 , ans )
42374237
4238+ def test_qlim1 (self ):
4239+ rx = rtb .ETS (rtb .ET .Rx ())
4240+
4241+ q = rx .qlim
4242+ nt .assert_equal (q , np .array ([[- np .pi ], [np .pi ]]))
4243+
4244+ def test_qlim2 (self ):
4245+ rx = rtb .ETS (rtb .ET .Rx (qlim = [- 1 , 1 ]))
4246+
4247+ q = rx .qlim
4248+ nt .assert_equal (q , np .array ([[- 1 ], [1 ]]))
4249+
4250+ def test_qlim3 (self ):
4251+ rx = rtb .ETS (rtb .ET .tx (qlim = [- 1 , 1 ]))
4252+
4253+ q = rx .qlim
4254+ nt .assert_equal (q , np .array ([[- 1 ], [1 ]]))
4255+
4256+ def test_qlim4 (self ):
4257+ rx = rtb .ETS (rtb .ET .tx ())
4258+
4259+ with self .assertRaises (ValueError ):
4260+ rx .qlim
4261+
4262+ def test_random_q (self ):
4263+ rx = rtb .ETS (rtb .ET .Rx (qlim = [- 1 , 1 ]))
4264+
4265+ q = rx .random_q ()
4266+ self .assertTrue (- 1 <= q <= 1 )
4267+
4268+ def test_random_q2 (self ):
4269+ rx = rtb .ETS ([rtb .ET .Rx (qlim = [- 1 , 1 ]), rtb .ET .Rx (qlim = [1 , 2 ])])
4270+
4271+ q = rx .random_q (10 )
4272+
4273+ self .assertTrue (np .all (- 1 <= q [:, 0 ]) and np .all (q [:, 0 ] <= 1 ))
4274+ self .assertTrue (np .all (1 <= q [:, 1 ]) and np .all (q [:, 1 ] <= 2 ))
4275+
4276+ def test_manip (self ):
4277+ r = rtb .models .Panda ()
4278+ ets = r .ets ()
4279+ q = r .qr
4280+
4281+ m1 = ets .manipulability (q )
4282+ m2 = ets .manipulability (q , axes = "trans" )
4283+ m3 = ets .manipulability (q , axes = "rot" )
4284+
4285+ nt .assert_almost_equal (m1 , 0.0837 , decimal = 4 )
4286+ nt .assert_almost_equal (m2 , 0.1438 , decimal = 4 )
4287+ nt .assert_almost_equal (m3 , 2.7455 , decimal = 4 )
4288+
4289+ def test_yoshi (self ):
4290+ puma = rtb .models .Puma560 ()
4291+ ets = puma .ets ()
4292+ q = puma .qn # type: ignore
4293+
4294+ m1 = ets .manipulability (q , axes = [True , True , True , True , True , True ])
4295+ m2 = ets .manipulability (np .c_ [q , q ].T )
4296+ m3 = ets .manipulability (q , axes = "trans" )
4297+ m4 = ets .manipulability (q , axes = "rot" )
4298+
4299+ a0 = 0.0805
4300+ a2 = 0.1354
4301+ a3 = 2.44949
4302+
4303+ nt .assert_almost_equal (m1 , a0 , decimal = 4 )
4304+ nt .assert_almost_equal (m2 [0 ], a0 , decimal = 4 ) # type: ignore
4305+ nt .assert_almost_equal (m2 [1 ], a0 , decimal = 4 ) # type: ignore
4306+ nt .assert_almost_equal (m3 , a2 , decimal = 4 )
4307+ nt .assert_almost_equal (m4 , a3 , decimal = 4 )
4308+
4309+ with self .assertRaises (ValueError ):
4310+ puma .manipulability (axes = "abcdef" ) # type: ignore
4311+
4312+ def test_cond (self ):
4313+ r = rtb .models .Panda ()
4314+ ets = r .ets ()
4315+
4316+ m = ets .manipulability (r .qr , method = "invcondition" )
4317+
4318+ self .assertAlmostEqual (m , 0.11222 , places = 4 ) # type: ignore
4319+
4320+ def test_minsingular (self ):
4321+ r = rtb .models .Panda ()
4322+ ets = r .ets ()
4323+
4324+ m = ets .manipulability (r .qr , method = "minsingular" )
4325+
4326+ self .assertAlmostEqual (m , 0.209013 , places = 4 ) # type: ignore
4327+
4328+ def test_manipulability_fail (self ):
4329+ puma = rtb .models .Puma560 ()
4330+ ets = puma .ets ()
4331+
4332+ with self .assertRaises (ValueError ):
4333+ ets .manipulability (q = [1 , 2 , 3.0 ], method = "notamethod" ) # type: ignore
4334+
4335+ def test_manip_fail2 (self ):
4336+ r = rtb .models .Panda ()
4337+ ets = r .ets ()
4338+ q = r .qr
4339+
4340+ with self .assertRaises (ValueError ):
4341+ ets .manipulability (q , axes = "abcdef" ) # type: ignore
4342+
42384343
42394344if __name__ == "__main__" :
42404345
0 commit comments