プログラミングの芽

面白そうな技術を使って、楽しいことやりたい

pythonによる2リンクロボットアームの順運動学

import math
import matplotlib.pyplot as plt

def fk(l1,l2,d1,d2):
    x1 = l1*math.cos(math.radians(d1))
    y1 = l1*math.sin(math.radians(d1))

    x2 = l1*math.cos(math.radians(d1)) 
            + l2*math.cos(math.radians(d1+d2))
    y2 = l1*math.sin(math.radians(d1)) 
            + l2*math.sin(math.radians(d1+d2))

    x =[0,x1,x2]
    y =[0,y1,y2]

    plt.plot(x,y,marker="0")
    plt.show()
fk(10,10,30,45)

>>f:id:atarms:20190128202306p:plain