1
$\begingroup$

Problem

Hi, I've exported a cad model from Soldiworks 2023 to URDF using the plugin from: http://wiki.ros.org/sw_urdf_exporter

I've put this STL that generates the geometry into my own package to load the stil file in RVIZ but. as shown in the code below, RVIZ can't retrieve the file but doesn't say why. Also please find below the error message.

What I've done already

I've included the stl file in my setup.py file. I've also tried to convert the STL to a dae file but that also couldn't be read.

If someone could help me out on this that would be great, thanks.

Edit

I've loaded the stl into rviz today using the same urdf file and its worked fine. Rviz continues not to load the stl in the urdf :/

error message

user@user-ENVY:~/ws/forfly_ws$ ros2 launch forfly forfly_launch.py 
[INFO] [launch]: All log files can be found below /home/user/.ros/log/2024-05-15-19-20-45-191071-user-ENVY-22221
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [robot_state_publisher-1]: process started with pid [22222]
[INFO] [rviz2-2]: process started with pid [22224]
[rviz2-2] Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
[robot_state_publisher-1] [INFO] [1715797245.277170403] [robot_state_publisher]: got segment air_layer
[robot_state_publisher-1] [INFO] [1715797245.277246959] [robot_state_publisher]: got segment testbed
[rviz2-2] [INFO] [1715797245.575394086] [rviz2]: Stereo is NOT SUPPORTED
[rviz2-2] [INFO] [1715797245.575574429] [rviz2]: OpenGl version: 4.6 (GLSL 4.6)
[rviz2-2] [INFO] [1715797245.590267725] [rviz2]: Stereo is NOT SUPPORTED
[rviz2-2] [ERROR] [1715797245.693698129] [rviz2]: Error retrieving file [/home/user/ws/forfly_ws/install/forfly/share/forfly/base_link.stl]: 
[rviz2-2] [ERROR] [1715797245.693800373] [rviz2]: Error retrieving file [/home/user/ws/forfly_ws/install/forfly/share/forfly/base_link.stl]: 
[rviz2-2] [ERROR] [1715797245.693840460] [rviz2]: Error retrieving file [/home/user/ws/forfly_ws/install/forfly/share/forfly/base_link.stl]: 
[rviz2-2] [ERROR] [1715797245.693887790] [rviz2]: Error retrieving file [/home/user/ws/forfly_ws/install/forfly/share/forfly/base_link.stl]: 

launch.py file

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
import xacro

def generate_launch_description():

    use_sim_time = LaunchConfiguration('use_sim_time', default='false')

    urdf_file_name = 'forfly_solidworks_v1.urdf'
    urdf = os.path.join(
        get_package_share_directory('forfly'),
        urdf_file_name)
    robot_desc = xacro.process_file(urdf).toxml()

    rviz_file = os.path.join(get_package_share_directory('forfly'),'urdf.rviz')

    return LaunchDescription([
        DeclareLaunchArgument(
            'use_sim_time',
            default_value='false',
            description='Use simulation (Gazebo) clock if true'),
        Node(
            package='robot_state_publisher',
            executable='robot_state_publisher',
            name='robot_state_publisher',
            output='screen',
            parameters=[{'use_sim_time': use_sim_time, 
            'robot_description': robot_desc}],
            arguments=[urdf]),
            Node(
            package='rviz2',
            namespace='',
            executable='rviz2',
            name='rviz2',
            output='screen',
            arguments=['-d' + rviz_file],
        ),
    ])

Setup.py file

import os
from glob import glob

package_name = 'forfly'

setup(
    name=package_name,
    version='0.0.0',
    packages=find_packages(exclude=['test']),
    data_files=[
        ('share/ament_index/resource_index/packages',
            ['resource/' + package_name]),
        ('share/' + package_name, ['package.xml']),
        (os.path.join('share', package_name, 'launch'), glob(os.path.join('launch', '*launch.[pxy][yma]*'))),
        (os.path.join('share', package_name), glob('urdf/*')),
        (os.path.join('share', package_name), glob('rviz/*urdf.rviz')),
        (os.path.join('share', package_name), glob('meshes/*')),
    ],
    install_requires=['setuptools'],
    zip_safe=True,
    maintainer='joe',
    maintainer_email='[email protected]',
    description='TODO: Package description',
    license='Apache-2.0',
    tests_require=['pytest'],
    entry_points={
        'console_scripts': [
        ],
    },
)

urdf file

<!-- This URDF was automatically created by SolidWorks to URDF Exporter! Originally created by Stephen Brawner ([email protected]) 
     Commit Version: 1.6.0-4-g7f85cfe  Build Version: 1.6.7995.38578
     For more information, please see http://wiki.ros.org/sw_urdf_exporter -->
<robot
  name="forfly_solidworks_v1">
  <link name="air_layer">
  <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
          <box size="0.3 0.3 0.000005"/>
      </geometry>
      <material
        name="">
        <color
          rgba="0 0 0 0" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
          <box size="0.3 0.3 0.000005"/>
      </geometry>
    </collision>
  </link>
  <link
    name="testbed">
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="$(find forfly)/base_link.stl" />
  </geometry>
  <material
    name="">
    <color
      rgba="0.75294 0.75294 0.75294 1" />
  </material>
</visual>
<collision>
  <origin
    xyz="0 0 0"
    rpy="0 0 0" />
  <geometry>
    <mesh
      filename="$(find forfly)/base_link.stl" />
      </geometry>
    </collision>
    <inertial>
      <origin
        xyz="-0.00096272 0.0016866 0.27122"
        rpy="0 0 0" />
      <mass
        value="9.6165" />
      <inertia
        ixx="0.073252"
        ixy="-2.4392E-08"
        ixz="2.8224E-08"
        iyy="0.073114"
        iyz="-1.951E-09"
        izz="0.045766" />
    </inertial>
  </link>
  <joint name="air_layer_to_robot_joint" type="fixed">
    <parent link="air_layer" />
    <child link="testbed" />
    <origin xyz="0 0 0.0000025" rpy="0 0 0" />
  </joint>
</robot>
```
$\endgroup$

1 Answer 1

0
$\begingroup$

I don't see anything inherently wrong in your approach, but I can suggest some debugging tips if that might interest you:

  1. Check if the base_link.stl has been copied over to your install space - if not, this could explain the error.

  2. Often, when SolidWorks exports STL files, it uses the extension ".STL" and not ".stl". Verify if this is the case.

  3. I suspect that while exporting, you had your meshes in the root of the package, and have since then moved them to the meshes directory. Try changing the call to <mesh filename="$(find forfly)/base_link.stl" /> in the URDF file to <mesh filename="$(find forfly)/meshes/base_link.stl" /> and see if it works.

$\endgroup$
1
  • $\begingroup$ Thank you for the reply, 1. I've checked the install space and the stl file is there. 2.It was originally .STL but I then changed it to .stl along with the references inside the files. Both .STL and .stl don't work sadly. 3.Originally the urdf file did contain <mesh filename="$(find forfly)/meshes/base_link.stl" /> However, the contents of the mesh file are put into the install space, not the actual file. Hence my naming convention. I've added an edit to the post, as I've now been able to load the stl file in Gazebo, but rviz still doesn't load it :/ $\endgroup$
    – M1lden
    May 16 at 17:49

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.