Forward and Inverse Kinematics for robot

236 ビュー (過去 30 日間)
Mohsina Zafar
Mohsina Zafar 2019 年 6 月 28 日
コメント済み: Sam Chak 2023 年 10 月 9 日
Hello,
Hope you are doing well.
I am verifying the output of my forward kinematics through inverse kinematics and the results are not as desired. As the output of my inverse kinematics is not coming out to be the same as the input of forward kinematics.
The D-H parameters of manipulator is given as:
alpha a theta d
Link 1 -90 0 theta1* d1
Link 2 0 a2 theta2* 0
Link 3 0 a3 theta3* 0
Functions used are:
Forward kinematics:
function ph = forward_kinematics(q)
%input: [q1 q2 q3]
l2 = 0.28;
l3 = 0.2;
d1 = 0.03;
q1 = q(1);
q2 = q(2);
q3 = q(3);
ph = zeros(3,1);
ph1 = l2*cos(q1)*cos(q2)+l3*cos(q1)*cos(q2+q3);
ph2 = l2*sin(q1)*cos(q2)+l3*sin(q1)*cos(q2+q3);
ph3 = d1-l2*sin(q2)-l3*sin(q2+q3);
ph=[ph1;ph2;ph3];
end
Inverse kinematics
function q = inv_kinematics(ph)
%input: [ph1 ph2 ph3]
l1 = 0.05;
l2 = 0.28;
l3 = 0.2;
d1 = 0.03;
ph1 = ph(1);
ph2 = ph(2);
ph3 = ph(3);
r=sqrt(ph1^2+(ph3-d1)^2);
alpha=acos((r^2+l2^2-l3^2)/(2*r*l2))
q = zeros(3,1);
q1=atan2(ph2,ph1);
q2=atan2(ph1,ph3-d1)-alpha;
q3=atan2(ph1-l2*sin(q2),ph3-d1-l2*cos(q2))-q2;
q=[q1;q2;q3];
end
  4 件のコメント
Mohd Musharaf Hussain Sarwari
Mohd Musharaf Hussain Sarwari 2021 年 2 月 13 日
comming error
Mohd Musharaf Hussain Sarwari
Mohd Musharaf Hussain Sarwari 2021 年 2 月 13 日

サインインしてコメントする。

回答 (3 件)

Mohd Musharaf Hussain Sarwari
Mohd Musharaf Hussain Sarwari 2021 年 2 月 13 日
I WANT SCARA ROBOT forward-and-inverse-kinematics MATLAB CODE
  2 件のコメント
Abdullah
Abdullah 2023 年 10 月 9 日
Hi Bro
can i have scara robot Forward and inverse code ?
Sam Chak
Sam Chak 2023 年 10 月 9 日
Could you please copy and paste the mathematical algorithms of the Forward and Inverse Kinematics in code form? Otherwise, we cannot verify their correctness.

サインインしてコメントする。


Krishna Akella
Krishna Akella 2019 年 6 月 28 日
Hi Mohsina,
I don't know the answer to your question but I looked at your model and I have a few observations. In your model I assume the inputs to your forward kinematics function are the joint angle values and the output is the end effector location. And I assume the inputs to your inverse kinematics function is the end effector location and the outputs are the joint values.
If this is correct, then why would you not pass the output from forward kinematics back to your inverse kinematics function to validate that you are getting back the same joint values?
I made this change and it seems like the first output value matches.
The reason the other joint angles might still not be matching is because you could have multiple solutions to worry about. For example, in the computation of your inverse kinematics function, you have
r = sqrt(ph1^2+(ph3-d1)^2);
There could be two solutions to the sqrt function. A positive and a negative value. And MATLAB returns the positive value. Similar thing is true for other functions like acos, where multiple angles can give the same result. All these will result in multiple solutions to result in the same end effector location.
Regards,
Krishna
  1 件のコメント
Mohsina Zafar
Mohsina Zafar 2019 年 7 月 1 日
編集済み: Mohsina Zafar 2019 年 7 月 1 日
Actually, I am giving output of inverse kinematics to the input of forward kinematics.
Thank you for your reply but unfortunately I am using MATLab 2016a version and am unable to open your code. Can you kindly share it in the previous version?

サインインしてコメントする。


Ram Bodhe
Ram Bodhe 2020 年 5 月 12 日
function q = inv_kinematics(ph)
%input: [ph1 ph2 ph3]
l1 = 0.05; l2 = 0.28; l3 = 0.2; d1 = 0.03;
ph1 = ph(1); ph2 = ph(2); ph3 = ph(3);
r=sqrt(ph1^2+(ph3-d1)^2); alpha=acos((r^2+l2^2-l3^2)/(2*r*l2))
q = zeros(3,1); q1=atan2(ph2,ph1); q2=atan2(ph1,ph3-d1)-alpha; q3=atan2(ph1-l2*sin(q2),ph3-d1-l2*cos(q2))-q2;
q=[q1;q2;q3];
end
  1 件のコメント
Ram Bodhe
Ram Bodhe 2020 年 5 月 12 日
iam getting error anyone can help with this

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeRobotics についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by