Scale problem when importing an .stl file with addVisual for adding a mesh corresponding to a rigidBody

8 次查看(过去 30 天)
kin = loadrobot('kinovaJacoJ2S6S300');
removeBody(kin,'j2s6s300_link_finger_1');
removeBody(kin,'j2s6s300_link_finger_2');
removeBody(kin,'j2s6s300_link_finger_3');
dhparams = [0 pi/2 0.290 0];
bodyTest= rigidBody('bodyTest');
jointTest= rigidBodyJoint('jointTest','revolute');
setFixedTransform(jointTest,dhparams(1,:),'dh');
bodyTest.Joint=jointTest;
addVisual(bodyTest,"Mesh",'arm.stl');
addBody(kin,bodyTest,'j2s6s300_end_effector');
show(kin)
I imported a robot from an existing library, removed some bodies and then I added a new rigidBody (bodyTest) to the rigidBodyTree (kin), all of this worked fine. But I also want to add a visual for this bodyTest in the form of arm.stl. The addVisual function works but there's a units problem, Matlab reads the [mm] values of the stl file as [m] values.
I looked at multiple topics on this problem but none of them offered a real answer for me. I can't use another stl file reader besides addVisual as it is the only function (I think) that specifies the stl file as being the geometrical representation of a rigidBody object.
Thanks in advance.
  1 个评论
Christopher Bitikofer
Just an fyi you can scale stl meshes using the transform argument in the add visual command. It's a bit sneaky since you need to recall that you can use matricies to rotate, translate and scale.
tForm = [eye(3).*0.001,[0 0 0]';[0 0 0 1]]; % scale units of stl from mm to m
addVisual(rb1,"Mesh","mymesh.STL",tForm)

请先登录,再进行评论。

采纳的回答

Johan Poccard
Johan Poccard 2020-9-9
My problem was kind of solved but outside of Matlab so it makes it work but others could still have the same problem.
From my CAD software Inventor, I was able to generate the stl files of my piece my choosing a meter unit which solves the issue.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Manipulator Modeling 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by