robot simulation collision detection

7 views (last 30 days)
Robert Shaw
Robert Shaw on 30 Jul 2021
Answered: Yiping Liu on 3 Aug 2021
Hello I use matlab to display robots and create controls simulations. I have been looking at https://www.mathworks.com/help/robotics/ref/rigidbodytree.show.html as a means to read stl files but the problem is I do not know DH convention and do not really intend to learn it lol. I would like to use this system because it has collision detection.
so my questions:
Is there a way to use matlabs rigidbody features with simular forward kinematics to what i do below instead of DH convension?
Would it just be easier to code my own collision detection into this? If anyone has any ideas on how I might go about doing that I would appriciate it :)
Here is an example of how I read in stl files and do the forward kinematics
[base_vertices_in_I, base_faces, ~, ~, ~] = stlread('Denso_6242_Base.STL');
[link1_vertices_in_1, link1_faces, ~, ~, ~] = stlread('Denso_6242_Link1.STL');
[link2_vertices_in_2, link2_faces, ~, ~, ~] = stlread('Denso_6242_Link2.STL');
[link3_vertices_in_3, link3_faces, ~, ~, ~] = stlread('Denso_6242_Link3.STL');
[link4_vertices_in_4, link4_faces, ~, ~, ~] = stlread('Denso_6242_Link4.STL');
[link5_vertices_in_5, link5_faces, ~, ~, ~] = stlread('Denso_6242_Link5.STL');
[gripper_vertices_in_E, gripper_faces, ~, ~, ~] = stlread('VP_6242_Gripper_JawE.STL');
IT1 = rotz(gamma(1));
oneT2 = roty(gamma(2));
twoT3 = roty(gamma(3));
threeT4 = roty(-pi/2)*rotx(gamma(4));
fourT5 = roty(gamma(5));
fiveTE = rotx(gamma(6));
IIr1 = [0;0;155];
oneoner2 = [0;0;123.5];
twotwor3 = [0;0;210];
threethreer4 = [-75;0;86];
fourfourr5 = [125.0;0;0];
fivefiverE = [132.5;0;0];
IT2 = IT1*oneT2;
IT3 = IT2*twoT3;
IT4 = IT3*threeT4;
IT5 = IT4*fourT5;
ITE = IT5*fiveTE
IIr2 = IIr1 + IT1*oneoner2;
IIr3 = IIr2 + IT2*twotwor3;
IIr4 = IIr3 + IT3*threethreer4;
IIr5 = IIr4 + IT4*fourfourr5;
IIrE = IIr5 + IT5*fivefiverE
IqE=quatmult([cos(gamma(1)/2);0;0;sin(gamma(1)/2)],[cos(gamma(2)/2);0;sin(gamma(2)/2);0]);
IqE=quatmult(IqE,[cos(gamma(3)/2);0;sin(gamma(3)/2);0]);
IqE=quatmult(IqE,[cos(gamma(4)/2);sin(gamma(4)/2);0;0]);
IqE=quatmult(IqE,[cos(gamma(5)/2);0;sin(gamma(5)/2);0]);
IqE=quatmult(IqE,[cos(gamma(6)/2);sin(gamma(6)/2);0;0]);
link1_vertices_in_I=IIr1+IT1*link1_vertices_in_1'; %transform link1 coordinates to frame I
link2_vertices_in_I=IIr2+IT2*link2_vertices_in_2'; %transform link2 coordinates to frame I
link3_vertices_in_I=IIr3+IT3*link3_vertices_in_3'; %transform link3 coordinates to frame I
link4_vertices_in_I=IIr4+IT4*link4_vertices_in_4'; %transform link4 coordinates to frame I
link5_vertices_in_I=IIr5+IT5*link5_vertices_in_5'; %transform link5 coordinates to frame I
gripper_vertices_in_I=IIrE+ITE*gripper_vertices_in_E'; %transform gripper coordinates to frame I
%create a patch object using the faces and vertices. Do not color the
%edges of the triangles only their faces in an [r g b] format.
p1=patch('Faces',base_faces,'Vertices',base_vertices_in_I,'EdgeColor','None','FaceColor',[0 0 1]);
p2=patch('Faces',link1_faces,'Vertices',link1_vertices_in_I','EdgeColor','None','FaceColor',[1 0 1]);
p3=patch('Faces',link2_faces,'Vertices',link2_vertices_in_I','EdgeColor','None','FaceColor',[1 0 1]);
p4=patch('Faces',link3_faces,'Vertices',link3_vertices_in_I','EdgeColor','None','FaceColor',[1 0 1]);
p5=patch('Faces',link4_faces,'Vertices',link4_vertices_in_I','EdgeColor','None','FaceColor',[1 0 1]);
p6=patch('Faces',link5_faces,'Vertices',link5_vertices_in_I','EdgeColor','None','FaceColor',[1 0 1]);
p7=patch('Faces',gripper_faces,'Vertices',gripper_vertices_in_I','EdgeColor','None','FaceColor',[1 0 0]);
axis equal %make axes equally scaled
camlight left %turn on a camera
set(gca,'projection','perspective')
%create a vanishing point at infinity
view([1;1;.5]) %set the viewer's location
% axis([-.8 .8 -.8 .8 0 .8]) %limit the axes
xlabel('x')
ylabel('y')
zlabel('z')

Answers (1)

Yiping Liu
Yiping Liu on 3 Aug 2021
It looks like you still want a robot model but just want to stay away with the DH parameters. You can use rigidBodyTree without DH parameters. rigidBodyTree allows you to specify the fixed transforms for each body directly using the 4x4 homogeneous transformation matrices.
To see an example, run the following two lines, and look in the generated iw_rbt.m file.
iw = loadrobot('kukaIiwa7')
iw.writeAsFunction('iw_rbt.m')
Also see doc page here.
setFixedTransform(jointObj,tform)
Note in our model, each body owns a joint and this tform here describes the fixed transform that relates the body i's joint to the parent of body i. See the description in this page for more details.
If you don't want to use rigidBodyTree at all and intend to compute all the transformations for all the bodies yourself - Not sure why you want to do that, but it's also possible. In this case, you should check out the following ref pages:
  1. collisionMesh
  2. checkCollision

Community Treasure Hunt

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

Start Hunting!