cd2021 - 40823109

  • Home
    • Site Map
    • reveal
    • blog
  • About
  • Stage1
    • W1
      • SSH setup
      • set website
    • W2
      • 草圖繪製
      • 3D圖繪製
    • W3
      • 3D爆炸圖與工作圖
      • 傳動設計修改
    • W4
  • stage2
    • W5
    • W6
    • W7
    • W8
    • W9
  • stage3
    • W10
      • task1
      • task2
    • W11
      • task 3
    • W13
    • W15
      • using geometry
      • using algebra
    • W16
      • 1. Onshape 零組件繪製
      • 2.建立 CoppeliaSim 4.1.0 MTB robot 場景
      • 3.手臂末端加入吸盤
      • 4.逆向運動學函式
      • 5.Python remote API 逆向運動學函式
    • 專案成果
  • w18
    • 期末報告影片
  • Questions and answers
    • ValueError
    • pip無法使用
    • leo 無法使用
3.手臂末端加入吸盤 << Previous Next >> 5.Python remote API 逆向運動學函式

4.逆向運動學函式

W16 part_4

執行影片 :

python  (x,y) 求法函式

# for acos, atan2 and sin
import math
import sys
 
# radian to degree
deg = 180/math.pi
# link 1 length
a1 = 0.457
# link 2 length
a2 = 0.426
# derivated based up https://www.youtube.com/watch?v=IKOGwoJ2HLk&t=311s
 
def ik(x, y):
    # (x, y)  need to be located inside the circle with radius a1+a2
    if (x**2 + y**2) <= (a1+ a2)**2:
        q2 = -math.acos((x**2+y**2-a1**2-a2**2)/(2*a1*a2))
        q1 = math.atan2(y, x) + math.atan2((a2*math.sin(q2)), (a1+a2*math.cos(q2)))
        # The decimal point of number is rounded to the 4th place
        return [round(q1*deg, 4), round(q2*deg, 4)]
    else:
        print("Over range!")
        # end the script execution
        sys.exit()
 
theta = ik(-0.3, -0.55)
 
print(theta[0], theta[1])


3.手臂末端加入吸盤 << Previous Next >> 5.Python remote API 逆向運動學函式

Copyright © All rights reserved | This template is made with by Colorlib