Rosanswers logo

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:

  1. 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.
  2. 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
Traceback (most recent call last):
  File "/opt/ros/noetic/share/ros/core/rosbuild/bin/check_same_directories.py", line 48, in <module>
    raise 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:


where it shows home/glenn/ORB_SLAM3/Examples_old/ROS/ORB_SLAM3 at the end, after /home/glenn/ws/covins_ws/src/covins/orb_slam3/Examples/ROS/ORB_SLAM3, thus it has a lower precedence, and when I type rospack find ORB_SLAM3, it returns the latter path.

I then tried adding the path to the first package, after I echo the path to the second package in my bashrc with export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/glenn/ws/covins_ws/src/covins/orb_slam3/Examples/ROS/ORB_SLAM3.

Now, the output of echo $ROS_PACKAGE_PATH is:


where it seems the order of precedence is correct. However, when I type rospack find ORB_SLAM3, it still returns /home/glenn/ws/covins_ws/src/covins/orb_slam3/Examples/ROS/ORB_SLAM3 as the path.

Is there any way to fix this? Even when I don't source the setup.bash in the /ws/covins_ws folder, ROS still seems to be able to find this package and I can't get it to find the appropriate ORB_SLAM3 folder. Note, I have already built another ORB_SLAM3 package with a ros wrapper from here, but due to some runtime issues with that one, I'm trying to run ROS from the original ORB_SLAM3 package.

Originally posted by gts_63 on ROS Answers with karma: 15 on 2023-07-27

Post score: 0


1 Answer 1


Rosanswers logo

Your catkin workspace "remembers" the things you previously sourced. Making it "forget" requires these steps, in this order:

  • in your catkin_ws, delete the top-level devel and build directories
  • source /opt/ros/noetic/setup.bash # only this one!
  • run your catkin_make or catkin build command
  • if the build succeeded, source devel/setup.bash

People also call this "doing a clean build".

Note: in general it's unwise to modify your ROS_PACKAGE_PATH env variable in your ~/.bashrc file, but it is especially unwise when the path you are adding is already inside your catkin_ws directory.

Originally posted by Mike Scheutzow with karma: 4903 on 2023-07-29

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by gts_63 on 2023-07-30:
Thank you. I noticed from the ROS wiki that ROS_PACKAGE_PATH doesn't need to be manually updated since catkin was introduced.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.