6 from pathlib
import Path
8 import pinocchio
as pin
16 model_path = self.
current_dir.parent /
"models" /
"test_mjcf.xml"
17 robot = pin.RobotWrapper.BuildFromMJCF(model_path)
18 self.assertEqual(robot.nq, 6)
19 self.assertEqual(robot.nv, 5)
20 self.assertEqual(robot.model.njoints, 4)
23 model_path = self.
current_dir.parent /
"models" /
"test_mjcf.xml"
24 robot = pin.RobotWrapper.BuildFromMJCF(model_path, pin.JointModelFreeFlyer())
25 self.assertEqual(robot.model.names[1],
"root_joint")
28 model_path = self.
current_dir.parent /
"models" /
"test_mjcf.xml"
29 name_ =
"freeflyer_joint"
30 robot = pin.RobotWrapper.BuildFromMJCF(
31 model_path, pin.JointModelFreeFlyer(), name_
33 self.assertEqual(robot.model.names[1], name_)
36 model_path = self.
current_dir.parent /
"models" /
"3DOF_planar.urdf"
37 robot = pin.RobotWrapper.BuildFromURDF(
38 model_path, [], pin.JointModelFreeFlyer()
40 self.assertEqual(robot.model.names[1],
"root_joint")
43 model_path = self.
current_dir.parent /
"models" /
"3DOF_planar.urdf"
44 name_ =
"freeflyer_joint"
45 robot = pin.RobotWrapper.BuildFromURDF(
46 model_path, [], pin.JointModelFreeFlyer(), name_
48 self.assertEqual(robot.model.names[1], name_)
51 model_path = self.
current_dir.parent /
"models" /
"3DOF_planar.urdf"
53 robot = pin.RobotWrapper.BuildFromURDF(
54 model_path, str(package_dir), pin.JointModelFreeFlyer()
56 self.assertEqual(robot.model.names[1],
"root_joint")
59 model_path = self.
current_dir.parent /
"models" /
"3DOF_planar.urdf"
61 robot = pin.RobotWrapper.BuildFromURDF(
62 model_path, package_dir, pin.JointModelFreeFlyer()
64 self.assertEqual(robot.model.names[1],
"root_joint")
67 model_path = self.
current_dir.parent /
"models" /
"3DOF_planar.urdf"
69 robot = pin.RobotWrapper.BuildFromURDF(
70 model_path, [str(package_dir)], pin.JointModelFreeFlyer()
72 self.assertEqual(robot.model.names[1],
"root_joint")
75 model_path = self.
current_dir.parent /
"models" /
"3DOF_planar.urdf"
77 robot = pin.RobotWrapper.BuildFromURDF(
78 model_path, [package_dir], pin.JointModelFreeFlyer()
80 self.assertEqual(robot.model.names[1],
"root_joint")
83 model_path = self.
current_dir.parent /
"models" /
"3DOF_planar.urdf"
84 robot = pin.RobotWrapper.BuildFromURDF(
85 model_path,
None, pin.JointModelFreeFlyer()
87 self.assertEqual(robot.model.names[1],
"root_joint")
89 @unittest.skipUnless(pin.WITH_SDFORMAT,
"Needs SDFORMAT")
91 model_path = self.
current_dir.parent.parent /
"models" /
"simple_humanoid.sdf"
92 mesh_path = self.
current_dir.parent.parent /
"models"
93 robot = pin.RobotWrapper.BuildFromSDF(
94 model_path, [mesh_path], pin.JointModelFreeFlyer(), verbose=
True
96 self.assertEqual(robot.model.names[1],
"root_joint")
98 @unittest.skipUnless(pin.WITH_SDFORMAT,
"Needs SDFORMAT")
100 model_path = self.
current_dir.parent.parent /
"models" /
"simple_humanoid.sdf"
101 mesh_path = self.
current_dir.parent.parent /
"models"
102 name_ =
"freeflyer_joint"
103 robot = pin.RobotWrapper.BuildFromSDF(
104 model_path, [mesh_path], pin.JointModelFreeFlyer(), root_joint_name=name_
106 self.assertEqual(robot.model.names[1], name_)
109 if __name__ ==
"__main__":