Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch ament_index_cpp::PackageNotFoundError #32

Merged
merged 1 commit into from
Nov 21, 2019

Conversation

sloretz
Copy link
Contributor

@sloretz sloretz commented Nov 21, 2019

This fixes a crash in rviz2. It should probably be backported to dashing and eloquent, though I've only tested on the latest ROS 2 sources.

To reproduce:

Save the following as pkg_dne.urdf

<?xml version="1.0" ?>
<robot name="does_not_exist">
  <link name="base_link">
    <visual>
      <geometry>
        <mesh filename="package://package_does_not_exist/meshes/base.stl"/>
      </geometry>
    </visual>
  </link>
</robot>

Publish it using robot_state_publisher

ros2 run robot_state_publisher robot_state_publisher pkg_dne.urdf

Launch rviz2 and add a RobotModel display. Tell the display to use the description topic /robot_description. RViz will immediately crash.

Parsing robot urdf xml string.
terminate called after throwing an instance of 'ament_index_cpp::PackageNotFoundError'
  what():  package 'package_does_not_exist' not found, searching: [...

With this PR, RViz will log errors but continue to run

Parsing robot urdf xml string.
[ERROR] [rviz2]: Error retrieving file [package://package_does_not_exist/meshes/base.stl]: Package [package_does_not_exist] does not exist
[ERROR] [rviz2]: FileNotFoundException: Cannot locate resource package://package_does_not_exist/meshes/base.stl in resource group OgreAutodetect. in ResourceGroupManager::openResource at /home/sloretz/ws/ros2/build/rviz_ogre_vendor/ogre-v1.12.1-prefix/src/ogre-v1.12.1/OgreMain/src/OgreResourceGroupManager.cpp (line 705)
[ERROR] [rviz2]: could not load model 'package://package_does_not_exist/meshes/base.stl' for link 'base_link': FileNotFoundException: Cannot locate resource package://package_does_not_exist/meshes/base.stl in resource group OgreAutodetect. in ResourceGroupManager::openResource at /home/sloretz/ws/ros2/build/rviz_ogre_vendor/ogre-v1.12.1-prefix/src/ogre-v1.12.1/OgreMain/src/OgreResourceGroupManager.cpp (line 705)
[ERROR] [rviz2]: Error retrieving file [package://package_does_not_exist/meshes/base.stl]: Package [package_does_not_exist] does not exist
[ERROR] [rviz2]: FileNotFoundException: Cannot locate resource package://package_does_not_exist/meshes/base.stl in resource group OgreAutodetect. in ResourceGroupManager::openResource at /home/sloretz/ws/ros2/build/rviz_ogre_vendor/ogre-v1.12.1-prefix/src/ogre-v1.12.1/OgreMain/src/OgreResourceGroupManager.cpp (line 705)
[ERROR] [rviz2]: could not load model 'package://package_does_not_exist/meshes/base.stl' for link 'base_link': FileNotFoundException: Cannot locate resource package://package_does_not_exist/meshes/base.stl in resource group OgreAutodetect. in ResourceGroupManager::openResource at /home/sloretz/ws/ros2/build/rviz_ogre_vendor/ogre-v1.12.1-prefix/src/ogre-v1.12.1/OgreMain/src/OgreResourceGroupManager.cpp (line 705)

Side note, RViz only crashes if the mesh type is stl. If I change it to dae then RViz does not crash, even without this PR. I don't know the reason for the difference. @wjwwood is this difference unexpected or something that should be looked at?

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@sloretz sloretz added the bug label Nov 21, 2019
@sloretz sloretz self-assigned this Nov 21, 2019
@wjwwood wjwwood self-requested a review November 21, 2019 21:07
@wjwwood
Copy link
Member

wjwwood commented Nov 21, 2019

If I change it to dae then RViz does not crash, even without this PR.

What does it do if you give it a .dae file that doesn't exist?

Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@sloretz
Copy link
Contributor Author

sloretz commented Nov 21, 2019

What does it do if you give it a .dae file that doesn't exist?

Just logs a different message

Parsing robot urdf xml string.
[ERROR] [rviz2]: Could not load resource [package://turtlebot3_description/meshes/base.dae]: Unable to open file "package://turtlebot3_description/meshes/base.dae".
[ERROR] [rviz2]: FileNotFoundException: Cannot locate resource package://turtlebot3_description/meshes/base.dae in resource group OgreAutodetect. in ResourceGroupManager::openResource at /home/sloretz/ws/ros2/build/rviz_ogre_vendor/ogre-v1.12.1-prefix/src/ogre-v1.12.1/OgreMain/src/OgreResourceGroupManager.cpp (line 705)
[ERROR] [rviz2]: could not load model 'package://turtlebot3_description/meshes/base.dae' for link 'base_link': FileNotFoundException: Cannot locate resource package://turtlebot3_description/meshes/base.dae in resource group OgreAutodetect. in ResourceGroupManager::openResource at /home/sloretz/ws/ros2/build/rviz_ogre_vendor/ogre-v1.12.1-prefix/src/ogre-v1.12.1/OgreMain/src/OgreResourceGroupManager.cpp (line 705)
[ERROR] [rviz2]: Could not load resource [package://turtlebot3_description/meshes/base.dae]: Unable to open file "package://turtlebot3_description/meshes/base.dae".
[ERROR] [rviz2]: FileNotFoundException: Cannot locate resource package://turtlebot3_description/meshes/base.dae in resource group OgreAutodetect. in ResourceGroupManager::openResource at /home/sloretz/ws/ros2/build/rviz_ogre_vendor/ogre-v1.12.1-prefix/src/ogre-v1.12.1/OgreMain/src/OgreResourceGroupManager.cpp (line 705)
[ERROR] [rviz2]: could not load model 'package://turtlebot3_description/meshes/base.dae' for link 'base_link': FileNotFoundException: Cannot locate resource package://turtlebot3_description/meshes/base.dae in resource group OgreAutodetect. in ResourceGroupManager::openResource at /home/sloretz/ws/ros2/build/rviz_ogre_vendor/ogre-v1.12.1-prefix/src/ogre-v1.12.1/OgreMain/src/OgreResourceGroupManager.cpp (line 705)

@wjwwood
Copy link
Member

wjwwood commented Nov 21, 2019

But in that case the package does exist?

@sloretz
Copy link
Contributor Author

sloretz commented Nov 21, 2019

CI (testing just resource retriever)

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@sloretz
Copy link
Contributor Author

sloretz commented Nov 21, 2019

But in that case the package does exist?

In that case the package doesn't exist because I didn't source my tb3 workspace. Here's the collada case again with a different package name.

Parsing robot urdf xml string.
[ERROR] [rviz2]: Could not load resource [package://package_dne/meshes/dne.dae]: Unable to open file "package://package_dne/meshes/dne.dae".
[ERROR] [rviz2]: FileNotFoundException: Cannot locate resource package://package_dne/meshes/dne.dae in resource group OgreAutodetect. in ResourceGroupManager::openResource at /home/sloretz/ws/ros2/build/rviz_ogre_vendor/ogre-v1.12.1-prefix/src/ogre-v1.12.1/OgreMain/src/OgreResourceGroupManager.cpp (line 705)
[ERROR] [rviz2]: could not load model 'package://package_dne/meshes/dne.dae' for link 'base_link': FileNotFoundException: Cannot locate resource package://package_dne/meshes/dne.dae in resource group OgreAutodetect. in ResourceGroupManager::openResource at /home/sloretz/ws/ros2/build/rviz_ogre_vendor/ogre-v1.12.1-prefix/src/ogre-v1.12.1/OgreMain/src/OgreResourceGroupManager.cpp (line 705)
[ERROR] [rviz2]: Could not load resource [package://package_dne/meshes/dne.dae]: Unable to open file "package://package_dne/meshes/dne.dae".
[ERROR] [rviz2]: FileNotFoundException: Cannot locate resource package://package_dne/meshes/dne.dae in resource group OgreAutodetect. in ResourceGroupManager::openResource at /home/sloretz/ws/ros2/build/rviz_ogre_vendor/ogre-v1.12.1-prefix/src/ogre-v1.12.1/OgreMain/src/OgreResourceGroupManager.cpp (line 705)
[ERROR] [rviz2]: could not load model 'package://package_dne/meshes/dne.dae' for link 'base_link': FileNotFoundException: Cannot locate resource package://package_dne/meshes/dne.dae in resource group OgreAutodetect. in ResourceGroupManager::openResource at /home/sloretz/ws/ros2/build/rviz_ogre_vendor/ogre-v1.12.1-prefix/src/ogre-v1.12.1/OgreMain/src/OgreResourceGroupManager.cpp (line 705)

@wjwwood
Copy link
Member

wjwwood commented Nov 21, 2019

What happens if the .dae file exists? haha I don't know how it resolves the package:// without going through resource retriever.

@sloretz
Copy link
Contributor Author

sloretz commented Nov 21, 2019

What happens if the .dae file exists?

It works 🤷‍♂️. Like you say, no clue how it found the package.

Screenshot from 2019-11-21 13-41-46

<?xml version="1.0" ?>
<robot name="some">
  <link name="base_link">
    <visual>
      <geometry>
        <mesh filename="package://some_desc/meshes/backpack.dae"/>
      </geometry>
    </visual>
  </link>
</robot>

@wjwwood
Copy link
Member

wjwwood commented Nov 21, 2019

Weird, maybe it could use more investigation, but it seems like the current behavior is ok for both, even if we don't understand it at the moment.

Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, with CI

@sloretz sloretz merged commit 27d70a0 into ros2 Nov 21, 2019
@sloretz sloretz deleted the catch_PackageNotFoundError branch November 21, 2019 22:00
sloretz added a commit that referenced this pull request Nov 21, 2019
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
sloretz added a commit that referenced this pull request Nov 21, 2019
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
sloretz added a commit that referenced this pull request Dec 5, 2019
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
sloretz added a commit that referenced this pull request Dec 5, 2019
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants