@@ -12,7 +12,7 @@ class TestRobotWrapper(unittest.TestCase):
1212 def setUp (self ):
1313 self .current_file = os .path .dirname (str (os .path .abspath (__file__ )))
1414
15- def test_mjcf (self ):
15+ def test_mjcf_without_root_joint (self ):
1616 model_path = os .path .abspath (
1717 os .path .join (self .current_file , "../models/test_mjcf.xml" )
1818 )
@@ -21,6 +21,59 @@ def test_mjcf(self):
2121 self .assertEqual (robot .nv , 5 )
2222 self .assertEqual (robot .model .njoints , 4 )
2323
24+ def test_mjcf_with_root_joint (self ):
25+ model_path = os .path .abspath (
26+ os .path .join (self .current_file , "../models/test_mjcf.xml" )
27+ )
28+ robot = pin .RobotWrapper .BuildFromMJCF (model_path , pin .JointModelFreeFlyer ())
29+ self .assertEqual (robot .model .names [1 ], "root_joint" )
30+
31+ def test_mjcf_with_root_joint_and_root_joint_name (self ):
32+ model_path = os .path .abspath (
33+ os .path .join (self .current_file , "../models/test_mjcf.xml" )
34+ )
35+ name_ = "freeflyer_joint"
36+ robot = pin .RobotWrapper .BuildFromMJCF (
37+ model_path , pin .JointModelFreeFlyer (), name_
38+ )
39+ self .assertEqual (robot .model .names [1 ], name_ )
40+
41+ def test_urdf_with_root_joint (self ):
42+ model_path = os .path .abspath (
43+ os .path .join (self .current_file , "../models/3DOF_planar.urdf" )
44+ )
45+ robot = pin .RobotWrapper .BuildFromURDF (
46+ model_path , [], pin .JointModelFreeFlyer ()
47+ )
48+ self .assertEqual (robot .model .names [1 ], "root_joint" )
49+
50+ def test_urdf_with_root_joint_and_root_joint_name (self ):
51+ model_path = os .path .abspath (
52+ os .path .join (self .current_file , "../models/3DOF_planar.urdf" )
53+ )
54+ name_ = "freeflyer_joint"
55+ robot = pin .RobotWrapper .BuildFromURDF (
56+ model_path , [], pin .JointModelFreeFlyer (), name_
57+ )
58+ self .assertEqual (robot .model .names [1 ], name_ )
59+
60+ def test_sdf_with_root_joint (self ):
61+ model_path = os .path .abspath (
62+ os .path .join (self .current_file , "../../models/simple_humanoid.sdf" )
63+ )
64+ robot = pin .RobotWrapper .BuildFromSDF (model_path , [], pin .JointModelFreeFlyer ())
65+ self .assertEqual (robot .model .names [1 ], "root_joint" )
66+
67+ def test_sdf_with_root_joint_and_root_joint_name (self ):
68+ model_path = os .path .abspath (
69+ os .path .join (self .current_file , "../../models/simple_humanoid.sdf" )
70+ )
71+ name_ = "freeflyer_joint"
72+ robot = pin .RobotWrapper .BuildFromSDF (
73+ model_path , [], pin .JointModelFreeFlyer (), root_joint_name = name_
74+ )
75+ self .assertEqual (robot .model .names [1 ], name_ )
76+
2477
2578if __name__ == "__main__" :
2679 unittest .main ()
0 commit comments