github 工程
Phylliade/ikpy: An Inverse Kinematics library aiming performance and modularity (github.com)
ikpy/Quickstart.ipynb at master · Phylliade/ikpy (github.com)
调整增加第一行和第25行,然后将该py文件放到tests目录下运行!
1 #! /usr/bin/python3.6 2 3 import ikpy.chain 4 import numpy as np 5 import ikpy.utils.plot as plot_utils 6 7 my_chain = ikpy.chain.Chain.from_urdf_file("../resources/poppy_ergo.URDF") 8 9 target_position = [ 0.1, -0.2, 0.1] 10 11 print("The angles of each joints are : ", my_chain.inverse_kinematics(target_position)) 12 13 real_frame = my_chain.forward_kinematics(my_chain.inverse_kinematics(target_position)) 14 print("Computed position vector : %s, original position vector : %s" % (real_frame[:3, 3], target_position)) 15 16 # Optional: support for 3D plotting in the NB 17 # If there is a matplotlib error, uncomment the next line, and comment the line below it. 18 #%matplotlib inline 19 #%matplotlib widget 20 import matplotlib.pyplot as plt 21 fig, ax = plot_utils.init_3d_figure() 22 my_chain.plot(my_chain.inverse_kinematics(target_position), ax, target=target_position) 23 plt.xlim(-0.1, 0.1) 24 plt.ylim(-0.1, 0.1) 25 plt.show()