Ask Your Question
0

How to add a tool from a STL file

asked 2021-07-21 04:57:33 -0500

DavidRedrejo gravatar image

updated 2021-07-29 10:02:16 -0500

Hello,

I'm new at ROS (kinetic 1.12.17, Ubuntu 16.04 LTS) and I want to know how can I add a tool to a robot, having the tool in STL format.

I'm working with the Robotnik's RB-Kairos robot with the UR10 arm and I am lost with all the URDF files that are in the packages (you can see my workspace at https://github.com/DavidRedrejo/test_ws/tree/main)

I want to add the tool.stl (found in my main branch) to the robot xacro (access here) but I don't know where and how I have to add the tool in the robot's xacro file.

The tool is suposed to be a "static holder" for a real tool, but I think that it is not necesary to represent that tool, just the "holder piece".

Hope somebody could help me. Many thanks for your time!

EDIT: I have made an URDF file for the tool, it looks like this:

<?xml version="1.0"?>
<robot name="spray_tool" xmlns:xacro="http://www.ros.org/wiki/xacro">

    <xacro:macro name="spray_tool" params="prefix parent *origin ">

        <joint name="${prefix}_base_joint" type="fixed">
            <origin xyz="0 0 0" rpy="0 0 0"/>
            <parent link="${parent}"/>
            <child link="${prefix}_base_link"/>
        </joint>

        <!-- BASE LINK -->
        <link name="${prefix}_base_link">
            <inertial>
                <mass value="0.25" />
                <origin xyz="0 0 0" />
                <inertia  ixx="1.0" ixy="0.0"  ixz="0.0"  iyy="1.0"  iyz="0.0"  izz="1.0" />
            </inertial>

            <visual>
                <origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0" />
                <geometry>
                    <mesh filename="package://spray_tool_description/meshes/tool.stl" scale="10 10 10"/>
                </geometry>
                <!-- <material name="grey">
                    <color rgba="0.5 0.5 0.5 1"/>
                </material> -->
            </visual>

            <collision>
                <origin xyz="0.0 0 0" rpy="0 0 0" />
                <geometry>
                <!--box size="0.146 0.05 0.0735"/-->
                    <mesh filename="package://spray_tool_description/meshes/tool.stl" scale="10 10 10"/>
                </geometry>
            </collision>
        </link>


    </xacro:macro>
</robot>

And in the rbkairos.urdf.xacro I also added the include line at the top and this other line.

When I run the simulation, there is no tool, but the link rbkairos_spray_tool_base_link is created, as seen in this frame. (Sorry, I don't have points to post pics here!)

So, the frame is correct but there is no visual display? Or any file is not properly done?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-07-21 12:10:27 -0500

shonigmann gravatar image

I'd highly recommend reading through the URDF tutorials to understand better what is inside a URDF or xacro file.

In this case, as the robot has been mostly defined already, and you just need to add the tool, you will want to add a link. You can either do this directly in the rbkairos.urdf.xacro, as a child of the <robot> tag, or you can define the tool in a separate xacro file (e.g. my_tool.xacro) and include it, as is done here. The latter is probably the cleaner approach but they are functionally equivelent. includeing an xacro file just inserts it into the final parsed file.

Your '<link>' will need the following

  • <visual> and <collision> tags. These can have identical contents if you want to use the same .stl file for both. Sometimes it makes more sense to use simplified collision models, but this depends on your application/models. The end of this tutorial shows you what your visual tag will need to import a mesh model
  • a <joint> definition; the joint defines just how and where your .stl model fits onto the robot? is it a fixed connection, can it rotate, if so how?
  • if you are simulating your robot, you will also need an <inertial> block for the sake of the physics engine

You can quickly to test to make sure your .xacro file compiles properly using the commandline interface (e.g. xacro myfile.xacro). Feel free to update your question with your attempt if you have issues, and I can try to help

edit flag offensive delete link more

Comments

Hi @shonigmann , thanks for your reply and your help!

I updated the question with my attempt and there might be something I'm missing but I don't see it.

If I need to post more info let me know! Many thaks!

DavidRedrejo gravatar image DavidRedrejo  ( 2021-07-29 10:06:00 -0500 )edit

are there any hints in the console output?

if you look in the gazebo log files (on ubuntu, they are in ~/.gazebo/server-XXXXX/default.log, ~/.gazebo/client-XXXXX/default.log, and ~/.gazebo/ogre.log), are there any hints?

My best guess is that the CAD model you specified cannot be found be Gazebo, indicating either that the models cannot be found on the Gazebo model path or that the path you provided cannot be resolved. If you replace the <mesh> with a <box> can you at least see the box when you load the model?

shonigmann gravatar image shonigmann  ( 2021-07-29 13:38:47 -0500 )edit

In the log files there is nothing related to xacro files or stl. Now is fixed and working fine. The problem was the scale param in the <mesh> tag. I thought that the scale was to specify a factor to multiply all dimensions, but scale is the relation between the dimension of the object and the dimension in the simulation (in my case, the .stl was defined in mm and the simulation is 1 m, so my scale param is -> scale="0.001 0.001 0.001")

I will set your answer as correct because the main question was solved with that. Thanks!

DavidRedrejo gravatar image DavidRedrejo  ( 2021-07-29 16:40:02 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-07-21 04:57:33 -0500

Seen: 195 times

Last updated: Jul 29 '21