Ask Your Question
0

ROS2 Foxy Gazebo spawn_entity [SystemPaths.cc:459] File or path does not exist [""]

asked 2021-03-07 14:56:43 -0600

vinny gravatar image

updated 2021-04-24 02:53:01 -0600

miura gravatar image

I am having trouble getting an xacro / URDF model to spawn in Gazebo, however I am able to get it working in rviz2. ROS2, Foxy, Gaebo-11.3.0, x86.

I am providing the minimal example in the following question.

I am getting the following on stdout

[gazebo-3] [Wrn] [SystemPaths.cc:459] File or path does not exist [""] [model://test_robot/src/description/meshes/test_robot.stl]
[gazebo-3] [Err] [Visual.cc:2956] No mesh specified
[gazebo-3] [Wrn] [SystemPaths.cc:459] File or path does not exist [""] [model://test_robot/src/description/meshes/test_robot.stl]
[gazebo-3] [Err] [Visual.cc:2956] No mesh specified
[gazebo-3] [Wrn] [SystemPaths.cc:459] File or path does not exist [""] [model://test_robot/src/description/meshes/test_robot.stl]

I have attempted to add the meshes folder to GAZEBO_MODEL_PATH with no luck.

Here is my working directory

.
├── CMakeLists.txt
├── include
│   └── test_robot
├── launch
│   ├── gazebo.launch.py
│   └── rviz.launch.py
├── package.xml
├── rviz
│   └── urdf_config.rviz
└── src
    └── description
        ├── meshes
        │   └── test_robot.stl
        └── test_robot.xacro

7 directories, 7 files

My CMakeLists

cmake_minimum_required(VERSION 3.5)
project(test_robot)

# Default to C99
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)

install(
  DIRECTORY src launch rviz
  DESTINATION share/${PROJECT_NAME}
)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # uncomment the line when a copyright and license is not present in all source files
  #set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # uncomment the line when this package is not in a git repo
  #set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()

My xacro (yes I am aware there is no collision mesh, but I don't think that is relevant):

<?xml version="1.0" encoding="UTF-8"?>
<robot name="test_robot" xmlns:xacro="http://www.ros.org/wiki/xacro">
<link name="base_link">
    <inertial>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <mass value="1"/>
        <inertia
          ixx="1" ixy="0" ixz="0"
          iyy="1" iyz="0"
          izz="1"/>
    </inertial>
    <visual>
        <origin xyz="0 0 0" rpy="0 0 0"/>
            <geometry>
                <mesh filename="package://test_robot/src/description/meshes/test_robot.stl"/>
            </geometry>
        <material name="grey"/>
    </visual>
</link>
</robot>

My gazebo launch file

"""
Spawn Robot Description
"""
import os

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import Command, LaunchConfiguration
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


def generate_launch_description():
    test_robot_description_share = FindPackageShare(package='test_robot').find('test_robot')
    default_model_path = os.path.join(test_robot_description_share, 'src/description/test_robot.xacro')

    robot_state_publisher_node = Node(
        package='robot_state_publisher',
        executable='robot_state_publisher',
        parameters=[{'robot_description': Command(['xacro ', LaunchConfiguration('model')])}]
    )

    # GAZEBO_MODEL_PATH has to be correctly set for Gazebo to be able to find the model
    spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py',
                        arguments=['-entity', 'my_test_robot', '-topic', '/robot_description'],
                        output='screen')

    return LaunchDescription([
        DeclareLaunchArgument(name='model', default_value=default_model_path,
                                    description='Absolute path to robot ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2021-03-08 08:35:10 -0600

vinny gravatar image

updated 2021-03-10 10:19:46 -0600

Use the file://$(find) syntax.

<?xml version="1.0" encoding="UTF-8"?>
<robot name="test_robot" xmlns:xacro="http://www.ros.org/wiki/xacro">
<link name="base_link">
    <inertial>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <mass value="1"/>
        <inertia
          ixx="1" ixy="0" ixz="0"
          iyy="1" iyz="0"
          izz="1"/>
    </inertial>
    <visual>
        <origin xyz="0 0 0" rpy="0 0 0"/>
            <geometry>
                <mesh filename="file://$(find test_robot)/src/description/meshes/test_robot.stl"/>
            </geometry>
        <material name="grey"/>
    </visual>
</link>
</robot>
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

Asked: 2021-03-07 14:56:43 -0600

Seen: 672 times

Last updated: Mar 10