日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

Matlab 符号运算 机器人正运动学DH 代公式

發(fā)布時(shí)間:2024/1/1 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Matlab 符号运算 机器人正运动学DH 代公式 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

通常算DH的時(shí)候需要先列DH參數(shù)表,再依次依據(jù)公式求T01,T12,T23,然后T03=T01*T12*T23

但是這最后一步T03=T01*T12*T23 非常麻煩,代公式容易代錯(cuò),算4*4的矩陣相乘也非常容易算錯(cuò),幸好matlab具有符號(hào)運(yùn)算功能

可以在B站搜索 Matlab公式推導(dǎo)? ?會(huì)有很多教授相關(guān)函數(shù)的視頻

照視頻重點(diǎn)學(xué)習(xí)syms,subs,simplify函數(shù)

也可以直接搜matlab官網(wǎng)函數(shù)的用法??

?

以這道題為例,求末端坐標(biāo)系3相對(duì)于坐標(biāo)系0的描述

T03=T01*T12*T23

編寫代碼如下:


clear
clc
%========================================每次調(diào)用先復(fù)制這段函數(shù)
syms alpha ?a d ?theta

y=[cos(theta) ? ? ? ? ? ? ? ? ? ? -sin(theta) ? ? ? ? ? ? ? ? ? ? ? ?0 ? ? ? ? ? ? ? ? ? ? a;?
? ? sin(theta)*cos(alpha) ?cos(theta)*cos(alpha) ? -sin(alpha) ?-sin(alpha)*d;
? ? sin(theta)*sin(alpha) ?cos(theta)*sin(alpha) ? ?cos(alpha) ? cos(alpha)*d;
? ? ?0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?0 ? ? ? ? ? ? ? ? ? ? ? ?1];
%====================================================


?syms theta1 ?theta2 ? theta3 ? L1 ?L2 ?%寫出所有用到的變量,這是定義


?T1=subs(y,[alpha ?a d ?theta],[0 0 0 theta1])%這一段是功能代碼照著DH表寫
?T2=subs(y,[alpha ?a d ?theta],[0 L1 0 theta2])%仔細(xì)觀察這里,就是照著DH表填
?T3=subs(y,[alpha ?a d ?theta],[0 L2 0 theta3])
?
?T=T1*T2*T3%矩陣合成,生成的是sym類型的矩陣
?T=simplify(T)%化簡(jiǎn)

%==========一句一句輸入以下代碼有助于理解(多嘗試,對(duì)照這自己的手算更容易理解)

edit%打開(kāi)編輯窗口
?T1

T2

T3

T1*T2

simplify(T1*T2)
?

T1*T2*T3

simplify(T1*T2*T3)

?%=========================================以下是我的edit窗口的顯示

>> T1
?
T1 =
?
[ cos(theta1), -sin(theta1), 0, 0]
[ sin(theta1), ?cos(theta1), 0, 0]
[ ? ? ? ? ? 0, ? ? ? ? ? ?0, 1, 0]
[ ? ? ? ? ? 0, ? ? ? ? ? ?0, 0, 1]
?
>> T2
?
T2 =
?
[ cos(theta2), -sin(theta2), 0, L1]
[ sin(theta2), ?cos(theta2), 0, ?0]
[ ? ? ? ? ? 0, ? ? ? ? ? ?0, 1, ?0]
[ ? ? ? ? ? 0, ? ? ? ? ? ?0, 0, ?1]
?
>> T3
?
T3 =
?
[ cos(theta3), -sin(theta3), 0, L2]
[ sin(theta3), ?cos(theta3), 0, ?0]
[ ? ? ? ? ? 0, ? ? ? ? ? ?0, 1, ?0]
[ ? ? ? ? ? 0, ? ? ? ? ? ?0, 0, ?1]
?
>> T1*T2
?
ans =
?
[ cos(theta1)*cos(theta2) - sin(theta1)*sin(theta2), - cos(theta1)*sin(theta2) - cos(theta2)*sin(theta1), 0, L1*cos(theta1)]
[ cos(theta1)*sin(theta2) + cos(theta2)*sin(theta1), ? cos(theta1)*cos(theta2) - sin(theta1)*sin(theta2), 0, L1*sin(theta1)]
[ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0, 1, ? ? ? ? ? ? ?0]
[ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0, 0, ? ? ? ? ? ? ?1]
?
>> simplify(T1*T2)
?
ans =
?
[ cos(theta1 + theta2), -sin(theta1 + theta2), 0, L1*cos(theta1)]
[ sin(theta1 + theta2), ?cos(theta1 + theta2), 0, L1*sin(theta1)]
[ ? ? ? ? ? ? ? ? ? ?0, ? ? ? ? ? ? ? ? ? ? 0, 1, ? ? ? ? ? ? ?0]
[ ? ? ? ? ? ? ? ? ? ?0, ? ? ? ? ? ? ? ? ? ? 0, 0, ? ? ? ? ? ? ?1]
?
>> T1*T2*T3
?
ans =
?
[ cos(theta3)*(cos(theta1)*cos(theta2) - sin(theta1)*sin(theta2)) - sin(theta3)*(cos(theta1)*sin(theta2) + cos(theta2)*sin(theta1)), - cos(theta3)*(cos(theta1)*sin(theta2) + cos(theta2)*sin(theta1)) - sin(theta3)*(cos(theta1)*cos(theta2) - sin(theta1)*sin(theta2)), 0, L2*(cos(theta1)*cos(theta2) - sin(theta1)*sin(theta2)) + L1*cos(theta1)]
[ cos(theta3)*(cos(theta1)*sin(theta2) + cos(theta2)*sin(theta1)) + sin(theta3)*(cos(theta1)*cos(theta2) - sin(theta1)*sin(theta2)), ? cos(theta3)*(cos(theta1)*cos(theta2) - sin(theta1)*sin(theta2)) - sin(theta3)*(cos(theta1)*sin(theta2) + cos(theta2)*sin(theta1)), 0, L2*(cos(theta1)*sin(theta2) + cos(theta2)*sin(theta1)) + L1*sin(theta1)]
[ ? ? ? ? ? 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? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?1]
?

總結(jié)

以上是生活随笔為你收集整理的Matlab 符号运算 机器人正运动学DH 代公式的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。