1 from __future__
import print_function
9 Construct a PyKDL.Tree from an URDF file. 10 :param filename: URDF file path 13 with open(filename)
as urdf_file:
18 Construct a PyKDL.Tree from an URDF in a ROS parameter. 19 :param param: Parameter name, ``str`` 26 Construct a PyKDL.Tree from an URDF xml string. 27 :param xml: URDF xml string, ``str`` 34 rpy = pose.rpy
if pose
and pose.rpy
and len(pose.rpy) == 3
else [0, 0, 0]
35 xyz = pose.xyz
if pose
and pose.xyz
and len(pose.xyz) == 3
else [0, 0, 0]
38 kdl.Rotation.RPY(*rpy),
47 return origin.M * kdl.RigidBodyInertia(
49 kdl.RotationalInertia(inertia.ixx, inertia.iyy, inertia.izz, inertia.ixy, inertia.ixz, inertia.iyz));
53 fixed =
lambda j,F: kdl.Joint(j.name, kdl.Joint.None)
54 rotational =
lambda j,F: kdl.Joint(j.name, F.p, F.M * kdl.Vector(*j.axis), kdl.Joint.RotAxis)
55 translational =
lambda j,F: kdl.Joint(j.name, F.p, F.M * kdl.Vector(*j.axis), kdl.Joint.TransAxis)
59 'revolute': rotational,
60 'continuous': rotational,
61 'prismatic': translational,
67 return type_map[jnt.type](jnt,
_toKdlPose(jnt.origin))
73 inert = kdl.RigidBodyInertia(0)
78 (parent_joint_name, parent_link_name) = robot_model.parent_map[root.name]
79 parent_joint = robot_model.joint_map[parent_joint_name]
89 if not tree.addSegment(sgm, parent_link_name):
92 if root.name
not in robot_model.child_map:
95 children = [robot_model.link_map[l]
for (j,l)
in robot_model.child_map[root.name]]
98 for child
in children:
106 Construct a PyKDL.Tree from an URDF model from urdf_parser_python. 108 :param robot_model: URDF xml string, ``str`` 109 :param quiet: If true suppress messages to stdout, ``bool`` 112 root = robot_model.link_map[robot_model.get_root()]
114 if root.inertial
and not quiet:
115 print(
"The root link %s has an inertia specified in the URDF, but KDL does not support a root link with an inertia. As a workaround, you can add an extra dummy link to your URDF." % root.name);
118 tree = kdl.Tree(root.name)
121 for (joint,child)
in robot_model.child_map[root.name]:
def treeFromUrdfModel(robot_model, quiet=False)
def treeFromFile(filename)
def _add_children_to_tree(robot_model, root, tree)