2017-01-13 4 views
0

Ich versuche, die Verbindungen eines Roboters ohne Erfolg zu animieren. FuncAnimation ruft nie die animierte Funktion auf - die print-Anweisung wird niemals ausgeführt. Jede Hilfe würde sehr geschätzt werden. Mein Code:matplotlib funcAnimation ruft nicht die übergebene Funktion auf

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() 
+1

Können Sie ein [MCVE] bereitstellen? – ImportanceOfBeingErnest

Antwort

0

Die Aufgabe wird durch FuncAnimation erstellt wurden, müssen offenbar zu einer globalen Variablen zugewiesen werden; Wenn es einer lokalen Variablen zugewiesen wird, wie hier, wird nichts passieren.

Verwandte Themen