-
Notifications
You must be signed in to change notification settings - Fork 213
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
[rviz_rendering] replace hard coded resource location with ament_index #3
Comments
Here is my understanding of this issue: Currently, the only "resource" we require is the ogre_media folder containing the plugins.cfg file. This is as of now linked into the program during CMake and it's linked from the source folder. Obviously, that's not the way to go. We now want two things: a) we want the ogre_media resources to be available in the ament_index. To do this, we can register the resources and move the folders during CMake. I would think that ogre_media was its own resource to which every plugin could then contribute, i.e. we would have a file b) we want the location of the ogre_media package loaded at runtime (not via CMake). This can be accomplished using the Is this the way to go? |
No, I wouldn't think of the This issue could be solved by simply getting the package's location and referencing the ogre media of this package with a relative path. The ament index will only tell you either:
It does not answer:
You could either hard code this information (probably the right thing to do in the case of the relative location of the resources, e.g. hard code
Yes, but as I described above, I think the solution for this issue is to get the "package" resource which tells us at runtime (not via CMake) where the |
We are preparing a PR for this issue. |
In ROS 1 rviz used
rospkg
(theROS_PACKAGE_PATH
) to find therviz
package's location to find the stuff distributed inogre_media
at runtime. As one example, see:Right now in the
rviz_rendering
package we have a hard coded value to find these files, which will not work long term. See:rviz/rviz_rendering/src/rviz_rendering/render_system.cpp
Line 279 in 7d93981
rviz/rviz_rendering/include/rviz_rendering/resource_config.hpp
Line 49 in 7d93981
rviz/rviz_rendering/src/rviz_rendering/config.hpp.in
Line 33 in 7d93981
rviz/rviz_rendering/CMakeLists.txt
Lines 72 to 73 in 7d93981
This should instead be replaced with finding the package's installation location using the
ament_index
. The idea behind theament_index
is described in detail here:https://github.com/ament/ament_cmake/blob/master/ament_cmake_core/doc/resource_index.md
There is a cmake API, which we would use to store things in the ament index if we needed to do so:
https://github.com/ament/ament_cmake/tree/master/ament_cmake_core/cmake/index
However, if we just need the installation location of the
rviz_rendering
package, that part is already "registered" in the ament index with this call in the CMake:rviz/rviz_rendering/CMakeLists.txt
Line 111 in 7d93981
We can access the information with the
ament_index_cpp
package which is C++ API for querying the ament index at runtime:https://github.com/ament/ament_index/tree/master/ament_index_cpp
Here is an example of finding a package's location at runtime using the C++ API:
https://github.com/ros2/demos/blob/8354081d55c627b60b8e1229bdcd84d6ec036068/composition/src/api_composition.cpp#L89
There is a more direct API call in the python version
ament_index_python
:https://github.com/ros2/ros2cli/blob/5584754399cb388b479814328dbf8840483ff985/ros2pkg/ros2pkg/api/__init__.py#L17
We could add that to C++ if needed.
You can introspect what is in the ament index by just browsing the files in
<install prefix>/share/ament_index/resource_index
.The text was updated successfully, but these errors were encountered: