I'm quite confused by how ROS2 manages packages and package locations.
In ROS1, I would compile my nodes with a CMAKE_INSTALL_PREFIX
like $HOME/ros-dev
and install them there, then source $HOME/ros-dev/setup.bash
(or manually set ROS_PACKAGE_PATH=$HOME/ros-dev/share
), and everyone was happy: ros run
& roslaunch
would find my packages, and I could compile other packages with cmake finding the dependencies on the installed one without trouble.
Now, ROS2/ament
got rid of setup.bash
. Fine, I can certainly live with that. But if I create a launch file with the new python framework (btw, this framework is awfully verbose -- I certainly liked the XML launch files better, even though it was XML), how is ros2 launch my_launch_file.py
supposed to know where my packages are located?
By default, it looks for packages in /opt/ros/bouncy
. I can set AMENT_PREFIX_PATH
to my install prefix, but it doesn't seem to be able to find the packages/nodes (I've tried as well $PREFIX/lib
and $PREFIX/share
without much success).
And beyond that specific issue, what is the correct way of telling ROS2 where the packages are installed? Setting AMENT_PREFIX_PATH
in my .bashrc
with a list of possible install prefixes? (in that case, it would have been nice to reuse ROS_PACKAGE_PATH
whose name is clearer)
Originally posted by severin on ROS Answers with karma: 240 on 2018-10-05
Post score: 2
Original comments
Comment by William on 2018-10-08:
Perhaps it is a typo, but ros2 launch my_launch_file.py
would not work unless my_launch_file.py
is in the current directory. Something like ros2 launch my_package my_launch_file.py
would work by finding where my_package
is installed and locating the launch file from there.
Comment by severin on 2018-10-09:
@William in that particular case, the launch file was indeed in the current directory, but yes, in general you are right :-)