MATLAB Answers

how to create a robot from DH parameters

조회 수: 69(최근 30일)
Ali Souliman
Ali Souliman 2021년 1월 20일
댓글: Valeria Leto 2021년 5월 13일
I have the DH matrix of my robot manipulator.
[0.033 -pi/2 0.147 q1;
0.155 0 0 q2-pi/2;
0.135 0 0 q3;
0 pi/2 0 q4+pi/2;
0 0 0.218 q5];
I am trying to create a model of the robot along what's used here:
the forward kinematics function getTransform() doesn't return the right Homogeneous transormation matrix, which means the model isn't correct.
the code I wrote:
dhparams=[0.033 -pi/2 0.147 0;
0.155 0 0 -pi/2;
0.135 0 0 0;
0 pi/2 0 pi/2;
0 0 0.218 0];
robot = rigidBodyTree('DataFormat','row');
body1 = rigidBody('body1');
jnt1 = rigidBodyJoint('jnt1','revolute');
body2 = rigidBody('body2');
jnt2 = rigidBodyJoint('jnt2','revolute');
body3 = rigidBody('body3');
jnt3 = rigidBodyJoint('jnt3','revolute');
body4 = rigidBody('body4');
jnt4 = rigidBodyJoint('jnt4','revolute');
body5 = rigidBody('body5');
jnt5 = rigidBodyJoint('jnt5','revolute');
body1.Joint = jnt1;
body2.Joint = jnt2;
body3.Joint = jnt3;
body4.Joint = jnt4;
body5.Joint = jnt5;
transform = getTransform(robot,[0.1 0.1 0.1 0.1 0.1],'body5')


Yiping Liu
Yiping Liu 2021년 1월 21일
Ali, the getTransform method is working correctly. But from the way you set the DH parameters, I assume you expect "theta offset" on joint angles 2 and 4.
% a alpha d theta
dhparams=[0.033 -pi/2 0.147 0;
0.155 0 0 -pi/2; % theta offset?
0.135 0 0 0;
0 pi/2 0 pi/2; % theta offset?
0 0 0.218 0];
In the current setFixedTransform implementation, the theta offset is ignored for a revolute joint (similary, the d offset is ignored for a prismatic joint), and that is a documented behavior, see here. In the future, we may consider to allow user to specify the offsets to ease some of the practical use cases, but for now, there are two workarounds:
1) manually adding fixed bodies in between to account for these offsets.
2) Modify the config with the offsets. i.e. instead of
getTransform(robot,[0.1 0.1 0.1 0.1 0.1],'body5')
You do
getTransform(robot,[0.1 0.1-pi/2 0.1 0.1+pi/2 0.1],'body5')
  댓글 수: 1
Valeria Leto
Valeria Leto 2021년 5월 13일
Hi, I have the same problem, but I haven't understood how to change the code. Could you make an example with the second joint?

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by