Issue with changing the precedence order of ROS_PACKAGE_PATH
My system: Ubuntu 20.04, ROS noetic.
My issue: I'm working with two packages that have ros1 packages with the same name ORB_SLAM3 which causes an issue with ROS_PACKAGE_PATH and thus with ROS finding the appropriate package to run. The packages I have installed are:
- https://github.com/VIS4ROB-lab/covins. This package uses ORB-SLAM3 as a frontend and can also run on ROS1. Per the instructions on the page, I have this project installed in ~/ws/covins_ws. Per the instructions on the section for ROS, I have sourced the file ~/ws/covins_ws/devel/setup.bash.
- The ORB_SLAM3 package https://github.com/UZ-SLAMLab/ORB_SLAM3, which originally is not a ROS package but offers an option to run on ROS as per section 7.
Where I run into an issue is when trying to build the ROS package for the second package above, specifically at the step ./build_ros.sh
with the following error message:
[rosbuild] Building package ORB_SLAM3
[rosbuild] Error from directory check: /opt/ros/noetic/share/ros/core/rosbuild/bin/check_same_directories.py /home/glenn/ws/covins_ws/src/covins/orb_slam3/Examples/ROS/ORB_SLAM3 /home/glenn/ORB_SLAM3/Examples_old/ROS/ORB_SLAM3
1
Traceback (most recent call last):
File "/opt/ros/noetic/share/ros/core/rosbuild/bin/check_same_directories.py", line 48, in <module>
raise Exception
Exception
CMake Error at /opt/ros/noetic/share/ros/core/rosbuild/private.cmake:99 (message):
[rosbuild] rospack found package "ORB_SLAM3" at
"/home/glenn/ws/covins_ws/src/covins/orb_slam3/Examples/ROS/ORB_SLAM3", but
the current directory is
"/home/glenn/ORB_SLAM3/Examples_old/ROS/ORB_SLAM3". You should
double-check your ROS_PACKAGE_PATH to ensure that packages are found in the
correct precedence order.
Call Stack (most recent call first):
/opt/ros/noetic/share/ros/core/rosbuild/public.cmake:177 (_rosbuild_check_package_location)
CMakeLists.txt:4 (rosbuild_init)
The error, as shown above, is because rospack find ORB_SLAM3 returns /home/glenn/ws/covins_ws/src/covins/orb_slam3/Examples/ROS/ORB_SLAM3 from package 1 above, even though I want it to find package 2.
My attempted solution:
Since I'm not currently using the first package, I choose not to source it (I used to have the line source ~/ws/covins_ws/devel/setup.bash
in my .bashrc, but commented it out. ). The two lines I have in bashrc are to source my underlay and overlay (source /opt/ros/noetic/setup.bash
, followed by source /home/glenn/catkin_ws/devel/setup.bash
). Note, there are no ORB_SLAM3 packages in the catkin_ws folder. Per the instruction from ORB-SLAM3, I also add the specfied path to the ROS_PACKAGE_PATH environment variable with the command export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/glenn/ORB_SLAM3/Examples_old/ROS/ORB_SLAM3
at the end of my bashrc (side note: the github says ORB_SLAM3/Examples, but the path to build ROS is actually in the Examples_old. I also modified the build script build_ros.sh to account for this).
From here, when I type echo $ROS_PACKAGE_PATH
, the output is:
/home/glenn/catkin_ws/src:/home/glenn/ws/covins_ws/src/catkin_simple:/home/glenn/ws/covins_ws/src/vision_opencv/cv_bridge:/home/glenn/ws/covins_ws/src/doxygen_catkin:/home/glenn/ws ...