How to properly set AMENT_PREFIX_PATH?
Hi,
I have some doubts about how AMENT_PREFIX_PATH
and CMAKE_PREFIX_PATH
should be set.
According to the ament design documentation http://design.ros2.org/articles/ament.html
Therefore ament uses a separate environment variable (AMENTPREFIXPATH) for that purpose which is used at runtime. At build time of CMake packages the CMake specific variable can be derived from the generic ament variable.
Now an example where I'm having issues.
I'm cross-compiling some ROS2 packages.
Thus I have a directory ~/sysroot
which contains all the library/headers/binaries of my target system.
This directory also contains a cross-compiled ROS2 SDK.
The cross-compiled ROS2 libraries and headers are respectively located in ~/sysroot/usr/lib
and ~/sysroot/usr/include
together with the system ones.
I cross-compiled the ROS2 SDK, before adding it to the sysroot, without specifying the AMENT_PREFIX_PATH
. In this way the compiler was able to correctly find the needed libraries in the sysroot (e.g. Python).
When I want to cross-compile an additional package, I need to set AMENT_PREFIX_PATH=~/sysroot/usr
to allow the compiler to find the already cross-compiled packages. Leaving this empty results in not finding the required ROS2 dependencies.
However, if my packages require Python, this is not found.
A solution I found is to set the path to the following
AMENT_PREFIX_PATH="~/sysroot/usr;~/sysroot/usr/bin
This works: both Python as well as the ROS2 dependencies are found. However I'm getting a warning:
[0.280s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/root/sysroot/bin' in the environment variable AMENT_PREFIX_PATH doesn't exist
My intuition is that there could be something strange going on between AMENT_PREFIX_PATH
and how CMAKE_PREFIX_PATH
is automatically set.
Do you have any idea about what's going on?
Asked by alsora on 2019-03-11 05:00:08 UTC
Answers
You need to use a colcon (:
) to separate both paths - not a semicolcon (;
).
Asked by Dirk Thomas on 2019-03-11 13:10:58 UTC
Comments
THIS IS WRONG I still have the same warning, I have updated with the exact message.
ROS2 should support both :
as well as ;
as delimiters.
I don't understand how can it work if I add a path which does not exists according to ROS2...
Asked by alsora on 2019-03-11 13:36:18 UTC
The environment variable AMENT_PREFIX_PATH
defines where to find other ROS 2 packages. If the directory doesn't actually exist it doesn't make sence to add that path to it.
Asked by Dirk Thomas on 2019-03-11 13:37:52 UTC
Ok sorry, ignore my previous message.
The directory exists.
Using :
as delimiter the warning disappears, but I get again the error that Python is not found. The same I get if I set AMENT_PREFIX_PATH
without that directory.
Asked by alsora on 2019-03-11 13:45:37 UTC
I might want to include more information (like your CMake toolchain file, exact steps to reproduce the problem) for others to be able to provide valuable feedback.
Asked by Dirk Thomas on 2019-03-11 18:14:18 UTC
Hello ! I am also getting a similar error. I am not getting how to set AMENT_PREFIX_PATH properly. I tried using ':' delimiter but getting the same Python error: ModuleNotFoundError: No module named 'ament_package I have opened my issue in ModuleNotFound
Do we have some progress in this?
Asked by petal on 2019-06-09 23:50:17 UTC
Comments