0
$\begingroup$

I try to include an stl in im urdf file, but not succeeding so far. What I've tried:

roscore

rosparam set /robot_description -t data/models/urdf/cube.urdf

rviz -> in rviz add RobotModel

With a basic cube geomety it works, I can see the cube. But when I swop it with an stl it stops working (I tried different stls). With this it works:

<?xml version="1.0"?>
<robot name="box">
    <material name="black">
        <color rgba="0 0 0 1" />
    </material>
    <link name="base_link">
        <visual>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <box size="0.18 0.18 0.18" />
            </geometry>
            <material name="black" />
        </visual>
        <collision>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <box size="0.18 0.18 0.18" />
            </geometry>
        </collision>
        <inertial>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <mass value="1.0" />
            <inertia
                ixx="0.0001" ixy="0.0" ixz="0.0"
                iyy="0.0001" iyz="0.0"
                izz="0.0001" />
        </inertial>
    </link>
</robot>

But when I swop

            <geometry>
                <box size="0.18 0.18 0.18" />
            </geometry>

with

            <geometry>
                <mesh filename="file:///home/me/models/meshes/engine.stl" />
            </geometry>

it doesn't. When I remove the file:// or define a wrong path it complains. With this code there is no error, but I don't see anything in rviz. I use ros noetic.

$\endgroup$

2 Answers 2

2
$\begingroup$

Have you tried using

<geometry>
    <mesh filename="package://<my-description-package>/models/meshes/engine.stl"/>
</geometry>

my-description-pacakge should be replaced with the proper name of the description package that you created. Conventionally, this is where you store your meshes under the meshes directory.

EDIT: Make sure that you indeed install this meshes directory in your install space, otherwise it might not be detectable.

$\endgroup$
2
$\begingroup$

The issue was that the stl was in mm and I had to use

            <geometry>
                <mesh filename="file:///home/me/models/meshes/engine.stl" scale="0.001 0.001 0.001"/>
            </geometry>

to scale it down for ROS which seemed to expect m. That is why I did not get an error and wasn't able to see it.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.