我正在尝试使机器人的链接动画化,但没有成功。FuncAnimation永远不会调用动画函数-永远不会执行print语句。任何帮助将不胜感激。我的代码:
joints = np.array([robot_kinematics.getJoints(a[0]) for a in path])
# this is [5x9x3]
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
colors = 'brgymcwkk'
lines = [ax.plot([], [], [])[0] for i,c in enumerate(colors)]
pt = ax.plot([], [], [])[0]
def animate(i,lines,pts):
print ('called')
for j,line in enumerate(lines):
line.set_data(joints[i,j,0:2])
line.set_3d_properties(joints[i,j,2])
pts.set_data(joints[i,:,0:2])
pts.set_3d_properties(joints[i,:,2])
return lines,pts
a = animation.FuncAnimation(fig, animate, 25, fargs=(lines,pt),interval=50, blit=False)
plt.show()
Run Code Online (Sandbox Code Playgroud)
必须将FuncAnimation创建的对象显然分配给全局变量。如果将其分配给局部变量(如我在此处所做的那样),则不会发生任何事情。
| 归档时间: |
|
| 查看次数: |
799 次 |
| 最近记录: |