# URDF JointsΒΆ

This example shows how to load a URDF description of a robot, set some joint angles and display relevant frames.

```import matplotlib.pyplot as plt
from pytransform3d.urdf import UrdfTransformManager

COMPI_URDF = """
<?xml version="1.0"?>
<robot name="compi">

<joint name="joint1" type="revolute">
<origin xyz="0 0 0" rpy="0 0 0"/>
<axis xyz="0 0 1.0"/>
</joint>

<joint name="joint2" type="revolute">
<origin xyz="0 0 0.158" rpy="1.570796 0 0"/>
<axis xyz="0 0 -1.0"/>
</joint>

<joint name="joint3" type="revolute">
<origin xyz="0 0.28 0" rpy="0 0 0"/>
<axis xyz="0 0 -1.0"/>
</joint>

<joint name="joint4" type="revolute">
<origin xyz="0 0 0" rpy="-1.570796 0 0"/>
<axis xyz="0 0 1.0"/>
</joint>

<joint name="joint5" type="revolute">
<origin xyz="0 0 0.34" rpy="1.570796 0 0"/>
<axis xyz="0 0 -1.0"/>
</joint>

<joint name="joint6" type="revolute">
<origin xyz="0 0.346 0" rpy="-1.570796 0 0"/>
<axis xyz="0 0 1.0"/>
</joint>

<joint name="jointtcp" type="fixed">
<origin xyz="0 0 0.05" rpy="0 0 0"/>
</joint>
</robot>
"""

tm = UrdfTransformManager()
joint_names = ["joint%d" % i for i in range(1, 7)]
joint_angles = [0, 0.5, 0.5, 0, 0.5, 0]
for name, angle in zip(joint_names, joint_angles):
tm.set_joint(name, angle)
ax = tm.plot_frames_in("compi", whitelist=["link%d" % d for d in range(1, 7)],
s=0.05, show_name=True)
ax = tm.plot_connections_in("compi", ax=ax)
ax.set_xlim((-0.2, 0.8))
ax.set_ylim((-0.5, 0.5))
ax.set_zlim((-0.2, 0.8))
plt.show()
```

Total running time of the script: ( 0 minutes 0.153 seconds)

Gallery generated by Sphinx-Gallery