[FATAL] [xxxxxxxxxx.xxxxxx, x.xxxxxx]: Error: specified file grasp_box.urdf does not exist

In Unit 3: Object Detection when I try to spawn the red cube from a fresh terminal I get the following:

user:~$ source /opt/ros/noetic/setup.bash
ROS_DISTRO was set to 'foxy' before. Please make sure that the environment does not mix paths from different distributions.
user:~$ rosrun gazebo_ros spawn_model -file grasp_box.urdf -urdf -x 0.5 -y 0.13 -z 0.1 -model grasp_box
[INFO] [1663845242.431040, 0.000000]: Loading model XML from file grasp_box.urdf
[FATAL] [1663845242.432597, 0.000000]: Error: specified file grasp_box.urdf does not exist

I created the URDF file as specified previously.

I found the lines of code where the error is triggered in the */opt/ros/noetic/lib/gazebo_ros/spawn_model* file:
        # Load model XML from file
        if self.args.file:
            rospy.loginfo("Loading model XML from file %s" % self.args.file)
            if not os.path.exists(self.args.file):
                rospy.logfatal("Error: specified file %s does not exist", self.args.file)
                return 1

And after that I tried to see if the file can be found through python. Indeed an error occurs. However it is present in an ls command.

see here
user:~/catkin_ws$ python
Python 3.8.10 (default, Jun  2 2021, 10:49:15)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.exists('grasp_box.urdf')
user:~/catkin_ws$ ls src/
CMakeLists.txt  grasp_box.urdf  load_params  my_moveit_config  ur3e_robot.urdf.xacro

A chmod +rwx grasp_box.urdf won’t change anything.

Any help will be much appreciated.

Hi @GasPatxo, I am yourself 5 years from now. I just found out that you need to be in the right directory to execute
rosrun gazebo_ros spawn_model -file FILENAME -urdf -x 0.5 -y 0.13 -z 0.1 -model grasp_box
So either execute it from /home/user/catkin_ws/src/ or input the full path:

user:~/ros2_ws$ rosrun gazebo_ros spawn_model -file '/home/user/catkin_ws/src/grasp_box.urdf' -urdf -x 0.5 -y 0.13 -z 0.1 -model grasp_box
[INFO] [1663849234.535679, 0.000000]: Loading model XML from file /home/user/catkin_ws/src/grasp_box.urdf
[INFO] [1663849234.540357, 0.000000]: Waiting for service /gazebo/spawn_urdf_model
[INFO] [1663849234.567258, 0.000000]: Calling service /gazebo/spawn_urdf_model
[INFO] [1663849234.816553, 11273.288000]: Spawn status: SpawnModel: Successfully spawned entity


PS: I cannot tell you anything else, we ain’t want no time paradox


This topic was automatically closed after 20 hours. New replies are no longer allowed.