###### tags: `Notes` # 手臂URDF、IKPY範例 目前把手臂的末端設成夾爪的中心 ## ipynb (jupyter notebook) ```python import ikpy from ikpy.chain import Chain from ikpy.link import OriginLink, URDFLink import numpy as np import ikpy.utils.plot as plot_utils import matplotlib from mpl_toolkits.mplot3d import Axes3D ``` ```python%matplotlib notebook ax = matplotlib.pyplot.figure().add_subplot(111, projection='3d') """ """ axis_len = 1.4 ax.plot([0, axis_len], [0, 0],[0, 0], color='g', marker='^', linestyle='dashed', linewidth=2) ax.plot([0, 0], [0, axis_len],[0, 0], color='c', marker='^', linestyle='dashed', linewidth=2) ax.plot([0, 0], [0, 0],[0, axis_len], color='orange', marker='^', linestyle='dashed', linewidth=2) ax.text(axis_len,0,0,'x') ax.text(0,axis_len,0,'y') ax.text(0,0,axis_len,'z') my_chain = Chain.from_urdf_file("./panda.URDF") my_chain.plot([0]*8, ax, [0]*3) #my_chain.plot(my_chain.inverse_kinematics([0.5, 0.5, 0.5]), ax, [0.5, 0.5, 0.5]) #my_chain.plot(my_chain.inverse_kinematics([0.2, 0.2, 0.8]), ax, [0.2, 0.2, 0.8]) ``` ## [panda.URDF](https://drive.google.com/drive/u/1/folders/1zxDqJ7NBkC8l9UG6lP7IBV9dEJo5I7Fy) ## Result: ![](https://i.imgur.com/LMkhl6a.png)